quangnguyen30192 / cmp-nvim-ultisnips

nvim-cmp source for ultisnips
Apache License 2.0
145 stars 19 forks source link

Feat: integrate treesitter to determine filetype at cursor position #50

Closed smjonas closed 2 years ago

smjonas commented 2 years ago

Heavily inspired by https://github.com/L3MON4D3/LuaSnip/pull/226.

TODO:

quangnguyen30192 commented 2 years ago

Just reviewed. thanks for the PR

smjonas commented 2 years ago

@quangnguyen30192 I just noticed we don't even need nvim-treesitter as a dependency. We can simply copy those functions from the nvim-treesitter plugin. Since Treesitter is built into Neovim we will always have the functionality we need.

quangnguyen30192 commented 2 years ago

Cool 😊

smjonas commented 2 years ago

@quangnguyen30192 Please review again and test this feature :) E.g. in a CSS code block within a .html file. Also what do you think about adding a "both" option (as Luasnip also has this option)? See TODO at the top of this PR. Maybe this could be a separate PR if users actually want it.

I don't think there will be noticeable performance issues right now because:

quangnguyen30192 commented 2 years ago

Just tested it and working fine 👍

I don't think there will be noticeable performance issues right now because: Treesitter has already parsed the entire file after entering a buffer then it is simply a lookup for the current node the cursor is on and return the info (no additional logic should be involved) our Python code is only called when Treesitter found a different language than the current filetype of the buffer

Sure, let's go with it for now

E.g. in a CSS code block within a .html file. Also, what do you think about adding a "both" option (as Luasnip also has this option)? See TODO at the top of this PR. Maybe this could be a separate PR if users actually want it.

Do we really need it as of now? Let's add it when the user needs it then.