mirror of
https://github.com/neovim/neovim.git
synced 2025-09-27 21:48:35 +00:00
refactor(treesitter): use npcall in _query_linter.lua #23985
This commit is contained in:
@@ -53,10 +53,7 @@ end
|
|||||||
local function guess_query_lang(buf)
|
local function guess_query_lang(buf)
|
||||||
local filename = api.nvim_buf_get_name(buf)
|
local filename = api.nvim_buf_get_name(buf)
|
||||||
if filename ~= '' then
|
if filename ~= '' then
|
||||||
local ok, query_lang = pcall(vim.fn.fnamemodify, filename, ':p:h:t')
|
return vim.F.npcall(vim.fn.fnamemodify, filename, ':p:h:t')
|
||||||
if ok then
|
|
||||||
return query_lang
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -270,11 +267,8 @@ function M.lint(buf, opts)
|
|||||||
for i = 1, math.max(1, #opts.langs) do
|
for i = 1, math.max(1, #opts.langs) do
|
||||||
local lang = opts.langs[i]
|
local lang = opts.langs[i]
|
||||||
|
|
||||||
--- @type boolean, (table|nil)
|
--- @type (table|nil)
|
||||||
local ok, parser_info = pcall(vim.treesitter.language.inspect, lang)
|
local parser_info = vim.F.npcall(vim.treesitter.language.inspect, lang)
|
||||||
if not ok then
|
|
||||||
parser_info = nil
|
|
||||||
end
|
|
||||||
|
|
||||||
local parser = vim.treesitter.get_parser(buf)
|
local parser = vim.treesitter.get_parser(buf)
|
||||||
parser:parse()
|
parser:parse()
|
||||||
|
Reference in New Issue
Block a user