Last active
June 9, 2022 09:45
-
-
Save rossabaker/52d60669192b0590c5c1775b1798ffa4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(use-package lsp-haskell | |
:config | |
(setq lsp-haskell-process-path-hie "haskell-language-server-wrapper") | |
;; xref backends don't compose. This creates one that first consults the | |
;; xref-lsp backend for the latest information from the language server, | |
;; and then falls through to etags for library definitions. | |
(defun my/xref-lsp-etags-backend () 'my/lsp-etags) | |
(cl-defmethod xref-backend-identifier-at-point ((_backend (eql my/lsp-etags))) | |
(xref-backend-identifier-at-point 'xref-lsp)) | |
(cl-defmethod xref-backend-identifier-completion-table ((_backend (eql my/lsp-etags))) | |
(xref-backend-identifier-completion-table 'xref-lsp)) | |
(cl-defmethod xref-backend-definitions ((_backend (eql my/lsp-etags)) identifier) | |
(or | |
(xref-backend-definitions 'xref-lsp identifier) | |
(xref-backend-definitions 'etags identifier))) | |
(cl-defmethod xref-backend-references ((_backend (eql my/lsp-etags)) identifier) | |
(or | |
;; HLS doesn't yet support textDocument/references | |
;; (xref-backend-references 'xref-lsp identifier)) | |
(xref-backend-references 'etags identifier))) | |
(cl-defmethod xref-backend-apropos ((_backend (eql my/lsp-etags)) pattern) | |
(append | |
;; HLS doesn't yet support workspace/symbol | |
;; (xref-backend-apropos 'xref-lsp pattern)) | |
(xref-backend-apropos 'etags pattern))) | |
(defun my/xref-add-lsp-etags-backend () | |
(add-hook 'xref-backend-functions #'my/xref-lsp-etags-backend nil t)) | |
:hook | |
(haskell-mode . lsp) | |
;; lsp-managed-mode installs the lsp backend. We need to | |
;; come after that, or it won't fall through to us, either. | |
(lsp-managed-mode . my/xref-add-lsp-etags-backend) | |
:general | |
(:keymaps 'interactive-haskell-mode-map | |
"M-." 'xref-find-definitions)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment