aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLewis Russell <lewis6991@gmail.com>2023-02-27 15:33:18 +0000
committerGitHub <noreply@github.com>2023-02-27 15:33:18 +0000
commitf64098a2df774c79dd454f63ac491570cdcaf2b2 (patch)
tree493c9112462e7d78e12a66519cc2f6b4f8099462
parent3f042854c8276119d91ee5a8ef07e060b119bf46 (diff)
downloadrneovim-f64098a2df774c79dd454f63ac491570cdcaf2b2.tar.gz
rneovim-f64098a2df774c79dd454f63ac491570cdcaf2b2.tar.bz2
rneovim-f64098a2df774c79dd454f63ac491570cdcaf2b2.zip
fix(treesitter): fixup for health
-rw-r--r--runtime/lua/vim/treesitter/health.lua22
-rw-r--r--runtime/lua/vim/treesitter/language.lua2
2 files changed, 11 insertions, 13 deletions
diff --git a/runtime/lua/vim/treesitter/health.lua b/runtime/lua/vim/treesitter/health.lua
index 1abcdd0b31..fd1188fde4 100644
--- a/runtime/lua/vim/treesitter/health.lua
+++ b/runtime/lua/vim/treesitter/health.lua
@@ -2,28 +2,26 @@ local M = {}
local ts = vim.treesitter
local health = require('vim.health')
---- Lists the parsers currently installed
----
----@return string[] list of parser files
-function M.list_parsers()
- return vim.api.nvim_get_runtime_file('parser/*', true)
-end
-
--- Performs a healthcheck for treesitter integration
function M.check()
- local parsers = M.list_parsers()
+ local parsers = vim.api.nvim_get_runtime_file('parser/*', true)
health.report_info(string.format('Nvim runtime ABI version: %d', ts.language_version))
for _, parser in pairs(parsers) do
local parsername = vim.fn.fnamemodify(parser, ':t:r')
- local is_loadable, ret = pcall(ts.language.add, parsername)
+ local is_loadable, err_or_nil = pcall(ts.language.add, parsername)
- if not is_loadable or not ret then
+ if not is_loadable then
health.report_error(
- string.format('Parser "%s" failed to load (path: %s): %s', parsername, parser, ret or '?')
+ string.format(
+ 'Parser "%s" failed to load (path: %s): %s',
+ parsername,
+ parser,
+ err_or_nil or '?'
+ )
)
- elseif ret then
+ else
local lang = ts.language.inspect_language(parsername)
health.report_ok(
string.format('Parser: %-10s ABI: %d, path: %s', parsername, lang._abi_version, parser)
diff --git a/runtime/lua/vim/treesitter/language.lua b/runtime/lua/vim/treesitter/language.lua
index 0796383bf5..5bcc786e88 100644
--- a/runtime/lua/vim/treesitter/language.lua
+++ b/runtime/lua/vim/treesitter/language.lua
@@ -63,7 +63,7 @@ function M.add(lang, opts)
M.register(lang, filetype or lang)
if vim._ts_has_language(lang) then
- return true
+ return
end
if path == nil then