init.el: Add support for common lisp

Since the common lisp bindings were conflicting with
rust cargo bindings refactor the key bindings by
using major mode keymap feature of general.

Signed-off-by: Sanchayan Maity <maitysanchayan@gmail.com>
This commit is contained in:
Sanchayan Maity 2019-02-21 19:45:37 +05:30
parent 5b7fa8ae20
commit 7a8704563b

445
init.el
View file

@ -221,165 +221,255 @@
motion motion
operator operator
replace)) replace))
:config (general-define-key :config
:states '(normal visual insert emacs) (general-define-key
:prefix "SPC" :states '(normal visual insert emacs)
:non-normal-prefix "M-SPC" :prefix "SPC"
"/" '(helm-projectile-rg :non-normal-prefix "M-SPC"
:which-key "ripgrep") "/" '(helm-projectile-rg
"TAB" '(switch-to-prev-buffer :which-key "ripgrep")
:which-key "previous buffer") "TAB" '(switch-to-prev-buffer
"SPC" '(helm-M-x :which-key "M-x") :which-key "previous buffer")
"ff" '(fzf :which-key "fuzzy file search") "SPC" '(helm-M-x :which-key "M-x")
"pf" '(helm-projectile-find-file "ff" '(fzf :which-key "fuzzy file search")
:which-key "find files") "pf" '(helm-projectile-find-file
"pp" '(helm-projectile-switch-project :which-key "find files")
:which-key "switch project") "pp" '(helm-projectile-switch-project
"pb" '(helm-projectile-switch-to-buffer :which-key "switch project")
:which-key "switch buffer") "pb" '(helm-projectile-switch-to-buffer
"pr" '(helm-show-kill-ring :which-key "switch buffer")
:which-key "show kill ring") "pr" '(helm-show-kill-ring
;; Buffers :which-key "show kill ring")
"bb" '(helm-mini :which-key "buffers list") ;; Buffers
;; Window "bb" '(helm-mini :which-key "buffers list")
"wl" '(windmove-right :which-key "move right") ;; Window
"wh" '(windmove-left :which-key "move left") "wl" '(windmove-right :which-key "move right")
"wk" '(windmove-up :which-key "move up") "wh" '(windmove-left :which-key "move left")
"wj" '(windmove-down :which-key "move bottom") "wk" '(windmove-up :which-key "move up")
"w/" '(split-window-right :which-key "split right") "wj" '(windmove-down :which-key "move bottom")
"w-" '(split-window-below :which-key "split bottom") "w/" '(split-window-right :which-key "split right")
"wx" '(delete-window :which-key "delete window") "w-" '(split-window-below :which-key "split bottom")
"qz" '(delete-frame :which-key "delete frame") "wx" '(delete-window :which-key "delete window")
"qq" '(kill-emacs :which-key "quit") "qz" '(delete-frame :which-key "delete frame")
"qr" '(restart-emacs :which-key "restart emacs") "qq" '(kill-emacs :which-key "quit")
;; Others "qr" '(restart-emacs :which-key "restart emacs")
"at" '(ansi-term :which-key "open terminal") ;; Others
;; Gtags "at" '(ansi-term :which-key "open terminal")
"mgc" '(helm-gtags-create-tags ;; Gtags
:which-key "create tag db") "mgc" '(helm-gtags-create-tags
"mgd" '(helm-gtags-find-tag :which-key "create tag db")
:which-key "find definitions") "mgd" '(helm-gtags-find-tag
"mgf" '(helm-gtags-select-path :which-key "find definitions")
:which-key "jump to a file in tag db") "mgf" '(helm-gtags-select-path
"mgG" '(helm-gtags-dwim-other-window :which-key "jump to a file in tag db")
:which-key "jump to location based on context") "mgG" '(helm-gtags-dwim-other-window
"mgi" '(helm-gtags-tags-in-this-function :which-key "jump to location based on context")
:which-key "present tags in current function") "mgi" '(helm-gtags-tags-in-this-function
"mgl" '(helm-gtags-parse-file :which-key "present tags in current function")
:which-key "jump to definitions in file") "mgl" '(helm-gtags-parse-file
"mgn" '(helm-gtags-next-history :which-key "jump to definitions in file")
:which-key "jump to next location in context stack") "mgn" '(helm-gtags-next-history
"mgp" '(helm-gtags-previous-history :which-key "jump to next location in context stack")
:which-key "jump to previous location in context stack") "mgp" '(helm-gtags-previous-history
"mgr" '(helm-gtags-find-rtag :which-key "jump to previous location in context stack")
:which-key "find references") "mgr" '(helm-gtags-find-rtag
"mgR" '(helm-gtags-resume :which-key "find references")
:which-key "resume previous helm-gtags session") "mgR" '(helm-gtags-resume
"mgs" '(helm-gtags-select :which-key "resume previous helm-gtags session")
:which-key "select any tag in project retrieved by gtags") "mgs" '(helm-gtags-select
"mgS" '(helm-gtags-show-stack :which-key "select any tag in project retrieved by gtags")
:which-key "show stack of visited locations") "mgS" '(helm-gtags-show-stack
"mgu" '(helm-gtags-update-tags :which-key "show stack of visited locations")
:which-key "create tag db") "mgu" '(helm-gtags-update-tags
;; Magit key bindings :which-key "create tag db")
"gc" '(magit-clone ;; Magit key bindings
:which-key "magit clone") "gc" '(magit-clone
"gff" '(magit-find-file :which-key "magit clone")
:which-key "magit find file") "gff" '(magit-find-file
"gfl" '(magit-log-buffer-file :which-key "magit find file")
:which-key "magit log buffer file") "gfl" '(magit-log-buffer-file
"gfd" '(magit-diff-buffer-file-popup :which-key "magit log buffer file")
:which-key "magit diff buffer file popup") "gfd" '(magit-diff-buffer-file-popup
"gi" '(magit-init :which-key "magit diff buffer file popup")
:which-key "magit initialize") "gi" '(magit-init
"gL" '(magit-list-repositories :which-key "magit initialize")
:which-key "magit list repositories") "gL" '(magit-list-repositories
"gm" '(magit-dispatch-popup :which-key "magit list repositories")
:which-key "magit dispatch popup") "gm" '(magit-dispatch-popup
"gs" '(magit-status :which-key "magit dispatch popup")
:which-key "open Magit status buffer") "gs" '(magit-status
"gS" '(magit-stage-file :which-key "open Magit status buffer")
:which-key "magit stage file") "gS" '(magit-stage-file
"gU" '(magit-unstage-file :which-key "magit stage file")
:which-key "magit unstage file") "gU" '(magit-unstage-file
"g/" '(helm-git-grep :which-key "magit unstage file")
:which-key "open helm git grep") "g/" '(helm-git-grep
"g*" '(helm-git-grep-at-point :which-key "open helm git grep")
:which-key "open helm git grep at point") "g*" '(helm-git-grep-at-point
;; Haskell bindings :which-key "open helm git grep at point")))
"mf" '(hindent-reformat-decl
:which-key "format declaration using hindent") (general-define-key
"mF" '(haskell-mode-stylish-buffer :states '(normal visual emacs)
:which-key "format buffer using haskell stylish") :prefix "SPC m"
"mgg" '(intero-goto-definition :keymaps 'haskell-mode-map
:which-key "goto definition or tag") ;; Haskell bindings
"mhi" '(intero-info "f" '(hindent-reformat-decl
:which-key "get info for identifier under cursor") :which-key "format declaration using hindent")
"mht" '(intero-type-at "F" '(haskell-mode-stylish-buffer
:which-key "get type of identifier under cursor") :which-key "format buffer using haskell stylish")
"mrs" '(intero-apply-suggestions) "gg" '(intero-goto-definition
"msb" '(intero-repl-load :which-key "goto definition or tag")
:which-key "load/reload current buffer in repl") "hi" '(intero-info
"mic" '(intero-cd :which-key "get info for identifier under cursor")
:which-key "change directory in backend process") "ht" '(intero-type-at
"mid" '(intero-devel-reload :which-key "get type of identifier under cursor")
:which-key "reload module DevelMain") "rs" '(intero-apply-suggestions)
"mik" '(intero-destroy "sb" '(intero-repl-load
:which-key "stop current process & kill its associated") :which-key "load/reload current buffer in repl")
"mil" '(intero-list-buffers "ic" '(intero-cd
:which-key "list hidden process buffers created") :which-key "change directory in backend process")
"mir" '(intero-restart "id" '(intero-devel-reload
:which-key "restart process with same config") :which-key "reload module DevelMain")
"mit" '(intero-targets "ik" '(intero-destroy
:which-key "set targets to use for stack ghci") :which-key "stop current process & kill its associated")
"msc" nil "il" '(intero-list-buffers
"mhT" '(haskell-intero/insert-type) :which-key "list hidden process buffers created")
"mss" '(haskell-intero/display-repl "ir" '(intero-restart
:which-key "show repl without switching") :which-key "restart process with same config")
"msS" '(haskell-intero/pop-to-repl "it" '(intero-targets
:which-key "show and switch to repl") :which-key "set targets to use for stack ghci")
"mrb" '(hlint-refactor-refactor-buffer "sc" nil
:which-key "apply all hlint suggestions") "hT" '(haskell-intero/insert-type)
"mrr" '(hlint-refactor-refactor-at-point "ss" '(haskell-intero/display-repl
:which-key "apply hlint suggestion under cursor") :which-key "show repl without switching")
"mc." '(cargo-process-repeat "sS" '(haskell-intero/pop-to-repl
:which-key "repeat the last cargo command") :which-key "show and switch to repl")
"mcC" '(cargo-process-clean "rb" '(hlint-refactor-refactor-buffer
:which-key "remove build artifacts with cargo") :which-key "apply all hlint suggestions")
"mcX" '(cargo-process-run-example "rr" '(hlint-refactor-refactor-at-point
:which-key "execute project example with cargo") :which-key "apply hlint suggestion under cursor"))
"mcc" '(cargo-process-build
:which-key "compile project with cargo") (general-define-key
"mcd" '(cargo-process-doc :states '(normal visual emacs)
:which-key "generate documentation with cargo") :prefix "SPC m"
"mcD" '(cargo-process-doc-open :keymaps 'rust-mode-map
:which-key "open cargo docs") "c." '(cargo-process-repeat
"mce" '(cargo-process-bench :which-key "repeat the last cargo command")
:which-key "run benchmarks with cargo") "cC" '(cargo-process-clean
"mcf" '(cargo-process-fmt :which-key "remove build artifacts with cargo")
:which-key "format all project files with rustfmt") "cX" '(cargo-process-run-example
"mci" '(cargo-process-init :which-key "execute project example with cargo")
:which-key "create a new project with cargo") "cc" '(cargo-process-build
"mcl" '(cargo-process-clippy :which-key "compile project with cargo")
:which-key "run linter with cargo") "cd" '(cargo-process-doc
"mcn" '(cargo-process-new :which-key "generate documentation with cargo")
:which-key "create new project with cargo") "cD" '(cargo-process-doc-open
"mco" '(cargo-process-current-file-tests :which-key "open cargo docs")
:which-key "run all tests in current file with cargo") "ce" '(cargo-process-bench
"mcs" '(cargo-process-search :which-key "run benchmarks with cargo")
:which-key "search for packages on crates.io") "cf" '(cargo-process-fmt
"mct" '(cargo-process-current-test :which-key "format all project files with rustfmt")
:which-key "run the current test with cargo") "ci" '(cargo-process-init
"mcu" '(cargo-process-update :which-key "create a new project with cargo")
:which-key "update dependencies with cargo") "cl" '(cargo-process-clippy
"mcx" '(cargo-process-run :which-key "run linter with cargo")
:which-key "execute a process with cargo") "cn" '(cargo-process-new
"mcv" '(cargo-process-check :which-key "create new project with cargo")
:which-key "verify a project with cargo") "co" '(cargo-process-current-file-tests
"mt" '(cargo-process-test :which-key "run all tests in current file with cargo")
:which-key "run test with cargo") "cs" '(cargo-process-search
"m==" '(rust-format-buffer :which-key "search for packages on crates.io")
:which-key "rust reformat the buffer"))) "ct" '(cargo-process-current-test
:which-key "run the current test with cargo")
"cu" '(cargo-process-update
:which-key "update dependencies with cargo")
"cx" '(cargo-process-run
:which-key "execute a process with cargo")
"cv" '(cargo-process-check
:which-key "verify a project with cargo")
"t" '(cargo-process-test
:which-key "run test with cargo")
"==" '(rust-format-buffer
:which-key "rust reformat the buffer"))
(general-define-key
:states '(normal visual emacs)
:prefix "SPC m"
:keymaps 'lisp-mode-map
"cc" '(slime-compile-file
:which-key "compile file")
"cC" '(slime-compile-and-load-file
:which-key "compile file and load")
"cl" '(slime-load-file
:which-key "load file")
"cf" '(slime-compile-defun
:which-key "compile function")
"cr" '(slime-compile-region
:which-key "compile region")
"cn" '(slime-remove-notes
:which-key "remove compilation notes")
"eb" '(slime-eval-buffer
:which-key "evaluate buffer")
"ef" '(slime-eval-defun
:which-key "evaluate top level sexpr")
"eF" '(slime-undefine-function
:which-key "undefine the fn at point")
"ee" '(slime-eval-last-expression
:which-key "evaluate last sexpr")
"er" '(slime-eval-region
:which-key "evaluate region")
"gb" '(slime-pop-find-definition-stack
:which-key "go back")
"gn" '(slime-next-note
:which-key "next note")
"gN" '(slime-previous-note
:which-key "previous note")
"ha" '(slime-apropos
:which-key "SLIME appropos")
"hA" '(slime-apropos-all
:which-key "SLIME appropos all")
"hd" '(slime-disassemble-symbol
:which-key "disassemble symbol at point")
"hh" '(slime-describe-symbol
:which-key "describe symbol at point")
"hH" '(slime-hyperspec-lookup
:which-key "hyperspec lookup symbol at point")
"hi" '(slime-inspect-definition
:which-key "inspect defintion")
"hp" '(slime-apropos-package
:which-key "browse appropos results for package's exported symbols")
"ht" '(slime-toggle-trace-definition
:which-key "toggle tracing of function at point")
"hT" '(slime-untrace-all
:which-key "untrace all functions")
"h<" '(slime-who-calls
:which-key "show all known callers")
"h>" '(slime-calls-who
:which-key "show all known callees")
"hr" '(slime-who-references
:which-key "show references to global variable")
"hm" '(slime-who-macroexpands
:which-key "show all usages of a macro")
"hs" '(slime-who-specializes
:which-key "show all methods specialized on a class")
"ma" '(slime-macroexpand-all
:which-key "macroexpand the expr at point completely")
"mo" '(slime-macroexpand-1
:which-key "macroexpand the expr at point once")
"se" '(slime-eval-last-expression-in-repl
:which-key "evaluate last sexpr in repl")
"si" '(slime
:which-key "start an inferior process")
"sq" '(slime-quit-lisp
:which-key "quit")
"tf" '(slime-toggle-fancy-trace))
;; custom functions ;; custom functions
(defun haskell-intero/insert-type () (defun haskell-intero/insert-type ()
@ -522,4 +612,41 @@
(use-package cargo (use-package cargo
:defer t) :defer t)
(use-package evil-cleverparens
:ensure t)
(use-package parinfer
:ensure t
:init
(progn
(setq parinfer-extensions '(defaults
pretty-parens
evil
paredit
smart-tab
smart-yank)))
:hook
((emacs-lisp-mode . parinfer-mode)
(common-lisp-mode . parinfer-mode)
(lisp-mode . parinfer-mode)))
(use-package slime
:commands slime-mode
:init
(progn
(setq slime-contribs '(slime-asdf
slime-fancy
slime-indentation
slime-sbcl-exts
slime-scratch)
inferior-lisp-program "sbcl")
(setq slime-complete-symbol*-fancy t)
(setq slime-complete-symbol-function 'slime-fuzzy-complete-symbol)
(defun slime/disable-smartparens ()
(smartparens-strict-mode -1)
(turn-off-smartparens-mode))
(add-hook 'slime-repl-mode-hook #'slime/disable-smartparens))
:config
(slime-setup))
;;; init.el ends ;;; init.el ends