neovim

Neovim text editor
git clone https://git.dasho.dev/neovim.git
Log | Files | Refs | README

commit ceb37ff1d83c6dc341dc43d3dc8c81f657bc9484
parent bde59e81473f29944ef80ff98f6b2c88010b2df6
Author: Stephan Seitz <sseitz@nvidia.com>
Date:   Sun, 11 Jun 2023 23:46:22 +0200

refactor(treesitter): use npcall in _query_linter.lua #23985


Diffstat:
Mruntime/lua/vim/treesitter/_query_linter.lua | 12+++---------
1 file changed, 3 insertions(+), 9 deletions(-)

diff --git a/runtime/lua/vim/treesitter/_query_linter.lua b/runtime/lua/vim/treesitter/_query_linter.lua @@ -53,10 +53,7 @@ end local function guess_query_lang(buf) local filename = api.nvim_buf_get_name(buf) if filename ~= '' then - local ok, query_lang = pcall(vim.fn.fnamemodify, filename, ':p:h:t') - if ok then - return query_lang - end + return vim.F.npcall(vim.fn.fnamemodify, filename, ':p:h:t') end end @@ -270,11 +267,8 @@ function M.lint(buf, opts) for i = 1, math.max(1, #opts.langs) do local lang = opts.langs[i] - --- @type boolean, (table|nil) - local ok, parser_info = pcall(vim.treesitter.language.inspect, lang) - if not ok then - parser_info = nil - end + --- @type (table|nil) + local parser_info = vim.F.npcall(vim.treesitter.language.inspect, lang) local parser = vim.treesitter.get_parser(buf) parser:parse()