[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

View File

@ -1428,7 +1428,12 @@ Due to this, I absolutely need a mode for editing Dockerfiles.
:hook (dockerfile-mode . lsp-deferred) :hook (dockerfile-mode . lsp-deferred)
:init :init
(put 'docker-image-name 'safe-local-variable #'stringp) (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 #+end_src
The ~docker~ package also provides interactivity with Docker and 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-mode-hook #'visual-line-mode)
(add-hook 'TeX-update-style-hook #'rainbow-delimiters-mode) (add-hook 'TeX-update-style-hook #'rainbow-delimiters-mode)
:general :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 (phundrak/major-leader-key
:packages 'auctex :packages 'auctex
:keymaps '(latex-mode-map LaTeX-mode-map) :keymaps '(latex-mode-map LaTeX-mode-map)
@ -6957,7 +6966,12 @@ configuration for StumpWM]].
#+begin_src emacs-lisp #+begin_src emacs-lisp
(use-package lsp-dart (use-package lsp-dart
:straight (:build t) :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 #+end_src
**** EmacsLisp **** EmacsLisp
@ -7085,7 +7099,12 @@ org-babel supports.
(setq python-indent-guess-indent-offset-verbose nil) (setq python-indent-guess-indent-offset-verbose nil)
(when (and (executable-find "python3") (when (and (executable-find "python3")
(string= python-shell-interpreter "python")) (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 #+end_src
Now lets add a package for [[https://docs.pytest.org/en/latest/][pytest]]. 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 :packages 'lsp
"M-t" #'lsp-ui-imenu "M-t" #'lsp-ui-imenu
"M-?" #'lsp-find-references) "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 (phundrak/major-leader-key
:keymaps 'rustic-mode-map :keymaps 'rustic-mode-map
:packages 'rustic :packages 'rustic
@ -7348,12 +7371,6 @@ development. First, lets install the most important package,
"bn" #'rustic-cargo-new "bn" #'rustic-cargo-new
"bo" #'rustic-cargo-outdated "bo" #'rustic-cargo-outdated
"br" #'rustic-cargo-run "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") "t" '(:ignore t :which-key "cargo test")
"ta" #'rustic-cargo-test "ta" #'rustic-cargo-test
"tt" #'rustic-cargo-current-test) "tt" #'rustic-cargo-current-test)
@ -7489,6 +7506,10 @@ Lets customize a bit the built-in CSS mode.
:init :init
(put 'css-indent-offset 'safe-local-variable #'integerp) (put 'css-indent-offset 'safe-local-variable #'integerp)
:general :general
(phundrak/major-leader-key
:keymaps 'css-mode-map
:packages 'lsp-mode
"l" '(:keymap lsp-command-map :which-key "lsp"))
(phundrak/major-leader-key (phundrak/major-leader-key
:keymaps 'css-mode-map :keymaps 'css-mode-map
:packages 'css-mode :packages 'css-mode
@ -7531,7 +7552,12 @@ activate when I open ~.less~ files by default. Lets fix that.
:mode "\\.less\\'" :mode "\\.less\\'"
:hook (less-css-mode . smartparens-mode) :hook (less-css-mode . smartparens-mode)
:hook (less-css-mode . lsp-deferred) :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 #+end_src
***** Javascript ***** Javascript
@ -7560,10 +7586,8 @@ Next.JS.
:general :general
(phundrak/major-leader-key (phundrak/major-leader-key
:keymaps 'rjsx-mode-map :keymaps 'rjsx-mode-map
:infix "a" :packages 'lsp-mode
"" '(:keymap lsp-command-map :which-key "lsp") "l" '(:keymap lsp-command-map :which-key "lsp"))
"=" '(:ignore t :wk "format")
"a" '(:ignore t :which-key "actions"))
:config :config
(setq js-chain-indent t (setq js-chain-indent t
js2-basic-offset 2 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)) (add-to-list 'auto-mode-alist '("\\.tsx\\'" . typescript-tsx-mode))
:general :general
(phundrak/major-leader-key (phundrak/major-leader-key
:packages 'lsp
:keymaps '(typescript-mode-map typescript-tsx-mode-map) :keymaps '(typescript-mode-map typescript-tsx-mode-map)
:infix "a" :packages 'lsp-mode
"" '(:keymap lsp-command-map :which-key "lsp") "l" '(:keymap lsp-command-map :which-key "lsp"))
"=" '(:ignore t :wk "format")
"a" '(:ignore t :which-key "actions"))
(phundrak/major-leader-key (phundrak/major-leader-key
:packages 'typescript-mode :packages 'typescript-mode
:keymaps '(typescript-mode-map typescript-tsx-mode-map) :keymaps '(typescript-mode-map typescript-tsx-mode-map)
@ -7707,6 +7728,10 @@ First, here is its major mode.
:modes zig-mode) :modes zig-mode)
(add-to-list 'flycheck-checkers 'zig) (add-to-list 'flycheck-checkers 'zig)
:general :general
(phundrak/major-leader-key
:keymaps 'zip-mode-map
:packages 'lsp-mode
"l" '(:keymap lsp-command-map :which-key "lsp"))
(phundrak/major-leader-key (phundrak/major-leader-key
:packages 'zig-mode :packages 'zig-mode
:keymaps 'zig-mode-map :keymaps 'zig-mode-map