mirror of
https://github.com/neovim/neovim.git
synced 2025-10-21 01:02:09 +00:00
fix(treesitter): suppress get_parser warnings via opts.error
This commit is contained in:

committed by
Christian Clason

parent
7b71fdbc1e
commit
0f067cd34d
@@ -76,9 +76,14 @@ end
|
||||
---
|
||||
---@package
|
||||
function TSTreeView:new(bufnr, lang)
|
||||
local parser = vim.treesitter._get_parser(bufnr or 0, lang)
|
||||
local parser = vim.treesitter.get_parser(bufnr or 0, lang, { error = false })
|
||||
if not parser then
|
||||
return nil, 'No parser available for the given buffer.'
|
||||
return nil,
|
||||
string.format(
|
||||
'Failed to create TSTreeView for buffer %s: no parser for lang "%s"',
|
||||
bufnr,
|
||||
lang
|
||||
)
|
||||
end
|
||||
|
||||
-- For each child tree (injected language), find the root of the tree and locate the node within
|
||||
@@ -539,7 +544,7 @@ local edit_ns = api.nvim_create_namespace('treesitter/dev-edit')
|
||||
local function update_editor_highlights(query_win, base_win, lang)
|
||||
local base_buf = api.nvim_win_get_buf(base_win)
|
||||
local query_buf = api.nvim_win_get_buf(query_win)
|
||||
local parser = assert(vim.treesitter._get_parser(base_buf, lang))
|
||||
local parser = assert(vim.treesitter.get_parser(base_buf, lang, { error = false }))
|
||||
api.nvim_buf_clear_namespace(base_buf, edit_ns, 0, -1)
|
||||
local query_content = table.concat(api.nvim_buf_get_lines(query_buf, 0, -1, false), '\n')
|
||||
|
||||
@@ -596,9 +601,10 @@ function M.edit_query(lang)
|
||||
end
|
||||
vim.cmd(cmd)
|
||||
|
||||
local parser = vim.treesitter._get_parser(buf, lang)
|
||||
local parser = vim.treesitter.get_parser(buf, lang, { error = false })
|
||||
if not parser then
|
||||
return nil, 'No parser available for the given buffer'
|
||||
return nil,
|
||||
string.format('Failed to show query editor for buffer %s: no parser for lang "%s"', buf, lang)
|
||||
end
|
||||
lang = parser:lang()
|
||||
|
||||
|
Reference in New Issue
Block a user