-
Notifications
You must be signed in to change notification settings - Fork 106
feat(fennel): add fennel support #498
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
stevearc
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR! Left a couple of questions/suggestions
| M.fennel = { | ||
| postprocess = function(bufnr, item, match) | ||
| local node = node_from_match(match, "symbol") | ||
| local full_form = get_node_text(node, bufnr) | ||
|
|
||
| if item.kind == "Function" then | ||
| local name = string.match(full_form, "[λ fn lambda macro] (%S+) %[") | ||
| item.name = name ~= nil and name or "<Anonymous>" | ||
| elseif item.kind == "Class" or item.kind == "Struct" then | ||
| local kind = (item.kind == "Class") and "local" or "var" | ||
| local query = kind .. " (%S+)" | ||
| local name = string.match(full_form, query) or "<parse error>" | ||
| item.name = name | ||
| else | ||
| item.name = "<parse error>" | ||
| end | ||
| end, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of using these extensions to extract the name, could you just adjust the treesitter queries? The @name capture group can be used to select the node that contains the name.
| (local_form | ||
| (#set! "kind" "Class")) @symbol @root | ||
|
|
||
| (var_form | ||
| (#set! "kind" "Struct")) @symbol @root |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do Struct and Class make sense for these? I would assume that this more naturally maps to the Variable type
Hi! Love the project!
I added fennel support for locals/vars and then function-like forms (lambdas, fns and macros), as well as tests.
Feedback is welcome