vscode-haskell icon indicating copy to clipboard operation
vscode-haskell copied to clipboard

Automatically add `-- ` when pressing enter in a comment

Open sir4ur0n opened this issue 4 years ago • 8 comments

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

sir4ur0n avatar Aug 18 '20 13:08 sir4ur0n

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

lukel97 avatar Aug 18 '20 18:08 lukel97

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 ?

sir4ur0n avatar Aug 18 '20 20:08 sir4ur0n

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?

lukel97 avatar Aug 18 '20 20:08 lukel97

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.

and-pete avatar Aug 20 '20 03:08 and-pete

FYI, LSP does support a textDocument/onTypeFormatting request, it might be possible to use it for this.

alanz avatar Sep 25 '20 14:09 alanz

See https://github.com/JustusAdam/language-haskell/pull/174

lukel97 avatar Oct 19 '20 14:10 lukel97

The issue is blocked on the pull request linked above

jneira avatar Mar 09 '21 07:03 jneira

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?)

dlight avatar Jul 11 '22 20:07 dlight