neovim/runtime/lua/vim/treesitter/health.lua
Jongwook Choi b6fdde5224 fix(treesitter): text alignment in checkhealth vim.treesitter
Problem: The column width 10 for parser name (lang) is too short.
For example, `markdown_inline` has 15 characters, which results in a
slight misalignment with other lines.

e.g. it looked like:

```
- OK Parser: markdown   ABI: 14, path: .../parser/markdown.so
- OK Parser: markdown_inline  ABI: 14, path: .../parser/markdown_inline.so
- OK Parser: php        ABI: 14, path: .../parser/php.so
```

Solution: Use column width 20. As of now, the longest name among those
available in nvim-treesitter has length 18 (`haskell_persistent`).

e.g.:

```
- OK Parser: markdown             ABI: 14, path: .../parser/markdown.so
- OK Parser: markdown_inline      ABI: 14, path: .../parser/markdown_inline.so
- OK Parser: php                  ABI: 14, path: .../parser/php.so
```
2024-05-13 09:19:54 +02:00

34 lines
877 B
Lua

local M = {}
local ts = vim.treesitter
local health = vim.health
--- Performs a healthcheck for treesitter integration
function M.check()
local parsers = vim.api.nvim_get_runtime_file('parser/*', true)
health.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, err_or_nil = pcall(ts.language.add, parsername)
if not is_loadable then
health.error(
string.format(
'Parser "%s" failed to load (path: %s): %s',
parsername,
parser,
err_or_nil or '?'
)
)
else
local lang = ts.language.inspect(parsername)
health.ok(
string.format('Parser: %-20s ABI: %d, path: %s', parsername, lang._abi_version, parser)
)
end
end
end
return M