mirror of
https://github.com/dwinkler1/nvimConfig.git
synced 2026-08-22 17:43:13 -04:00
Tackles the critical and high-impact findings from the in-PR review of commit7f01be5, 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 `<CR>` -> `smart_send.send_repl` mapping. Override `<CR>` from a per-buffer `ftplugin/<lang>.lua` if you want enter-to-send behavior. R.nvim's `<Plug>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 `<S-CR>` from `M.setup_keybindings` on the same principle as C2. `<S-CR>` 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` from7f01be5. 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 `<CR>` 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`.
120 lines
3.4 KiB
Lua
120 lines
3.4 KiB
Lua
local Config = require('config')
|
|
|
|
local add = Config.add
|
|
local now_if_args = Config.now_if_args
|
|
local later = MiniDeps.later
|
|
local nix = require('config.nix')
|
|
|
|
if not Config.isNixCats then
|
|
local add = MiniDeps.add
|
|
later(function()
|
|
add({ source = "Bilal2453/luvit-meta" })
|
|
add({ source = "folke/lazydev.nvim" })
|
|
end)
|
|
end
|
|
|
|
-- lua
|
|
later(function()
|
|
if nix.get_cat("lua", false) then
|
|
add("luvit-meta")
|
|
add("lazydev")
|
|
require("lazydev").setup({
|
|
library = {
|
|
-- See the configuration section for more details
|
|
-- Load luvit types when the `vim.uv` word is found
|
|
"lua",
|
|
"mini.nvim",
|
|
"MiniDeps",
|
|
{ path = "luvit-meta/library", words = { "vim%.uv" } },
|
|
{ path = "${3rd}/luv/library", words = { "vim%.uv" } },
|
|
},
|
|
})
|
|
end
|
|
end)
|
|
|
|
-- Linting (via nvim-lint)
|
|
later(function()
|
|
Config.add("nvim-lint")
|
|
local lint_ok, lint = pcall(require, "lint")
|
|
if not lint_ok then
|
|
return
|
|
end
|
|
|
|
-- R code style via lintr (must be available in the R runtime).
|
|
-- lintr::lint() returns a "lints" object; format() turns it into the
|
|
-- standard "file:line:col: severity: message" lines.
|
|
lint.linters.lintr = {
|
|
cmd = "Rscript",
|
|
stdin = false,
|
|
args = {
|
|
"-e",
|
|
"args <- commandArgs(trailingOnly=TRUE); l <- lintr::lint(args[1]); if (length(l) > 0) cat(paste(format(l), collapse='\\n'), '\\n')",
|
|
},
|
|
append_fname = true,
|
|
stream = "both",
|
|
ignore_exitcode = true,
|
|
parser = function(output, bufnr, linter_cwd)
|
|
local diagnostics = {}
|
|
-- Pattern: /path/file.R:10:5: style: Some message
|
|
for line in output:gmatch("[^\r\n]+") do
|
|
local path, lnum, col, severity, message = line:match("^[^:]+:(%d+):(%d+):%s*(%w+):%s*(.+)$")
|
|
if path then
|
|
local severity_map = {
|
|
style = vim.diagnostic.severity.INFO,
|
|
warning = vim.diagnostic.severity.WARN,
|
|
error = vim.diagnostic.severity.ERROR,
|
|
}
|
|
table.insert(diagnostics, {
|
|
bufnr = bufnr,
|
|
lnum = math.max(0, tonumber(lnum) - 1),
|
|
col = math.max(0, tonumber(col) - 1),
|
|
end_lnum = tonumber(lnum) - 1,
|
|
end_col = tonumber(col),
|
|
severity = severity_map[severity:lower()] or vim.diagnostic.severity.WARN,
|
|
message = message or "lintr issue",
|
|
source = "lintr",
|
|
})
|
|
end
|
|
end
|
|
return diagnostics
|
|
end,
|
|
}
|
|
|
|
lint.linters_by_ft = {
|
|
r = { "lintr" },
|
|
rmd = { "lintr" },
|
|
quarto = { "lintr" },
|
|
}
|
|
|
|
vim.api.nvim_create_autocmd({ "BufReadPost", "BufWritePost", "InsertLeave" }, {
|
|
group = vim.api.nvim_create_augroup("LintOnEvents", { clear = true }),
|
|
callback = function()
|
|
lint.try_lint()
|
|
end,
|
|
})
|
|
end)
|
|
|
|
-- Markdown
|
|
now_if_args(function()
|
|
add("render-markdown.nvim")
|
|
require('render-markdown').setup({
|
|
-- completions = { blink = { enabled = true } },
|
|
file_types = { 'markdown', 'codecompanion', },
|
|
link = {
|
|
wiki = {
|
|
body = function(ctx)
|
|
local diagnostics = vim.diagnostic.get(ctx.buf, {
|
|
lnum = ctx.row,
|
|
severity = vim.diagnostic.severity.HINT,
|
|
})
|
|
for _, diagnostic in ipairs(diagnostics) do
|
|
if diagnostic.source == 'marksman' then
|
|
return diagnostic.message
|
|
end
|
|
end
|
|
return nil
|
|
end,
|
|
},
|
|
},
|
|
})
|
|
end)
|