-
|
I'm not sure how to configure the I've tried setting {
"haskell.formattingProvider": "fourmolu"
}If I run (:jsonrpc "2.0" :method "workspace/didChangeConfiguration" :params
(:settings
(:haskell\.formattingProvider "fourmolu")))but I'm not seeing any kind of reaction from the server. There's nothing in the server's stderr either. |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments
-
|
I just realised that 1.8.0.0 doesn't support formatting with the fourmolu with GHC 9.4.2, which I was using. This might have been my fault then, sorry! |
Beta Was this translation helpful? Give feedback.
-
|
Re: eglot in general, someone has to write the docs! We need an eglot user who actually understands how this works to step up and write some documentation on how to do it. Maybe that's you :) |
Beta Was this translation helpful? Give feedback.
-
|
Reading https://www.gnu.org/software/emacs/manual/html_node/eglot/Project_002dspecific-configuration.html#Examples it seems the correct way is this: (setq-default eglot-workspace-configuration '(:haskell (:formattingProvider "fourmolu")))(or {
"haskell": {
"formattingProvider": "fourmolu"
}
}I'm not sure how to introspect what HLS actually parsed it as, but after setting that I get four spaces and leading commas in lists, whereas without it I got two spaces and trailing commas. |
Beta Was this translation helpful? Give feedback.
-
|
Configuring the formatting provider in HLS via eglot is a bit more involved than most LSP servers because HLS has multiple formatters and eglot needs to know which one to request. eglot's formatting setup: Configuring HLS formatter via eglot: (setq-default eglot-workspace-configuration
'(:haskell
(:formattingProvider "fourmolu" ; or "ormolu", "stylish-haskell", "floskell", "brittany"
:plugin
(:fourmolu
(:globalOn t)))))Place this in your Verifying the configuration reached HLS: Common issue: fourmolu not found: cabal install fourmolu
# or
ghcup install fourmoluPer-project override: Format-on-save: (add-hook 'haskell-mode-hook
(lambda ()
(add-hook 'before-save-hook #'eglot-format nil t)))Is the issue that HLS isn't formatting at all, or that it's using the wrong formatter? |
Beta Was this translation helpful? Give feedback.
Reading https://www.gnu.org/software/emacs/manual/html_node/eglot/Project_002dspecific-configuration.html#Examples it seems the correct way is this:
(or
M-x add-dir-local-variableto make it project-specific). Then runningM-x eglot-show-workspace-configurationI see{ "haskell": { "formattingProvider": "fourmolu" } }I'm not sure how to introspect what HLS actually parsed it as, but after setting that I get four spaces and leading commas in lists, whereas without it I got two spaces and trailing commas.