From 710a9c75c7fd714d2f9783ab515902f8ae72a19e Mon Sep 17 00:00:00 2001 From: Martin Polden Date: Wed, 13 May 2020 21:58:25 +0200 Subject: Enable eglot imenu integration Now works with gopls. --- lisp/init-eglot.el | 6 +----- lisp/init-go.el | 30 +----------------------------- 2 files changed, 2 insertions(+), 34 deletions(-) (limited to 'lisp') diff --git a/lisp/init-eglot.el b/lisp/init-eglot.el index f852bcf..1b407c7 100644 --- a/lisp/init-eglot.el +++ b/lisp/init-eglot.el @@ -15,10 +15,6 @@ :config ;; disable symbol highlighting and documentation on hover (setq eglot-ignored-server-capabilites '(:documentHighlightProvider - :hoverProvider)) - - ;; disable imenu integration as it's currently unsupported with gopls - ;; https://github.com/joaotavora/eglot/pull/303 - (setq eglot-stay-out-of '("imenu"))) + :hoverProvider))) (provide 'init-eglot) diff --git a/lisp/init-go.el b/lisp/init-go.el index 499da78..c7308a5 100644 --- a/lisp/init-go.el +++ b/lisp/init-go.el @@ -1,34 +1,6 @@ -(defun go-mode-create-imenu-index () - "Create and return an imenu index alist. Unlike the default -alist created by go-mode, this method creates an alist where -items follow a style that is consistent with other prog-modes." - (let* ((patterns '(("type" "^type *\\([^ \t\n\r\f]*\\)" 1))) - (type-index (imenu--generic-function patterns)) - (func-index)) - (save-excursion - (goto-char (point-min)) - (while (re-search-forward go-func-meth-regexp (point-max) t) - (let* ((var (match-string-no-properties 1)) - (func (match-string-no-properties 2)) - (name (if var - (concat (substring var 0 -1) "." func) - func)) - (beg (match-beginning 0)) - (marker (copy-marker beg)) - (item (cons name marker))) - (setq func-index (cons item func-index))))) - (nconc type-index (list (cons "func" func-index))))) - -(defun go-mode-create-flat-imenu-index () - "Return a flat imenu index alist. See `go-mode-create-imenu-index'." - (apply 'nconc (mapcar 'cdr (go-mode-create-imenu-index)))) - (defun go-mode-buffer-local-variables () ;; adjust fill-column - (setq-local fill-column 120) - ;; use flat imenu index - (setq-local imenu-create-index-function - #'go-mode-create-flat-imenu-index)) + (setq-local fill-column 120)) (use-package go-mode :hook (go-mode . go-mode-buffer-local-variables)) -- cgit v1.2.3