[Emacs] Better keybinds for LSP in major-modes

This commit is contained in:
Lucien Cartier-Tilet 2023-01-23 10:45:46 +01:00
parent 1b24386366
commit 54d6b097e4
Signed by: phundrak
GPG Key ID: BD7789E705CB8DCA
1 changed files with 46 additions and 21 deletions

View File

@ -1428,7 +1428,12 @@ Due to this, I absolutely need a mode for editing Dockerfiles.
:hook (dockerfile-mode . lsp-deferred)
:init
(put 'docker-image-name 'safe-local-variable #'stringp)
:mode "Dockerfile\\'")
:mode "Dockerfile\\'"
:general
(phundrak/major-leader-key
:keymaps 'general-mode-map
:packages 'lsp-mode
"l" '(:keymap lsp-command-map :which-key "lsp")))
#+end_src
The ~docker~ package also provides interactivity with Docker and
@ -4270,6 +4275,10 @@ enhances a couple of built-in functions from Emacs, namely:
(add-hook 'TeX-mode-hook #'visual-line-mode)
(add-hook 'TeX-update-style-hook #'rainbow-delimiters-mode)
:general
(phundrak/major-leader-key
:packages 'lsp-mode
:keymaps '(latex-mode-map LaTeX-mode-map)
"l" '(:keymap lsp-command-map :which-key "lsp"))
(phundrak/major-leader-key
:packages 'auctex
:keymaps '(latex-mode-map LaTeX-mode-map)
@ -6957,7 +6966,12 @@ configuration for StumpWM]].
#+begin_src emacs-lisp
(use-package lsp-dart
:straight (:build t)
:defer t)
:defer t
:general
(phundrak/major-leader-key
:keymaps 'dart-mode-map
:packages '(lsp-mode lsp-dart)
"l" '(:keymap lsp-command-map :which-key "lsp")))
#+end_src
**** EmacsLisp
@ -7085,7 +7099,12 @@ org-babel supports.
(setq python-indent-guess-indent-offset-verbose nil)
(when (and (executable-find "python3")
(string= python-shell-interpreter "python"))
(setq python-shell-interpreter "python3")))
(setq python-shell-interpreter "python3"))
:general
(phundrak/major-leader-key
:keymaps 'python-mode-map
:packages 'lsp-mode
"l" '(:keymap lsp-command-map :which-key "lsp")))
#+end_src
Now lets add a package for [[https://docs.pytest.org/en/latest/][pytest]].
@ -7335,6 +7354,10 @@ development. First, lets install the most important package,
:packages 'lsp
"M-t" #'lsp-ui-imenu
"M-?" #'lsp-find-references)
(phundrak/major-leader-key
:keymaps 'rustic-mode-map
:packages 'lsp-mode
"l" '(:keymap lsp-command-map :which-key "lsp"))
(phundrak/major-leader-key
:keymaps 'rustic-mode-map
:packages 'rustic
@ -7348,12 +7371,6 @@ development. First, lets install the most important package,
"bn" #'rustic-cargo-new
"bo" #'rustic-cargo-outdated
"br" #'rustic-cargo-run
"l" '(:ignore t :which-key "lsp")
"la" #'lsp-execute-code-action
"lr" #'lsp-rename
"lq" #'lsp-workspace-restart
"lQ" #'lsp-workspace-shutdown
"ls" #'lsp-rust-analyzer-status
"t" '(:ignore t :which-key "cargo test")
"ta" #'rustic-cargo-test
"tt" #'rustic-cargo-current-test)
@ -7489,6 +7506,10 @@ Lets customize a bit the built-in CSS mode.
:init
(put 'css-indent-offset 'safe-local-variable #'integerp)
:general
(phundrak/major-leader-key
:keymaps 'css-mode-map
:packages 'lsp-mode
"l" '(:keymap lsp-command-map :which-key "lsp"))
(phundrak/major-leader-key
:keymaps 'css-mode-map
:packages 'css-mode
@ -7531,7 +7552,12 @@ activate when I open ~.less~ files by default. Lets fix that.
:mode "\\.less\\'"
:hook (less-css-mode . smartparens-mode)
:hook (less-css-mode . lsp-deferred)
:hook (less-css-mode . prettier-js-mode))
:hook (less-css-mode . prettier-js-mode)
:general
(phundrak/major-leader-key
:keymaps 'less-css-mode-map
:packages 'lsp-mode
"l" '(:keymap lsp-command-map :which-key "lsp")))
#+end_src
***** Javascript
@ -7559,11 +7585,9 @@ Next.JS.
2 3 4))
:general
(phundrak/major-leader-key
:keymaps 'rjsx-mode-map
:infix "a"
"" '(:keymap lsp-command-map :which-key "lsp")
"=" '(:ignore t :wk "format")
"a" '(:ignore t :which-key "actions"))
:keymaps 'rjsx-mode-map
:packages 'lsp-mode
"l" '(:keymap lsp-command-map :which-key "lsp"))
:config
(setq js-chain-indent t
js2-basic-offset 2
@ -7638,12 +7662,9 @@ Typescript is a safer alternative to Javascript. Lets install its major mode
(add-to-list 'auto-mode-alist '("\\.tsx\\'" . typescript-tsx-mode))
:general
(phundrak/major-leader-key
:packages 'lsp
:keymaps '(typescript-mode-map typescript-tsx-mode-map)
:infix "a"
"" '(:keymap lsp-command-map :which-key "lsp")
"=" '(:ignore t :wk "format")
"a" '(:ignore t :which-key "actions"))
:keymaps '(typescript-mode-map typescript-tsx-mode-map)
:packages 'lsp-mode
"l" '(:keymap lsp-command-map :which-key "lsp"))
(phundrak/major-leader-key
:packages 'typescript-mode
:keymaps '(typescript-mode-map typescript-tsx-mode-map)
@ -7707,6 +7728,10 @@ First, here is its major mode.
:modes zig-mode)
(add-to-list 'flycheck-checkers 'zig)
:general
(phundrak/major-leader-key
:keymaps 'zip-mode-map
:packages 'lsp-mode
"l" '(:keymap lsp-command-map :which-key "lsp"))
(phundrak/major-leader-key
:packages 'zig-mode
:keymaps 'zig-mode-map