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).
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 | ||
| 35 | 35 | |
| 36 | 36 | - [nui.nvim] |
| 37 | 37 | |
| 38 | -- [nvim-treesitter] _**(optional, but highly recommended)**_ | |
| 38 | +- [tree-sitter-html] _**(optional, but highly recommended)**_ | |
| 39 | 39 | used for formatting the question description. |
| 40 | - Make sure to install the parser for `html`. | |
| 40 | + Can be installed with [nvim-treesitter]. | |
| 41 | 41 | |
| 42 | 42 | - [nvim-notify] _**(optional)**_ |
| 43 | 43 | |
| @@ -497,3 +497,4 @@ You can then exit [leetcode.nvim] using `:Leet exit` command | ||
| 497 | 497 | [nvim-treesitter]: https://github.com/nvim-treesitter/nvim-treesitter |
| 498 | 498 | [nvim-web-devicons]: https://github.com/nvim-tree/nvim-web-devicons |
| 499 | 499 | [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") | ||
| 10 | 10 | ---@param text string |
| 11 | 11 | ---@return lc.ui.Group |
| 12 | 12 | 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 | |
| 19 | 14 | return Tag:parse(text) |
| 20 | 15 | else |
| 21 | 16 | return Plain:parse(text) |