vscode-haskell
vscode-haskell copied to clipboard
Automatically add `-- ` when pressing enter in a comment
A minor but nice feature I would like to propose is to automatically add --
on the new line when pressing "enter" in a comment/documentation.
Example (cursor position represented by []
) below.
Current behavior
-- | Somme doc[]
foo = "hello world"
Press enter
-- | Somme doc
[]
foo = "hello world"
Proposed behavior
-- | Somme doc[]
foo = "hello world"
Press enter
-- | Somme doc
-- []
foo = "hello world"
I think this default behavior makes much more sense for developers.
To be discussed: should we do the same when in a regular comment? I'd say "no" but I am not strongly opinionated on this one.
Cheers
I think this is going to be specific to the client/editor, as far as I'm aware LSP doesn't have anything in the specification for auto-indenting. It has auto-formatting but that seems to be something slightly different. If this is in VS Code then maybe https://github.com/JustusAdam/language-haskell might be able to handle this
Fair point @bubba, it slipped my mind that it probably doesn't belong in the HLS backend, thank you!
That being said, any reason why this wouldn't belong in https://github.com/haskell/vscode-haskell ?
vscode-haskell itself doesn't handle anything outside of setting up + spinning up the language server, i.e. the commenting and syntax highlighting is done by that https://github.com/JustusAdam/language-haskell dependency. Although perhaps its possible for vscode-haskell to specifically handle the commenting stuff?
Would it be possible to have a setting in the VSCode Haskell extension to select which other VSCode extension is responsible for the Haskell syntax highlighting/etc. (...in the same way that there is an option for Formatting Providers like stylish-haskell, etc.)?
I've currently got a fork of JustusAdam/language-haskell
with a range of domain-specific syntax highlighting choices (mainly around quasi-quotations of different types). But the choice to use that highlighting fork disables the VSCode Haskell extension from working.
FYI, LSP does support a textDocument/onTypeFormatting
request, it might be possible to use it for this.
See https://github.com/JustusAdam/language-haskell/pull/174
The issue is blocked on the pull request linked above
So https://github.com/haskell/vscode-haskell/pull/174 wasn't merged, and JustusAdam/language-haskell#186 (the followup PR) wasn't either, so.. the extension currently doesn't have this feature, right? (Or is there another PR I'm missing?)