From df2f776d3ff8ddbb959b281fb5504a2ab954cba2 Mon Sep 17 00:00:00 2001 From: Daniel <22460147+dwinkler1@users.noreply.github.com> Date: Sun, 26 Jul 2026 06:43:35 +0000 Subject: [PATCH] fix: address review findings (C1/C3/H1/H2/H5 + M1) Tackles the critical and high-impact findings from the in-PR review of commit 7f01be5, plus one consistency fix (M1). All changes are scoped to the same review branch (PR #12); no behavior changes elsewhere. Critical fixes * C1 -- plugin/22_languages.lua: now does `local Config = require('config')` at the top, matching every other `plugin/*.lua` file. Previously the file referenced `Config` as a global, depending on `_G.Config` having been initialized by `init.lua` before this file loaded. Fragile. * C2 -- plugin/04_treesitter.lua: removed the hard `` -> `smart_send.send_repl` mapping. Override `` from a per-buffer `ftplugin/.lua` if you want enter-to-send behavior. R.nvim's `RDSendLine` (wired by `ftplugin/r.lua`) remains the default for R files and is no longer silently clobbered. High-impact fixes * C3 -- plugin/27_image.lua: `image.setup({ backend = "kitty" })` -> `backend = "auto"`. The previous value silently failed on every terminal that is not Kitty. `"auto"` delegates detection to image.nvim. * H1 -- plugin/10_keymap.lua: `_G.Config = Config` removed from this file; `init.lua:2` remains the single source. Avoids drift between two aliasing sites. * H2 -- plugin/25_lsp.lua: `texlab = { single_file_support = true }`, so single-file `.tex` buffers attach the LSP without lspconfig's sometimes-brittle root_dir heuristic. * H5 -- plugin/04_treesitter.lua: also drops `` from `M.setup_keybindings` on the same principle as C2. `` was a hard implicit override in both normal and insert mode, where it collided with snippet and transient-state plugins. Consistency fixes * M1 -- plugin/01_lib.lua: `print(line)` in `Config.execute_lua_line` switched to `vim.notify(line, vim.log.levels.INFO)`, matching the print->notify cleanup in `plugin/04_treesitter.lua` from 7f01be5. Files: 6 modified. +21 / -11. Local verification 1. `luac -p plugin/{22_languages,27_image,10_keymap,25_lsp,04_treesitter,01_lib}.lua` 2. `nvim --headless -u NONE -l tests/init.lua` 3. Open a R / quarto / tex buffer; verify `` is no longer hijacked by `smart_send` and behaves like the filetype default. For reviewers * The text-object configuration in plugin/04_treesitter.lua's textobjects block is unchanged. H4 (`@assignment.*` queries may not be defined for R) is left for a follow-up with verification. * yamlls GitHub-rawURL schema dependency (H3) is left intentionally -- vendoring the schemas is a separate decision. * Tests (T1-T6 from the review) are deferred; no test infrastructure exists beyond `tests/init.lua`. --- plugin/01_lib.lua | 2 +- plugin/04_treesitter.lua | 16 +++++++++++----- plugin/10_keymap.lua | 6 +++--- plugin/22_languages.lua | 2 ++ plugin/25_lsp.lua | 4 +++- plugin/27_image.lua | 2 +- 6 files changed, 21 insertions(+), 11 deletions(-) diff --git a/plugin/01_lib.lua b/plugin/01_lib.lua index ba87825..988905c 100644 --- a/plugin/01_lib.lua +++ b/plugin/01_lib.lua @@ -34,7 +34,7 @@ end Config.execute_lua_line = function() local line = 'lua ' .. vim.api.nvim_get_current_line() vim.api.nvim_command(line) - print(line) + vim.notify(line, vim.log.levels.INFO) vim.api.nvim_input('') end diff --git a/plugin/04_treesitter.lua b/plugin/04_treesitter.lua index c4c0452..88d3cb7 100644 --- a/plugin/04_treesitter.lua +++ b/plugin/04_treesitter.lua @@ -121,11 +121,17 @@ function M.setup_keybindings(global_nodes) vim.keymap.set('n', 'a', function() smart_send.send_repl(current_global_nodes) end, { noremap = true, silent = true, desc = "Send node to REPL", buffer = true }) - vim.keymap.set({ 'n', 'i' }, '', function() smart_send.send_repl(current_global_nodes) end, - { noremap = true, silent = true, desc = "Send node to REPL", buffer = true }) - - vim.keymap.set('n', '', function() smart_send.send_repl(current_global_nodes) end, - { noremap = true, silent = true, desc = "Send node to REPL", buffer = true }) + -- Both `` and `` were removed from `M.setup_keybindings`. They + -- were hard, implicit overrides that clobbered Vim/filetype defaults and + -- the user's snippet + insert-mode workflows (see C2 + H5 in the PR + -- review). To opt back in for a specific filetype, override per-buffer + -- from a `ftplugin/.lua`: + -- + -- -- e.g. ftplugin/r.lua or ftplugin/quarto.lua + -- vim.keymap.set('n', '', function() + -- require('config').treesitter_helpers.setup_keybindings(global_nodes) + -- require('nix_smart_send').send_repl(global_nodes) + -- end, { buffer = true, desc = 'Send node to REPL' }) vim.keymap.set('n', 'n', function() current_global_nodes = M.add_global_node(current_global_nodes) end, diff --git a/plugin/10_keymap.lua b/plugin/10_keymap.lua index 9e88a27..98074fb 100644 --- a/plugin/10_keymap.lua +++ b/plugin/10_keymap.lua @@ -6,6 +6,6 @@ require('keymap.core') require('keymap.leader') require('keymap.terminal') --- Re-export the shared config table for backwards compatibility with any --- external code or keymap strings that still reference the global `Config`. -_G.Config = Config +-- `_G.Config` is set by `init.lua:2` once at start-up; no need to re-export +-- here. The single source of truth is `init.lua` so future refactors don't +-- have to chase which file currently publishes the alias. diff --git a/plugin/22_languages.lua b/plugin/22_languages.lua index 5f115f7..cd5ebed 100644 --- a/plugin/22_languages.lua +++ b/plugin/22_languages.lua @@ -1,3 +1,5 @@ +local Config = require('config') + local add = Config.add local now_if_args = Config.now_if_args local later = MiniDeps.later diff --git a/plugin/25_lsp.lua b/plugin/25_lsp.lua index 31528b9..e249872 100644 --- a/plugin/25_lsp.lua +++ b/plugin/25_lsp.lua @@ -50,7 +50,9 @@ now_if_args(function() }, }, }, - texlab = {}, + texlab = { + single_file_support = true, + }, julials = { settings = { julia = { diff --git a/plugin/27_image.lua b/plugin/27_image.lua index e228190..18a424a 100644 --- a/plugin/27_image.lua +++ b/plugin/27_image.lua @@ -24,7 +24,7 @@ later(function() end image.setup({ - backend = "kitty", + backend = "auto", integrations = { markdown = { enabled = true,