fix: add pcall to other uses of vim.treesitter.get_parser

This commit is contained in:
Calvin Bochulak 2024-05-22 16:58:47 -06:00
parent 5c93dfdfb3
commit 3d96e2c9f1
No known key found for this signature in database
GPG Key ID: 49927EF8F85114FB
2 changed files with 6 additions and 6 deletions

View File

@ -243,8 +243,8 @@ local function check_close_tag(close_slash_tag)
end
M.close_tag = function()
local buf_parser = vim.treesitter.get_parser()
if not buf_parser then
local ok, buf_parser = pcall(vim.treesitter.get_parser)
if not ok then
return
end
buf_parser:parse(true)
@ -256,8 +256,8 @@ M.close_tag = function()
end
M.close_slash_tag = function()
local buf_parser = vim.treesitter.get_parser()
if not buf_parser then
local ok, buf_parser = pcall(vim.treesitter.get_parser)
if not ok then
return
end
buf_parser:parse(true)

View File

@ -65,8 +65,8 @@ M.get_node_at_cursor = function(winnr)
local row, col = unpack(vim.api.nvim_win_get_cursor(winnr))
row = row - 1
local buf = vim.api.nvim_win_get_buf(winnr)
local root_lang_tree = vim.treesitter.get_parser(buf)
if not root_lang_tree then
local ok, root_lang_tree = pcall(vim.treesitter.get_parser, buf)
if not ok then
return
end