tree-sitter-haskell
tree-sitter-haskell copied to clipboard
Maybe include indentation in some node
This is related to https://github.com/lukas-reineke/indent-blankline.nvim/issues/926
In summary, in indent-blankline, there is a logic which allows to highlight indentation based on "visibility" scope. Actually, you can list a serie of tree sitter nodes which are considered as a "scope" and the indentation logic while highlight the indentation guide for the "scope".
For example, here is how it behaves for do
:
(See how the indentation line for do
is bolder and red. Sorry, this maybe a bit confusing, my indentation guides are indeed very rainbowish).
I tried to apply the same logic for other nodes. The idea is to get a quick view of how long a block extends. I'm thinking about do
blocks, where
binding, any function, case
, ... and maybe actually any multiline expression.
So I've tried to add at least the local_binds
node in the list of node to be highlighted (that's for the where
and let
) and it does not work as expected.
The semantic is unclear for me, but it appears that the indentation level in the different blocs is kinda surprising and inconsistent.
For example, in the where
, the local_binds
node does not include the where
and starts on the first token of the indented lines, without including the indentation, but includes the indentation for the following lines:
And hence the scope
logic breaks.
I'm unsure about if this should be fixed in this parser or in indent-blankline.nvim
, but I'm wondering if most node must not start a bit earlier in the stream of characters. The local_binds
should include the where
or let
. Maybe a new node should be created, so we can have something to match only on all the binding, and something to match on the where
or let
clause.
Right now, it is kinda impossible to do something including the where
keywoard, but not including the complete function above.
If we extend selection starting on one of the binding, b = 2
here:
We then get all the bindings, without the where
And then we get the complete function: