Skip to content

Commit

Permalink
update ts parser detection
Browse files Browse the repository at this point in the history
  • Loading branch information
pynappo committed Oct 27, 2024
1 parent 2c751f5 commit 174d283
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions plugin/cmp.lua
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,18 @@ if vim.on_key then
end

-- see compare.scopes
if vim.fn.has('nvim-0.9') then
if vim.fn.has('nvim-0.9') == 1 then
local ts = vim.treesitter
local has_ts_parser = ts.language.get_lang
-- vim.treesitter.language.add is recommended for checking treesitter in 0.11 nightly
if vim.fn.has('nvim-0.11') then
has_ts_parser = function(filetype)
local lang = ts.language.get_lang(filetype)
return lang and ts.language.add(lang)
end
end
autocmd.subscribe({ 'FileType' }, function(details)
if vim.treesitter.language.get_lang(details.match) then
if has_ts_parser(details.match) then
vim.b[details.buf].cmp_buf_has_ts_parser = true
else
vim.b[details.buf].cmp_buf_has_ts_parser = false
Expand Down

0 comments on commit 174d283

Please sign in to comment.