Skip to content

Commit 51da174

Browse files
committed
update ts parser detection
1 parent be8b111 commit 51da174

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

plugin/cmp.lua

+11-2
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,18 @@ if vim.on_key then
5454
end
5555

5656
-- see compare.scopes
57-
if vim.fn.has('nvim-0.9') then
57+
if vim.fn.has('nvim-0.9') == 1 then
58+
local ts = vim.treesitter
59+
local has_ts_parser = ts.language.get_lang
60+
-- vim.treesitter.language.add is recommended for checking treesitter in 0.11 nightly
61+
if vim.fn.has('nvim-0.11') then
62+
has_ts_parser = function(filetype)
63+
local lang = ts.language.get_lang(filetype)
64+
return lang and ts.language.add(lang)
65+
end
66+
end
5867
autocmd.subscribe({ 'FileType' }, function(details)
59-
if vim.treesitter.language.get_lang(details.match) then
68+
if has_ts_parser(details.match) then
6069
vim.b[details.buf].cmp_buf_has_ts_parser = true
6170
else
6271
vim.b[details.buf].cmp_buf_has_ts_parser = false

0 commit comments

Comments
 (0)