Switch out lsp-mode for eglot

This commit is contained in:
Jeremy Dormitzer 2023-04-04 21:33:56 -04:00
parent 1f25985231
commit ac3f6c6025
9 changed files with 11 additions and 124 deletions

View File

@ -108,23 +108,6 @@ targets."
"k" #'password-store-remove
"U" #'password-store-url)
(add-to-list 'embark-keymap-alist '(password-store . embark-password-store-actions))
;; Add identifiers in LSP-mode as their own target type
(with-eval-after-load 'lsp-mode
(defun embark-target-lsp-identifier-at-point ()
(when lsp-mode
(when-let ((sym (embark-target-identifier-at-point)))
(cons 'lsp-identifier (cdr sym)))))
(add-to-list 'embark-target-finders 'embark-target-lsp-identifier-at-point)
(defun embark-lsp-execute-code-action (_target)
"Ignores the target and calls lsp-execute-code-action."
(call-interactively #'lsp-execute-code-action))
(defvar-keymap embark-lsp-identifier-actions
:doc "Keymap for actions on LSP identifiers"
:parent embark-identifier-map
"a" #'embark-lsp-execute-code-action
"h" #'lsp-describe-thing-at-point)
(add-to-list 'embark-keymap-alist '(lsp-identifier . embark-lsp-identifier-actions))
(add-to-list 'embark-target-injection-hooks '(lsp-describe-thing-at-point embark--ignore-target)))
(add-to-list 'embark-target-injection-hooks '(xref-find-references embark--ignore-target))
:general
((emacs normal motion insert visual) "C-." #'embark-act)

View File

@ -38,40 +38,14 @@
:custom
(xref-prompt-for-identifier nil))
;; Full-on IDE functionality via LSP mode
(use-package lsp-mode
(use-package eglot
:commands (eglot)
:hook
(python-mode . lsp-deferred)
(rust-mode . lsp-deferred)
(go-mode . lsp-deferred)
(sh-mode . lsp-deferred)
:init
(which-key-add-keymap-based-replacements global-map
"C-c l" '("lsp"))
:config
(add-hook 'lsp-mode-hook #'lsp-enable-which-key-integration)
(add-to-list 'lsp-language-id-configuration '(direnv-envrc-mode . "shellscript"))
;; Only add projects to the current workspace when I open a file from that project
;; https://emacs-lsp.github.io/lsp-mode/page/faq/#how-do-i-force-lsp-mode-to-forget-the-workspace-folders-for-multi-root-servers-so-the-workspace-folders-are-added-on-demand
(advice-add 'lsp :before (lambda (&rest _args) (eval '(setf (lsp-session-server-id->folders (lsp-session)) (ht)))))
:custom
(lsp-keymap-prefix "C-c l")
(lsp-headerline-breadcrumb-enable nil)
(lsp-file-watch-threshold 100000)
:general
(normal lsp-mode-map "K" #'lsp-describe-thing-at-point))
(use-package lsp-ui
:hook (lsp-mode . lsp-ui-mode)
:custom
(lsp-ui-doc-show-with-cursor t))
;; Integrated debugger
(use-package dap-mode
:commands (dap-debug dap-debug-edit-template dap-mode)
:config
(add-hook 'dap-stopped-hook
(lambda (arg) (call-interactively #'dap-hydra))))
(java-mode . eglot-ensure)
(rust-mode . eglot-ensure)
(js-mode . eglot-ensure)
(typescript-mode . eglot-ensure)
(python-mode . eglot-ensure))
;; Some compilation-mode conveniences
(use-package compile

View File

@ -4,34 +4,6 @@
(use-package google-c-style
:hook (java-mode . google-set-c-style))
(use-package lsp-java
:custom
(lsp-java-maven-download-sources t)
(lsp-java-configuration-runtimes '[(:name "JavaSE-11"
:path "/Library/Java/JavaVirtualMachines/amazon-corretto-11.jdk/Contents/Home"
:default t)
(:name "JavaSE-17"
:path "/Library/Java/JavaVirtualMachines/amazon-corretto-17.jdk/Contents/Home")]))
(defvar java-debug-map (make-sparse-keymap))
(general-def java-mode-map
"C-c d" '(:keymap java-debug-map :which-key "debug"))
(general-def java-debug-map
"d" 'dap-java-debug
"t" 'dap-java-debug-test-method
"c" 'dap-java-debug-test-class
"b" 'dap-breakpoint-toggle)
(with-eval-after-load 'dap-java
(setq dap-java-test-additional-args '("-n" "\".*(Test|IT).*\"")))
(defun jdormit-java-setup ()
(lsp-deferred)
(require 'dap-java)
(dap-mode))
(add-hook 'java-mode-hook 'jdormit-java-setup)
(use-package protobuf-mode)
(provide 'init-java)

View File

@ -26,22 +26,9 @@
(use-package js
:straight (:type built-in)
:defer t
:config
(add-hook 'js-mode-hook #'lsp-deferred)
:custom
(js-indent-level 2))
;; Make sure we load LSP in React files
(with-eval-after-load 'lsp-clients
(defun lsp-typescript-javascript-tsx-jsx-activate-p (filename major-mode)
"Checks if the javascript-typescript language server should be enabled
based on FILE-NAME and MAJOR-MODE"
(or (member major-mode '(typescript-mode typescript-tsx-mode js-mode js2-mode rjsx-mode))
(and (eq major-mode 'web-mode)
(or (string-suffix-p ".tsx" filename t)
(string-suffix-p ".jsx" filename t)
(string-suffix-p ".js" filename t))))))
(use-package js-comint
:commands (run-js)
:config
@ -53,8 +40,6 @@
"C-c M-z" #'js-send-buffer-and-go))
(use-package typescript-mode
:config
(add-hook 'typescript-mode-hook #'lsp-deferred)
:custom
(typescript-indent-level 2))

View File

@ -82,17 +82,6 @@
:defer 2
:hook (python-mode . pipenv-mode))
;; LSP using Microsoft's pyright language server
(use-package lsp-pyright
:hook (python-mode . (lambda ()
(require 'lsp-pyright)
(lsp-deferred)))
:custom
(lsp-pyright-use-library-code-for-types t)
(lsp-pyright-multi-root t)
:general
(python-mode-map "C-c C-d" #'lsp-describe-thing-at-point))
;; isort to sort Python imports
(use-package py-isort
:commands (py-isort-buffer py-isort-region)

View File

@ -1,11 +1,6 @@
;; -*- lexical-binding: t; -*-
(use-package rust-mode
:mode (("\\.rs\\'" . rust-mode))
:config
(add-hook 'rust-mode-hook 'lsp-deferred)
(with-eval-after-load 'lsp-rust
(general-def rust-mode-map
"C-c C-c C-d" 'lsp-rust-analyzer-open-external-docs)))
:mode (("\\.rs\\'" . rust-mode)))
(provide 'init-rust)

View File

@ -1,11 +1,5 @@
;; -*- lexical-binding: t; -*-
(use-package lsp-metals
:hook (scala-mode . lsp)
:custom
;; Metals claims to support range formatting by default but it supports range
;; formatting of multiline strings only. You might want to disable it so that
;; emacs can use indentation provided by scala-mode.
(lsp-metals-server-args '("-J-Dmetals.allow-multiline-string-formatting=off")))
(use-package scala-mode)
(provide 'init-scala)

View File

@ -16,13 +16,6 @@
:config
(setq web-mode-engines-alist
'(("django" . "\\.jinja2\\'")))
(add-hook 'web-mode-hook
(lambda ()
(when (equal web-mode-content-type "javascript")
(web-mode-set-content-type "jsx"))
(when (or (equal web-mode-content-type "javascript")
(equal web-mode-content-type "jsx"))
(lsp-deferred))))
:custom
(web-mode-enable-auto-pairing nil)
(web-mode-markup-indent-offset 2)

View File

@ -13,6 +13,7 @@ brew "git-lfs"
brew "gnupg"
brew "grpcurl"
brew "isync"
brew "jdtls"
brew "jq"
brew "kubectx"
brew "maven"
@ -27,6 +28,7 @@ brew "pipx"
brew "plantuml"
brew "prettier"
brew "pyenv"
brew "pyright"
brew "python@3.9"
brew "restic"
brew "ripgrep"