Skip to content

Conversation

@NobbZ
Copy link
Owner

@NobbZ NobbZ commented Apr 21, 2025

Summary by CodeRabbit

  • New Features
    • Added support for C/C++ and Meson language servers, enabling enhanced language features and health monitoring for these languages.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Apr 21, 2025

Walkthrough

This update introduces two new Lua modules for configuring Language Server Protocol (LSP) support: one for C/C++ using clangd, and another for Meson. Both modules set up their respective language servers by specifying key mappings, capabilities, and integrating with a health monitoring system. The main LSP configuration file is updated to require these new modules, thereby extending the set of language servers managed by the plugin.

Changes

File(s) Change Summary
plugins/nobbz/lua/nobbz/lsp.lua Added requirements for new C/C++ (c-cpp.lua) and Meson (meson.lua) LSP configuration modules.
plugins/nobbz/lua/nobbz/lsp/c-cpp.lua New: Configures clangd LSP for C/C++, sets up key mappings, capabilities, and health checks.
plugins/nobbz/lua/nobbz/lsp/meson.lua New: Configures Meson LSP, sets up key mappings, capabilities, and health checks.

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
Loading

Possibly related PRs

  • add python LSP #51: Adds Python LSP configuration; similar update pattern in nobbz.lsp.lua and new language server setup.
  • add beancount LSP #19: Introduces a Beancount LSP module; shares structural similarities in adding language-specific LSP configs.

Poem

Two new servers join the codey dance,
C and C++ clangd now get their chance.
Meson builds with LSP delight,
Helpers and health checks keep things right.
In Lua’s warren, configs hop anew—
A rabbit’s work is never through! 🐇✨

Tip

⚡💬 Agentic Chat (Pro Plan, General Availability)
  • We're introducing multi-step agentic chat in review comments and issue comments, within and outside of PR's. This feature enhances review and issue discussions with the CodeRabbit agentic chat by enabling advanced interactions, including the ability to create pull requests directly from comments and add commits to existing pull requests.
✨ Finishing Touches
  • 📝 Generate Docstrings

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.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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 calling require("nobbz.health") inline, pull it in as a local at the top and then invoke health.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 the nobbz.health require 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

📥 Commits

Reviewing files that changed from the base of the PR and between a7121ea and b923237.

📒 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.lazy
  • local has to be used
  • coding follows the luarocks styleguide, but with 2 spaces indentation
  • plugins/nobbz/lua/nobbz/lsp.lua
  • plugins/nobbz/lua/nobbz/lsp/c-cpp.lua
  • plugins/nobbz/lua/nobbz/lsp/meson.lua
🔇 Additional comments (5)
plugins/nobbz/lua/nobbz/lsp/c-cpp.lua (1)

1-2: Helpers import is compliant.
The local 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 new require("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 new require("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.
The local helpers = require("nobbz.lsp.helpers") adheres to our styleguide. No change needed here.


3-6:

Details

❓ Verification inconclusive

Leverage nobbz.lazy and verify the server identifier
Apply the same lazy‑loading pattern and ensure the LSP server key matches lspconfig’s actual name (e.g., meson vs. 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, or mesonlsp) and update both the .setup and .register_lsp calls 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.lazy and correct server key

Please update plugins/nobbz/lua/nobbz/lsp/meson.lua to:

  • 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:

  1. Verify the Meson LSP key in nvim‑lspconfig (e.g. by checking its lua/lspconfig/*.lua file or the official docs).
  2. Replace both <server> placeholders above with that exact identifier.
  3. Ensure everything loads lazily via nobbz.lazy.

Comment on lines +3 to +6
require("lspconfig").clangd.setup({
on_attach = helpers.keymap,
capabilities = LSP_CAPAS,
})
Copy link
Contributor

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.

Suggested change
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,
})

@NobbZ NobbZ merged commit 65ff3fc into main Apr 21, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants