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

Indentation support for bird-style Literate Haskell

Open ghost opened this issue 5 years ago • 4 comments

Currently, using bird-style Literate Haskell means that Visual Studio Code believes no line is indented, which means folding doesn't work. In addition, hitting Enter will always place one at the beginning of the line, no matter the indentation level behind the 'bird marker' - instead a marker should be automatically inserted and the indentation level continued as if no marker existed.

I would probably try implementing this if I could figure out what the right APIs are.

ghost avatar Jun 12 '20 21:06 ghost

Took a look again and this time I found it. Seems like setting up OnTypeFormatting and FoldingRange providers is the place to hook into. This being a language server level feature however makes me wonder if it belongs in there instead of in this extension, however.

hyperfekt avatar Nov 09 '20 13:11 hyperfekt

I've looked into this a little more and it seems while this may be the approved / currently available way to go, there doesn't seem to be a way to override the Indent / Outdent actions and there would be a lot of duplication of logic that VSCode already has. I'll be looking into extending VSCode so it provides customization that can be used to make it understand the bird marker (and other similar forms like C-style asterisk-prefixed comment blocks) instead.

hyperfekt avatar Nov 09 '20 21:11 hyperfekt

Sorry for the lack of response from my part on this, I'm not familiar with how VS Code actions work and thus don't have anything of value to contribute.
Literate Haskell support is quite poor at the moment anyway, because many regexes work over multiple lines by keeping track of indentation level (in the limited way that this is possible with TextMate grammars), and all of that falls down when each line is prefaced by ">". I don't know how to fix that short of rewriting all of those regexes to specifically account for it.
If you could muster up some support from the editor itself so that it can act as if the bird markers weren't there, that could go a long way solving all those problems.

sheaf avatar Nov 09 '20 23:11 sheaf

The assumption that indentation consists of whitespace is baked quite deeply into Visual Studio Code, and I don't see myself changing that or the team accepting such a change. I think folding is best left to the language server, and creating a new line to the implementation of https://github.com/microsoft/vscode/issues/17281.

hyperfekt avatar May 26 '21 20:05 hyperfekt