Posts tagged "lsp":
Orderless completion in lsp-mode
If you, like me, are using corfu to get in-buffer completion and extend it with orderless to make it even more powerful, you might have noticed that you lose the orderless style as soon as you enter lsp-mode.
My setup of orderless looks like this
(use-package orderless :custom (orderless-matching-styles '(orderless-literal orderless-regexp orderless-flex)) (completion-styles '(orderless partial-completion basic)) (completion-category-defaults nil) (completion-category-overrides '((file (styles partial-completion)))))
which basically turns on orderless style for all things except when completing filenames.
It turns out that lsp-mode messes around with completion-category-defaults
and when entering lsp-mode
this code here adds a setting for 'lsp-capf
.
Unfortunately there seems to be no way to prevent lsp-mode from doing this so
the only option is to fix it up afterwards. Luckily there's a hook for running
code after the completion for lsp-mode is set up, lsp-completion-mode-hook
.
Adding the following function to it makes sure I now get to enjoy orderless
also when writing code.
(lambda () (setq-local completion-category-defaults (assoc-delete-all 'lsp-capf completion-category-defaults)))
Haskell, ghcide, and Spacemacs
The other day I read Chris Penner's post on Haskell IDE Support and thought I'd make an attempt to use it with Spacemacs.
After running stack build hie-bios ghcide haskell-lsp --copy-compiler-tool
I
had a look at the instructions on using haskell-ide-engine
with Spacemacs.
After a bit of trial and error I came up with these changes to my
~/.spacemacs
:
(defun dotspacemacs/layers () (setq-default dotspacemacs-configuration-layers '( ... lsp (haskell :variables haskell-completion-backend 'lsp ) ...) ) )
(defun dotspacemacs/user-config () (setq lsp-haskell-process-args-hie '("exec" "ghcide" "--" "--lsp") lsp-haskell-process-path-hie "stack" lsp-haskell-process-wrapper-function (lambda (argv) (cons (car argv) (cddr argv))) ) (add-hook 'haskell-mode-hook #'lsp))
The slightly weird looking lsp-haskell-process-wrapper-function
is removing
the pesky --lsp
inserted by this line.
That seems to work. Though I have to say I'm not ready to switch from intero just yet. Two things in particular didn't work with =ghcide=/LSP:
- Switching from one the
Main.hs
in one executable to theMain.hs
of another executable in the same project didn't work as expected – I had hints and types in the first, but nothing in the second. - Jump to the definition of a function defined in the package didn't work – I'm not willing to use GNU GLOBAL or some other source tagging system.