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
operator
replace))
:config (general-define-key
:states '(normal visual insert emacs)
:prefix "SPC"
:non-normal-prefix "M-SPC"
"/" '(helm-projectile-rg
:which-key "ripgrep")
"TAB" '(switch-to-prev-buffer
:which-key "previous buffer")
"SPC" '(helm-M-x :which-key "M-x")
"ff" '(fzf :which-key "fuzzy file search")
"pf" '(helm-projectile-find-file
:which-key "find files")
"pp" '(helm-projectile-switch-project
:which-key "switch project")
"pb" '(helm-projectile-switch-to-buffer
:which-key "switch buffer")
"pr" '(helm-show-kill-ring
:which-key "show kill ring")
;; Buffers
"bb" '(helm-mini :which-key "buffers list")
;; Window
"wl" '(windmove-right :which-key "move right")
"wh" '(windmove-left :which-key "move left")
"wk" '(windmove-up :which-key "move up")
"wj" '(windmove-down :which-key "move bottom")
"w/" '(split-window-right :which-key "split right")
"w-" '(split-window-below :which-key "split bottom")
"wx" '(delete-window :which-key "delete window")
"qz" '(delete-frame :which-key "delete frame")
"qq" '(kill-emacs :which-key "quit")
"qr" '(restart-emacs :which-key "restart emacs")
;; Others
"at" '(ansi-term :which-key "open terminal")
;; Gtags
"mgc" '(helm-gtags-create-tags
:which-key "create tag db")
"mgd" '(helm-gtags-find-tag
:which-key "find definitions")
"mgf" '(helm-gtags-select-path
:which-key "jump to a file in tag db")
"mgG" '(helm-gtags-dwim-other-window
:which-key "jump to location based on context")
"mgi" '(helm-gtags-tags-in-this-function
:which-key "present tags in current function")
"mgl" '(helm-gtags-parse-file
:which-key "jump to definitions in file")
"mgn" '(helm-gtags-next-history
:which-key "jump to next location in context stack")
"mgp" '(helm-gtags-previous-history
:which-key "jump to previous location in context stack")
"mgr" '(helm-gtags-find-rtag
:which-key "find references")
"mgR" '(helm-gtags-resume
:which-key "resume previous helm-gtags session")
"mgs" '(helm-gtags-select
:which-key "select any tag in project retrieved by gtags")
"mgS" '(helm-gtags-show-stack
:which-key "show stack of visited locations")
"mgu" '(helm-gtags-update-tags
:which-key "create tag db")
;; Magit key bindings
"gc" '(magit-clone
:which-key "magit clone")
"gff" '(magit-find-file
:which-key "magit find file")
"gfl" '(magit-log-buffer-file
:which-key "magit log buffer file")
"gfd" '(magit-diff-buffer-file-popup
:which-key "magit diff buffer file popup")
"gi" '(magit-init
:which-key "magit initialize")
"gL" '(magit-list-repositories
:which-key "magit list repositories")
"gm" '(magit-dispatch-popup
:which-key "magit dispatch popup")
"gs" '(magit-status
:which-key "open Magit status buffer")
"gS" '(magit-stage-file
:which-key "magit stage file")
"gU" '(magit-unstage-file
:which-key "magit unstage file")
"g/" '(helm-git-grep
:which-key "open helm git grep")
"g*" '(helm-git-grep-at-point
:which-key "open helm git grep at point")
;; Haskell bindings
"mf" '(hindent-reformat-decl
:which-key "format declaration using hindent")
"mF" '(haskell-mode-stylish-buffer
:which-key "format buffer using haskell stylish")
"mgg" '(intero-goto-definition
:which-key "goto definition or tag")
"mhi" '(intero-info
:which-key "get info for identifier under cursor")
"mht" '(intero-type-at
:which-key "get type of identifier under cursor")
"mrs" '(intero-apply-suggestions)
"msb" '(intero-repl-load
:which-key "load/reload current buffer in repl")
"mic" '(intero-cd
:which-key "change directory in backend process")
"mid" '(intero-devel-reload
:which-key "reload module DevelMain")
"mik" '(intero-destroy
:which-key "stop current process & kill its associated")
"mil" '(intero-list-buffers
:which-key "list hidden process buffers created")
"mir" '(intero-restart
:which-key "restart process with same config")
"mit" '(intero-targets
:which-key "set targets to use for stack ghci")
"msc" nil
"mhT" '(haskell-intero/insert-type)
"mss" '(haskell-intero/display-repl
:which-key "show repl without switching")
"msS" '(haskell-intero/pop-to-repl
:which-key "show and switch to repl")
"mrb" '(hlint-refactor-refactor-buffer
:which-key "apply all hlint suggestions")
"mrr" '(hlint-refactor-refactor-at-point
:which-key "apply hlint suggestion under cursor")
"mc." '(cargo-process-repeat
:which-key "repeat the last cargo command")
"mcC" '(cargo-process-clean
:which-key "remove build artifacts with cargo")
"mcX" '(cargo-process-run-example
:which-key "execute project example with cargo")
"mcc" '(cargo-process-build
:which-key "compile project with cargo")
"mcd" '(cargo-process-doc
:which-key "generate documentation with cargo")
"mcD" '(cargo-process-doc-open
:which-key "open cargo docs")
"mce" '(cargo-process-bench
:which-key "run benchmarks with cargo")
"mcf" '(cargo-process-fmt
:which-key "format all project files with rustfmt")
"mci" '(cargo-process-init
:which-key "create a new project with cargo")
"mcl" '(cargo-process-clippy
:which-key "run linter with cargo")
"mcn" '(cargo-process-new
:which-key "create new project with cargo")
"mco" '(cargo-process-current-file-tests
:which-key "run all tests in current file with cargo")
"mcs" '(cargo-process-search
:which-key "search for packages on crates.io")
"mct" '(cargo-process-current-test
:which-key "run the current test with cargo")
"mcu" '(cargo-process-update
:which-key "update dependencies with cargo")
"mcx" '(cargo-process-run
:which-key "execute a process with cargo")
"mcv" '(cargo-process-check
:which-key "verify a project with cargo")
"mt" '(cargo-process-test
:which-key "run test with cargo")
"m==" '(rust-format-buffer
:which-key "rust reformat the buffer")))
:config
(general-define-key
:states '(normal visual insert emacs)
:prefix "SPC"
:non-normal-prefix "M-SPC"
"/" '(helm-projectile-rg
:which-key "ripgrep")
"TAB" '(switch-to-prev-buffer
:which-key "previous buffer")
"SPC" '(helm-M-x :which-key "M-x")
"ff" '(fzf :which-key "fuzzy file search")
"pf" '(helm-projectile-find-file
:which-key "find files")
"pp" '(helm-projectile-switch-project
:which-key "switch project")
"pb" '(helm-projectile-switch-to-buffer
:which-key "switch buffer")
"pr" '(helm-show-kill-ring
:which-key "show kill ring")
;; Buffers
"bb" '(helm-mini :which-key "buffers list")
;; Window
"wl" '(windmove-right :which-key "move right")
"wh" '(windmove-left :which-key "move left")
"wk" '(windmove-up :which-key "move up")
"wj" '(windmove-down :which-key "move bottom")
"w/" '(split-window-right :which-key "split right")
"w-" '(split-window-below :which-key "split bottom")
"wx" '(delete-window :which-key "delete window")
"qz" '(delete-frame :which-key "delete frame")
"qq" '(kill-emacs :which-key "quit")
"qr" '(restart-emacs :which-key "restart emacs")
;; Others
"at" '(ansi-term :which-key "open terminal")
;; Gtags
"mgc" '(helm-gtags-create-tags
:which-key "create tag db")
"mgd" '(helm-gtags-find-tag
:which-key "find definitions")
"mgf" '(helm-gtags-select-path
:which-key "jump to a file in tag db")
"mgG" '(helm-gtags-dwim-other-window
:which-key "jump to location based on context")
"mgi" '(helm-gtags-tags-in-this-function
:which-key "present tags in current function")
"mgl" '(helm-gtags-parse-file
:which-key "jump to definitions in file")
"mgn" '(helm-gtags-next-history
:which-key "jump to next location in context stack")
"mgp" '(helm-gtags-previous-history
:which-key "jump to previous location in context stack")
"mgr" '(helm-gtags-find-rtag
:which-key "find references")
"mgR" '(helm-gtags-resume
:which-key "resume previous helm-gtags session")
"mgs" '(helm-gtags-select
:which-key "select any tag in project retrieved by gtags")
"mgS" '(helm-gtags-show-stack
:which-key "show stack of visited locations")
"mgu" '(helm-gtags-update-tags
:which-key "create tag db")
;; Magit key bindings
"gc" '(magit-clone
:which-key "magit clone")
"gff" '(magit-find-file
:which-key "magit find file")
"gfl" '(magit-log-buffer-file
:which-key "magit log buffer file")
"gfd" '(magit-diff-buffer-file-popup
:which-key "magit diff buffer file popup")
"gi" '(magit-init
:which-key "magit initialize")
"gL" '(magit-list-repositories
:which-key "magit list repositories")
"gm" '(magit-dispatch-popup
:which-key "magit dispatch popup")
"gs" '(magit-status
:which-key "open Magit status buffer")
"gS" '(magit-stage-file
:which-key "magit stage file")
"gU" '(magit-unstage-file
:which-key "magit unstage file")
"g/" '(helm-git-grep
:which-key "open helm git grep")
"g*" '(helm-git-grep-at-point
:which-key "open helm git grep at point")))
(general-define-key
:states '(normal visual emacs)
:prefix "SPC m"
:keymaps 'haskell-mode-map
;; Haskell bindings
"f" '(hindent-reformat-decl
:which-key "format declaration using hindent")
"F" '(haskell-mode-stylish-buffer
:which-key "format buffer using haskell stylish")
"gg" '(intero-goto-definition
:which-key "goto definition or tag")
"hi" '(intero-info
:which-key "get info for identifier under cursor")
"ht" '(intero-type-at
:which-key "get type of identifier under cursor")
"rs" '(intero-apply-suggestions)
"sb" '(intero-repl-load
:which-key "load/reload current buffer in repl")
"ic" '(intero-cd
:which-key "change directory in backend process")
"id" '(intero-devel-reload
:which-key "reload module DevelMain")
"ik" '(intero-destroy
:which-key "stop current process & kill its associated")
"il" '(intero-list-buffers
:which-key "list hidden process buffers created")
"ir" '(intero-restart
:which-key "restart process with same config")
"it" '(intero-targets
:which-key "set targets to use for stack ghci")
"sc" nil
"hT" '(haskell-intero/insert-type)
"ss" '(haskell-intero/display-repl
:which-key "show repl without switching")
"sS" '(haskell-intero/pop-to-repl
:which-key "show and switch to repl")
"rb" '(hlint-refactor-refactor-buffer
:which-key "apply all hlint suggestions")
"rr" '(hlint-refactor-refactor-at-point
:which-key "apply hlint suggestion under cursor"))
(general-define-key
:states '(normal visual emacs)
:prefix "SPC m"
:keymaps 'rust-mode-map
"c." '(cargo-process-repeat
:which-key "repeat the last cargo command")
"cC" '(cargo-process-clean
:which-key "remove build artifacts with cargo")
"cX" '(cargo-process-run-example
:which-key "execute project example with cargo")
"cc" '(cargo-process-build
:which-key "compile project with cargo")
"cd" '(cargo-process-doc
:which-key "generate documentation with cargo")
"cD" '(cargo-process-doc-open
:which-key "open cargo docs")
"ce" '(cargo-process-bench
:which-key "run benchmarks with cargo")
"cf" '(cargo-process-fmt
:which-key "format all project files with rustfmt")
"ci" '(cargo-process-init
:which-key "create a new project with cargo")
"cl" '(cargo-process-clippy
:which-key "run linter with cargo")
"cn" '(cargo-process-new
:which-key "create new project with cargo")
"co" '(cargo-process-current-file-tests
:which-key "run all tests in current file with cargo")
"cs" '(cargo-process-search
:which-key "search for packages on crates.io")
"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
(defun haskell-intero/insert-type ()
@ -522,4 +612,41 @@
(use-package cargo
: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