Skip to content

Commit

Permalink
Add check if buffer has treesitter parsers
Browse files Browse the repository at this point in the history
  • Loading branch information
deathbeam committed Feb 22, 2024
1 parent 3dfd602 commit 9cccb3d
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lua/autocomplete/buffer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,18 @@ local state = {
}

local function complete_treesitter(bufnr, prefix, cmp_start)
local items = {}
local ok, parsers = pcall(require, 'nvim-treesitter.parsers')
if not ok or not parsers.has_parser() then
return
end

local ok, locals = pcall(require, 'nvim-treesitter.locals')
if not ok then
return items
return
end

local defs = locals.get_definitions(bufnr)
local items = {}

for _, def in ipairs(defs) do
local node
Expand Down

0 comments on commit 9cccb3d

Please sign in to comment.