Skip to content

LSP autocmds - #44

Merged
nikero41 merged 8 commits into
mainfrom
lsp-autocmds
Apr 6, 2026
Merged

LSP autocmds#44
nikero41 merged 8 commits into
mainfrom
lsp-autocmds

Conversation

@nikero41

@nikero41 nikero41 commented Apr 6, 2026

Copy link
Copy Markdown
Owner

This pull request introduces improvements to Neovim's LSP (Language Server Protocol) and autocmd (autocommand) integration, adds configuration for several language servers, and refactors some utility functions for better code clarity and maintainability. The changes enhance LSP feature handling, streamline keymap processing, and update plugin and option setups.

LSP and Autocmd Enhancements:

  • Introduced a new lsp_setup method in Autocmds to modularize and improve the setup of LSP-related autocommands, including folding, document colors, inlay hints, and code lens, and invoked it from the main setup function. [1] [2]
  • Refactored logic for skipping autocmd groups in Autocmds:setup to use iterator-based processing for better readability and efficiency.

Language Server Configurations:

  • Added configuration files for emmet_language_server, sourcekit, and tailwindcss to enable language-specific features and settings. [1] [2] [3]
  • Added a hide_code_lens_ft option to the main config to allow disabling code lens for specific filetypes (e.g., Lua).

Utility and Plugin Improvements:

  • Refactored keymap conversion functions in keymaps.lua for clearer naming and usage, replacing from_nvim_keymap with to_keymap and updating all references. [1] [2] [3]
  • Improved the DAP plugin configuration by using iterators for filetype setup and simplifying error handling.

Other Notable Changes:

  • Enabled the new UI2 core module in Neovim options for enhanced UI features.
  • Removed the tohtml plugin from the list of disabled built-in plugins in the main setup.

@coderabbitai

coderabbitai Bot commented Apr 6, 2026

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: ace0599d-d5a6-4df4-ac41-ef74ce97b2d2

📥 Commits

Reviewing files that changed from the base of the PR and between 18a03cf and 0b1e12b.

📒 Files selected for processing (2)
  • lua/nikero/config.lua
  • lua/plugins/quickfix.lua
💤 Files with no reviewable changes (1)
  • lua/plugins/quickfix.lua
✅ Files skipped from review due to trivial changes (1)
  • lua/nikero/config.lua

📝 Walkthrough

Summary by CodeRabbit

  • New Features

    • Emmet expansion support for templ files
    • Swift language server support
    • Emmet completions enabled for Tailwind CSS
  • Improvements

    • Centralized LSP setup with improved controls for inlay hints, document colors, code lens, and folding
    • New configuration option to hide code lens by filetype

Walkthrough

Adds three new LSP server config modules (Emmet, SourceKit, TailwindCSS), centralizes LSP-related autocmds into a new lsp_setup() with conditional feature toggles (document color, inlay hints, code lens), introduces hide_code_lens_ft config, and refactors LSP filetype merging and some iteration patterns.

Changes

Cohort / File(s) Summary
New LSP server configs
after/lsp/emmet_language_server.lua, after/lsp/sourcekit.lua, after/lsp/tailwindcss.lua
Three new modules exporting vim.lsp.Config tables: Emmet maps templhtml; SourceKit sets filetypes = { "swift" }; TailwindCSS enables settings.tailwindCSS.emmetCompletions = true.
Autocmd centralization
lua/autocmds.lua
Added Autocmds:lsp_setup() and moved LSP-related autocmds from setup() into it; registers handlers to disable document color, enable inlay hints, and conditionally enable/disable code lens per filetype.
Config addition
lua/nikero/config.lua
Added hide_code_lens_ft field (default { "lua" }) to exported config table.
LSP filetype handling refactor
lua/plugins/language/support.lua
Changed server setup iteration pattern to pass extra directly, deep-copy and extend filetypes, and set filetypes = vim.list.unique(vim.list_extend(filetypes, extra)); removed prior global on_attach that handled codelens/inlay hints.
Iteration pattern update
lua/plugins/quickfix.lua
Removed :enumerate() wrapper from vim.iter(results) used in should_close computation, changing the iterator values passed into the subsequent filter.

Sequence Diagram

sequenceDiagram
    participant Buffer as Buffer Event
    participant LSP as LSP Client
    participant Autocmd as Autocmds.lsp_setup
    participant Config as Config (hide_code_lens_ft)
    participant DocColor as DocumentColorHandler
    participant Inlay as InlayHintsHandler
    participant CodeLens as CodeLensHandler

    Buffer->>Autocmd: BufEnter / LspAttach triggers
    Autocmd->>LSP: Inspect client & capabilities
    Autocmd->>DocColor: Disable document color if configured
    Autocmd->>Inlay: Enable inlay hints when supported
    Autocmd->>CodeLens: Query Config.hide_code_lens_ft for filetype
    CodeLens->>Config: Check allowlist/denylist
    alt filetype denied
        CodeLens->>LSP: Disable code lens for buffer
    else filetype allowed
        CodeLens->>LSP: Enable code lens for buffer
    end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~50 minutes

