-
-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Golang autocomplete + linting #2426
Comments
I am not sure if this is possible to achieve with |
I have If it makes a difference, I'm on Mint |
@Proziam could you paste the |
@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 |
@hlissner thanks a bunch! Here is what I get back:
As it appears on my screen (might be more readable): Screenshot BTW, I tried to switch using |
Hi @Proziam, completion with LSP works for me. Have you checked that your emacs can actually find On info howto install |
@Proziam Sorry for the late response.
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.
What's concerning about your config is that you appear to have installed With With
We've restricted flycheck into checking only when you save for performance's sake. By changing (after! flycheck
(setq flycheck-check-syntax-automatically '(save idle-change new-line mode-enabled))) See 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. 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) ```And status of gopls is always Sorry for my English. |
@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
Flycheck works, though. I only enabled |
Hi, I'm having trouble too,
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 get -u github.com/sourcegraph/go-langserver
go get -u github.com/saibing/bingo If you also like [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 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
|
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. 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 |
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 |
@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.
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. ErrorError 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. |
I have a same problem,I added the following code to (setq lsp-gopls-staticcheck t)
(setq lsp-eldoc-render-all t)
(setq lsp-gopls-complete-unimported t)
(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)
;; Company mode is a standard completion package that works well with lsp-mode.
(use-package company
:ensure t
:config
;; Optionally enable completion-as-you-type behavior.
(setq company-idle-delay 0)
(setq company-minimum-prefix-length 1))
;; Optional - provides snippet support.
(use-package yasnippet
:ensure t
:commands yas-minor-mode
:hook (go-mode . yas-minor-mode)) |
This issue has been automatically marked stale because of a lack of recent activity. If this issue is still valid, reply to it or remove the label or it will be closed in 7 days. |
What are you trying to achieve?
When typing package names such as
fmt
oros
I'd like to see the list of available functions such asfmt.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
Certain autocompletes do work, such as
struct
andif err !=nil
It does show errors after saving, just not in real-time
It does detect the correct go version
System information
The text was updated successfully, but these errors were encountered: