Skip to content

Conversation

@NobbZ
Copy link
Owner

@NobbZ NobbZ commented Jun 22, 2025

FIXES #56

Summary by CodeRabbit

  • New Features

    • Health checks now include LSP configurations alongside existing program checks.
    • LSP servers are tracked, with their configuration status reported in health summaries.
    • Programs can be registered as required based on filetypes, dynamically updating when relevant files are opened.
  • Refactor

    • Unified sorting and reporting logic for health checks of programs and LSP configurations.
  • Chores

    • Registered the "alejandra" program for health monitoring related to the "nix" filetype.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jun 22, 2025

Walkthrough

The changes introduce health checks for LSP configurations in addition to existing program checks, refactor sorting and reporting logic into reusable functions, and enhance program registration to support filetype-based dynamic requirements. The register_lsp function is updated to integrate with these changes, and a new dependency registration is added for "alejandra" in the nil LSP module.

Changes

File(s) Change Summary
plugins/nobbz/lua/nobbz/health.lua Added LSP configuration health checks, refactored sorting/reporting logic, enhanced program registration, updated register_lsp.
plugins/nobbz/lua/nobbz/lsp/nil.lua Imported health module and registered "alejandra" program as a dependency for the nil LSP.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant HealthModule
    participant Lspconfig
    participant Vim

    User->>HealthModule: M.register_lsp(lsp_name)
    HealthModule->>Lspconfig: require("lspconfig")[lsp_name]
    alt Config exists and valid
        HealthModule->>HealthModule: register_program(program, filetypes)
        HealthModule->>Vim: autocmd FileType for filetypes
    else Config missing/invalid
        HealthModule->>Vim: notify("LSP configuration for ... not found", WARN)
    end

    User->>HealthModule: M.check()
    HealthModule->>HealthModule: check_lspconfigs()
    HealthModule->>HealthModule: check_programs()
Loading

Assessment against linked issues

