Doom-emacs: Golang autocomplete + linting

Created on 25 Jan 2020  路  25Comments  路  Source: hlissner/doom-emacs

What are you trying to achieve?
When typing package names such as fmt or os I'd like to see the list of available functions such as fmt.Println(). Also, currently, I only get visual indications for errors when the file is saved. I would love to be able to see errors/typos in real-time.

What have you tried?
I've tried adding packages like (packages! go-autocomplete) to packages.el file, I looked for eldoc support, and I eventually posted a prior issue (which was resolved almost immediately, by the way! You rock.) which I thought would solve the issue by getting the go language to be recognized.

Of course, I can't rule out that there's probably something I missed as I'm brand-new to emacs and my first venture into it is using Doom (because tbh it looks awesome).

Additional information

System information

emacs   version    26.3
        features   XPM JPEG TIFF GIF PNG RSVG IMAGEMAGICK SOUND GPM DBUS GSETTINGS GLIB NOTIFY LIBSELINUX GNUTLS LIBXML2 FREETYPE M17N_FLT LIBOTF XFT ZLIB TOOLKIT_SCROLL_BARS GTK3 X11 XDBE XIM MODULES THREADS XWIDGETS LIBSYSTEMD LCMS2
        build      Sep 16, 2019
        buildopts  (--build=x86_64-linux-gnu --prefix=/usr '--includedir=${prefix}/include' '--mandir=${prefix}/share/man' '--infodir=${prefix}/share/info' --sysconfdir=/etc --localstatedir=/var --disable-silent-rules '--libdir=${prefix}/lib/x86_64-linux-gnu' '--libexecdir=${prefix}/lib/x86_64-linux-gnu' --disable-maintainer-mode --disable-dependency-tracking --prefix=/usr --sharedstatedir=/var/lib --program-suffix=26 --with-modules --with-file-notification=inotify --with-mailutils --with-x=yes --with-x-toolkit=gtk3 --with-xwidgets --with-lcms2 'CFLAGS=-g -O2 -fdebug-prefix-map=/build/emacs26-TP6iDo/emacs26-26.3~1.git96dd019=. -fstack-protector-strong -Wformat -Werror=format-security -no-pie' 'CPPFLAGS=-Wdate-time -D_FORTIFY_SOURCE=2' 'LDFLAGS=-Wl,-Bsymbolic-functions -Wl,-z,relro -no-pie')
        windowsys  x
        daemonp    server-running
doom    version    2.0.9
        build      HEAD -> develop, origin/develop, origin/HEAD 3ebdc513f 2020-01-24 05:16:09 -0500
        dir        ~/.doom.d/
system  type       gnu/linux
        config     x86_64-pc-linux-gnu
        shell      /bin/bash
        uname      Linux 5.3.0-26-generic #28~18.04.1-Ubuntu SMP Wed Dec 18 16:40:14 UTC 2019 x86_64
        path       (~/.emacs.d/bin /usr/local/sbin /usr/local/bin /usr/sbin /usr/bin /sbin /bin /usr/games /usr/local/games /usr/local/go/bin /usr/lib/x86_64-linux-gnu/emacs/26.3/x86_64-linux-gnu/)
config  envfile    envvar-file
        elc-files  0
        modules    (:completion (company +auto) ivy :ui doom doom-dashboard doom-quit hl-todo modeline nav-flash neotree ophints (popup +all +defaults) vc-gutter vi-tilde-fringe window-select workspaces :editor (evil +everywhere) file-templates fold multiple-cursors rotate-text snippets :emacs electric ibuffer vc :term term :checkers syntax :tools (eval +overlay) (lookup +docsets) magit :lang data emacs-lisp (go +lsp) javascript markdown (org +dragndrop +hugo +present) python sh :config (default +bindings +smartparens))
        packages   ((company-go :pin "939b4a677f2f843ea13d9dd90206d57111f0ceb9"))
        elpa       (popup go-autocomplete auto-complete)

:completion company :lang go :tools lsp question

All 25 comments

I am not sure if this is possible to achieve with go-autocomplete I do use (go +lsp) and it has all the features you want to have.

I have (go +lsp) in my .doom.d/init.el file, but it doesn't seem to do auto-complete for even the standard library, as in the screenshots. My emacs is basically 100% fresh, so I don't think there are any other conflicts.

If it makes a difference, I'm on Mint

@Proziam could you paste the lsp-log messages?

@iris-garcia I'd be happy to, can you give me some direction on where to find the lsp-log? Apologies for being a noob, I tried to find some information from google but found mention of the existence of lsp logs but not how to access them.

@Proziam Enable debug mode with SPC h d d (or M-x doom/toggle-debug-mode) and lsp should create an *lsp-log* buffer you can switch to (with SPC b b).

@hlissner thanks a bunch! Here is what I get back:

