irongit

A Neovim plugin enabling you to solve LeetCode problems.

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).
Marc Jakobiauthored committed by GitHub
parent 458da8ecommit 02fb2c855658ad6b60e43671f6b040c812181a1dBrowse files

2 files changed, +4 -8

+3-2README.md
@@ -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
+1-6lua/leetcode/parser/init.lua
@@ -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)