Skip to content
This repository has been archived by the owner on Oct 24, 2024. It is now read-only.

Use new parser form types #1

Merged
merged 2 commits into from
Oct 13, 2024
Merged

Conversation

datwaft
Copy link
Contributor

@datwaft datwaft commented Mar 16, 2024

As the default parser for Fennel has changed the form_types are different now.

See alexmozaidze/tree-sitter-fennel for the new default parser for Fennel.

I tested these changes with the following test file:

(+ 1 2)

(+ (+ 1 2) 3 4 (- 5 6) (/ 10 (+ 20 3)))

[1 2 [3] [4 5] 6]

(fn salute []
  (print "Hello, World!"))

(macro some-macro []
  (let [v "Hello, World!"]
    `(print ,v)))

#(print "Hello, World")

(macrodebug '(print "Hello, World!"))

I applied all the operations and they seem to work perfectly.

A fun fact is that the reader macros are moved with the slurp and barf operations, which in my opinion is desirable:

#(print "Hello, World!")
; '>('
print #("Hello, World!")

The only issues I am having right now are with the ( and ) movement operations, which if used after reaching the end show the following error:

E5108: Error executing lua: ...vim-paredit-fennel/lua/nvim-paredit-fennel/extension.lua:15: attempt to index local 'current_node' (a nil value)
stack traceback:
        ...vim-paredit-fennel/lua/nvim-paredit-fennel/extension.lua:15: in function 'find_next_parent_form'
        ...vim-paredit-fennel/lua/nvim-paredit-fennel/extension.lua:33: in function 'get_node_root'
        .../nvim/lazy/nvim-paredit/lua/nvim-paredit/api/motions.lua:195: in function 'move_to_parent_form_edge'
        .../nvim/lazy/nvim-paredit/lua/nvim-paredit/api/motions.lua:231: in function <.../nvim/lazy/nvim-paredit/lua/nvim-paredit/api/motions.lua:230

And also with the paredit.api.raise_form operation, which fails every time with the following error:

E5108: Error executing lua: ...vim-paredit-fennel/lua/nvim-paredit-fennel/extension.lua:15: attempt to index local 'current_node' (a nil value)
stack traceback:
        ...vim-paredit-fennel/lua/nvim-paredit-fennel/extension.lua:15: in function 'find_next_parent_form'
        ...vim-paredit-fennel/lua/nvim-paredit-fennel/extension.lua:33: in function 'get_node_root'
        .../nvim/lazy/nvim-paredit/lua/nvim-paredit/api/motions.lua:195: in function 'move_to_parent_form_edge'
        .../nvim/lazy/nvim-paredit/lua/nvim-paredit/api/motions.lua:231: in function <.../nvim/lazy/nvim-paredit/lua/nvim-paredit/api/motions.lua:230

Do you know how this could be fixed? I don't know enough about your plugin to fix it confidently.

@datwaft
Copy link
Contributor Author

datwaft commented Mar 16, 2024

BTW, here are the test results:

image

We can now do this because the `open` and `close` fields are now in the tree-sitter grammar for Fennel
@datwaft
Copy link
Contributor Author

datwaft commented Mar 16, 2024

I added a commit using the get_form_edges from the Clojure implementation.

As you can see in the following snippet (from here) the Fennel grammar now includes the open and close fields so we can use the same implementation.

list: $ => seq(
  field('open', '('),
  optional($._list_content),
  field('close', ')'),
),

Note

BTW, this doesn't fix the errors I told you about.

@julienvincent
Copy link
Owner

Thanks I'll try take a look at this as soon as I get a chance.

datwaft added a commit to datwaft/nvim.conf that referenced this pull request Apr 10, 2024
@julienvincent
Copy link
Owner

julienvincent commented Oct 13, 2024

Hi there, I have just finished reworking nvim-paredit to use treesitter queries instead of these language-extension APIs

See https://github.com/julienvincent/nvim-paredit/releases/tag/v1.0.0

I have now added the appropriate fennel treesitter grammars directly to nvim-paredit and so this plugin is no longer needed.

I incorporated the grammar fixes/changes you made here into that body of work, and by improving the internals of nvim-paredit the errors reported here should no longer show up.

I wasn't able to reproduce them at least.

Please open an issue on nvim-paredit directly if you notice any more issues or if the issues reported here continue to be a problem.

@julienvincent julienvincent reopened this Oct 13, 2024
@julienvincent julienvincent merged commit f75ec45 into julienvincent:master Oct 13, 2024
1 of 2 checks passed
@julienvincent
Copy link
Owner

I figured might as well merge this for historic reasons.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants