-
Notifications
You must be signed in to change notification settings - Fork 4
add meson and C/C++ support #60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
WalkthroughThis update introduces two new Lua modules for configuring Language Server Protocol (LSP) support: one for C/C++ using Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant LSPConfig
participant CCppModule as C/C++ LSP Module
participant MesonModule as Meson LSP Module
participant HealthMonitor
User->>LSPConfig: Load main LSP config
LSPConfig->>CCppModule: Require C/C++ config
CCppModule->>LSPConfig: Setup clangd with keymaps and capabilities
CCppModule->>HealthMonitor: Register clangd server
LSPConfig->>MesonModule: Require Meson config
MesonModule->>LSPConfig: Setup Meson LSP with keymaps and capabilities
MesonModule->>HealthMonitor: Register Meson server
Possibly related PRs
Poem
Tip ⚡💬 Agentic Chat (Pro Plan, General Availability)
✨ 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:
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
Documentation and Community
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (2)
plugins/nobbz/lua/nobbz/lsp/c-cpp.lua (1)
8-8: Use a local import for the health module
Instead of callingrequire("nobbz.health")inline, pull it in as a local at the top and then invokehealth.register_lsp:-local helpers = require("nobbz.lsp.helpers") -local lspconfig = require("nobbz.lazy").lspconfig +local helpers = require("nobbz.lsp.helpers") +local lspconfig = require("nobbz.lazy").lspconfig +local health = require("nobbz.health") --- -lspconfig.clangd.setup({ … }) -require("nobbz.health").register_lsp("clangd") +health.register_lsp("clangd")plugins/nobbz/lua/nobbz/lsp/meson.lua (1)
8-8: Use a local import for the health module
Make thenobbz.healthrequire local, in line with other modules:-local helpers = require("nobbz.lsp.helpers") -local lspconfig = require("nobbz.lazy").lspconfig +local helpers = require("nobbz.lsp.helpers") +local lspconfig = require("nobbz.lazy").lspconfig +local health = require("nobbz.health") lspconfig.meson.setup({ … }) -health.register_lsp("mesonlsp") +health.register_lsp("mesonlsp")
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
plugins/nobbz/lua/nobbz/lsp.lua(1 hunks)plugins/nobbz/lua/nobbz/lsp/c-cpp.lua(1 hunks)plugins/nobbz/lua/nobbz/lsp/meson.lua(1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
`plugins/**/*.lua`: Please ensure all of the following: - Plugins are lazyloaded if possible through `nobbz.lazy` - `local` has to be used - coding follows the [luarocks styleguide...
plugins/**/*.lua: Please ensure all of the following:
- Plugins are lazyloaded if possible through
nobbz.lazylocalhas to be used- coding follows the luarocks styleguide, but with 2 spaces indentation
plugins/nobbz/lua/nobbz/lsp.luaplugins/nobbz/lua/nobbz/lsp/c-cpp.luaplugins/nobbz/lua/nobbz/lsp/meson.lua
🔇 Additional comments (5)
plugins/nobbz/lua/nobbz/lsp/c-cpp.lua (1)
1-2: Helpers import is compliant.
Thelocal helpers = require("nobbz.lsp.helpers")follows the styleguide. No change needed here.plugins/nobbz/lua/nobbz/lsp.lua (2)
29-29: Register the C/C++ module in the main loader
The newrequire("nobbz.lsp.c-cpp")line correctly integrates the C/C++ LSP config alongside existing modules.
36-36: Register the Meson module in the main loader
The newrequire("nobbz.lsp.meson")line correctly integrates the Meson LSP config alongside existing modules.plugins/nobbz/lua/nobbz/lsp/meson.lua (2)
1-1: Helpers import is compliant.
Thelocal helpers = require("nobbz.lsp.helpers")adheres to our styleguide. No change needed here.
3-6:Details
❓ Verification inconclusive
Leverage
nobbz.lazyand verify the server identifier
Apply the same lazy‑loading pattern and ensure the LSP server key matcheslspconfig’s actual name (e.g.,mesonvs.mesonlsp). For instance:-local helpers = require("nobbz.lsp.helpers") -require("lspconfig").mesonlsp.setup({ - on_attach = helpers.keymap, - capabilities = LSP_CAPAS, -}) +local helpers = require("nobbz.lsp.helpers") +local lspconfig = require("nobbz.lazy").lspconfig + +# If the server name is `meson` in lspconfig: +lspconfig.meson.setup({ + on_attach = helpers.keymap, + capabilities = LSP_CAPAS, +})Please confirm the correct identifier in
lspconfig(e.g.,meson,meson_ls, ormesonlsp) and update both the.setupand.register_lspcalls accordingly.
🏁 Script executed:
#!/bin/bash set -e # 1. Locate the `nobbz.lazy` file in the repo LAZY_FILE=$(rg -l "nobbz\\.lazy" | grep -i "lazy.lua" | head -n1) echo "Found lazy file: $LAZY_FILE" echo "---- Begin lazy.lua (first 200 lines) ----" sed -n '1,200p' "$LAZY_FILE" echo "---- End lazy.lua ----" echo # 2. Check how lspconfig is exposed in nobbz.lazy echo "---- lspconfig references inside lazy.lua ----" grep -R "lspconfig" "$LAZY_FILE" || echo "(none found)" # 3. Find all lspconfig.* calls in the repo echo echo "---- All require('lspconfig').<server> usages ----" rg -n "require(\"lspconfig\"\)" -A2 || echo "(none found)" # 4. Search for any mention of 'meson' to see existing patterns echo echo "---- All occurrences of 'meson' ----" rg -n "meson" || echo "(none found)"Length of output: 279
🏁 Script executed:
#!/bin/bash set -e echo "1. List all files named 'lazy.lua' or under a 'lazy' directory:" fd -HI 'lazy' -t f || echo "No 'lazy' files found" echo echo "2. Search for any 'nobbz.lazy' references:" rg -n "nobbz\\.lazy" || echo "No occurrences of 'nobbz.lazy'" echo echo "3. Inspect the Meson LSP config:" if [ -f plugins/nobbz/lua/nobbz/lsp/meson.lua ]; then echo "---- plugins/nobbz/lua/nobbz/lsp/meson.lua ----" sed -n '1,200p' plugins/nobbz/lua/nobbz/lsp/meson.lua else echo "meson.lua not found at expected path" fi echo echo "4. Check other LSP configs for patterns:" find plugins/nobbz/lua/nobbz/lsp -type f -name '*.lua' ! -name 'meson.lua' -print -exec sed -n '1,50p' {} \;Length of output: 12260
Refactor Meson LSP to use
nobbz.lazyand correct server keyPlease update
plugins/nobbz/lua/nobbz/lsp/meson.luato:
- Import LSP through our lazy‑loader
- Use the exact server identifier as defined in nvim‑lspconfig
- Mirror the pattern used by other modules
Suggested changes in
meson.lua:-local helpers = require("nobbz.lsp.helpers") -require("lspconfig").mesonlsp.setup({ - on_attach = helpers.keymap, - capabilities = LSP_CAPAS, -}) -require("nobbz.health").register_lsp("mesonlsp") +local helpers = require("nobbz.lsp.helpers") +local lspconfig = require("nobbz.lazy").lspconfig + +# Replace `<server>` with the exact name from nvim‑lspconfig +# (e.g., `meson`, `mesonls`, or `mesonlsp`) +lspconfig.<server>.setup({ + on_attach = helpers.keymap, + capabilities = LSP_CAPAS, +}) + +require("nobbz.health").register_lsp("<server>")• File to update:
• plugins/nobbz/lua/nobbz/lsp/meson.lua• Next steps:
- Verify the Meson LSP key in nvim‑lspconfig (e.g. by checking its
lua/lspconfig/*.luafile or the official docs).- Replace both
<server>placeholders above with that exact identifier.- Ensure everything loads lazily via
nobbz.lazy.
| require("lspconfig").clangd.setup({ | ||
| on_attach = helpers.keymap, | ||
| capabilities = LSP_CAPAS, | ||
| }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Leverage nobbz.lazy and local imports for plugin modules
To adhere to our lazy‑loading policy and ensure all plugin dependencies are declared as locals, replace the inline require("lspconfig") with a lazy import. For example:
-local helpers = require("nobbz.lsp.helpers")
-require("lspconfig").clangd.setup({
- on_attach = helpers.keymap,
- capabilities = LSP_CAPAS,
-})
+local helpers = require("nobbz.lsp.helpers")
+local lspconfig = require("nobbz.lazy").lspconfig
+
+lspconfig.clangd.setup({
+ on_attach = helpers.keymap,
+ capabilities = LSP_CAPAS,
+})📝 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.
| require("lspconfig").clangd.setup({ | |
| on_attach = helpers.keymap, | |
| capabilities = LSP_CAPAS, | |
| }) | |
| local helpers = require("nobbz.lsp.helpers") | |
| local lspconfig = require("nobbz.lazy").lspconfig | |
| lspconfig.clangd.setup({ | |
| on_attach = helpers.keymap, | |
| capabilities = LSP_CAPAS, | |
| }) |
Summary by CodeRabbit