summary refs log tree commit diff
diff options
context:
space:
mode:
authorFranck Cuny <franck@fcuny.net>2022-09-24 12:35:03 -0700
committerFranck Cuny <franck@fcuny.net>2022-09-24 12:40:38 -0700
commit73d02ab60344af6a4746e53afffb89ac30b1ee6f (patch)
tree347a35abd4421e307221473ba2c59d57d7c70fd5
parentfeat(packages): install corfu-doc (diff)
downloademacs.d-73d02ab60344af6a4746e53afffb89ac30b1ee6f.tar.gz
fix(prog/lsp): apply a number of fixes related to LSP
Now that I've switched back to LSP, there's some configuration to delete
and some to update.

The configuration related to rust is fixed (lsp-ui was not loading
properly), and I'm also disabling the inlay hints (they are very
intrusive, I'll need more tweaks to find something that works for me).

For the LSP configuration itself, I'm tweaking a few more things,
especially related to the UI.

Finally, deleting configurations for eglot and go: eglot is replaced by
lsp-mode, and go's configuration is in its own file.

Change-Id: I73fb4b66c8816dd6e20efa358c81e3c306b8255f
-rw-r--r--emacs/custom/my-lang-rust.el11
-rw-r--r--emacs/custom/my-lsp.el26
-rw-r--r--emacs/custom/my-prog.el45
3 files changed, 23 insertions, 59 deletions
diff --git a/emacs/custom/my-lang-rust.el b/emacs/custom/my-lang-rust.el
index eb8e9a5..e6374a7 100644
--- a/emacs/custom/my-lang-rust.el
+++ b/emacs/custom/my-lang-rust.el
@@ -8,11 +8,16 @@
 (require 'rustic)
 (require 'lsp-rust)
 
-(setq rustic-lsp-server 'rust-analyzer)
-(setq rustic-lsp-client 'lsp-mode)
+(setq lsp-rust-analyzer-cargo-watch-enable t)
+(setq lsp-rust-analyzer-proc-macro-enable t)
+(setq lsp-rust-full-docs t)
+(setq lsp-rust-server 'rust-analyzer)
+
 (setq rustic-format-on-save t)
+(setq rustic-lsp-client 'lsp-mode)
+(setq rustic-lsp-server 'rust-analyzer)
 
-(add-hook 'rustic-mode-hook #'lsp-rust-analyzer-inlay-hints-mode)
+(add-hook 'rusti-mode-hook #'lsp-deferred)
 
 (provide 'my-lang-rust)
 
diff --git a/emacs/custom/my-lsp.el b/emacs/custom/my-lsp.el
index 98c061a..c10e06c 100644
--- a/emacs/custom/my-lsp.el
+++ b/emacs/custom/my-lsp.el
@@ -7,26 +7,30 @@
 
 (require 'lsp-mode)
 (require 'lsp-ui)
+(require 'lsp-diagnostics)
+(require 'consult-lsp)
+(require 'lsp-completion)
 
-(setq lsp-ui-doc-position 'at-point)
+(setq lsp-ui-doc-enable                 t) ;; Enable documentation
+(setq lsp-ui-doc-position       'at-point) ;; Show the documentation at point
+(setq lsp-ui-doc-header                 t)
+(setq lsp-ui-doc-include-signature      t)
 (setq lsp-ui-peek-enable                t) ;; Enable `lsp-ui-peek'.
 (setq lsp-ui-peek-show-directory        t) ;; Show the directory of files.
-(setq lsp-ui-sideline-enable            t) ;; Enable `lsp-ui-sideline'.
-(setq lsp-ui-sideline-show-hover        t) ;; Show hover messages in sideline.
-(setq lsp-ui-sideline-show-code-actions t) ;; Show code actions in sideline.
+(setq lsp-ui-sideline-enable          nil) ;; Don't enable `lsp-ui-sideline'.
 
-(setq lsp-completion-enable t) ;; Enable `completion-at-point' integration.
+(add-hook 'lsp-mode-hook #'lsp-ui-mode)
 
-(require 'lsp-diagnostics)
-(setq lsp-diagnostics-provider :flymake)
+;; Enable `completion-at-point' integration.
+(setq lsp-completion-enable t)
 
-(add-hook 'lsp-mode-hook #'lsp-ui-mode)
+;; The default is to use flycheck
+(setq lsp-diagnostics-provider :flymake)
 
-(require 'consult-lsp)
 (define-key lsp-mode-map [remap xref-find-apropos] #'consult-lsp-symbols)
 
-(require 'lsp-completion)
-(setq lsp-completion-provider :none)   ;; I use corfu
+;; Configure the completion to be corfu
+(setq lsp-completion-provider :none)
 (add-hook 'lsp-completion-mode-hook
           (lambda ()
 	    (setf (alist-get 'lsp-capf completion-category-defaults) '((styles . (orderless flex))))))
diff --git a/emacs/custom/my-prog.el b/emacs/custom/my-prog.el
index 578207c..d11eebd 100644
--- a/emacs/custom/my-prog.el
+++ b/emacs/custom/my-prog.el
@@ -61,26 +61,6 @@
 
 (add-hook 'makefile-mode-hook 'my/makefile-mode-hook)
 
-(require 'go-mode)
-(require 'gotest)
-
-(defun my/go-mode-hook ()
-  "Hooks for `go-mode'."
-  (setq tab-width 4)
-  (setq go-test-verbose t)
-
-  (set (make-local-variable 'compile-command)
-       "go build -v && go test -v -cover")
-  (define-key go-mode-map (kbd "C-c C-r") 'compile)
-  (define-key go-mode-map (kbd "C-c C-R") 'recompile)
-  (define-key go-mode-map (kbd "C-c C-n") 'go-run)
-  (define-key go-mode-map (kbd "C-c C-c") 'go-coverage)
-  (define-key go-mode-map (kbd "C-c .")   'go-test-current-test)
-  (define-key go-mode-map (kbd "C-c C-f") 'go-test-current-file)
-  (define-key go-mode-map (kbd "C-c C-p") 'go-test-current-project))
-
-(add-hook 'go-mode-hook 'my/go-mode-hook)
-
 (defun my/elisp-mode-hook ()
   "Hooks for `elisp-mode'."
   (define-key emacs-lisp-mode-map (kbd "C-c C-e") 'eval-buffer)
@@ -92,31 +72,6 @@
 (dolist (hook '(prog-mode-hook conf-mode-hook))
   (add-hook hook 'turn-on-eldoc-mode))
 
-(require 'eglot)
-;; List of settings for gopls:
-;; https://github.com/golang/tools/blob/master/gopls/doc/settings.md
-(setq eglot-workspace-configuration
-      '((:gopls .
-                ((staticcheck                 . t)
-                 (experimentalWorkspaceModule . t)
-                 (matcher                     . "CaseSensitive")
-                 (usePlaceholders             . t)))))
-
-(defun my/eglot-install-save-hook ()
-  "Install the local hooks that are executed before saving a buffer."
-  ;; the last thing we do is to format the buffer
-  (add-hook 'before-save-hook #'eglot-format-buffer 100 t))
-
-;; ensure we load eglot for some specific modes
-(dolist (hook '(go-mode-hook nix-mode-hook rust-mode-hook))
-  (add-hook hook 'eglot-ensure)
-  (add-hook hook #'my/eglot-install-save-hook))
-
-(require 'rustic)
-(setq rustic-lsp-server 'rust-analyzer
-      rustic-lsp-client 'eglot
-      rustic-format-on-save t)
-
 (provide 'my-prog)
 
 ;;; my-prog.el ends here