Skip to content

Instantly share code, notes, and snippets.

@sirn
Last active October 7, 2022 17:53
Show Gist options
  • Save sirn/510fbd9c15c0f85533fdbb62569200c8 to your computer and use it in GitHub Desktop.
Save sirn/510fbd9c15c0f85533fdbb62569200c8 to your computer and use it in GitHub Desktop.
Gopls failing under Eglot

Gopls failing under Eglot

Demostrating Gopls failing under Eglot v0.9.5.

Instructions

  1. Save init-eglot-test.el somewhere
  2. Save main.go at $PWD
  3. Run Emacs using:
    • GUI mode: /path/to/Emacs.app/MacOS/Emacs -Q -l test-eglot.el
    • Terminal mode: /path/to/Emacs.app/MacOS/Emacs -nw -Q -l test-eglot.el

Note

It may not fail on the first start (when e.g. go-mode is being compiled), but subsequent runs will/may fail.

(setq user-emacs-directory (format "~/.emacs.d/%s/%s/" (file-name-base load-file-name) emacs-version))
(setq package-user-dir (concat user-emacs-directory "elpa/"))
(setq package-archives
'(("gnu" . "https://elpa.gnu.org/packages/")
("melpa" . "https://melpa.org/packages/")))
(package-initialize)
(defun install-package (pkg)
(unless (package-installed-p pkg)
(package-refresh-contents)
(package-install pkg))
(require pkg))
(install-package 'eglot)
(install-package 'go-mode)
(add-to-list 'eglot-server-programs '(go-mode . ("gopls")))
(add-hook 'go-mode-hook 'eglot-ensure)
(add-hook 'after-init-hook
(lambda ()
(find-file "main.go")))
(run-hooks 'after-init-hook)
package main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment