Skip to content

Commit 02fb2c8

Browse files
authored
fix: remove nvim-treesitter dependency (#107)
This plugin actually uses Neovim's core API and doesn't depend on nvim-treesitter's legacy API (which will be removed). I have - Replaced the only place where nvim-treesitter is needed to use Neovim's core API to check for a parser on the runtimepath. - Updated the reamde to clarify that this plugin doesn't depend on nvim-treesitter (there are multiple ways to install parsers).
1 parent 458da8e commit 02fb2c8

File tree

2 files changed

+4
-8
lines changed

2 files changed

+4
-8
lines changed

README.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ https://github.com/kawre/leetcode.nvim/assets/69250723/aee6584c-e099-4409-b114-1
3535

3636
- [nui.nvim]
3737

38-
- [nvim-treesitter] _**(optional, but highly recommended)**_
38+
- [tree-sitter-html] _**(optional, but highly recommended)**_
3939
used for formatting the question description.
40-
Make sure to install the parser for `html`.
40+
Can be installed with [nvim-treesitter].
4141

4242
- [nvim-notify] _**(optional)**_
4343

@@ -497,3 +497,4 @@ You can then exit [leetcode.nvim] using `:Leet exit` command
497497
[nvim-treesitter]: https://github.com/nvim-treesitter/nvim-treesitter
498498
[nvim-web-devicons]: https://github.com/nvim-tree/nvim-web-devicons
499499
[telescope.nvim]: https://github.com/nvim-telescope/telescope.nvim
500+
[tree-sitter-html]: https://github.com/tree-sitter/tree-sitter-html

lua/leetcode/parser/init.lua

+1-6
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,7 @@ local Parser = Object("LeetParser")
1010
---@param text string
1111
---@return lc.ui.Group
1212
function Parser.static:parse(text)
13-
local check_for_html = function()
14-
local parsers = require("nvim-treesitter.parsers")
15-
assert(parsers.get_parser_configs()["html"])
16-
end
17-
18-
if pcall(check_for_html) then
13+
if #vim.api.nvim_get_runtime_file("parser/html.so", true) > 0 then
1914
return Tag:parse(text)
2015
else
2116
return Plain:parse(text)

0 commit comments

Comments
 (0)