Skip to content

Commit e713498

Browse files
committed
fix(utils): Added parser detection logic for nvim-treesitter:main
Adds checks for the new format of `nvim-treesitter.parsers`. Closes #10
1 parent f45abad commit e713498

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

lua/patterns/utils.lua

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,18 @@ utils.parser_installed = function (parser_name)
88
local has_ts, parsers = pcall(require, "nvim-treesitter.parsers");
99

1010
if has_ts == false then
11-
--- `nvim-treesitter` not available.
11+
-- `nvim-treesitter` not available.
1212
return false;
13-
elseif parsers.has_parser(parser_name) == true then
14-
--- Parser installed via `nvim-treesitter`.
13+
elseif parsers.has_parser and parsers.has_parser(parser_name) == true then
14+
-- Parser installed via `nvim-treesitter`.
15+
-- NOTE: This only works for `master` branch.
16+
return true;
17+
elseif parsers[parser_name] then
18+
-- Parser installed via `nvim-treesitter`.
19+
-- NOTE: This only works for `main` branch.
1520
return true;
1621
elseif pcall(vim.treesitter.query.get, parser_name, "highlights") == true then
17-
--- Parser installed manually.
22+
-- Parser installed `manually`.
1823
return true;
1924
end
2025

0 commit comments

Comments
 (0)