Debugger entered--Lisp error: (error "Empty string for buffer name is not allowed")
  get-buffer-create("")
  window-normalize-buffer-to-switch-to("")
  #f(compiled-function (buffer-or-name &optional norecord force-same-window) "Display buffer BUFFER-OR-NAME in the selected window.\n\nWARNING: This is NOT the way to work on another buffer temporarily\nwithin a Lisp program!  Use `set-buffer' instead.  That avoids\nmessing with the window-buffer correspondences.\n\nIf the selected window cannot display the specified buffer\nbecause it is a minibuffer window or strongly dedicated to\nanother buffer, call `pop-to-buffer' to select the buffer in\nanother window.  In interactive use, if the selected window is\nstrongly dedicated to its buffer, the value of the option\n`switch-to-buffer-in-dedicated-window' specifies how to proceed.\n\nIf called interactively, read the buffer name using `read-buffer'.\nThe variable `confirm-nonexistent-file-or-buffer' determines\nwhether to request confirmation before creating a new buffer.\nSee `read-buffer' for features related to input and completion\nof buffer names.\n\nBUFFER-OR-NAME may be a buffer, a string (a buffer name), or nil.\nIf BUFFER-OR-NAME is a string that does not identify an existing\nbuffer, create a buffer with that name.  If BUFFER-OR-NAME is\nnil, switch to the buffer returned by `other-buffer'.\n\nIf optional argument NORECORD is non-nil, do not put the buffer\nat the front of the buffer list, and do not make the window\ndisplaying it the most recently selected one.\n\nIf optional argument FORCE-SAME-WINDOW is non-nil, the buffer\nmust be displayed in the selected window when called\nnon-interactively; if that is impossible, signal an error rather\nthan calling `pop-to-buffer'.\n\nThe option `switch-to-buffer-preserve-window-point' can be used\nto make the buffer appear at its last position in the selected\nwindow.\n\nReturn the buffer switched to." (interactive #f(compiled-function () #<bytecode 0x1a4bdad>)) #<bytecode 0x2304cf>)("" nil force-same-window)
  apply(#f(compiled-function (buffer-or-name &optional norecord force-same-window) "Display buffer BUFFER-OR-NAME in the selected window.\n\nWARNING: This is NOT the way to work on another buffer temporarily\nwithin a Lisp program!  Use `set-buffer' instead.  That avoids\nmessing with the window-buffer correspondences.\n\nIf the selected window cannot display the specified buffer\nbecause it is a minibuffer window or strongly dedicated to\nanother buffer, call `pop-to-buffer' to select the buffer in\nanother window.  In interactive use, if the selected window is\nstrongly dedicated to its buffer, the value of the option\n`switch-to-buffer-in-dedicated-window' specifies how to proceed.\n\nIf called interactively, read the buffer name using `read-buffer'.\nThe variable `confirm-nonexistent-file-or-buffer' determines\nwhether to request confirmation before creating a new buffer.\nSee `read-buffer' for features related to input and completion\nof buffer names.\n\nBUFFER-OR-NAME may be a buffer, a string (a buffer name), or nil.\nIf BUFFER-OR-NAME is a string that does not identify an existing\nbuffer, create a buffer with that name.  If BUFFER-OR-NAME is\nnil, switch to the buffer returned by `other-buffer'.\n\nIf optional argument NORECORD is non-nil, do not put the buffer\nat the front of the buffer list, and do not make the window\ndisplaying it the most recently selected one.\n\nIf optional argument FORCE-SAME-WINDOW is non-nil, the buffer\nmust be displayed in the selected window when called\nnon-interactively; if that is impossible, signal an error rather\nthan calling `pop-to-buffer'.\n\nThe option `switch-to-buffer-preserve-window-point' can be used\nto make the buffer appear at its last position in the selected\nwindow.\n\nReturn the buffer switched to." (interactive #f(compiled-function () #<bytecode 0x1a4bf09>)) #<bytecode 0x2304cf>) "" (nil force-same-window))
  (and t (apply orig-fn buffer-or-name args))
  (let* ((buffer (and t (apply orig-fn buffer-or-name args)))) (if buffer (progn (save-current-buffer (set-buffer (if (windowp buffer) (window-buffer buffer) buffer)) (run-hooks (quote doom-switch-buffer-hook))) buffer) nil))
  (let ((doom-inhibit-switch-buffer-hooks t)) (let* ((buffer (and t (apply orig-fn buffer-or-name args)))) (if buffer (progn (save-current-buffer (set-buffer (if (windowp buffer) (window-buffer buffer) buffer)) (run-hooks (quote doom-switch-buffer-hook))) buffer) nil)))
  (if (or doom-inhibit-switch-buffer-hooks (eq (current-buffer) (get-buffer buffer-or-name)) (and (eq orig-fn (function switch-to-buffer)) (car args))) (apply orig-fn buffer-or-name args) (let ((doom-inhibit-switch-buffer-hooks t)) (let* ((buffer (and t (apply orig-fn buffer-or-name args)))) (if buffer (progn (save-current-buffer (set-buffer (if ... ... buffer)) (run-hooks (quote doom-switch-buffer-hook))) buffer) nil))))
  (let ((gc-cons-threshold most-positive-fixnum)) (if (or doom-inhibit-switch-buffer-hooks (eq (current-buffer) (get-buffer buffer-or-name)) (and (eq orig-fn (function switch-to-buffer)) (car args))) (apply orig-fn buffer-or-name args) (let ((doom-inhibit-switch-buffer-hooks t)) (let* ((buffer (and t (apply orig-fn buffer-or-name args)))) (if buffer (progn (save-current-buffer (set-buffer ...) (run-hooks ...)) buffer) nil)))))
  doom-run-switch-buffer-hooks-a(#f(compiled-function (buffer-or-name &optional norecord force-same-window) "Display buffer BUFFER-OR-NAME in the selected window.\n\nWARNING: This is NOT the way to work on another buffer temporarily\nwithin a Lisp program!  Use `set-buffer' instead.  That avoids\nmessing with the window-buffer correspondences.\n\nIf the selected window cannot display the specified buffer\nbecause it is a minibuffer window or strongly dedicated to\nanother buffer, call `pop-to-buffer' to select the buffer in\nanother window.  In interactive use, if the selected window is\nstrongly dedicated to its buffer, the value of the option\n`switch-to-buffer-in-dedicated-window' specifies how to proceed.\n\nIf called interactively, read the buffer name using `read-buffer'.\nThe variable `confirm-nonexistent-file-or-buffer' determines\nwhether to request confirmation before creating a new buffer.\nSee `read-buffer' for features related to input and completion\nof buffer names.\n\nBUFFER-OR-NAME may be a buffer, a string (a buffer name), or nil.\nIf BUFFER-OR-NAME is a string that does not identify an existing\nbuffer, create a buffer with that name.  If BUFFER-OR-NAME is\nnil, switch to the buffer returned by `other-buffer'.\n\nIf optional argument NORECORD is non-nil, do not put the buffer\nat the front of the buffer list, and do not make the window\ndisplaying it the most recently selected one.\n\nIf optional argument FORCE-SAME-WINDOW is non-nil, the buffer\nmust be displayed in the selected window when called\nnon-interactively; if that is impossible, signal an error rather\nthan calling `pop-to-buffer'.\n\nThe option `switch-to-buffer-preserve-window-point' can be used\nto make the buffer appear at its last position in the selected\nwindow.\n\nReturn the buffer switched to." (interactive #f(compiled-function () #<bytecode 0xfcdd09>)) #<bytecode 0x2304cf>) "" nil force-same-window)
  apply(doom-run-switch-buffer-hooks-a #f(compiled-function (buffer-or-name &optional norecord force-same-window) "Display buffer BUFFER-OR-NAME in the selected window.\n\nWARNING: This is NOT the way to work on another buffer temporarily\nwithin a Lisp program!  Use `set-buffer' instead.  That avoids\nmessing with the window-buffer correspondences.\n\nIf the selected window cannot display the specified buffer\nbecause it is a minibuffer window or strongly dedicated to\nanother buffer, call `pop-to-buffer' to select the buffer in\nanother window.  In interactive use, if the selected window is\nstrongly dedicated to its buffer, the value of the option\n`switch-to-buffer-in-dedicated-window' specifies how to proceed.\n\nIf called interactively, read the buffer name using `read-buffer'.\nThe variable `confirm-nonexistent-file-or-buffer' determines\nwhether to request confirmation before creating a new buffer.\nSee `read-buffer' for features related to input and completion\nof buffer names.\n\nBUFFER-OR-NAME may be a buffer, a string (a buffer name), or nil.\nIf BUFFER-OR-NAME is a string that does not identify an existing\nbuffer, create a buffer with that name.  If BUFFER-OR-NAME is\nnil, switch to the buffer returned by `other-buffer'.\n\nIf optional argument NORECORD is non-nil, do not put the buffer\nat the front of the buffer list, and do not make the window\ndisplaying it the most recently selected one.\n\nIf optional argument FORCE-SAME-WINDOW is non-nil, the buffer\nmust be displayed in the selected window when called\nnon-interactively; if that is impossible, signal an error rather\nthan calling `pop-to-buffer'.\n\nThe option `switch-to-buffer-preserve-window-point' can be used\nto make the buffer appear at its last position in the selected\nwindow.\n\nReturn the buffer switched to." (interactive #f(compiled-function () #<bytecode 0xfcde65>)) #<bytecode 0x2304cf>) ("" nil force-same-window))
  #f(advice-wrapper :around #f(compiled-function (buffer-or-name &optional norecord force-same-window) "Display buffer BUFFER-OR-NAME in the selected window.\n\nWARNING: This is NOT the way to work on another buffer temporarily\nwithin a Lisp program!  Use `set-buffer' instead.  That avoids\nmessing with the window-buffer correspondences.\n\nIf the selected window cannot display the specified buffer\nbecause it is a minibuffer window or strongly dedicated to\nanother buffer, call `pop-to-buffer' to select the buffer in\nanother window.  In interactive use, if the selected window is\nstrongly dedicated to its buffer, the value of the option\n`switch-to-buffer-in-dedicated-window' specifies how to proceed.\n\nIf called interactively, read the buffer name using `read-buffer'.\nThe variable `confirm-nonexistent-file-or-buffer' determines\nwhether to request confirmation before creating a new buffer.\nSee `read-buffer' for features related to input and completion\nof buffer names.\n\nBUFFER-OR-NAME may be a buffer, a string (a buffer name), or nil.\nIf BUFFER-OR-NAME is a string that does not identify an existing\nbuffer, create a buffer with that name.  If BUFFER-OR-NAME is\nnil, switch to the buffer returned by `other-buffer'.\n\nIf optional argument NORECORD is non-nil, do not put the buffer\nat the front of the buffer list, and do not make the window\ndisplaying it the most recently selected one.\n\nIf optional argument FORCE-SAME-WINDOW is non-nil, the buffer\nmust be displayed in the selected window when called\nnon-interactively; if that is impossible, signal an error rather\nthan calling `pop-to-buffer'.\n\nThe option `switch-to-buffer-preserve-window-point' can be used\nto make the buffer appear at its last position in the selected\nwindow.\n\nReturn the buffer switched to." (interactive #f(compiled-function () #<bytecode 0x1c0af79>)) #<bytecode 0x2304cf>) doom-run-switch-buffer-hooks-a)("" nil force-same-window)
  ad-Advice-switch-to-buffer(#f(advice-wrapper :around #f(compiled-function (buffer-or-name &optional norecord force-same-window) "Display buffer BUFFER-OR-NAME in the selected window.\n\nWARNING: This is NOT the way to work on another buffer temporarily\nwithin a Lisp program!  Use `set-buffer' instead.  That avoids\nmessing with the window-buffer correspondences.\n\nIf the selected window cannot display the specified buffer\nbecause it is a minibuffer window or strongly dedicated to\nanother buffer, call `pop-to-buffer' to select the buffer in\nanother window.  In interactive use, if the selected window is\nstrongly dedicated to its buffer, the value of the option\n`switch-to-buffer-in-dedicated-window' specifies how to proceed.\n\nIf called interactively, read the buffer name using `read-buffer'.\nThe variable `confirm-nonexistent-file-or-buffer' determines\nwhether to request confirmation before creating a new buffer.\nSee `read-buffer' for features related to input and completion\nof buffer names.\n\nBUFFER-OR-NAME may be a buffer, a string (a buffer name), or nil.\nIf BUFFER-OR-NAME is a string that does not identify an existing\nbuffer, create a buffer with that name.  If BUFFER-OR-NAME is\nnil, switch to the buffer returned by `other-buffer'.\n\nIf optional argument NORECORD is non-nil, do not put the buffer\nat the front of the buffer list, and do not make the window\ndisplaying it the most recently selected one.\n\nIf optional argument FORCE-SAME-WINDOW is non-nil, the buffer\nmust be displayed in the selected window when called\nnon-interactively; if that is impossible, signal an error rather\nthan calling `pop-to-buffer'.\n\nThe option `switch-to-buffer-preserve-window-point' can be used\nto make the buffer appear at its last position in the selected\nwindow.\n\nReturn the buffer switched to." (interactive #f(compiled-function () #<bytecode 0x1c0b129>)) #<bytecode 0x2304cf>) doom-run-switch-buffer-hooks-a) "" nil force-same-window)
  apply(ad-Advice-switch-to-buffer #f(advice-wrapper :around #f(compiled-function (buffer-or-name &optional norecord force-same-window) "Display buffer BUFFER-OR-NAME in the selected window.\n\nWARNING: This is NOT the way to work on another buffer temporarily\nwithin a Lisp program!  Use `set-buffer' instead.  That avoids\nmessing with the window-buffer correspondences.\n\nIf the selected window cannot display the specified buffer\nbecause it is a minibuffer window or strongly dedicated to\nanother buffer, call `pop-to-buffer' to select the buffer in\nanother window.  In interactive use, if the selected window is\nstrongly dedicated to its buffer, the value of the option\n`switch-to-buffer-in-dedicated-window' specifies how to proceed.\n\nIf called interactively, read the buffer name using `read-buffer'.\nThe variable `confirm-nonexistent-file-or-buffer' determines\nwhether to request confirmation before creating a new buffer.\nSee `read-buffer' for features related to input and completion\nof buffer names.\n\nBUFFER-OR-NAME may be a buffer, a string (a buffer name), or nil.\nIf BUFFER-OR-NAME is a string that does not identify an existing\nbuffer, create a buffer with that name.  If BUFFER-OR-NAME is\nnil, switch to the buffer returned by `other-buffer'.\n\nIf optional argument NORECORD is non-nil, do not put the buffer\nat the front of the buffer list, and do not make the window\ndisplaying it the most recently selected one.\n\nIf optional argument FORCE-SAME-WINDOW is non-nil, the buffer\nmust be displayed in the selected window when called\nnon-interactively; if that is impossible, signal an error rather\nthan calling `pop-to-buffer'.\n\nThe option `switch-to-buffer-preserve-window-point' can be used\nto make the buffer appear at its last position in the selected\nwindow.\n\nReturn the buffer switched to." (interactive #f(compiled-function () #<bytecode 0x1c85ad9>)) #<bytecode 0x2304cf>) doom-run-switch-buffer-hooks-a) ("" nil force-same-window))
  switch-to-buffer("" nil force-same-window)
  ivy--switch-buffer-action("")
  ivy-call()
  ivy-read("Switch to workspace buffer: " internal-complete-buffer :action ivy--switch-buffer-action :predicate +ivy--is-workspace-other-buffer-p :update-fn nil :unwind nil :preselect "*scratch*" :matcher ivy--switch-buffer-matcher :keymap (keymap (33554443 . scroll-down-command) (33554442 . scroll-up-command) (10 . next-line) (26 closure (t) nil (interactive) (condition-case nil (progn (call-interactively (function undo))) (error nil))) (23 . doom/delete-backward-word) (22 . yank) (21 . evil-delete-back-to-indentation) (18 . evil-paste-from-register) (1 . move-beginning-of-line) (escape . abort-recursive-edit) (19 . counsel-minibuffer-history) (11 . previous-line)) :caller ivy-switch-buffer)
  (let ((current (not other)) prompt action filter update unwind) (cond ((and workspace current) (setq prompt "Switch to workspace buffer: " action (function ivy--switch-buffer-action) filter (function +ivy--is-workspace-other-buffer-p))) (workspace (setq prompt "Switch to workspace buffer in other window: " action (function ivy--switch-buffer-other-window-action) filter (function +ivy--is-workspace-buffer-p))) (current (setq prompt "Switch to buffer: " action (function ivy--switch-buffer-action))) ((setq prompt "Switch to buffer in other window: " action (function ivy--switch-buffer-other-window-action)))) (if +ivy-buffer-preview (progn (cond ((not (and ivy-use-virtual-buffers (eq +ivy-buffer-preview ...))) (setq update (function +ivy--switch-buffer-preview) unwind (function +ivy--switch-buffer-unwind))) ((setq update (function +ivy--switch-buffer-preview-all) unwind (function +ivy--switch-buffer-unwind)))))) (ivy-read prompt (quote internal-complete-buffer) :action action :predicate filter :update-fn update :unwind unwind :preselect (buffer-name (other-buffer (current-buffer))) :matcher (function ivy--switch-buffer-matcher) :keymap ivy-switch-buffer-map :caller (function ivy-switch-buffer)))
  +ivy--switch-buffer(t nil)
  +ivy/switch-workspace-buffer(nil)
  funcall-interactively(+ivy/switch-workspace-buffer nil)
  call-interactively(+ivy/switch-workspace-buffer nil nil)
  command-execute(+ivy/switch-workspace-buffer)

As it appears on my screen (might be more readable): Screenshot

BTW, I tried to switch using SPC b b but was only getting workspace buffers, nothing related to lsp. I'm not exactly sure what I punched in to get this up, was just trying a few things to see what I could do.

Hi @Proziam, completion with LSP works for me. Have you checked that your emacs can actually find gopls command? You can try it by running it in a shell in emacs for example.

On info howto install gopls check: https://github.com/golang/tools/blob/master/gopls/doc/user.md#installation

@Proziam Sorry for the late response.

BTW, I tried to switch using SPC b b but was only getting workspace buffers, nothing related to lsp. I'm not exactly sure what I punched in to get this up, was just trying a few things to see what I could do.

SPC b b only lists workspace buffers. SPC b B will list all buffers, across all workspaces (and more). You'll want the latter to find *lsp-log*.

In any case, the particular error you mentioned is unrelated, but was fixed sometime in the past month. Try upgrading Doom. Perhaps your Go issue will be resolved along with it.

When typing package names such as fmt or os I'd like to see the list of available functions such as fmt.Println().

What's concerning about your config is that you appear to have installed company-go, auto-complete and go-autocomplete. auto-complete conflicts with company, and the :lang go module already installs company-go for you. There are likely conflicts. I suggest removing them from your packages.el and running doom purge.

With :lang (go +lsp) we use LSP (so long as gopls is installed). LSP is exceptionally good at code completion, and is likely what you want.

With :lang go (without +lsp), it falls back to company-go, which uses stamblerre/gocode installed on your system. This (from what I've been told) is inferior to LSP.

Also, currently, I only get visual indications for errors when the file is saved. I would love to be able to see errors/typos in real-time.

We've restricted flycheck into checking only when you save for performance's sake. By changing flycheck-check-syntax-automatically you can have it check in real time:

(after! flycheck
  (setq flycheck-check-syntax-automatically '(save idle-change new-line mode-enabled)))

See SPC h v flycheck-check-syntax-automatically (or C-h v flycheck-check-syntax-automatically if you aren't using evil) for more possible values for this variable.


Hope that helps!

is there any way to enable showing types on hover?

Hi there. I''m trying to switch from spacemacs to doom and for now I have both distributions.
I've just installed doom emacs, uncomment (go +lsp) and when I open some *.go project files, status of gopl is permanently connecting and no linting, no autocomplete.
In the other hand I start spacemacs with the same bunch of tools and it works well.


Mesages buffer

LSP :: Guessed project root is ~/Documents/projects/another-go-test
LSP :: Connected to [gopls:25870 status:starting].
LSP :: json: cannot unmarshal object into Go struct field .capabilities.textDocument.publishDiagnostics.tagSupport of type bool



LSP log buffer

Command "gopls" is present on the path.
Command "bingo" is present on the path.
Command "go-langserver" is present on the path.
Found the following clients for /home/user/Documents/projects/another-go-test/main.go: (server-id gopls, priority 0), (server-id go-bingo, priority -1), (server-id go-ls, priority -2)
The following clients were selected based on priority: (server-id gopls, priority 0)

The behavior
Screenshot_20200304_004640

And status of gopls is always starting

Sorry for my English.
Regards.

@hlissner thanks for the help! It seems there may have been conflicts as you pointed out. I will definitely try out the flycheck change as well.

consider this solved for me - but it appears a few others have questions so I'll let someone else take the decision to close or not.

I fixed my problem. Just deleted go-tools that I installed from my os repository, and the problem is gone.

I have this same problem, and I don't see any log when I put emacs into debug mode.

Same here, fresh install, go tools installed, the bin directory is in exec-path list and I can run gopls from an emacs shell (getting gopls: disconnected). Yet I see no lsp-log buffer and no other error messages. Autocomplete doesn't work, when I try it manually with ctrl + space it doesn't even suggest local names from the same file. Any ideas on how to debug?

Ok, totally my bad... lsp wasn't enabled. :( facepalm. Now everything works like a charm.

Hi! I'm also having trouble getting autocomplete/lsp to work.

I'm getting this in *lsp-log* even though gopls is the PATH generated in ~/.emacs.d/.local/env:

Command "gopls" is not present on the path.
Command "bingo" is not present on the path.
Command "go-langserver" is not present on the path.

Flycheck works, though. I only enabled (go +lsp) and lsp in .doom.d/init.el. Do I need to add anything to .doom.d/config.el for LSP to find my stuff in PATH?

Hi, I'm having trouble too,
I can't find a way to make autocomplete work
my lsp-log

Command "gopls" is present on the path.
Command "bingo" is not present on the path.
Command "go-langserver" is not present on the path.
Found the following clients for /home/arconec/bo/main.go: (server-id gopls, priority 0)
The following clients were selected based on priority: (server-id gopls, priority 0)
2020/05/23 17:10:59 Build info
----------
golang.org/x/tools/cmd/gopls master-cmd.gopls
    golang.org/x/tools@(devel)
    golang.org/x/[email protected] h1:8gQV6CLnAEikrhgkHFbMAEhagSSnXWGV915qUMm9mrU=
    golang.org/x/[email protected] h1:9zdDQZ7Thm29KFXgAX/+yaf3eVbP7djjWp/dXAppNCc=

Go info
-------
go version go1.14.2 linux/amd64

GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/arconec/.cache/go-build"
GOENV="/home/arconec/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/arconec/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/lib/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/arconec/bo/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build445920769=/tmp/go-build -gno-record-gcc-switches"

2020/05/23 17:10:59 go/packages.Load
    packages = 9
2020/05/23 17:10:59 go/packages.Load
    package = contree/models
    files = [/home/arconec/bo/models/db.go /home/arconec/bo/models/user.go]
2020/05/23 17:10:59 go/packages.Load
    package = contree/api/auth
    files = [/home/arconec/bo/api/auth/auth.ctrl.go /home/arconec/bo/api/auth/auth.go]
2020/05/23 17:10:59 go/packages.Load
    package = contree/api
    files = [/home/arconec/bo/api/api.go]
2020/05/23 17:10:59 go/packages.Load
    package = contree/game
    files = [/home/arconec/bo/game/call.go /home/arconec/bo/game/card.go /home/arconec/bo/game/contree.go /home/arconec/bo/game/deck.go]
2020/05/23 17:10:59 go/packages.Load
    package = contree/iohandler
    files = [/home/arconec/bo/iohandler/endpoints.go /home/arconec/bo/iohandler/game.go /home/arconec/bo/iohandler/io.go /home/arconec/bo/iohandler/lobby.go /home/arconec/bo/iohandler/player.go]
2020/05/23 17:10:59 go/packages.Load
    package = contree/game
    files = [/home/arconec/bo/game/call.go /home/arconec/bo/game/card.go /home/arconec/bo/game/contree.go /home/arconec/bo/game/deck.go /home/arconec/bo/game/card_test.go /home/arconec/bo/game/contree_test.go]
2020/05/23 17:10:59 go/packages.Load
    package = contree/api/ping
    files = [/home/arconec/bo/api/ping/ping.ctrl.go /home/arconec/bo/api/ping/ping.go]
2020/05/23 17:10:59 go/packages.Load
    package = contree/game.test
    files = [/home/arconec/.cache/go-build/8e/8e4d7ac0c8cd3125a4a70816dc0baea450332e7c59a9d2faa9b894391215d013-d]
2020/05/23 17:10:59 go/packages.Load
    package = contree
    files = [/home/arconec/bo/main.go]
2020/05/23 17:11:02 go/packages.Load
    packages = 1
2020/05/23 17:11:02 go/packages.Load
    package = contree
    files = [/home/arconec/bo/main.go]
2020/05/23 17:11:02 no package for file: no parsed files for package contree
2020/05/23 17:11:03 no package for file: no parsed files for package contree
2020/05/23 17:11:03 no package for file: no parsed files for package contree
2020/05/23 17:11:03 no package for file: no parsed files for package contree
2020/05/23 17:11:03 no package for file: no parsed files for package contree
2020/05/23 17:11:03 no package for file: no parsed files for package contree
2020/05/23 17:11:03 no completions found
    At = {27 6}
    Failure = no parsed files for package contree
2020/05/23 17:11:05 : line is beyond end of file 2
2020/05/23 17:11:05 : line is beyond end of file 2
2020/05/23 17:11:05 : line is beyond end of file 2
2020/05/23 17:11:05 : line is beyond end of file 2
2020/05/23 17:11:05 : line is beyond end of file 2

This is in one of my project.

Recently I also found something wired, the completion sometimes it works, sometimes it doesn't. And I cant found out why...Sorry, I'm a fresh noob...I'm guessing it's due to the language server issues. Here I'm willing to share some info that might help.

I Manually Installed the go-langserver and the bingo(Dont figure out whether this two server matters, because gopls is the first priority server)

go get -u github.com/sourcegraph/go-langserver
go get -u github.com/saibing/bingo

If you also like Python a bit more:

[sudo] pip3 install python-language-server

After resync and restart(maybe restart your computer too...) and the completion just works fine for me now 馃槶馃槆, and the *lsp-log* looks like this:

image

Here are several configs might be related to this issue:

    :completion
    (company +auto)             ; the ultimate code completion backend

    :tools
    lsp

    :lang
    (go +lsp)
    (python +lsp
            +pyenv
            +cpython)            ; beautiful is better than ugly

I fixed my problem. Just deleted go-tools that I installed from my os repository, and the problem is gone.

This fixed the problem of ("file.go" is not part of a package - LSP), and the code auto-completion is now working as it should be as well for me on Arch Linux.

Hey everyone. I had this issue happen as well and I traced it back to an issue with an update to lsp-mode.

https://github.com/emacs-lsp/lsp-mode/issues/1778

Adding the following to my config.el has solved the issue for me temporarily. It is worth mentioning I am running emacs 27 and have only been able to reproduce this error with that version.

;; FIXME Fix for emacs 27
;; https://github.com/emacs-lsp/lsp-mode/issues/1778
(setq lsp-gopls-codelens nil)

Hope this is useful, cheers

Hey everyone. I had this issue happen as well and I traced it back to an issue with an update to lsp-mode.

emacs-lsp/lsp-mode#1778

Adding the following to my config.el has solved the issue for me temporarily. It is worth mentioning I am running emacs 27 and have only been able to reproduce this error with that version.

;; FIXME Fix for emacs 27
;; https://github.com/emacs-lsp/lsp-mode/issues/1778
(setq lsp-gopls-codelens nil)

Hope this is useful, cheers

Been struggeling with missing completion as well. This did the trick for me. Thanks a lot!

Even I had this issue on Arch linux. I had go-tools installed. I uninstalled it and followed the instructions here in doom emacs modules readme for the dependencies. Now it works flawlessly. I have also installed gopls from the official page here

Hi. I've been trying to get go lsp to work and none of the directions seem to be helping me. Whenever I open a go file it shows a message at the bottom saying File local-variables error: (doom-hook-error lsp! (invalid-function lsp!)). I'm on a mac and using all of the latest versions of emacs, go, etc.

Hi. I've been trying to get go lsp to work and none of the directions seem to be helping me. Whenever I open a go file it shows a message at the bottom saying File local-variables error: (doom-hook-error lsp! (invalid-function lsp!)). I'm on a mac and using all of the latest versions of emacs, go, etc.

@taylorallred I had the same issue and I just managed to fix it. It was because the lsp module wasn't loaded.

       :tools
       ;;ansible
       ;;debugger          ; FIXME stepping through code, to help you add bugs
       ;;direnv
       ;;docker
       ;;editorconfig      ; let someone else argue about tabs vs spaces
       ;;ein               ; tame Jupyter notebooks with emacs
       (eval +overlay)     ; run code, run (also, repls)
       ;;gist              ; interacting with github gists
       lookup              ; navigate your code and its documentation
       lsp
       ;;macos             ; MacOS-specific commands
       magit             ; a git porcelain for Emacs

I found the solution while browsing the debug logs, there was a message about it.

I have installed all the basic stuff, but I get no autocomplete.

  • (go +lsp) and lsp added init.el
  • gopls installed and path added
  • doom doctor is ok
  • tried FIXME Fix for emacs 27

System information:


SYSTEM type gnu/linux
config x86_64-pc-linux-gnu
shell /bin/bash
uname Linux 5.4.0-1025-gcp #25-Ubuntu SMP Fri Sep 11 15:02:15 UTC 2020 x86_64
path (/usr/local/sbin /usr/local/bin /usr/sbin /usr/bin /sbin /bin /usr/games /usr/local/games /snap/bin ~/.emacs.d/bin ~/go/bin /snap/emacs/current/usr/libexec/emacs/27.1/x86_64-pc-linux-gnu)
EMACS dir ~/.emacs.d/
version 27.1
build Aug 26, 2020
buildopts --prefix= --prefix=/snap/emacs/current/usr --with-xwidgets --with-x-toolkit=gtk3 --without-xaw3d --with-modules --with-cairo 'CFLAGS= -isystem/build/emacs/parts/emacs/install/usr/include -O2' 'CPPFLAGS= -isystem/build/emacs/parts/emacs/install/usr/include' 'LDFLAGS= -L/build/emacs/parts/emacs/install/lib -L/build/emacs/parts/emacs/install/usr/lib -L/build/emacs/parts/emacs/install/lib/x86_64-linux-gnu -L/build/emacs/parts/emacs/install/usr/lib/x86_64-linux-gnu'
features XPM JPEG TIFF GIF PNG RSVG CAIRO SOUND GPM DBUS GSETTINGS GLIB NOTIFY INOTIFY ACL LIBSELINUX GNUTLS LIBXML2 FREETYPE HARFBUZZ M17N_FLT LIBOTF ZLIB TOOLKIT_SCROLL_BARS GTK3 X11 XDBE XIM MODULES THREADS XWIDGETS LIBSYSTEMD JSON PDUMPER LCMS2 GMP
traits (envvar-file)
DOOM dir ~/.doom.d/
version 2.0.9
build grafted, HEAD -> develop, origin/develop, origin/HEAD 1456108 2020-09-10 18:03:32 -0400
elc-files 0
modules (:completion company ivy :ui doom doom-dashboard doom-quit hl-todo modeline ophints (popup +defaults) vc-gutter vi-tilde-fringe workspaces :editor (evil +everywhere) file-templates fold snippets :emacs dired electric undo vc :checkers syntax :tools (eval +overlay) lookup lsp magit :lang emacs-lisp (go +lsp) markdown org sh :config (default +bindings +smartparens))
packages (n/a)
unpin (n/a)
elpa (n/a)

When starting debug with doom-debug-mode I get this error. I have used gopls with spacemacs without problems.


Error

Error in pre-command-hook (evil-repeat-pre-hook): (wrong-type-argument number-or-marker-p "  explain-pause-report-measuring-bug(\"not top level in wrap-native for # nil t 0.01)
  apply(explain-pause--wrap-native # (nil t 0.01))
  read-event(nil t 0.01)
  sit-for(0.01)
  evil-esc((keymap (91 keymap (53 keymap (126 . [prior]) (59 keymap (50 keymap (126 . [S-prior])))) (54 keymap (126 . [next]) (59 keymap (50 keymap (126 . [S-next])))) (49 keymap (59 k$
")
ESC   explain-pause-report-measuring-bug("not top level in wrap-native for # nil t 0.01)
  apply(explain-pause--wrap-native # (nil t 0.01))
  read-event(nil t 0.01)
  sit-for(0.01)
  evil-esc((keymap (91 keymap (53 keymap (126 . [prior]) (59 keymap (50 keymap (126 . [S-prior])))) (54 keymap (126 . [next]) (59 keymap (50 keymap (126 . [S-next])))) (49 keymap (59 k$
 is undefined

OK, now it works. Looks like in Doom you need to be in a project, in Spacemacs it seemed to work without.

Was this page helpful?
0 / 5 - 0 ratings