From 834d1a8c72adcb0d0b765c2391fd61d8b6c77856 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20Alvari=C3=B1o?= Date: Mon, 21 Mar 2022 16:01:53 +0100 Subject: [PATCH] Add a golang LSP configuration --- myconfig.org | 58 ++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 52 insertions(+), 6 deletions(-) diff --git a/myconfig.org b/myconfig.org index 2eabaeb..7190bd2 100644 --- a/myconfig.org +++ b/myconfig.org @@ -616,7 +616,8 @@ Quick navigation to words #+end_src * LSP - We are using =lsp-mode= but keep an eye on =eglot= as an alternative. + We are using [[https://emacs-lsp.github.io/lsp-mode/][lsp-mode]] but keep an eye on [[https://github.com/joaotavora/eglot][eglot]] as an alternative. + **WARNING**: =lsp-company= is no longer supported Links to check - [[https://emacs-lsp.github.io/lsp-mode/][LSP-mode Home]] @@ -629,6 +630,7 @@ Links to check - [[https://www.mortens.dev/blog/emacs-and-the-language-server-protocol/][Morten's Dev]] (tiene buena pinta) - [[https://mullikine.github.io/posts/setting-up-lsp-with-emacs-attempt-2/][Bodacious Blog]] (parece muy completo pero algo criptico) - [[https://gitlab.com/nathanfurnal/dotemacs/-/snippets/2060535][Nathan Furnal Guide]] +- [[https://emacs-lsp.github.io/lsp-mode/tutorials/how-to-turn-off/][A visual guide to LSP mode]] LSP mode, allows the use of Language Server Protocol for programming. @@ -650,7 +652,7 @@ LSP mode, allows the use of Language Server Protocol for programming. (lsp-print-performance t) ;; general - ;; (lsp-auto-guess-root t) + ;; (lsp-auto-guess-root t) ;; Probably you want to choose root interactively ;; (lsp-document-sync-method 'incremental) ;; none, full, incremental, or nil ;; (lsp-response-timeout 10) @@ -661,7 +663,6 @@ LSP mode, allows the use of Language Server Protocol for programming. ;; (company-lsp-async t) ;; (company-lsp-enable-recompletion t) ;; (company-lsp-enable-snippet t) - ;; (lsp-document-sync-method (quote incremental)) ;; :hook ;; ((python-mode . lsp-deferred) @@ -715,16 +716,61 @@ LSP mode, allows the use of Language Server Protocol for programming. ;; (lsp-ui-sideline-show-hover t) ;; (lsp-ui-sideline-show-symbol t) + :after lsp-mode) +#+end_src +** go +**WARNING**: you need to install =gopls= in your system. +**WARNING**: =company-go= is deprecated, don't use it +References: +- [[https://kasperdeng.github.io/2015/04/15/go-dev-env/][kasperdeng golang development enviroment]] +- [[https://github.com/golang/tools/tree/master/gopls][gopls repo]] +- [[https://gist.github.com/psanford/b5d2689ff1565ec7e46867245e3d2c76][psandford/gopls configuration]] +#+begin_src emacs-lisp + (use-package go-mode + :custom + ;; (lsp-enable-links nil) + ;; (lsp-clients-go-server-args '("--cache-style=always" "--diagnostics-style=onsave" "--format-style=goimports")) + (lsp-gopls-server-args '("--debug=localhost:6060")) + :hook + ((go-mode . lsp-deferred) + (before-save . lsp-format-buffer) + (before-save . lsp-organize-imports) + (before-save . gofmt-before-save) + ) + ) +#+end_src - :after lsp-mode) +*** go-snippets +#+begin_src emacs-lisp + (use-package go-snippets + :after go-mode + ) #+end_src -** go +*** got-projectile #+begin_src emacs-lisp -;; '(lsp-clients-go-server-args '("--cache-style=always" "--diagnostics-style=onsave" "--format-style=goimports")) --> + ;; (use-package go-projectile + ;; ) + +#+end_src + +*** go-test +#+begin_src emacs-lisp + (use-package gotest + :bind + (:map go-mode-map + ("C-c a t" . #'go-test-current-test) + ) + ) + #+end_src +** Rust +- [[https://robert.kra.hn/posts/2021-02-07_rust-with-emacs/][Robert Kra Emacs Rust Configuration]] + +** Python + * next #+begin_src emacs-lisp