Skip to content

Commit 04e4857

Browse files
authored
feat(go): Add auto install for gopls (#4650)
1 parent 791d9a3 commit 04e4857

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

clients/lsp-go.el

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,16 @@ These are assembled from the customizable variables `lsp-go-server-path'
428428
and `lsp-go-server-wrapper-function'."
429429
(funcall lsp-go-server-wrapper-function (append (list lsp-go-gopls-server-path) lsp-go-gopls-server-args)))
430430

431+
(defun lsp-go--cls-download-server (_client callback error-callback _update?)
432+
"Install/update shader-ls language server using `go install'.
433+
434+
Will invoke CALLBACK or ERROR-CALLBACK based on result.
435+
Will update if UPDATE? is t"
436+
(lsp-async-start-process
437+
callback
438+
error-callback
439+
"go" "install" "golang.org/x/tools/gopls@latest"))
440+
431441
(lsp-register-client
432442
(make-lsp-client :new-connection (lsp-stdio-connection 'lsp-go--server-command)
433443
:activation-fn (lsp-activate-on "go" "go.mod")
@@ -438,7 +448,8 @@ and `lsp-go-server-wrapper-function'."
438448
:library-folders-fn #'lsp-go--library-default-directories
439449
:after-open-fn (lambda ()
440450
;; https://github.com/golang/tools/commit/b2d8b0336
441-
(setq-local lsp-completion-filter-on-incomplete nil))))
451+
(setq-local lsp-completion-filter-on-incomplete nil))
452+
:download-server-fn #'lsp-go--cls-download-server))
442453

443454
(lsp-consistency-check lsp-go)
444455

0 commit comments

Comments
 (0)