Skip to content

feat(neovim): add recommended settings from dmtrKovalenko/dotfiles - #393

Merged
shunkakinoki merged 1 commit into
mainfrom
claude/add-nvim-settings-01AhAjbTprd768Z8vSs48PuL
Dec 7, 2025
Merged

feat(neovim): add recommended settings from dmtrKovalenko/dotfiles#393
shunkakinoki merged 1 commit into
mainfrom
claude/add-nvim-settings-01AhAjbTprd768Z8vSs48PuL

Conversation

@shunkakinoki

@shunkakinoki shunkakinoki commented Dec 6, 2025

Copy link
Copy Markdown
Owner
  • Add smart delete function (avoids polluting registers with whitespace-only lines)
  • Add yank register rotation to preserve yank history (registers 1-9)
  • Add SSH/OSC52 clipboard handling for remote sessions
  • Add filetype-specific keyword extensions (TS/JS, CSS, HTML, JSON, YAML, etc.)
  • Add auto-save on buffer leave and focus loss
  • Add custom terminal title with file icons
  • Add close floating windows utility
  • Add visible whitespace rendering (tabs, trailing spaces, etc.)
  • Add enhanced diagnostic display configuration

Reference: https://github.com/dmtrKovalenko/dotfiles


Summary by cubic

Adopt recommended Neovim settings from dmtrKovalenko/dotfiles to polish editing UX and diagnostics. Improves remote clipboard, auto-save, yank history, and UI details.

  • New Features
    • Editing UX: smart delete, yank register rotation, auto-save, visible whitespace
    • Remote clipboard: OSC52 clipboard when running over SSH
    • UI polish: terminal titles with file icons; Esc closes floating windows and clears search
    • Language-aware keywords: better word navigation in TS/JS, CSS, HTML/XML/Vue/Svelte, JSON, YAML/TOML, Markdown
    • Diagnostics: refined virtual text, signs, underline, and rounded float configuration

Written for commit adfab56. Summary will update automatically on new commits.

- Add smart delete function (avoids polluting registers with whitespace-only lines)
- Add yank register rotation to preserve yank history (registers 1-9)
- Add SSH/OSC52 clipboard handling for remote sessions
- Add filetype-specific keyword extensions (TS/JS, CSS, HTML, JSON, YAML, etc.)
- Add auto-save on buffer leave and focus loss
- Add custom terminal title with file icons
- Add close floating windows utility
- Add visible whitespace rendering (tabs, trailing spaces, etc.)
- Add enhanced diagnostic display configuration

Reference: https://github.com/dmtrKovalenko/dotfiles
Copilot AI review requested due to automatic review settings December 6, 2025 10:39
@coderabbitai

coderabbitai Bot commented Dec 6, 2025

Copy link
Copy Markdown
📝 Walkthrough

Summary by CodeRabbit

Release Notes

  • New Features

    • Auto-save functionality when switching buffers or losing focus
    • Yank register rotation to track copy history
    • Smart deletion behavior for improved text editing
    • Enhanced keyword navigation across multiple file types (TypeScript, JavaScript, CSS, HTML, JSON, YAML, Markdown)
    • SSH-aware clipboard handling with OSC 52 support
    • Quickfix list management with cycling and clearing utilities
  • Style

    • Visible whitespace indicators for tabs and trailing spaces
    • Enhanced diagnostic display with improved formatting and floating window borders

✏️ Tip: You can customize this high-level summary in your review settings.

Walkthrough

This pull request expands the Neovim configuration with multiple runtime enhancements. Changes include new autocmds for auto-saving, yank highlighting with register rotation, dynamic terminal titles, and per-filetype keyword expansions. Utility functions are introduced for buffer cycling, register manipulation, SSH detection, and floating window management. Settings additions cover SSH-aware clipboard handling, diagnostic display options, and visible whitespace configuration. Two new keymaps modify deletion and floating window behavior.

Changes

Cohort / File(s) Summary
Utility Functions
home-manager/programs/neovim/lua/utils.lua
Added 8 new public API functions: smart_delete() for register-aware deletion, yank_shift() for register rotation, close_floating_wins() for window management, is_ssh() for SSH detection, get_file_icon() for file icon retrieval, cycle_buffer() for buffer navigation with wrapping, copen() and cclear() for quickfix list operations.
Autocmd Enhancements
home-manager/programs/neovim/lua/autocmds.lua
Added yank highlighting with automatic register rotation, auto-save on buffer leave/focus loss (with conditions for modified, named buffers), dynamic terminal title formatting with file icons, per-filetype keyword character expansion (TypeScript, JavaScript, CSS, HTML, JSON, YAML, Markdown, etc.), and multiple new augroups for UI/editing enhancements (ResizeSplits, CheckTime, GitCommit, NewFile, Help, Git, Fugitive, QuickfixHelp, Markdown, Terminal).
Configuration & Settings
home-manager/programs/neovim/lua/settings.lua
Added SSH-aware clipboard override using OSC 52 protocol with separate handlers for + and * registers, visible whitespace display (tabs, trailing spaces, special characters), enhanced diagnostic configuration (virtual text, signs, underline, floating window border), and deprecation suppression via vim.deprecate stub function.
Keymap Additions
home-manager/programs/neovim/lua/keymaps.lua
Added two new normal-mode mappings: dd now calls smart_delete("dd") for register-aware deletion, and Esc closes floating windows and clears search highlights via nohlsearch.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~30 minutes

