about summary refs log tree commit diff
path: root/users/fcuny
diff options
context:
space:
mode:
authorFranck Cuny <franck@fcuny.net>2022-05-10 08:17:37 -0700
committerFranck Cuny <franck@fcuny.net>2022-05-10 08:17:37 -0700
commit2be7a6c9fec9822af397f8b691e43f2efdbc0489 (patch)
tree8034f7c55cffca46e567a593e5667110ac3c9e3c /users/fcuny
parentnix: start documenting what I'm learning (diff)
downloadworld-2be7a6c9fec9822af397f8b691e43f2efdbc0489.tar.gz
go: replace lsp-mode with eglot
Diffstat (limited to '')
-rw-r--r--users/fcuny/notes/content/notes/working-with-go.org81
1 files changed, 15 insertions, 66 deletions
diff --git a/users/fcuny/notes/content/notes/working-with-go.org b/users/fcuny/notes/content/notes/working-with-go.org
index e00f635..fd39d26 100644
--- a/users/fcuny/notes/content/notes/working-with-go.org
+++ b/users/fcuny/notes/content/notes/working-with-go.org
@@ -116,76 +116,25 @@ require (
 ** =go-mode=
 [[https://github.com/dominikh/go-mode.el][This is the mode]] to install to get syntax highlighting (mostly).
 ** Integration with LSP
-Emacs has a pretty good integration with LSP.
-https://geeksocket.in/posts/emacs-lsp-go/
-*** =lsp-mode=
-[[src:https://github.com/emacs-lsp/lsp-mode][This is the main mode to install]]. It provides the integration with LSP.
+Emacs has a pretty good integration with LSP, and [[https://whatacold.io/blog/2022-01-22-emacs-eglot-lsp/]["Eglot for better programming experience in Emacs"]] is a good starting point.
+*** eglot
+[[https://github.com/joaotavora/eglot][This is the main mode to install]].
 
-I've configured the mode like this:
+The configuration is straightforward, this is what I use:
 #+begin_src elisp
-(use-package lsp-mode
-  :ensure t
-  :commands (lsp lsp-deferred)
-  :diminish lsp-mode
-  :hook ((go-mode . lsp-deferred)
-         (lsp-mode . (lambda() (let ((lsp-keymap-prefix "C-c l"))
-                                 (lsp-enable-which-key-integration)))))
-  :config
-  (define-key lsp-mode-map (kbd "C-c l") lsp-command-map)
-  (lsp-register-custom-settings
-   '(("gopls.completeUnimported" t t)
-     ("gopls.staticcheck" t t)))
-  :bind
-  (("C-c l i" . lsp-ui-imenu))
-  :custom
-  (lsp-session-file (expand-file-name "lsp-session-v1" fcuny/path-emacs-var))
-  (lsp-enable-snippet nil)
-  (lsp-signature-doc-lines 5)
-  (lsp-modeline-diagnostic-scope :workspace)
-  (lsp-completion-provider :capf)
-  (lsp-completion-enable t)
-  (lsp-enable-indentation t)
-  (lsp-eldoc-render-all t)
-  (lsp-prefer-flymake nil))
+;; for go's LSP I want to use staticcheck and placeholders for completion
+(customize-set-variable 'eglot-workspace-configuration
+                        '((:gopls .
+                                  ((staticcheck     . t)
+                                   (matcher         . "CaseSensitive")
+                                   (usePlaceholders . t)))))
+
+;; ensure we load eglot for some specific modes
+(dolist (hook '(go-mode-hook nix-mode-hook))
+  (add-hook hook 'eglot-ensure))
 #+end_src
 
-+ =C-c l= brings a menu via [[https://github.com/abo-abo/hydra][hydra]]
-+ By default it seems that =staticcheck= is not used, so I force it with the =lsp-register-custom-settings=
-+ I prefer [[https://www.flycheck.org/en/latest/][flycheck]]
-*** =lsp-ui=
-This is mostly for UI tweaks. I use the following configuration
-#+begin_src elisp
-(use-package lsp-ui
-  :ensure t
-  :hook (lsp-mode . lsp-ui-mode)
-  :commands lsp-ui-mode
-  :custom
-  (lsp-ui-doc-delay 0.4)
-  (lsp-ui-doc-enable t)
-  (lsp-ui-doc-position 'top)
-  (lsp-ui-doc-include-signature t)
-  (lsp-ui-peek-enable t)
-  (lsp-ui-sideline-enable t)
-  (lsp-ui-imenu-enable t)
-  (lsp-ui-flycheck-enable t))
-
-#+end_src
-*** =lsp-ivy=
-I use ivy for completion, [[https://github.com/emacs-lsp/lsp-ivy][it provides]] completion based on the current workspace. This is my configuration:
-#+begin_src elisp
-(use-package lsp-ivy
-  :ensure t
-  :commands lsp-ivy-workspace-symbol)
-#+end_src
-*** =lsp-treemacs=
-[[https://github.com/emacs-lsp/lsp-treemacs][It provides]] some nice improvement regarding the UI. This is my configuration:
-#+begin_src elisp
-(use-package lsp-treemacs
-  :ensure t
-  :config
-  (lsp-treemacs-sync-mode 1))
-
-#+end_src
+=eglot= integrates well with existing modes for Emacs, mainly xref, flymake, eldoc.
 * Profiling
 ** pprof
 [[https://github.com/google/pprof][pprof]] is a tool to visualize performance data. Let's start with the following test: