-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Expose API for snippet parser. #18772
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
Conversation
|
Actually, I'll turn this into a draft for now, it isn't really ready for review yet. |
5dc55ea to
9fd1049
Compare
|
I need some guidance/opinions on the api for AST-nodes. I currently favor having the nodes just be flat tables (+ A Choice contains the fields
- {tabstop} (number) Position of the choice ("${<tabstop>|choice1,choice2,choice3|}")
- {items} (string[]) The different choices in order of appearance ("${1|<items[1]>,<items[2]>,...,<items[n]>}")) but this could make it harder to be backward-compatible if (and that's a very big, unlikely if, in my judgment) the lsp-specification for snippets changes in a not-backward-compatible way. @hrsh7th I'd love to hear your thoughts on the API How are spec-changes handled in other modules? |
9fd1049 to
c72fd34
Compare
|
Just found microsoft/language-server-protocol#303 (comment), I guess we won't need to worry about breaking changes :) |
fcac983 to
f65de58
Compare
|
Okay, I think this can be looked at :D The parser lives at |
f65de58 to
3a826df
Compare
To be honest, I still think I'm also not 100% happy with |
Ah, so
I share the sentiment, but can't think of anything better as well :/
eg. |
|
I'm wondering if neovim should document the internal AST that's from parses and creates the snippet syntax defined in the LSP specification. So in the PR, I chose a mechanism that customize the features by overriding the function as like (Of course, in case we try to define AST spec, I can help for it) |
It should be enough to show which field of an ast-node corresponds to which part of the snippet, explaining how they should interact would just be repeating the official spec I think.
Ahh, okay that's pretty nice |
|
Tangentially, there's a few small bugs in the current implementation ( |
|
I think the bug should be fixed with some of the tests. |
Depends on how they interact with your changes -- if they're independent, a separate PR is better as it can be merged quickly (and backported) -- as a bonus, this will then lose you your "first contributor" status so you don't need constant approval for running CI on your other more complex PRs ;) |
|
The bugs cab be fixed independently of this PR, I'll open another one
Truue, nice :) |
b4ffcbc to
d76eec1
Compare
| ============================================================================== | ||
| Lua module: vim.lsp.parser *lsp-parser* | ||
|
|
||
| parse({input}) *vim.lsp.parser.parse()* |
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.
| parse({input}) *vim.lsp.parser.parse()* | |
| parse({input}) *vim.lsp.snippet.parse()* |
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.
Right, I'll have to also change the paths in genvimdoc.py, I think that's where this is from
d76eec1 to
09d7802
Compare
|
09d7802 makes the ast-api more like languagetree
Should it stay like this? |
Changes meaning, no if_text -> capture, empty if_text -> "".
for example, ${1:?:} should have empty if- and else-text, not both as
nil.
|
Closing this as we've vim.snippet now. It doesn't expose a |
Hi!
I'd like to make use of neovims snippet-parser in Luasnip, but it's currently not public.
So far I've added a few functions that will be useful for manipulating the produced AST, but I'm not yet sure where the api should be exposed.
vim.snippet.parserwould be compatible with feat(snippet): Minimal snippet API #16499, but it'd be unclear that lsp-snippets are being parsedvim.lsp.snippetorvim.lsp.snippet_parserwill seem a bit disconnected once feat(snippet): Minimal snippet API #16499 is mergedIf this should be split up more, or needs more discussion before a PR let me know, I'll open an issue instead.