From c11a2f29d078fa488d308b2272ba3ed6278d2d71 Mon Sep 17 00:00:00 2001 From: pupbrained Date: Mon, 7 Oct 2024 23:43:23 -0400 Subject: [PATCH] switch back to eglot with eglot-booster --- config.org | 96 +++++++++++++++++++++++++++++++----------------------- 1 file changed, 55 insertions(+), 41 deletions(-) diff --git a/config.org b/config.org index fccd7f9..62fec8d 100644 --- a/config.org +++ b/config.org @@ -224,6 +224,7 @@ (general-define-key :states '(normal visual emacs) :keymaps 'override + "K" '(eldoc-box-help-at-point :wk "Hover") "C-t" '(vterm-toggle :wk "Toggle VTerm"))) (use-package evil-collection @@ -239,8 +240,11 @@ (evil-leader/set-key "bb" #'switch-to-buffer) (evil-leader/set-key "bd" #'kill-this-buffer) (evil-leader/set-key "e" #'dirvish-side) - (evil-leader/set-key "N" #'lsp-bridge-diagnostic-jump-prev) - (evil-leader/set-key "n" #'lsp-bridge-diagnostic-jump-next)) + (evil-leader/set-key "d" #'flymake-show-diagnostic) + (evil-leader/set-key "n" #'flymake-goto-next-error) + (evil-leader/set-key "N" #'flymake-goto-prev-error) + (evil-leader/set-key "n" #'flymake-goto-next-error) + (evil-leader/set-key "a" #'eglot-code-actions)) (use-package catppuccin-theme :ensure t @@ -266,49 +270,59 @@ ** LSP -*** LSP-Bridge +*** Eglot #+begin_src emacs-lisp - (use-package yasnippet - :ensure t - :init - (yas-global-mode 1)) + (use-package eglot-booster + :after eglot + :ensure (eglot-booster :type git :host github :repo "jdtsmith/eglot-booster") + :config (eglot-booster-mode)) - (use-package lsp-bridge - :ensure '(lsp-bridge :type git :host github :repo "manateelazycat/lsp-bridge" :files (:defaults "*")) - :init - (defun lsp-bridge-mode-hook-func () - (local-set-key (kbd "M-[") #'lsp-bridge-return-from-def) - (local-set-key (kbd "M-]") #'lsp-bridge-find-def) - (local-set-key [remap xref-find-definitions] #'lsp-bridge-find-def) - (local-set-key [remap xref-find-definitions-other-window] #'lsp-bridge-find-def-other-window) - (local-set-key [remap xref-find-references] #'lsp-bridge-find-references) + (use-package eglot + :ensure nil + :config + (defun my-eglot-rename (newname) + "Rename the current symbol to NEWNAME with initial input a." + (interactive + (list (read-from-minibuffer + (format "Rename `%s' to: " (or (thing-at-point 'symbol t) + (error "no symbol at point"))) + (or (thing-at-point 'symbol t) "") nil nil nil + (symbol-name (symbol-at-point))))) + (eglot--server-capable-or-lose :renameProvider) + (eglot--apply-workspace-edit + (jsonrpc-request (eglot--current-server-or-lose) + :textDocument/rename `(,@(eglot--TextDocumentPositionParams) + :newName ,newname)) + current-prefix-arg)) + (fset #'jsonrpc--log-event #'ignore) + (setopt eglot-events-buffer-size 0) + (defun eglot-format-buffer-on-save () + (when (not (derived-mode-p 'python-ts-mode)) + (add-hook 'before-save-hook #'eglot-format-buffer -10 t))) + (add-hook 'eglot-managed-mode-hook #'eglot-format-buffer-on-save) + :hook + (rust-mode . eglot-ensure) + (rust-ts-mode . eglot-ensure) + (sh-script-mode . eglot-ensure) + (python-mode . eglot-ensure) + (python-ts-mode . eglot-ensure) + (json-mode . eglot-ensure) + (json-ts-mode . eglot-ensure) + (yaml-mode . eglot-ensure) + (yaml-ts-mode . eglot-ensure) + (c-mode . eglot-ensure) + (c-ts-mode . eglot-ensure) + (c++-mode . eglot-ensure) + (c++-ts-mode . eglot-ensure) + (go-mode . eglot-ensure) + (go-ts-mode . eglot-ensure)) - (evil-define-key 'normal 'local (kbd "gd") #'lsp-bridge-find-def) - (evil-define-key 'normal 'local (kbd "gD") #'lsp-bridge-find-def-other-window) - (evil-define-key 'normal 'local (kbd "gi") #'lsp-bridge-find-impl) - (evil-define-key 'normal 'local (kbd "gI") #'lsp-bridge-find-impl-other-window) - (evil-define-key 'normal 'local (kbd "gr") #'lsp-bridge-find-references) - (evil-define-key 'normal 'local (kbd "K") #'lsp-bridge-popup-documentation)) - - (setq lsp-bridge-enable-log t - lsp-bridge-enable-inlay-hint t - lsp-bridge-nix-lsp-server "nil" - acm-enable-icon t - acm-enable-doc t - acm-enable-copilot t - acm-enable-quick-access t - acm-completion-backend-merge-order '("codeium-candidates" - "mode-first-part-candidates" - "template-first-part-candidates" - "template-second-part-candidates" - "mode-second-part-candidates")) - - (require 'lsp-bridge) - (evil-set-initial-state 'lsp-bridge-ref-mode 'insert) - (add-hook 'lsp-bridge-mode-hook #'lsp-bridge-mode-hook-func) - - (add-hook 'prog-mode-hook #'lsp-bridge-mode)) + (use-package eldoc-box + :custom + (eldoc-box-max-pixel-width 1024) + :config + (setq eldoc-idle-delay 0)) #+end_src *** Apheleia