fix: remove nvim-treesitter dependency#15
Conversation
Remove the nvim-treesitter dependency. The has_parser() function has been removed in the newer nvim-treesitter main branch, so this fixes errors related to that.
WalkthroughReplaces the Treesitter parser existence check using nvim-treesitter parsers/has_parser with a direct availability check via vim.treesitter.language.add("helm"), returning early with a warning if unavailable. Retains existing setup steps: optional conceal/indent-hints loading, autocmd group creation, patterns, and CursorMoved/CursorMovedI updates. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant User as User
participant Neovim as Neovim
participant Plugin as helm-ls.nvim
participant TS as vim.treesitter.language
User->>Neovim: Open Helm file
Neovim->>Plugin: Setup()
Plugin->>TS: add("helm")
alt Language available
TS-->>Plugin: true
Plugin->>Plugin: Load conceal/indent-hints (if enabled)
Plugin->>Neovim: Create augroup + autocmds (CursorMoved/Insert)
else Language missing
TS-->>Plugin: false
Plugin->>Neovim: Warn "parser for helm not installed"
Plugin-->>Neovim: Return early (no autocmds)
end
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Assessment against linked issues
Possibly related PRs
Poem
✨ Finishing Touches
🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (2)
lua/helm-ls.lua (2)
54-60: Guard for Neovim < 0.9 and surface the load error.On older Neovim,
vim.treesitter.language.addis absent and this will throw. Also, capturing the second return value lets you show why loading failed. (neovim.io)Apply:
- if not vim.treesitter.language.add("helm") then - vim.notify( - "Helm-ls.nvim: tree-sitter parser for helm not installed, some features will not work. Make sure you have nvim-treesitter and then install it with :TSInstall helm", - vim.log.levels.WARN - ) - return - end + -- Neovim 0.9+ provides vim.treesitter.language.add() + local has_add = vim.treesitter and vim.treesitter.language and type(vim.treesitter.language.add) == "function" + if not has_add then + vim.notify("Helm-ls.nvim: Neovim >= 0.9 required for Tree-sitter features (missing vim.treesitter.language.add()).", vim.log.levels.WARN) + return + end + local ok, err = vim.treesitter.language.add("helm") + if not ok then + vim.notify( + ("Helm-ls.nvim: Helm Tree-sitter parser not found; features will be disabled. Install a Helm parser (e.g., via nvim-treesitter: :TSInstall helm) or place parser/helm.* on 'runtimepath'.%s") + :format(err and ("\nDetails: " .. err) or ""), + vim.log.levels.WARN + ) + return + end
54-60: Option: don’t hard-return; let features auto-activate after on-the-fly :TSInstall.If you omit the
returnon missing parser and instead short-circuit in the callback, users who install the parser during the session won’t need to reload Neovim.Outside the selected range, inside the autocmd callback (around Line 71), add a one-time per-buffer guard:
if vim.bo.filetype ~= "helm" then return end if not vim.b._helm_ls_has_parser then local ok = vim.treesitter and vim.treesitter.language and vim.treesitter.language.add and vim.treesitter.language.add("helm") if not ok then return end vim.b._helm_ls_has_parser = true end
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (1)
lua/helm-ls.lua(1 hunks)
🔇 Additional comments (1)
lua/helm-ls.lua (1)
54-60: Good swap to the built-in Treesitter check.Using
vim.treesitter.language.add("helm")removes the hard dependency onnvim-treesitter.parsersand is the documented way to check/load a parser before enabling features. Looks correct. (neovim.io)
|
Thanks for the fix and the detailed description. |
Fixes #14
Remove the nvim-treesitter dependency, so this doesn't error when the nvim-treesitter
mainbranch is used. Thehas_parser()function has been removed in the newer nvim-treesitter main branch, so this fixes errors related to that change.NOTE:
vim.treesitter.language.add()requires nvim 0.9+ (first released in April 2023)master&mainbranchesSummary by CodeRabbit
Bug Fixes
Refactor