Skip to content
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

fix(context): in_treesitter_capture #1211

Merged
merged 5 commits into from
Oct 10, 2022
Merged

fix(context): in_treesitter_capture #1211

merged 5 commits into from
Oct 10, 2022

Conversation

f3fora
Copy link
Contributor

@f3fora f3fora commented Oct 3, 2022

in_treesitter_capture used to compare a node:type() with what should be a capture, returning always a falsy value.
The example https://github.com/hrsh7th/nvim-cmp/wiki/Advanced-techniques#disabling-completion-in-certain-contexts-such-as-comments did not work as expected, being in_treesitter_capture("comment") always not true.
Now it works as expected.

`in_treesitter_capture` used to compare a node:type() with what should
be a capture, returning always a falsy value.
The example https://github.com/hrsh7th/nvim-cmp/wiki/Advanced-techniques#disabling-completion-in-certain-contexts-such-as-comments
did not work as expected, being in_treesitter_capture("comment") always
not true.
Now it works as expected.
`in_treesitter_capture` and `in_syntax_group` can take a list of string
as argument.
Use vim.treesitter.get_captures_at_cursor()
get_captures_at_cursor() sometimes fails. Do it explicitly with
get_captures_at_pos(buf, row, col)
Get row and col using vim.api and not vim.fn in in_syntax_group, as done
in in_treesitter_capture
@hrsh7th
Copy link
Owner

hrsh7th commented Oct 10, 2022

LGTM

@hrsh7th hrsh7th merged commit 0ad2450 into hrsh7th:main Oct 10, 2022
@smjonas
Copy link
Contributor

smjonas commented Oct 10, 2022

@f3fora This is a breaking change for Neovim users that haven't upgraded to 0.8 stable yet. The reason is that get_captures_at_position has been renamed to get_captures_at_pos: neovim/neovim#20331. Could you please add a fallback to get_captures_at_position in case get_captures_at_pos is nil?

williamboman added a commit to williamboman/nvim-cmp that referenced this pull request Oct 27, 2022
…indow

* upstream/main:
  Use `default_capabilities()` in doc and util (hrsh7th#1254)
  Fix undefined new() error in example source (hrsh7th#1237)
  Update README to use the new default_capabilities (hrsh7th#1243)
  Fix hrsh7th#1217
  ci
  Remove ansiblels test
  fix compatibility with nvim < 0.8 (hrsh7th#1227)
  Fix hrsh7th#1213
  fix(context): compatibility with nvim<0.8 (hrsh7th#1224)
  fix(context): `in_treesitter_capture` (hrsh7th#1211)
  fix(entry/get_replace_range): workaround for end char matching cursor position (hrsh7th#1177)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants