From 65dea73b1362ba9ce03389e2148656bfba90d566 Mon Sep 17 00:00:00 2001 From: Raul Benencia Date: Tue, 26 May 2020 15:46:38 -0700 Subject: lsp in go --- .emacs.local.d/modes/lsp.el | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 .emacs.local.d/modes/lsp.el (limited to '.emacs.local.d/modes/lsp.el') diff --git a/.emacs.local.d/modes/lsp.el b/.emacs.local.d/modes/lsp.el new file mode 100644 index 0000000..30a5d8f --- /dev/null +++ b/.emacs.local.d/modes/lsp.el @@ -0,0 +1,19 @@ +(use-package lsp-mode + :ensure t + :commands (lsp lsp-deferred) + :hook (go-mode . lsp-deferred)) + +;;Set up before-save hooks to format buffer and add/delete imports. +;;Make sure you don't have other gofmt/goimports hooks enabled. + +(defun lsp-go-install-save-hooks () + (add-hook 'before-save-hook #'lsp-format-buffer t t) + (add-hook 'before-save-hook #'lsp-organize-imports t t)) +(add-hook 'go-mode-hook #'lsp-go-install-save-hooks) + +;;Optional - provides fancier overlays. +(use-package lsp-ui + :ensure t + :commands lsp-ui-mode + :init +) -- cgit v1.2.3