Possibly related PRs

  • Nvim 0.12 update #42: Modifies LSP code-lens and inlay-hint handling in lua/plugins/language/support.lua, overlapping with the refactor of LSP feature management here.
  • Kickstart rewrite #40: Adjusts LSP setup logic and attachment behavior, related to the changes moving on-attach feature toggles into autocmds.

Poem

🐰 I hopped through configs, neat and spry,

Emmet, SourceKit, Tailwind fly.
Hints and lenses, toggled light,
Autocmds gather, set things right.
A tiny rabbit cheers at night.

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title 'LSP autocmds' is vague and generic, describing only a subset of the changes. The PR includes language server configurations, code refactoring, and utility improvements beyond just autocmds. Consider a more descriptive title like 'Enhance LSP autocmds and add language server configurations' to better reflect the scope of changes.
✅ Passed checks (1 passed)
Check name Status Explanation
Description check ✅ Passed The description clearly relates to the changeset, detailing LSP enhancements, language server configurations, utility refactoring, and other notable changes that match the PR content.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch lsp-autocmds

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

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
lua/plugins/quickfix.lua (1)

99-108: ⚠️ Potential issue | 🔴 Critical

Bug: ipairs does not iterate over neotest's string-keyed results.

In neotest, results is a dictionary keyed by position ID strings (e.g., "/path/to/test.lua::test_name"). Using ipairs(results) on a string-keyed table yields nothing—the filter never runs, should_close is always true, and Trouble closes after every test run regardless of failures.

Use vim.iter(results) to iterate over the dictionary:

🐛 Proposed fix
 local should_close = vim.tbl_count(
 	vim
-		.iter(ipairs(results))
+		.iter(results)
 		:filter(
 			function(pos_id, result)
 				return result.status ~= "failed" and tree:get_key(pos_id)
 			end
 		)
 		:totable()
 ) == 0
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@lua/plugins/quickfix.lua` around lines 99 - 108, The closure-detection logic
uses ipairs on neotest's results (string-keyed table) so the filter never runs;
update the iterator to vim.iter(results) instead of vim.iter(ipairs(results))
inside the should_close calculation so the filter receives position IDs and
result tables correctly (referencing the local should_close, the results
variable, and the tree:get_key(pos_id) callback).
🧹 Nitpick comments (1)
lua/nikero/config.lua (1)

4-4: Consider adding type annotation for the new field.

The hide_code_lens_ft field would benefit from a type annotation in the @class definition for better IDE support and documentation.

 ---@class Config
+---@field hide_code_lens_ft string[] Filetypes where code lens should be disabled
 local Config = {
 	transparency = false,
 	hide_code_lens_ft = { "lua" },
 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@lua/nikero/config.lua` at line 4, Add a type annotation for the new
hide_code_lens_ft field in the module's `@class/`@field docs so editors can infer
its type; update the existing class comment (e.g., the NikeroConfig `@class`) to
include a line like "@field hide_code_lens_ft string[] — list of filetype names
to hide code lenses for" so the hide_code_lens_ft symbol is documented as an
array of strings.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@lua/plugins/quickfix.lua`:
- Around line 99-108: The closure-detection logic uses ipairs on neotest's
results (string-keyed table) so the filter never runs; update the iterator to
vim.iter(results) instead of vim.iter(ipairs(results)) inside the should_close
calculation so the filter receives position IDs and result tables correctly
(referencing the local should_close, the results variable, and the
tree:get_key(pos_id) callback).

---

Nitpick comments:
In `@lua/nikero/config.lua`:
- Line 4: Add a type annotation for the new hide_code_lens_ft field in the
module's `@class/`@field docs so editors can infer its type; update the existing
class comment (e.g., the NikeroConfig `@class`) to include a line like "@field
hide_code_lens_ft string[] — list of filetype names to hide code lenses for" so
the hide_code_lens_ft symbol is documented as an array of strings.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: f6b40871-aa48-47f9-9979-fd566727ae7d

📥 Commits

Reviewing files that changed from the base of the PR and between 2d0d88d and 18a03cf.

📒 Files selected for processing (18)
  • after/lsp/basedpyright.lua
  • after/lsp/bashls.lua
  • after/lsp/clangd.lua
  • after/lsp/cssls.lua
  • after/lsp/emmet_language_server.lua
  • after/lsp/gopls.lua
  • after/lsp/html.lua
  • after/lsp/jsonls.lua
  • after/lsp/lua_ls.lua
  • after/lsp/omnisharp.lua
  • after/lsp/sourcekit.lua
  • after/lsp/tailwindcss.lua
  • after/lsp/tsgo.lua
  • after/lsp/yamlls.lua
  • lua/autocmds.lua
  • lua/nikero/config.lua
  • lua/plugins/language/support.lua
  • lua/plugins/quickfix.lua

@nikero41
nikero41 merged commit 2069457 into main Apr 6, 2026
3 checks passed
@nikero41
nikero41 deleted the lsp-autocmds branch April 6, 2026 01:48
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.

1 participant