RRethy/nvim-treesitter-endwise

Elixir support

rspeicher opened this issue · 2 comments

I was looking into adding Elixir support for this plugin, however I'm not very familiar with Treesitter query syntax.

Looking at an Elixir file in Treesitter playground, it doesn't look to me like there's a difference between an unclosed def foo do node and a closed one:

An already-closed node (def foo do \n end)

        call [16, 4] - [17, 7]
          target: identifier [16, 4] - [16, 6]
          arguments [16, 7] - [16, 10]
            identifier [16, 7] - [16, 10]
          do_block [16, 11] - [17, 7]

while an unclosed node (def foo do) shows:

        call [19, 4] - [20, 5]
          target: identifier [19, 4] - [19, 6]
          arguments [19, 7] - [19, 10]
            identifier [19, 7] - [19, 10]
          do_block [19, 11] - [20, 5]

I'd appreciate knowing if this is even possible before pursuing it further.

When you're in the Treesitter playground, try pressing a to show anonymous nodes. You'll see an anonymous end node there. This query seems to work in the little bit of testing I did (((do_block "do") @cursor @endable) @indent (#endwise! "end")) if you want to use it as a starting point.

I'll leave this issue open for tracking/questions.

Actually this seems to be more correct (((do_block "do" @cursor) @endable @indent) (#endwise! "end")).