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

feat(treesitter): no longer depends on nvim-treesitter #151

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ofseed
Copy link

@ofseed ofseed commented Sep 11, 2024

The former API was already removed on the develop main branch of the nvim-treesitter repo.

@kevinhwang91
Copy link
Owner

Will bump neovim version to 0.9. However, the stable version is 0.7.2 from https://packages.debian.org/search?keywords=neovim.

We can write adaptive functions to be compatible with 0.7.2.

@ofseed
Copy link
Author

ofseed commented Sep 11, 2024

Should be done now. I think there's only vim.treesitter.language.get_lang does not exist in 0.7.

README.md Outdated Show resolved Hide resolved
lua/bqf/preview/treesitter.lua Outdated Show resolved Hide resolved
else
parser = parsersCache:get(srcBufnr)
if parser and not api.nvim_buf_is_valid(parser:source()) then
parser = nil
parsersCache:set(srcBufnr, nil)
end
end
if parser and configs.is_enabled('highlight', parser:lang(), srcBufnr) then
if parser and treesitter.highlighter.active[srcBufnr] then
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without nvim-treesitter, we can't decide whether the buffer of lang should render, so the condition may be meanless.

highlighter.active[bufnr] checks whether the target buffer is rendered by treesitter or not, it is incorrect to use it here.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only way to enable treesitter highlighting is vim.treesitter.start in the future, nvim-treesitter will no longer needed, the config module is removed in the experimental branch, see https://github.com/nvim-treesitter/nvim-treesitter/tree/main.

In the meantime, it is supported in neovim 0.10 now, now c, lua, and vim parsers and corresponding queries are bundled within neovim distribution, so everyone has treesitter bundled and highlight enabled for lua, see https://github.com/neovim/neovim/blob/5931f780e0282ad486fa070bb05b3877cc1d44f0/runtime/ftplugin/lua.lua#L2

nvim-treesitter will only provide extra parsers and queries in the experimental main branch and the future 1.0 release.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First, we need a prediction to decide whether the buffer of lang should render, highlighter.active[bufnr] is a state here, not a prediction. Without nvim-treesitter, passby this condition. If you have any ideas for prediction, write it to code directly.

Second, we must keep the original configs.is_enabled for nvim-treesitter.

else
parser = parsersCache:get(srcBufnr)
if parser and not api.nvim_buf_is_valid(parser:source()) then
parser = nil
parsersCache:set(srcBufnr, nil)
end
end
if parser and configs.is_enabled('highlight', parser:lang(), srcBufnr) then
if parser and treesitter.highlighter.active[srcBufnr] then
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First, we need a prediction to decide whether the buffer of lang should render, highlighter.active[bufnr] is a state here, not a prediction. Without nvim-treesitter, passby this condition. If you have any ideas for prediction, write it to code directly.

Second, we must keep the original configs.is_enabled for nvim-treesitter.

@ofseed
Copy link
Author

ofseed commented Sep 30, 2024

Update: I have temporarily frozen this PR because I realized that upstream is still making changes to the API.

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.

2 participants