From 174d283f9261aaf0dcfb6eefa227cab168e4266f Mon Sep 17 00:00:00 2001 From: pynappo Date: Sun, 27 Oct 2024 04:08:38 -0700 Subject: [PATCH] update ts parser detection --- plugin/cmp.lua | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/plugin/cmp.lua b/plugin/cmp.lua index 3e44d90d3..110fe01a8 100644 --- a/plugin/cmp.lua +++ b/plugin/cmp.lua @@ -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