Areas requiring extra attention:

  • Register rotation logic in yank_shift() and its integration with yank autocmd—verify the shift sequence is correct (registers 9→2, unnamed→1)
  • Buffer cycling logic in cycle_buffer() with wrapping behavior and window/buffer state management
  • Per-filetype keyword expansion in autocmds—ensure all intended filetypes are covered and character sets are correct
  • SSH detection (is_ssh()) and OSC 52 clipboard handling for correctness across SSH environments
  • Auto-save condition logic in autocmds (modified check, filename presence, buftype exclusions) to avoid unintended saves
  • File icon retrieval in terminal title formatter with graceful fallback when plugin unavailable

Poem

🐰 A rabbit hops through configs so fine,
Registers spin, clipboards align,
Auto-saves dance when buffers depart,
Terminal titles sparkle with art!
Eight friendly helpers now join the spree,
Vim's magic amplified—it's plain to see!

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: adopting recommended Neovim settings from an external dotfiles repository, which aligns with the comprehensive configuration updates across multiple files.
Description check ✅ Passed The description provides detailed information about the changeset, listing all major features being added (smart delete, yank rotation, SSH clipboard, keywords, auto-save, terminal titles, floating windows, whitespace, diagnostics) with a reference to the source repository.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch claude/add-nvim-settings-01AhAjbTprd768Z8vSs48PuL

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.

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @shunkakinoki, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request integrates a comprehensive set of recommended Neovim configurations and utility functions, primarily sourced from dmtrKovalenko/dotfiles. The changes focus on enhancing the overall Neovim user experience by improving text manipulation, clipboard management in remote sessions, visual feedback, and filetype-specific editing capabilities. The aim is to make the editor more efficient, intuitive, and robust for daily development tasks.

Highlights

  • Smart Delete Function: Implemented a 'smart delete' feature that prevents polluting the default register with whitespace-only lines, instead directing them to the blackhole register.
  • Yank Register Rotation: Added functionality to rotate Neovim's numbered yank registers (1-9) upon yanking, effectively preserving a history of yanked text.
  • SSH/OSC52 Clipboard Handling: Configured Neovim to use the OSC 52 protocol for clipboard operations when running in an SSH session, enabling seamless copy-pasting to and from remote environments.
  • Filetype-Specific Keyword Extensions: Extended the 'iskeyword' option for various file types (e.g., TypeScript/JavaScript, CSS, HTML, JSON, YAML, Markdown) to include additional characters like '@', '-', '#', ':', '$', and '.', improving word navigation.
  • Auto-Save on Buffer Events: Introduced an auto-save mechanism that triggers when a buffer is left or Neovim loses focus, ensuring changes are saved automatically.
  • Custom Terminal Title with File Icons: Set up a custom terminal title that dynamically displays the current filename, its icon (if nvim-web-devicons is available), and the current directory.
  • Close Floating Windows Utility: Added a utility function and a keymap (mapped to ) to quickly close all active floating Neovim windows and clear search highlights.
  • Visible Whitespace Rendering: Configured 'listchars' to visually represent tabs, trailing spaces, and other invisible characters, enhancing code readability and consistency.
  • Enhanced Diagnostic Display: Improved the display configuration for diagnostics, including virtual text with a prefix, signs, underlining, and a rounded border for floating diagnostic windows.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@mesa-dot-dev

mesa-dot-dev Bot commented Dec 6, 2025

Copy link
Copy Markdown

Mesa Description

TL;DR

Added a suite of recommended Neovim settings and features from dmtrKovalenko/dotfiles.

What changed?

  • Added smart delete function (avoids polluting registers with whitespace-only lines)
  • Added yank register rotation to preserve yank history (registers 1-9)
  • Added SSH/OSC52 clipboard handling for remote sessions
  • Added filetype-specific keyword extensions (TS/JS, CSS, HTML, JSON, YAML, etc.)
  • Added auto-save on buffer leave and focus loss
  • Added custom terminal title with file icons
  • Added close floating windows utility
  • Added visible whitespace rendering (tabs, trailing spaces, etc.)
  • Added enhanced diagnostic display configuration

Description generated by Mesa. Update settings