Objective Addressed Explanation
Add error handling for missing/invalid LSP config, cmd, or filetypes in health module (#56) No error handling or notification logic for missing/invalid LSP config, cmd, or filetypes added.

Assessment against linked issues: Out-of-scope changes

Code Change Explanation
Refactoring of sorting/reporting logic into helper functions (plugins/nobbz/lua/nobbz/health.lua) The linked issue focuses on error handling, not refactoring or code organization.
Addition of LSP configuration health checks (plugins/nobbz/lua/nobbz/health.lua) The linked issue is about error handling, not about adding new LSP health check reporting logic.
Registration of "alejandra" program in nil LSP module (plugins/nobbz/lua/nobbz/lsp/nil.lua) The linked issue does not mention registering new dependencies or modifying LSP module setup.

Possibly related PRs

  • healthchecks #55: Introduced foundational health check and registration methods for programs and LSPs, which this PR extends.
  • 0.11 LSP loading #74: Changes internal LSP config access in register_lsp, directly relating to the function updated here.
  • LSP initialisation abstraction #73: Refactored LSP modules and uses register_lsp for registration, directly related to the health check and registration logic.

Poem

In the warren of code, new health checks hop,
For LSPs and programs, we now never stop.
Sorting and reporting, all neat in a row,
With "alejandra" checked, our confidence grows.
The bunny approves, with a twitch of its nose—
Healthier plugins, from ears to toes! 🐇✨


📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0492d92 and ce363c9.

📒 Files selected for processing (1)
  • plugins/nobbz/lua/nobbz/health.lua (6 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • plugins/nobbz/lua/nobbz/health.lua
✨ 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.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

Support

Need 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)

  • @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 generate sequence diagram to generate a sequence diagram of the changes in 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.

@NobbZ NobbZ marked this pull request as ready for review June 22, 2025 08:20
@NobbZ NobbZ requested a review from Copilot June 22, 2025 08:20

This comment was marked as outdated.

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

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between bc152ad and 0492d92.

📒 Files selected for processing (2)
  • plugins/nobbz/lua/nobbz/health.lua (6 hunks)
  • plugins/nobbz/lua/nobbz/lsp/nil.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/nil.lua
  • plugins/nobbz/lua/nobbz/health.lua
🔇 Additional comments (8)
plugins/nobbz/lua/nobbz/health.lua (6)

4-4: LGTM!

The addition of lsp_configs table to track LSP configurations is well-structured and follows the existing pattern used for programs.


16-38: Excellent refactoring of sorting and reporting logic.

The extraction of health_cmp, health_sort, and report_table into reusable helper functions is a great improvement that eliminates code duplication and makes the codebase more maintainable.


41-57: Well-implemented LSP configuration health checks.

The check_lspconfigs function properly integrates with the existing health check infrastructure and provides clear feedback on LSP configuration status. The sorting and reporting using the helper functions maintains consistency with program checks.


86-101: Innovative filetype-based program registration enhancement.

The enhancement to support both boolean and filetype array parameters is well-designed. The autocmd approach for dynamically marking programs as required when specific filetypes are opened is elegant and efficient.


114-124: Well-integrated LSP registration function.

The register_lsp function properly extracts LSP configuration details and integrates with the enhanced register_program function. The approach of checking vim.lsp.config[lsp] availability and registering the command with associated filetypes is sound.


142-142: Proper integration of LSP checks into main health function.

The addition of check_lspconfigs() before check_programs() provides a logical flow in the health check report.

plugins/nobbz/lua/nobbz/lsp/nil.lua (2)

2-2: Proper module import following coding guidelines.

The health module import uses local declaration and follows the established pattern in the file.


4-4: Excellent integration with the enhanced health system.

The registration of "alejandra" with the "nix" filetype leverages the new filetype-based program registration feature introduced in the health module. This ensures the formatter is only marked as required when working with Nix files, which is the intended behavior.

@NobbZ NobbZ requested a review from Copilot June 22, 2025 09:27
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR enhances the healthcheck framework by adding LSP configuration checks alongside existing program checks and refactors sorting/reporting logic.

  • Introduces tracking and reporting of LSP server configuration status.
  • Refactors sorting and reporting into shared helper functions (health_sort, report_table).
  • Extends register_program to support filetype-based dynamic requirements and adds register_lsp.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
plugins/nobbz/lua/nobbz/lsp/nil.lua Registers the “alejandra” program for nix files
plugins/nobbz/lua/nobbz/health.lua Adds lsp_configs, refactors sorting/reporting, updates register_program, and implements check_lspconfigs
Comments suppressed due to low confidence (5)

plugins/nobbz/lua/nobbz/health.lua:43

  • There are no tests covering check_lspconfigs; adding unit or integration tests would ensure both configured and missing LSP scenarios are validated.
local function check_lspconfigs()

plugins/nobbz/lua/nobbz/health.lua:88

  • [nitpick] Mixing boolean and table types in the required_or_filetypes parameter can be confusing; consider separating into two distinct functions or using a more explicit options table.
M.register_program = function(program, required_or_filetypes)

plugins/nobbz/lua/nobbz/health.lua:113

  • [nitpick] Update the docblock for register_lsp to mention that it now also registers filetype-based program requirements and populates lsp_configs.
---@param lsp string the name of the LSP server as defined in lspconfig

plugins/nobbz/lua/nobbz/lsp/nil.lua:4

  • Registering the alejandra program in the nil.lua (Nil LSP) module seems misplaced—this should live in the Nix-related plugin or configuration module to avoid confusion.
health.register_program("alejandra", { "nix", })

plugins/nobbz/lua/nobbz/health.lua:5

  • The done variable is declared but never used; consider removing it to clean up dead code.
local done = false

@NobbZ NobbZ merged commit f445ba9 into main Jun 22, 2025
3 checks 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.

Add error handling for LSP configuration access in health module

2 participants