Conversation
WalkthroughThe updates add and configure several new Neovim LSP-related plugins, update existing plugin versions, and refactor the plugin setup logic. Configuration for "mason.nvim" and its dependencies is moved from static option tables to explicit Lua setup functions. Additional plugins are registered, and dependency management is clarified with a new workaround module. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant Neovim
participant Mason
participant MasonLspConfig
participant LspConfig
User->>Neovim: Start
Neovim->>Mason: require("mason").setup()
Neovim->>MasonLspConfig: require("mason-lspconfig").setup()
Neovim->>LspConfig: require("lspconfig").setup_handlers()
LspConfig->>Neovim: Register LSP servers (with custom handlers)
Poem
✨ Finishing Touches
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. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 2
🔭 Outside diff range comments (1)
lua/ronb/plugins/lsp/lspconfig.lua (1)
4-8:⚠️ Potential issueAdd missing mason-lspconfig dependency.
The code requires
mason-lspconfigon line 14 but it's not declared in the dependencies list. This could cause runtime errors if the plugin isn't installed.dependencies = { "hrsh7th/cmp-nvim-lsp", { "antosha417/nvim-lsp-file-operations", config = true }, { "folke/lazydev.nvim", opts = {} }, + "williamboman/mason-lspconfig.nvim", },
🧹 Nitpick comments (2)
lua/ronb/lazy.lua (1)
14-14: Track the TODO comment for future refactoring.The TODO comment indicates that some code should be moved to a different file. Consider creating an issue to track this technical debt.
Would you like me to open a new issue to track this refactoring task?
lua/ronb/plugins/lsp/mason.lua (1)
24-45: Consider enabling some LSP servers or documenting the commented configuration.The
ensure_installedlist is entirely commented out, which means no LSP servers will be automatically installed. Whileautomatic_installation = truewill install servers when they're used, you might want to uncomment some essential servers for a better out-of-the-box experience.Consider uncommenting commonly used servers:
ensure_installed = { - -- "tsserver", - -- "html", - -- "jsonls", - -- "cssls", - -- "gopls", - -- "pyright", + "tsserver", + "html", + "jsonls", + "cssls", + "gopls", + "pyright", -- "htmx", -- "autotools_ls", -- "tailwindcss", -- "asm_lsp", -- "golangci_lint_ls", -- "graphql", -- "emmet_ls", -- "marksman", -- "sqlls", -- "prismals", },Alternatively, document why all servers are commented out if this is intentional.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
lazy-lock.json(2 hunks)lua/ronb/lazy.lua(2 hunks)lua/ronb/plugins/lsp/lspconfig.lua(1 hunks)lua/ronb/plugins/lsp/mason-workaround.lua(1 hunks)lua/ronb/plugins/lsp/mason.lua(1 hunks)
🔇 Additional comments (12)
lua/ronb/lazy.lua (2)
3-10: LGTM! Formatting improvements enhance readability.The indentation adjustments to the git clone command array improve code consistency.
26-38: LGTM! Consistent formatting applied.The indentation changes to the lazy.setup configuration maintain consistency with the rest of the file.
lua/ronb/plugins/lsp/lspconfig.lua (3)
10-19: LGTM! Improved code documentation.The added comments clearly explain each import, improving code readability.
77-82: LGTM! Cleaner diagnostic signs configuration.Using
vim.fn.sign_definedirectly is more explicit than configuring throughvim.diagnostic.config.
129-145: LGTM! Simplified lua_ls configuration.The removal of workspace library and telemetry settings simplifies the configuration while maintaining essential functionality.
lua/ronb/plugins/lsp/mason.lua (3)
3-5: LGTM! Dependencies section correctly simplified.The refactoring from nested dependency options to a simple string reference is clean and follows the new explicit configuration pattern.
6-23: LGTM! Mason setup is correctly configured.The explicit
mason.setup()call with UI icons configuration is properly implemented and preserves the previous functionality.
6-46:Details
❓ Verification inconclusive
Verify the configuration refactoring works correctly.
The refactoring from declarative
optsto explicitconfigfunction calls looks correct, but please ensure this change resolves the LSP issues mentioned in the PR objectives.Let me verify that both mason modules are properly available:
🏁 Script executed:
#!/bin/bash # Description: Verify mason modules are correctly referenced and available. # Search for mason module usage patterns in the codebase rg -A 3 -B 1 'require.*mason' # Check if there are any other mason configuration files that might conflict fd -e lua -x grep -l "mason" {} \;Length of output: 999
Verify duplicate mason plugin specs and confirm configuration
- The search output shows both
lua/ronb/plugins/lsp/mason.luaandlua/ronb/plugins/lsp/mason-workaround.luareference themason.nvimplugin. Please ensure only one plugin spec formason.nvimis loaded to avoid conflicting setups.- If the workaround file is no longer needed after refactoring to the explicit
configfunction, remove or merge its logic intomason.lua.- Confirm that your
mason.setup({…})andmason_lspconfig.setup({…})calls inmason.luaactually resolve the LSP issues outlined in the PR objectives.- In Neovim, run
:Masonto verify the UI icons and:LspInstallto ensure automatic installation behaves as expected.lazy-lock.json (4)
6-6: LGTM! LSP completion plugin correctly added.The addition of
cmp-nvim-lspenhances LSP completion integration, which aligns with fixing LSP functionality.
15-15: LGTM! New LSP development plugins added.The addition of
lazydev.nvim,neodev.nvim, andnvim-lsp-file-operationsexpands the LSP ecosystem with useful development tools:
lazydev.nvim: Enhanced Lua development supportneodev.nvim: Neovim API development assistancenvim-lsp-file-operations: File operation integration with LSPThese additions support a more comprehensive LSP setup.
Also applies to: 24-24, 27-27
18-19: LGTM! Mason and LSP config plugins updated to newer versions.The commit updates for
mason-lspconfig.nvim,mason.nvim, andnvim-lspconfigare consistent with the configuration refactoring in mason.lua and should help resolve the LSP issues mentioned in the PR.Also applies to: 28-28
1-47:Details
✅ Verification successful
Verify plugin compatibility and potential breaking changes.
While the plugin updates look good, please ensure the newer versions are compatible with the current configuration and don't introduce breaking changes.
🏁 Script executed:
#!/bin/bash # Description: Check for any potential compatibility issues or breaking changes in updated plugins. # Check if there are any configuration files that might need updates due to plugin changes rg -l "mason-lspconfig\|nvim-lspconfig\|lazydev\|neodev" --type lua # Look for any deprecated configuration patterns rg -A 5 -B 5 "opts.*mason|config.*mason" --type luaLength of output: 1393
No immediate breaking changes detected in plugin configurations
I ran searches across your Lua configs (
mason.luaandlspconfig.lua) for any deprecated or changed API patterns related to the updated plugins (mason-lspconfig,nvim-lspconfig,lazydev,neodev) and found none. Both files import and call the plugins’ setup functions as before, and there are no lingeringopts.*masonor outdatedconfig.*masonpatterns.Unless upstream commits introduce undocumented breaking changes (in which case you’d see errors at runtime), your current configuration should remain compatible.
| return { | ||
| { "mason-org/mason.nvim", version = "^1.0.0" }, | ||
| { "mason-org/mason-lspconfig.nvim", version = "^1.0.0" }, | ||
| } |
There was a problem hiding this comment.
🛠️ Refactor suggestion
Document the purpose of this workaround.
This file introduces a workaround but lacks documentation explaining:
- What issue is being worked around
- Why version constraints are needed
- When this workaround can be removed
Consider adding a comment block at the top of the file explaining the context.
+-- TODO: This is a temporary workaround for [describe issue here]
+-- Can be removed when [describe condition here]
return {
{ "mason-org/mason.nvim", version = "^1.0.0" },
{ "mason-org/mason-lspconfig.nvim", version = "^1.0.0" },
}📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| return { | |
| { "mason-org/mason.nvim", version = "^1.0.0" }, | |
| { "mason-org/mason-lspconfig.nvim", version = "^1.0.0" }, | |
| } | |
| -- TODO: This is a temporary workaround for [describe issue here] | |
| -- Can be removed when [describe condition here] | |
| return { | |
| { "mason-org/mason.nvim", version = "^1.0.0" }, | |
| { "mason-org/mason-lspconfig.nvim", version = "^1.0.0" }, | |
| } |
🤖 Prompt for AI Agents
In lua/ronb/plugins/lsp/mason-workaround.lua at lines 1 to 4, add a comment
block at the top of the file explaining the purpose of this workaround. Document
what specific issue this workaround addresses, why the version constraints are
necessary, and under what conditions or future updates this workaround can be
removed. This will provide clarity and context for future maintainers.
| callback = function(ctx) | ||
| -- Here use ctx.match instead of ctx.file | ||
| client.notify("$/onDidChangeTsOrJsFile", { uri = ctx.match }) |
There was a problem hiding this comment.
💡 Verification agent
🧩 Analysis chain
Verify the change from ctx.file to ctx.match.
The svelte server configuration now uses ctx.match instead of ctx.file. Ensure this is the correct field for the file URI in the autocmd callback context.
🏁 Script executed:
#!/bin/bash
# Description: Check Neovim documentation and similar usage patterns for autocmd context fields
# Search for other uses of BufWritePost autocmd callbacks to see the pattern
rg -A 5 -B 5 'BufWritePost.*callback.*ctx\.(file|match)' --type lua
# Search for notify with uri parameter patterns
ast-grep --pattern 'client.notify($_, { uri = $_ })'Length of output: 233
🌐 Web query:
In Neovim Lua nvim_create_autocmd callback context, what are ctx.file and ctx.match?
💡 Result:
When working with Neovim's Lua API for creating autocommands, the callback function receives a context table with several important fields. The ctx.file and ctx.match properties provide valuable information about the event that triggered the autocommand.
Autocommand Callback Context
In Neovim's nvim_create_autocmd API, the callback function receives a context table (often referred to as args in examples) containing several properties:
ctx.file represents the file name of the buffer in which the autocommand event was triggered[6]. This corresponds to what you would access with <afile> in Vimscript autocommands. It provides the full path to the file that triggered the event.
ctx.match contains the string that matched the pattern specified in your autocommand[6]. This corresponds to <amatch> in Vimscript. The value of ctx.match depends on the specific event type:
- For buffer-related events, it typically contains the buffer name
- For FileType events, it contains the filetype that was set[5]
- For other events, it contains whatever matched against your specified pattern
Example Usage
Here's how you might use these properties in practice:
vim.api.nvim_create_autocmd("FileType", {
pattern = "lua",
callback = function(args)
-- args.match would contain "lua" here
-- args.file would contain the file path
print("FileType set to: " .. args.match)
print("File path: " .. args.file)
-- Set buffer-local mapping
vim.keymap.set('n', 'K', vim.lsp.buf.hover, { buffer = args.buf })
end
})The callback receives other useful properties as well:
ctx.buf: the buffer number where the event was triggered[6]ctx.data: a table with event-specific data that's passed for some events[6]
This context information allows you to create highly customized autocommands that respond intelligently to different conditions and file types in your Neovim configuration.
Citations:
- 1: README: improve
autocmdinstructions wbthomason/packer.nvim#1082 - 2: https://neovim.io/doc/user/lsp.html
- 3: Svelte is not reflect typescript file neovim/nvim-lspconfig#725
- 4: https://neovim.io/doc/user/autocmd.html
- 5: https://www.youtube.com/watch?v=HR1dKKrOmDs
- 6: https://neovim.io/doc/user/lua-guide.html
- 7: https://xnacly.me/posts/2023/autocommand-nvim/
- 8: https://neovim.discourse.group/t/help-debugging-my-beloved-settings/1934
- 9: https://github.com/hrsh7th/nvim-cmp/blob/main/doc/cmp.txt
- 10: https://www.josean.com/posts/how-to-setup-neovim-2024
Use ctx.file for the file URI
The ctx.match field maps to <amatch> (the autocommand pattern), not the actual filename. To send the correct URI in your Svelte LSP notification, switch back to ctx.file (<afile>).
- File:
lua/ronb/plugins/lsp/lspconfig.lua
Lines: 98–100
Change:callback = function(ctx) -- Here use ctx.match instead of ctx.file
- client.notify("$/onDidChangeTsOrJsFile", { uri = ctx.match })
- client.notify("$/onDidChangeTsOrJsFile", { uri = ctx.file })
end
<!-- suggestion_start -->
<details>
<summary>📝 Committable suggestion</summary>
> ‼️ **IMPORTANT**
> Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
```suggestion
callback = function(ctx)
-- Here use ctx.file instead of ctx.match
client.notify("$/onDidChangeTsOrJsFile", { uri = ctx.file })
🤖 Prompt for AI Agents
In lua/ronb/plugins/lsp/lspconfig.lua around lines 98 to 100, the callback uses
ctx.match for the file URI, but ctx.match corresponds to the autocommand pattern
match, not the actual file path. To fix this, revert to using ctx.file which
holds the correct file URI for the notification. Replace ctx.match with ctx.file
in the client.notify call.
Add a workaround to the lspconfig, fixing the issue causing the lsp servers to not work
Summary by CodeRabbit