@gemini-code-assist gemini-code-assist 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.

Code Review

This pull request introduces several useful features from dmtrKovalenko/dotfiles. The changes are generally good, but I have a few suggestions to improve maintainability and avoid potential issues. I've pointed out some code duplication that should be addressed, an opportunity to refactor a series of autocommands to be more data-driven and maintainable, and a concern about a keymap override that could have unintended side effects. Please see the detailed comments.

Comment on lines +15 to +19
local function is_ssh()
return os.getenv("SSH_CLIENT") ~= nil or os.getenv("SSH_TTY") ~= nil
end

if is_ssh() then

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.

high

The is_ssh function is duplicated here and in lua/utils.lua. To adhere to the DRY (Don't Repeat Yourself) principle and improve maintainability, you should remove this local implementation and use the one from the utils module. You can require the module inline to avoid adding it at the top of the file.

if require("utils").is_ssh() then

Comment on lines +64 to 112
autocmd("FileType", {
group = keyword_group,
pattern = { "typescript", "typescriptreact", "javascript", "javascriptreact" },
callback = function()
-- Add @ and - to keyword characters for better word navigation
vim.opt_local.iskeyword:append("@-@")
vim.opt_local.iskeyword:append("-")
end,
})
autocmd("FileType", {
group = keyword_group,
pattern = { "css", "scss", "sass", "less" },
callback = function()
vim.opt_local.iskeyword:append("-")
vim.opt_local.iskeyword:append("#")
end,
})
autocmd("FileType", {
group = keyword_group,
pattern = { "html", "xml", "vue", "svelte" },
callback = function()
vim.opt_local.iskeyword:append("-")
vim.opt_local.iskeyword:append(":")
end,
})
autocmd("FileType", {
group = keyword_group,
pattern = { "json", "jsonc" },
callback = function()
vim.opt_local.iskeyword:append("-")
vim.opt_local.iskeyword:append("$")
end,
})
autocmd("FileType", {
group = keyword_group,
pattern = { "yaml", "toml" },
callback = function()
vim.opt_local.iskeyword:append("-")
vim.opt_local.iskeyword:append(".")
end,
})
autocmd("FileType", {
group = keyword_group,
pattern = "markdown",
callback = function()
vim.opt_local.iskeyword:append("-")
vim.opt_local.iskeyword:append("#")
end,
})

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.

medium

There's a lot of repetition in the creation of FileType autocommands for setting iskeyword. This can be refactored into a more concise, data-driven approach to improve maintainability. You can define a table of configurations and loop through it to create the autocommands.

This also allows for merging the rules for css, scss, sass, less, and markdown since they share the same keyword additions.

Additionally, vim.opt_local.iskeyword:append("@-@") is functionally equivalent to vim.opt_local.iskeyword:append("@") but is less clear. The suggested refactoring simplifies this as well.

local keyword_extensions = {
	{
		patterns = { "typescript", "typescriptreact", "javascript", "javascriptreact" },
		keywords = { "@", "-" },
	},
	{
		patterns = { "css", "scss", "sass", "less", "markdown" },
		keywords = { "-", "#" },
	},
	{
		patterns = { "html", "xml", "vue", "svelte" },
		keywords = { "-", ":" },
	},
	{
		patterns = { "json", "jsonc" },
		keywords = { "-", "$" },
	},
	{
		patterns = { "yaml", "toml" },
		keywords = { "-", "." },
	},
}

for _, config in ipairs(keyword_extensions) do
	autocmd("FileType", {
		group = keyword_group,
		pattern = config.patterns,
		callback = function()
			for _, keyword in ipairs(config.keywords) do
				vim.opt_local.iskeyword:append(keyword)
			end
		end,
	})
end

Comment on lines +120 to +123
keymap("n", "<Esc>", function()
utils.close_floating_wins()
vim.cmd("nohlsearch")
end, opts)

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.

medium

Overriding the <Esc> key to close all floating windows is quite aggressive and may lead to unexpected behavior. For instance, many plugins use floating windows where <Esc> is used to return to normal mode within that window. This mapping would close the window entirely, along with any other floating windows that might be open (like diagnostics). Consider using a more specific keymap (e.g., <leader><Esc>) or making the function less aggressive, for example, by only closing the current window if it's a floating window.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
home-manager/programs/neovim/lua/settings.lua (1)

15-32: Consider using utils.is_ssh() to avoid duplication.

The local is_ssh() function duplicates the same logic already available in utils.is_ssh() (lines 55-57 of utils.lua). The OSC52 clipboard configuration itself is correct.

To reduce duplication, import from utils:

+local utils = require("utils")
+
 -- ====================================================================================
 -- SSH / OSC52 CLIPBOARD HANDLING
 -- From: https://github.com/dmtrKovalenko/dotfiles
 -- Uses OSC 52 protocol for clipboard when running over SSH
 -- ====================================================================================
-local function is_ssh()
-	return os.getenv("SSH_CLIENT") ~= nil or os.getenv("SSH_TTY") ~= nil
-end
-
-if is_ssh() then
+if utils.is_ssh() then
 	-- Use OSC 52 for clipboard when in SSH session
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 38ce9f6 and adfab56.

📒 Files selected for processing (4)
  • home-manager/programs/neovim/lua/autocmds.lua (1 hunks)
  • home-manager/programs/neovim/lua/keymaps.lua (1 hunks)
  • home-manager/programs/neovim/lua/settings.lua (2 hunks)
  • home-manager/programs/neovim/lua/utils.lua (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (13)
  • GitHub Check: Agent
  • GitHub Check: cubic · AI code reviewer
  • GitHub Check: Mesa Review
  • GitHub Check: e2e-run (NixOS, ubuntu-latest)
  • GitHub Check: nix-linux
  • GitHub Check: nix-nixos
  • GitHub Check: docker-build-push (linux/arm64, arm64, ubuntu-24.04-arm)
  • GitHub Check: e2e-run (MacOS, macos-latest)
  • GitHub Check: docker-build-push (linux/amd64, amd64, ubuntu-latest)
  • GitHub Check: e2e-run (Ubuntu, ubuntu-latest)
  • GitHub Check: lua-hammerspoon
  • GitHub Check: lua-neovim
  • GitHub Check: nix-darwin
🔇 Additional comments (13)
home-manager/programs/neovim/lua/keymaps.lua (2)

113-117: LGTM! Smart delete implementation is clean.

The expr-mode mapping correctly delegates to utils.smart_delete(), which will avoid polluting registers with whitespace-only lines while preserving normal dd behavior for content lines.


119-123: LGTM! Escape key enhancement is sensible.

This mapping provides a clean UX by closing floating windows and clearing search highlights with a single key. The combination of actions is logical and non-destructive.

home-manager/programs/neovim/lua/settings.lua (2)

76-83: LGTM! Whitespace rendering configuration is standard.

The listchars configuration uses sensible symbols for tabs, trailing spaces, and other whitespace elements, providing good visual feedback without being obtrusive.


89-102: LGTM! Diagnostic configuration is well-structured.

The diagnostic display settings provide a good balance of visibility and clarity with rounded borders, source attribution, and appropriate virtual text formatting.

home-manager/programs/neovim/lua/autocmds.lua (4)

10-20: LGTM! Yank rotation logic is correctly scoped.

The condition vim.v.event.operator == "y" ensures register rotation only happens on yank operations, not on deletions, which is the correct behavior to preserve yank history separately from delete history.


26-36: LGTM! Auto-save guards are appropriate.

The conditions properly filter for regular file buffers that are modified and have a filename, avoiding special buffers and unintentional saves. The silent! prefix prevents errors on read-only files.


63-112: LGTM! Filetype-specific keyword extensions are well-considered.

The keyword character additions are appropriate for each language:

  • TS/JS decorators and kebab-case
  • CSS properties and color codes
  • HTML attributes and namespaces
  • JSON keys and variable notation
  • YAML/TOML nested paths
  • Markdown syntax elements

These will improve word motion navigation (w, b, e) in their respective contexts.


42-57: BufFilePost is a valid Neovim autocmd event.

BufFilePost is a documented event that fires after the buffer's filename changes via :file or :saveas. However, consider whether using both BufEnter and BufFilePost is necessary—BufEnter alone may be sufficient for updating the terminal title on buffer navigation, since BufFilePost only fires when the buffer filename explicitly changes, not on normal buffer switching.

Likely an incorrect or invalid review comment.

home-manager/programs/neovim/lua/utils.lua (5)

8-15: LGTM! Smart delete logic is correct.

The pattern ^%s*$ correctly identifies whitespace-only lines, and the blackhole register ("_) prevents cluttering the default register with blank content.


22-33: LGTM! Register rotation implementation is correct.

The backward iteration from 9 to 2 prevents overwrites, and using both getreg() and getregtype() ensures the register type (characterwise/linewise/blockwise) is preserved during rotation.


40-49: LGTM! Floating window detection and closure is correct.

The check config.relative ~= "" correctly identifies floating windows, and force=false preserves buffers with unsaved changes, preventing accidental data loss.


55-57: LGTM! SSH detection is standard and correct.

Checking both SSH_CLIENT and SSH_TTY environment variables is the standard approach for detecting SSH sessions.


63-70: LGTM! Icon retrieval is safely guarded.

The pcall wrapper ensures the function degrades gracefully when nvim-web-devicons is unavailable, and the empty string fallback prevents UI breakage.

Copilot AI 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.

Pull request overview

This pull request enhances Neovim configuration with quality-of-life improvements sourced from dmtrKovalenko/dotfiles. The changes add smart register management, remote session support, and improved visual feedback while maintaining the existing codebase structure and conventions.

Key changes:

  • Smart delete and yank register rotation to improve clipboard management
  • SSH/OSC52 clipboard integration for seamless remote editing
  • Auto-save functionality and enhanced terminal titles with file icons
  • Filetype-specific keyword extensions for better navigation in TS/JS, CSS, HTML, and other web development files

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 6 comments.

File Description
home-manager/programs/neovim/lua/utils.lua Adds utility functions for smart delete, yank rotation, SSH detection, file icons, and closing floating windows
home-manager/programs/neovim/lua/settings.lua Configures OSC52 clipboard for SSH sessions, visible whitespace rendering, and enhanced diagnostic display
home-manager/programs/neovim/lua/keymaps.lua Implements smart delete keymap and Esc key override for closing floating windows
home-manager/programs/neovim/lua/autocmds.lua Adds autocmds for yank rotation, auto-save, terminal title updates, and filetype-specific keyword extensions

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

callback = function()
vim.highlight.on_yank()
-- Rotate registers on yank to preserve yank history
if vim.v.event.operator == "y" then

Copilot AI Dec 6, 2025

Copy link

Choose a reason for hiding this comment

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

The register rotation runs on every yank operation, including yanks to named registers (e.g., "ayy), which may not be the desired behavior. This could pollute the numbered register history with intentional named register operations.

Consider checking vim.v.event.regname to only rotate when yanking to the unnamed register:

if vim.v.event.operator == "y" and vim.v.event.regname == "" then
	utils.yank_shift()
end
Suggested change
if vim.v.event.operator == "y" then
if vim.v.event.operator == "y" and vim.v.event.regname == "" then

Copilot uses AI. Check for mistakes.
Comment on lines +41 to +48
for _, win in ipairs(vim.api.nvim_list_wins()) do
if vim.api.nvim_win_is_valid(win) then
local config = vim.api.nvim_win_get_config(win)
if config.relative ~= "" then
vim.api.nvim_win_close(win, false)
end
end
end

Copilot AI Dec 6, 2025

Copy link

Choose a reason for hiding this comment

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

The function may fail to close some floating windows if closing one window invalidates others in the iteration. When a floating window is closed, it's removed from the window list, but the iteration continues with indices that may now be stale. This could result in errors or some floating windows not being closed.

Consider collecting window handles first, then closing them, or iterate in reverse order:

function M.close_floating_wins()
	local floating_wins = {}
	for _, win in ipairs(vim.api.nvim_list_wins()) do
		if vim.api.nvim_win_is_valid(win) then
			local config = vim.api.nvim_win_get_config(win)
			if config.relative ~= "" then
				table.insert(floating_wins, win)
			end
		end
	end
	for _, win in ipairs(floating_wins) do
		if vim.api.nvim_win_is_valid(win) then
			vim.api.nvim_win_close(win, false)
		end
	end
end
Suggested change
for _, win in ipairs(vim.api.nvim_list_wins()) do
if vim.api.nvim_win_is_valid(win) then
local config = vim.api.nvim_win_get_config(win)
if config.relative ~= "" then
vim.api.nvim_win_close(win, false)
end
end
end
local floating_wins = {}
for _, win in ipairs(vim.api.nvim_list_wins()) do
if vim.api.nvim_win_is_valid(win) then
local config = vim.api.nvim_win_get_config(win)
if config.relative ~= "" then
table.insert(floating_wins, win)
end
end
end
for _, win in ipairs(floating_wins) do
if vim.api.nvim_win_is_valid(win) then
vim.api.nvim_win_close(win, false)
end
end

Copilot uses AI. Check for mistakes.
Comment on lines +15 to +19
local function is_ssh()
return os.getenv("SSH_CLIENT") ~= nil or os.getenv("SSH_TTY") ~= nil
end

if is_ssh() then

Copilot AI Dec 6, 2025

Copy link

Choose a reason for hiding this comment

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

The is_ssh() function is duplicated - it's defined both here and in utils.lua (line 55). This creates code duplication and potential maintenance issues if the logic needs to be updated.

Consider removing this local definition and using require("utils").is_ssh() instead, or if this file is loaded before utils.lua, keep it here and remove the duplicate from utils.lua.

Suggested change
local function is_ssh()
return os.getenv("SSH_CLIENT") ~= nil or os.getenv("SSH_TTY") ~= nil
end
if is_ssh() then
if require("utils").is_ssh() then

Copilot uses AI. Check for mistakes.
-- From: https://github.com/dmtrKovalenko/dotfiles
-- ====================================================================================
local title_group = augroup("TerminalTitle", { clear = true })
autocmd({ "BufEnter", "BufFilePost" }, {

Copilot AI Dec 6, 2025

Copy link

Choose a reason for hiding this comment

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

BufFilePost is not a standard Neovim autocmd event. This appears to be a typo - the correct event name is likely BufFilePre or BufReadPost. This event will never trigger, meaning the terminal title won't be updated when files are read.

Consider using BufReadPost or BufWinEnter instead, which are standard events that trigger when buffers are loaded or displayed in windows.

Suggested change
autocmd({ "BufEnter", "BufFilePost" }, {
autocmd({ "BufEnter", "BufReadPost" }, {

Copilot uses AI. Check for mistakes.
callback = function()
-- Only save if buffer is modified and has a filename
if vim.bo.modified and vim.fn.expand("%") ~= "" and vim.bo.buftype == "" then
vim.cmd("silent! update")

Copilot AI Dec 6, 2025

Copy link

Choose a reason for hiding this comment

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

The auto-save logic may fail silently for unwritable files. The silent! command suppresses all errors, which could hide important issues like permission errors or readonly files. Users may not realize their changes aren't being saved.

Consider using pcall to handle errors gracefully while still logging them:

local ok, err = pcall(vim.cmd, "update")
if not ok then
	vim.notify("Auto-save failed: " .. err, vim.log.levels.WARN)
end
Suggested change
vim.cmd("silent! update")
local ok, err = pcall(vim.cmd, "update")
if not ok then
vim.notify("Auto-save failed: " .. err, vim.log.levels.WARN)
end

Copilot uses AI. Check for mistakes.
Comment on lines +119 to +120
-- @keymap <Esc>: Close floating windows
keymap("n", "<Esc>", function()

Copilot AI Dec 6, 2025

Copy link

Choose a reason for hiding this comment

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

Overriding the <Esc> key in normal mode could interfere with other plugins or user workflows that expect <Esc> to only clear search highlights. Some plugins use <Esc> as a cancellation key, and closing all floating windows might be too aggressive in certain contexts (e.g., when a user wants to cancel an action without closing all floating windows).

Consider using a different key combination like <leader><Esc> or <C-c> for this functionality, or make the floating window closing conditional.

Suggested change
-- @keymap <Esc>: Close floating windows
keymap("n", "<Esc>", function()
-- @keymap <leader><Esc>: Close floating windows
keymap("n", "<leader><Esc>", function()

Copilot uses AI. Check for mistakes.

@mesa-dot-dev mesa-dot-dev Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Performed full review of 38ce9f6...adfab56

Analysis

  1. Critical Breaking of Vim Register Semantics - Custom yank history rotation breaks Vim's standard numbered register behavior. The implementation makes registers rotate on EVERY yank operation, conflicting with native behavior and breaking standard Vim workflows where registers 1-9 are for deletions, not yanks.

  2. Unconfigurable Auto-save Feature - Implements auto-save on BufLeave/FocusLost events without opt-out options. Could interfere with git workflows, temporary edits, and has error suppression that hinders debugging.

  3. Overriding Core Vim Commands - Remapping fundamental commands like dd and <Esc> changes muscle memory behaviors with no escape hatches for standard operation, potentially breaking user expectations and plugin compatibility.

  4. Code Duplication and Organization Issues - is_ssh() function duplicated in two files, vim options placed in incorrect modules, and missing error handling for features like OSC52 clipboard that requires specific Neovim versions.

  5. Performance Concerns - Frequent trigger points (BufEnter for terminal titles, BufLeave/FocusLost for saves) could cause performance issues with no throttling mechanisms.

Tip

Help

Slash Commands:

  • /review - Request a full code review
  • /review latest - Review only changes since the last review
  • /describe - Generate PR description. This will update the PR body or issue comment depending on your configuration
  • /help - Get help with Mesa commands and configuration options

4 files reviewed | 6 comments | Edit Agent SettingsRead Docs

callback = function()
vim.highlight.on_yank()
-- Rotate registers on yank to preserve yank history
if vim.v.event.operator == "y" then

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

High

This yank register rotation fundamentally breaks Vim's numbered register semantics. In standard Vim, registers 1-9 store the last 9 deletions (not yanks), and Vim manages this automatically. By rotating registers on every yank operation:

  1. You're overwriting the deletion history that users expect with "1p, "2p, etc.
  2. This triggers on ALL yank events including plugin-initiated ones, potentially causing unexpected side effects
  3. It conflicts with standard Vim behavior documented everywhere

If keeping this feature, strongly consider:

  • Adding a configuration flag to opt-in (vim.g.enable_yank_rotation)
  • Documenting this non-standard behavior prominently in README
  • Filtering by v:event.regname to avoid affecting special registers
  • Adding guards against recursive or plugin-initiated yanks

Agent: 🏛 Architecture • Fix in Cursor • Fix in Claude

Prompt for Agent
Task: Address review feedback left on GitHub.
Repository: shunkakinoki/dotfiles#393
File: home-manager/programs/neovim/lua/autocmds.lua#L16
Action: Open this file location in your editor, inspect the highlighted code, and resolve the issue described below.

Feedback:
This yank register rotation fundamentally breaks Vim's numbered register semantics. In standard Vim, registers 1-9 store the last 9 **deletions** (not yanks), and Vim manages this automatically. By rotating registers on every yank operation:

1. You're overwriting the deletion history that users expect with `"1p`, `"2p`, etc.
2. This triggers on ALL yank events including plugin-initiated ones, potentially causing unexpected side effects
3. It conflicts with standard Vim behavior documented everywhere

If keeping this feature, strongly consider:
- Adding a configuration flag to opt-in (`vim.g.enable_yank_rotation`)
- Documenting this non-standard behavior prominently in README
- Filtering by `v:event.regname` to avoid affecting special registers
- Adding guards against recursive or plugin-initiated yanks

callback = function()
-- Only save if buffer is modified and has a filename
if vim.bo.modified and vim.fn.expand("%") ~= "" and vim.bo.buftype == "" then
vim.cmd("silent! update")

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Medium

The silent! suppresses all errors including critical ones like filesystem permission problems, disk full conditions, or network filesystem timeouts. Consider removing silent! and handling errors explicitly, or at minimum add checks for file writability before attempting save. Also consider adding configuration options:

  • Global flag: vim.g.auto_save_enabled
  • Buffer-local opt-out: vim.b.disable_auto_save
  • Per-filetype configuration to avoid interfering with git rebase/merge workflows

Agent: 🏛 Architecture • Fix in Cursor • Fix in Claude

Prompt for Agent
Task: Address review feedback left on GitHub.
Repository: shunkakinoki/dotfiles#393
File: home-manager/programs/neovim/lua/autocmds.lua#L33
Action: Open this file location in your editor, inspect the highlighted code, and resolve the issue described below.

Feedback:
The `silent!` suppresses all errors including critical ones like filesystem permission problems, disk full conditions, or network filesystem timeouts. Consider removing `silent!` and handling errors explicitly, or at minimum add checks for file writability before attempting save. Also consider adding configuration options:
- Global flag: `vim.g.auto_save_enabled`
- Buffer-local opt-out: `vim.b.disable_auto_save`
- Per-filetype configuration to avoid interfering with git rebase/merge workflows

end, { noremap = true, expr = true })

-- @keymap <Esc>: Close floating windows
keymap("n", "<Esc>", function()

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Medium

Remapping <Esc> globally changes fundamental Vim behavior. The floating window close could interfere with:

  • Plugin UI elements that need manual dismissal (telescope, which-key, lazy.nvim)
  • Intentionally persistent floating windows
  • Custom workflows that rely on keeping floating windows open

Consider using a different key like <leader><Esc> or <C-l>, or add checks to exclude certain floating windows from being closed.

Agent: 🏛 Architecture • Fix in Cursor • Fix in Claude

Prompt for Agent
Task: Address review feedback left on GitHub.
Repository: shunkakinoki/dotfiles#393
File: home-manager/programs/neovim/lua/keymaps.lua#L120
Action: Open this file location in your editor, inspect the highlighted code, and resolve the issue described below.

Feedback:
Remapping `<Esc>` globally changes fundamental Vim behavior. The floating window close could interfere with:
- Plugin UI elements that need manual dismissal (telescope, which-key, lazy.nvim)
- Intentionally persistent floating windows
- Custom workflows that rely on keeping floating windows open

Consider using a different key like `<leader><Esc>` or `<C-l>`, or add checks to exclude certain floating windows from being closed.

-- Utility to close all floating windows
-- From: https://github.com/dmtrKovalenko/dotfiles
-- ====================================================================================
function M.close_floating_wins()

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Medium

This function closes ALL floating windows without discrimination, which could close important plugin UIs (lazy.nvim, mason.nvim, telescope previews, LSP hover docs). Add:

  1. pcall protection around nvim_win_close
  2. Filetype filtering to exclude important windows
  3. Optional parameter to specify exclude list

Example:

function M.close_floating_wins(opts)
  opts = opts or {}
  local exclude_fts = opts.exclude_filetypes or {}
  for _, win in ipairs(vim.api.nvim_list_wins()) do
    if vim.api.nvim_win_is_valid(win) then
      local config = vim.api.nvim_win_get_config(win)
      if config.relative ~= "" then
        local buf = vim.api.nvim_win_get_buf(win)
        local ft = vim.bo[buf].filetype
        if not vim.tbl_contains(exclude_fts, ft) then
          pcall(vim.api.nvim_win_close, win, false)
        end
      end
    end
  end
end

Agent: 🏛 Architecture • Fix in Cursor • Fix in Claude

Prompt for Agent
Task: Address review feedback left on GitHub.
Repository: shunkakinoki/dotfiles#393
File: home-manager/programs/neovim/lua/utils.lua#L40
Action: Open this file location in your editor, inspect the highlighted code, and resolve the issue described below.

Feedback:
This function closes ALL floating windows without discrimination, which could close important plugin UIs (lazy.nvim, mason.nvim, telescope previews, LSP hover docs). Add:
1. `pcall` protection around `nvim_win_close`
2. Filetype filtering to exclude important windows
3. Optional parameter to specify exclude list

Example:
```lua
function M.close_floating_wins(opts)
  opts = opts or {}
  local exclude_fts = opts.exclude_filetypes or {}
  for _, win in ipairs(vim.api.nvim_list_wins()) do
    if vim.api.nvim_win_is_valid(win) then
      local config = vim.api.nvim_win_get_config(win)
      if config.relative ~= "" then
        local buf = vim.api.nvim_win_get_buf(win)
        local ft = vim.bo[buf].filetype
        if not vim.tbl_contains(exclude_fts, ft) then
          pcall(vim.api.nvim_win_close, win, false)
        end
      end
    end
  end
end

</details>


-- @keymap dd: Smart delete (uses blackhole register for empty lines)
-- From: https://github.com/dmtrKovalenko/dotfiles
keymap("n", "dd", function()

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Medium

Overriding dd (one of Vim's most fundamental commands) is architecturally risky and changes muscle memory for all Vim users. Consider:

  • Using a different keymap like <leader>dd instead to avoid breaking standard behavior
  • Making this opt-in via configuration
  • Adding a toggle command to enable/disable
  • Document this breaking change prominently if you keep it

The expr mapping adds indirection and could interfere with plugins that rely on standard dd behavior.

Agent: 🏛 Architecture • Fix in Cursor • Fix in Claude

Prompt for Agent
Task: Address review feedback left on GitHub.
Repository: shunkakinoki/dotfiles#393
File: home-manager/programs/neovim/lua/keymaps.lua#L115
Action: Open this file location in your editor, inspect the highlighted code, and resolve the issue described below.

Feedback:
Overriding `dd` (one of Vim's most fundamental commands) is architecturally risky and changes muscle memory for all Vim users. Consider:
- Using a different keymap like `<leader>dd` instead to avoid breaking standard behavior
- Making this opt-in via configuration
- Adding a toggle command to enable/disable
- Document this breaking change prominently if you keep it

The expr mapping adds indirection and could interfere with plugins that rely on standard `dd` behavior.

-- From: https://github.com/dmtrKovalenko/dotfiles
-- Uses OSC 52 protocol for clipboard when running over SSH
-- ====================================================================================
local function is_ssh()

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Medium

Duplicate code: is_ssh() function is defined identically in utils.lua (lines 55-57). This should use require("utils").is_ssh() instead. Additionally, the require("vim.ui.clipboard.osc52") below lacks error handling - OSC52 is only available in Neovim >= 0.10. Add pcall protection:

local utils = require("utils")
if utils.is_ssh() then
  local ok, osc52 = pcall(require, "vim.ui.clipboard.osc52")
  if not ok then
    vim.notify("OSC52 clipboard not available", vim.log.levels.WARN)
    return
  end
  -- ... rest of config
end

Agent: 🏛 Architecture • Fix in Cursor • Fix in Claude

Prompt for Agent
Task: Address review feedback left on GitHub.
Repository: shunkakinoki/dotfiles#393
File: home-manager/programs/neovim/lua/settings.lua#L15
Action: Open this file location in your editor, inspect the highlighted code, and resolve the issue described below.

Feedback:
Duplicate code: `is_ssh()` function is defined identically in `utils.lua` (lines 55-57). This should use `require("utils").is_ssh()` instead. Additionally, the `require("vim.ui.clipboard.osc52")` below lacks error handling - OSC52 is only available in Neovim >= 0.10. Add `pcall` protection:
```lua
local utils = require("utils")
if utils.is_ssh() then
  local ok, osc52 = pcall(require, "vim.ui.clipboard.osc52")
  if not ok then
    vim.notify("OSC52 clipboard not available", vim.log.levels.WARN)
    return
  end
  -- ... rest of config
end

</details>

@cubic-dev-ai cubic-dev-ai 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.

No issues found across 4 files

@shunkakinoki
shunkakinoki merged commit e4253d2 into main Dec 7, 2025
35 checks passed
@shunkakinoki
shunkakinoki deleted the claude/add-nvim-settings-01AhAjbTprd768Z8vSs48PuL branch December 7, 2025 19:30
@coderabbitai coderabbitai Bot mentioned this pull request Feb 19, 2026
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.

3 participants