feat: nvim config tracks the live tree
Port the live ~/.config/nvim working tree (bcherb2/nvim master plus its uncommitted git.lua and minimap.lua edits): adds claudecode, eslint, lsp, typescript, meow-yarn and refactoring-fix specs, drops the files the live repo deleted, and takes live for everything else. Kept from public: lazy.lua with luarocks disabled, the ai_assist cond guard (nvim-ai-assist is not anonymously clonable, so a fresh box only gets it from the private clone list), and the scrubbed endpoint comment in place of live's LAN address.
This commit is contained in:
1 parent
9baaf78522
commit
0aaaf51421
28 files changed
+1001
-611
No files matched your search
@@ -13,3 +13,27 @@ vim.keymap.set("n", "<leader>cY", function()
|
||||
vim.fn.setreg("+", vim.fn.expand("%:p"))
|
||||
print("Copied absolute path: " .. vim.fn.expand("%:p"))
|
||||
end, { desc = "Copy absolute path" })
|
||||
|
||||
-- Select mode (Shift+arrows) replaces the selection with what you type, so `y`
|
||||
-- types a "y". Conventional copy/cut instead (<C-g> switches to Visual first).
|
||||
-- The `y`/`d` is fed remappable so buffer maps still apply (md-render's render
|
||||
-- view copies markdown source); `"+` is fed noremap so which-key's `"` trigger
|
||||
-- stays out. Both go to the front of typeahead, in this order.
|
||||
local function clipboard_op(prefix, op)
|
||||
return function()
|
||||
vim.api.nvim_feedkeys(op, "mi", false)
|
||||
vim.api.nvim_feedkeys(vim.keycode(prefix) .. '"+', "ni", false)
|
||||
end
|
||||
end
|
||||
vim.keymap.set("s", "<C-c>", clipboard_op("<C-g>", "y"), { desc = "Copy selection to clipboard" })
|
||||
vim.keymap.set("s", "<C-x>", clipboard_op("<C-g>", "d"), { desc = "Cut selection to clipboard" })
|
||||
vim.keymap.set("x", "<C-c>", clipboard_op("", "y"), { desc = "Copy selection to clipboard" })
|
||||
|
||||
-- VS Code's terminal toggle (Ctrl+`, the ~ key), mirroring LazyVim's <C-/>.
|
||||
-- Only reaches nvim when the terminal sends CSI u / kitty keys; the legacy
|
||||
-- encoding of Ctrl+` is NUL, which is <C-Space> (flash) and is left alone.
|
||||
local function toggle_terminal()
|
||||
Snacks.terminal.focus(nil, { cwd = LazyVim.root() })
|
||||
end
|
||||
vim.keymap.set({ "n", "t" }, "<C-`>", toggle_terminal, { desc = "Terminal (Root Dir)" })
|
||||
vim.keymap.set({ "n", "t" }, "<C-~>", toggle_terminal, { desc = "which_key_ignore" })
|
||||
@@ -2,10 +2,16 @@
|
||||
-- Default options that are always set: https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/options.lua
|
||||
-- Add any additional options here
|
||||
|
||||
-- No AI/inline completion: LazyVim's blink extra sets
|
||||
-- completion.ghost_text.enabled = vim.g.ai_cmp (grey inline preview of the top
|
||||
-- item). Must be set here, before LazyVim imports its extras.
|
||||
vim.g.ai_cmp = false
|
||||
|
||||
-- Clipboard provider. LazyVim disables `clipboard=unnamedplus` under SSH, so
|
||||
-- select the right provider and explicitly re-enable clipboard-linked yanks:
|
||||
-- * tmux -> tmux's own clipboard buffer (readable)
|
||||
-- * SSH/remote -> OSC 52 copy-only (see note below)
|
||||
-- * tmux -> tmux buffer (p first asks the outer terminal via
|
||||
-- `refresh-client -l`; only works if it allows OSC 52 reads)
|
||||
-- * SSH/remote -> OSC 52 copy + host-local paste cache (see below)
|
||||
-- * local macOS -> native pbcopy/pbpaste.
|
||||
-- Do NOT use OSC 52 locally: yanky's `sync_with_ring` reads the system
|
||||
-- clipboard, and OSC 52 reads depend on the terminal answering a query, which
|
||||
@@ -17,34 +23,97 @@ elseif vim.env.SSH_CONNECTION then
|
||||
-- Remote session (bare SSH, or a multiplexer like herdr that exports no env
|
||||
-- var of its own). Copy via OSC 52 so yanks reach the OUTER terminal's
|
||||
-- clipboard, but NEVER read the clipboard back: OSC 52 reads require the
|
||||
-- terminal to answer a query, which Warp/herdr don't, so a read returns stale
|
||||
-- data (or hangs) and blows up yanky's ring sync. Trade-off: pasting FROM the
|
||||
-- local host INTO nvim over SSH won't work here -- use the terminal's own
|
||||
-- paste in insert mode.
|
||||
-- terminal to answer a query, which Warp/herdr/Ghostty don't, and the runtime
|
||||
-- reader then blocks for up to 10 s. Pasting FROM the Mac INTO nvim is the
|
||||
-- terminal's own paste (Cmd-V, bracketed paste; works in every mode).
|
||||
--
|
||||
-- `p` returns the last copy made by ANY nvim on this host: copy() also writes
|
||||
-- {regtype, lines...} to stdpath("state")/clipboard/last (dir 0700, file 0600,
|
||||
-- atomic rename; writefile/readfile "b" keep NUL bytes and trailing empty
|
||||
-- lines), so a yank in one herdr pane pastes in another. Falls back to this
|
||||
-- instance's last copy. Over 8 MiB the shared file is removed, not left stale.
|
||||
-- No "nothing to paste" hint: yanky reads "+ when it loads, so paste() can't
|
||||
-- tell a user's `p` from a plugin's read.
|
||||
--
|
||||
-- The paste function below must NOT call vim.fn.getreg('"')/'*'/'+' itself:
|
||||
-- Neovim's clipboard provider (autoload/provider/clipboard.vim) guards
|
||||
-- against re-entrant provider calls (`s:here`, see nvim#7184), so a getreg()
|
||||
-- of a clipboard-linked register issued from *inside* a registered paste()
|
||||
-- callback is swallowed and silently returns empty -- not the register's
|
||||
-- real content. Cache what copy() was last given instead, and have paste()
|
||||
-- return that cached value directly.
|
||||
local osc52 = require("vim.ui.clipboard.osc52")
|
||||
local last = { lines = {}, regtype = "" }
|
||||
local function make_copy(reg)
|
||||
local osc52_copy = osc52.copy(reg)
|
||||
return function(lines, regtype)
|
||||
last.lines, last.regtype = lines, regtype
|
||||
osc52_copy(lines, regtype)
|
||||
-- real content. It reads the shared file or what copy() was last given.
|
||||
-- Neither function may throw: an error would land in the middle of a yank.
|
||||
local osc52_send = require("vim.ui.clipboard.osc52").copy("+")
|
||||
local share_dir = vim.fn.stdpath("state") .. "/clipboard"
|
||||
local share_file = share_dir .. "/last"
|
||||
local SHARE_MAX, OSC52_WARN = 8 * 1024 * 1024, 512 * 1024
|
||||
local last, dir_mode_set = { lines = {}, regtype = "v" }, false
|
||||
local stale -- identity of a shared file we failed to replace or remove
|
||||
local function file_id()
|
||||
local st = vim.uv.fs_stat(share_file)
|
||||
return st and ("%d:%d.%d:%d"):format(st.ino, st.mtime.sec, st.mtime.nsec, st.size)
|
||||
end
|
||||
local function share(lines, regtype, size)
|
||||
local tmp = ("%s.%d.tmp"):format(share_file, vim.uv.os_getpid())
|
||||
local ok = pcall(function()
|
||||
if size > SHARE_MAX then error("too large to share") end
|
||||
if vim.fn.isdirectory(share_dir) == 0 then
|
||||
vim.fn.mkdir(share_dir, "p", tonumber("700", 8))
|
||||
dir_mode_set = false
|
||||
end
|
||||
if not dir_mode_set then -- once per process, also for a pre-existing dir
|
||||
dir_mode_set = true
|
||||
vim.uv.fs_chmod(share_dir, tonumber("700", 8))
|
||||
end
|
||||
local data = { regtype }
|
||||
vim.list_extend(data, lines)
|
||||
if vim.fn.writefile(data, tmp, "bS") ~= 0 then error("write failed") end
|
||||
assert(vim.uv.fs_chmod(tmp, tonumber("600", 8)))
|
||||
assert(vim.uv.fs_rename(tmp, share_file))
|
||||
end)
|
||||
stale = nil
|
||||
if not ok then -- never serve a stale shared copy
|
||||
pcall(os.remove, tmp)
|
||||
pcall(os.remove, share_file)
|
||||
stale = file_id() -- still there (read-only dir): ignore it until replaced
|
||||
end
|
||||
end
|
||||
local function paste_from_cache()
|
||||
local function remember(lines, regtype)
|
||||
last.lines, last.regtype = lines, regtype
|
||||
local size = 0
|
||||
for _, l in ipairs(lines) do size = size + #l + 1 end
|
||||
share(lines, regtype, size)
|
||||
return size
|
||||
end
|
||||
local function copy_plus(lines, regtype)
|
||||
local size = remember(lines, regtype)
|
||||
pcall(osc52_send, lines, regtype)
|
||||
if size > OSC52_WARN then
|
||||
vim.schedule(function()
|
||||
vim.notify(("Copied %d KiB via OSC 52; the terminal may drop payloads this large (nvim `p` on this host still has it)."):format(math.floor(size / 1024)), vim.log.levels.WARN)
|
||||
end)
|
||||
end
|
||||
end
|
||||
-- OSC 52 'p' (primary selection) means nothing on the Mac, so "* only updates
|
||||
-- the paste cache. A yank that fans out to "+ AND "* (provider:
|
||||
-- s:copy['*'] != s:copy['+'], i.e. 'clipboard' has unnamed) still sends
|
||||
-- exactly one OSC 52 sequence.
|
||||
local function copy_star(lines, regtype)
|
||||
remember(lines, regtype)
|
||||
end
|
||||
local function paste()
|
||||
if vim.fn.filereadable(share_file) == 1 and (not stale or file_id() ~= stale) then
|
||||
local ok, data = pcall(vim.fn.readfile, share_file, "b")
|
||||
if ok and type(data) == "table" and #data > 0 and data[1]:match("^[vVb]$") then
|
||||
local regtype = table.remove(data, 1)
|
||||
return { data, regtype }
|
||||
end
|
||||
end
|
||||
return { last.lines, last.regtype }
|
||||
end
|
||||
vim.g.clipboard = {
|
||||
name = "osc52-copyonly",
|
||||
copy = { ["+"] = make_copy("+"), ["*"] = make_copy("*") },
|
||||
paste = { ["+"] = paste_from_cache, ["*"] = paste_from_cache },
|
||||
copy = { ["+"] = copy_plus, ["*"] = copy_star },
|
||||
paste = { ["+"] = paste, ["*"] = paste },
|
||||
cache_enabled = 0,
|
||||
}
|
||||
elseif vim.fn.has("mac") == 1 then
|
||||
@@ -76,7 +145,10 @@ vim.opt.scrolloff = 8 -- Keep 8 lines visible above/below cursor
|
||||
vim.opt.sidescrolloff = 8 -- Keep 8 columns visible left/right
|
||||
vim.opt.smoothscroll = true -- Smooth scrolling
|
||||
|
||||
-- Make Shift+movement and mouse selections behave like a conventional editor.
|
||||
-- Keep `cmd` out of selectmode so v/V continue to enter Vim's Visual mode.
|
||||
-- Shift+arrows start Select mode like a conventional editor: typing replaces
|
||||
-- the selection; <C-c>/<C-x> copy/cut it to the clipboard (keymaps.lua).
|
||||
-- Mouse drags start Visual mode so y/d/p work as usual (over SSH with
|
||||
-- mouse=a the terminal can't copy a drag itself). Keep `cmd` out of
|
||||
-- selectmode so v/V continue to enter Vim's Visual mode.
|
||||
vim.opt.keymodel = { "startsel", "stopsel" }
|
||||
vim.opt.selectmode = { "key", "mouse" }
|
||||
vim.opt.selectmode = { "key" }
|
||||
@@ -1,37 +0,0 @@
|
||||
local completion_state = {
|
||||
enabled = true, -- current state
|
||||
backup = { -- store the original values so we can restore them
|
||||
omnifunc = nil,
|
||||
completefunc = nil,
|
||||
completeopt = nil,
|
||||
},
|
||||
}
|
||||
|
||||
vim.keymap.set("n", "<leader>co", function()
|
||||
if completion_state.enabled then
|
||||
-- ----- DISABLE -----
|
||||
completion_state.backup.omnifunc = vim.opt_local.omnifunc:get()
|
||||
completion_state.backup.completefunc = vim.opt_local.completefunc:get()
|
||||
completion_state.backup.completeopt = vim.opt_local.completeopt:get()
|
||||
|
||||
-- Clear the sources
|
||||
vim.opt_local.omnifunc = ""
|
||||
vim.opt_local.completefunc = ""
|
||||
|
||||
-- Hide the menu even if something tries to show it
|
||||
vim.opt_local.completeopt = { "noinsert", "noselect" }
|
||||
|
||||
completion_state.enabled = false
|
||||
print("⛔ Autocompletion disabled")
|
||||
else
|
||||
-- ----- ENABLE -----
|
||||
vim.opt_local.omnifunc = completion_state.backup.omnifunc
|
||||
vim.opt_local.completefunc = completion_state.backup.completefunc
|
||||
|
||||
-- Restore the previous `completeopt` (or a safe default)
|
||||
vim.opt_local.completeopt = completion_state.backup.completeopt or { "menu", "preview", "noinsert", "noselect" }
|
||||
|
||||
completion_state.enabled = true
|
||||
print("✅ Autocompletion re‑enabled")
|
||||
end
|
||||
end, { desc = "Toggle all autocompletion (omnifunc, completefunc, menu)" })
|
||||
@@ -15,7 +15,7 @@ return {
|
||||
require("nvim_ai_assist").setup({
|
||||
-- Active: Z.AI Coding Plan (uses ZAI_API_KEY from env)
|
||||
provider = "zai-coding",
|
||||
model = "glm-4.7",
|
||||
model = "glm-5-turbo",
|
||||
max_tokens = 300,
|
||||
temperature = 0.05,
|
||||
debug = true, -- writes request/response to ~/.cache/nvim/nvim_ai_assist.log; :AILog to view
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
-- * drop the `buffer` (next-word) source everywhere
|
||||
-- * markdown/md-render buffers use LSP+path only (no snippet callout noise)
|
||||
-- * disable friendly-snippets' global snippets (datetime/dateMDY/lorem/...)
|
||||
-- Inline AI suggestions are handled by minuet instead (see minuet.lua).
|
||||
-- Inline LLM ghost-text (minuet-ai.nvim) was removed; blink is the only completion source.
|
||||
return {
|
||||
"saghen/blink.cmp",
|
||||
opts = function(_, opts)
|
||||
@@ -28,5 +28,27 @@ return {
|
||||
opts.sources.providers.snippets = opts.sources.providers.snippets or {}
|
||||
opts.sources.providers.snippets.opts = opts.sources.providers.snippets.opts or {}
|
||||
opts.sources.providers.snippets.opts.global_snippets = {}
|
||||
|
||||
-- Global on/off switch for completion (<leader>uk below). While it's on,
|
||||
-- blink's own `enabled` check still applies.
|
||||
local prev = opts.enabled
|
||||
opts.enabled = function()
|
||||
if vim.g.thembones_completion == false then return false end
|
||||
if type(prev) == "function" then return prev() end
|
||||
return true
|
||||
end
|
||||
end,
|
||||
keys = {
|
||||
{
|
||||
"<leader>uk",
|
||||
function()
|
||||
vim.g.thembones_completion = vim.g.thembones_completion == false
|
||||
if not vim.g.thembones_completion then
|
||||
pcall(function() require("blink.cmp").hide() end)
|
||||
end
|
||||
vim.notify("Completion " .. (vim.g.thembones_completion and "on" or "off"))
|
||||
end,
|
||||
desc = "Toggle Completion (global)",
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
-- LazyVim's ai.claudecode extra maps "<leader>a" (group) and "<leader>as" (Send to
|
||||
-- Claude) with mode "v", which also covers Select mode. A space typed over a
|
||||
-- Shift+arrow selection (selectmode=key) then waits 'timeoutlen' for the rest of
|
||||
-- a <leader> map instead of replacing the selection at once. Keep those maps in
|
||||
-- Visual mode only ("x"); Visual <leader>as behaves exactly as before.
|
||||
return {
|
||||
{
|
||||
"coder/claudecode.nvim",
|
||||
optional = true,
|
||||
keys = function(_, keys)
|
||||
local function visual_only(mode)
|
||||
if mode == "v" then
|
||||
return "x"
|
||||
end
|
||||
if type(mode) == "table" then
|
||||
return vim.tbl_map(function(m)
|
||||
return m == "v" and "x" or m
|
||||
end, mode)
|
||||
end
|
||||
return mode
|
||||
end
|
||||
return vim.tbl_map(function(k)
|
||||
if type(k) ~= "table" or k.mode == nil then
|
||||
return k
|
||||
end
|
||||
return vim.tbl_extend("force", k, { mode = visual_only(k.mode) })
|
||||
end, keys)
|
||||
end,
|
||||
},
|
||||
}
|
||||
@@ -7,8 +7,6 @@ return {
|
||||
{ "<leader>dh", "<cmd>DiffviewFileHistory %<cr>", desc = "File history (current)" },
|
||||
{ "<leader>dH", "<cmd>DiffviewFileHistory<cr>", desc = "File history (all)" },
|
||||
},
|
||||
config = function()
|
||||
require("diffview").setup({})
|
||||
-- removed the vim.keymap.set lines from here
|
||||
end,
|
||||
-- No `config` here: lazy calls require("diffview").setup(opts) with the
|
||||
-- options from lua/plugins/git.lua (a setup({}) here discarded them).
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
-- In-editor ESLint diagnostics via the eslint language server (Mason: eslint-lsp,
|
||||
-- i.e. vscode-eslint-language-server). Added 2026-10-23 for the TS code-walkthrough prep.
|
||||
--
|
||||
-- Diagnostics only, NO format/fix on save: eslint attaches and shows lint squiggles
|
||||
-- inline, but will not silently rewrite the buffer when you save (which would bury your
|
||||
-- real diff in a walkthrough). Fix manually with <leader>ca (code action -> "Fix all
|
||||
-- ESLint problems") or :EslintFixAll when you actually want it.
|
||||
--
|
||||
-- Note: eslint runs the project's own eslint + typescript-eslint. typescript-eslint does
|
||||
-- not yet support TypeScript 7, so on a TS 7 project the server errors out — that is the
|
||||
-- project's toolchain, not this config. Projects pinned to TS 5.x work normally.
|
||||
return {
|
||||
{
|
||||
"neovim/nvim-lspconfig",
|
||||
opts = {
|
||||
servers = {
|
||||
eslint = {
|
||||
settings = {
|
||||
-- find eslint config even when it lives in a subfolder, not the cwd root
|
||||
workingDirectories = { mode = "auto" },
|
||||
format = false,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -1,197 +0,0 @@
|
||||
-- since this is just an example spec, don't actually load anything here and return an empty spec
|
||||
-- stylua: ignore
|
||||
if true then return {} end
|
||||
|
||||
-- every spec file under the "plugins" directory will be loaded automatically by lazy.nvim
|
||||
--
|
||||
-- In your plugin files, you can:
|
||||
-- * add extra plugins
|
||||
-- * disable/enabled LazyVim plugins
|
||||
-- * override the configuration of LazyVim plugins
|
||||
return {
|
||||
-- add gruvbox
|
||||
{ "ellisonleao/gruvbox.nvim" },
|
||||
|
||||
-- Configure LazyVim to load gruvbox
|
||||
{
|
||||
"LazyVim/LazyVim",
|
||||
opts = {
|
||||
colorscheme = "gruvbox",
|
||||
},
|
||||
},
|
||||
|
||||
-- change trouble config
|
||||
{
|
||||
"folke/trouble.nvim",
|
||||
-- opts will be merged with the parent spec
|
||||
opts = { use_diagnostic_signs = true },
|
||||
},
|
||||
|
||||
-- disable trouble
|
||||
{ "folke/trouble.nvim", enabled = false },
|
||||
|
||||
-- override nvim-cmp and add cmp-emoji
|
||||
{
|
||||
"hrsh7th/nvim-cmp",
|
||||
dependencies = { "hrsh7th/cmp-emoji" },
|
||||
---@param opts cmp.ConfigSchema
|
||||
opts = function(_, opts)
|
||||
table.insert(opts.sources, { name = "emoji" })
|
||||
end,
|
||||
},
|
||||
|
||||
-- change some telescope options and a keymap to browse plugin files
|
||||
{
|
||||
"nvim-telescope/telescope.nvim",
|
||||
keys = {
|
||||
-- add a keymap to browse plugin files
|
||||
-- stylua: ignore
|
||||
{
|
||||
"<leader>fp",
|
||||
function() require("telescope.builtin").find_files({ cwd = require("lazy.core.config").options.root }) end,
|
||||
desc = "Find Plugin File",
|
||||
},
|
||||
},
|
||||
-- change some options
|
||||
opts = {
|
||||
defaults = {
|
||||
layout_strategy = "horizontal",
|
||||
layout_config = { prompt_position = "top" },
|
||||
sorting_strategy = "ascending",
|
||||
winblend = 0,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
-- add pyright to lspconfig
|
||||
{
|
||||
"neovim/nvim-lspconfig",
|
||||
---@class PluginLspOpts
|
||||
opts = {
|
||||
---@type lspconfig.options
|
||||
servers = {
|
||||
-- pyright will be automatically installed with mason and loaded with lspconfig
|
||||
pyright = {},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
-- add tsserver and setup with typescript.nvim instead of lspconfig
|
||||
{
|
||||
"neovim/nvim-lspconfig",
|
||||
dependencies = {
|
||||
"jose-elias-alvarez/typescript.nvim",
|
||||
init = function()
|
||||
require("lazyvim.util").lsp.on_attach(function(_, buffer)
|
||||
-- stylua: ignore
|
||||
vim.keymap.set( "n", "<leader>co", "TypescriptOrganizeImports", { buffer = buffer, desc = "Organize Imports" })
|
||||
vim.keymap.set("n", "<leader>cR", "TypescriptRenameFile", { desc = "Rename File", buffer = buffer })
|
||||
end)
|
||||
end,
|
||||
},
|
||||
---@class PluginLspOpts
|
||||
opts = {
|
||||
---@type lspconfig.options
|
||||
servers = {
|
||||
-- tsserver will be automatically installed with mason and loaded with lspconfig
|
||||
tsserver = {},
|
||||
},
|
||||
-- you can do any additional lsp server setup here
|
||||
-- return true if you don't want this server to be setup with lspconfig
|
||||
---@type table<string, fun(server:string, opts:_.lspconfig.options):boolean?>
|
||||
setup = {
|
||||
-- example to setup with typescript.nvim
|
||||
tsserver = function(_, opts)
|
||||
require("typescript").setup({ server = opts })
|
||||
return true
|
||||
end,
|
||||
-- Specify * to use this function as a fallback for any server
|
||||
-- ["*"] = function(server, opts) end,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
-- for typescript, LazyVim also includes extra specs to properly setup lspconfig,
|
||||
-- treesitter, mason and typescript.nvim. So instead of the above, you can use:
|
||||
{ import = "lazyvim.plugins.extras.lang.typescript" },
|
||||
|
||||
-- add more treesitter parsers
|
||||
{
|
||||
"nvim-treesitter/nvim-treesitter",
|
||||
opts = {
|
||||
ensure_installed = {
|
||||
"bash",
|
||||
"html",
|
||||
"javascript",
|
||||
"json",
|
||||
"lua",
|
||||
"markdown",
|
||||
"markdown_inline",
|
||||
"python",
|
||||
"query",
|
||||
"regex",
|
||||
"tsx",
|
||||
"typescript",
|
||||
"vim",
|
||||
"yaml",
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
-- since `vim.tbl_deep_extend`, can only merge tables and not lists, the code above
|
||||
-- would overwrite `ensure_installed` with the new value.
|
||||
-- If you'd rather extend the default config, use the code below instead:
|
||||
{
|
||||
"nvim-treesitter/nvim-treesitter",
|
||||
opts = function(_, opts)
|
||||
-- add tsx and treesitter
|
||||
vim.list_extend(opts.ensure_installed, {
|
||||
"tsx",
|
||||
"typescript",
|
||||
})
|
||||
end,
|
||||
},
|
||||
|
||||
-- the opts function can also be used to change the default opts:
|
||||
{
|
||||
"nvim-lualine/lualine.nvim",
|
||||
event = "VeryLazy",
|
||||
opts = function(_, opts)
|
||||
table.insert(opts.sections.lualine_x, {
|
||||
function()
|
||||
return "😄"
|
||||
end,
|
||||
})
|
||||
end,
|
||||
},
|
||||
|
||||
-- or you can return new options to override all the defaults
|
||||
{
|
||||
"nvim-lualine/lualine.nvim",
|
||||
event = "VeryLazy",
|
||||
opts = function()
|
||||
return {
|
||||
--[[add your custom lualine config here]]
|
||||
}
|
||||
end,
|
||||
},
|
||||
|
||||
-- use mini.starter instead of alpha
|
||||
{ import = "lazyvim.plugins.extras.ui.mini-starter" },
|
||||
|
||||
-- add jsonls and schemastore packages, and setup treesitter for json, json5 and jsonc
|
||||
{ import = "lazyvim.plugins.extras.lang.json" },
|
||||
|
||||
-- add any tools you want to have installed below
|
||||
{
|
||||
"williamboman/mason.nvim",
|
||||
opts = {
|
||||
ensure_installed = {
|
||||
"stylua",
|
||||
"shellcheck",
|
||||
"shfmt",
|
||||
"flake8",
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -1,16 +1,67 @@
|
||||
-- Git enhancement plugins
|
||||
--
|
||||
-- Change markers and blame both come from gitsigns.nvim (LazyVim's default; the
|
||||
-- editor.mini-diff extra is off in lazyvim.json because it disables gitsigns).
|
||||
local MIN_BLAME_ROOM = 12 -- columns needed before the summary is worth showing
|
||||
local blame_hl = "GitSignsCurrentLineBlame"
|
||||
|
||||
-- Current-line blame that fits the window: "author, 3 days ago · summary". The
|
||||
-- summary is cut to the room left after the line's text, and dropped when the
|
||||
-- line nearly fills the window, so the annotation never runs off screen.
|
||||
local function blame_formatter(_, info)
|
||||
if info.author == "Not Committed Yet" then
|
||||
return { { " ● Uncommitted change", "GitSignsChange" } }
|
||||
end
|
||||
local util = require("gitsigns.util")
|
||||
local head = (" %s, %s"):format(info.author, util.get_relative_time(tonumber(info.author_time)))
|
||||
|
||||
local win = vim.api.nvim_get_current_win()
|
||||
local textoff = vim.fn.getwininfo(win)[1].textoff
|
||||
local room = vim.api.nvim_win_get_width(win) - textoff
|
||||
- vim.api.nvim_strwidth(vim.api.nvim_get_current_line()) - vim.api.nvim_strwidth(head) - 4
|
||||
if room < MIN_BLAME_ROOM then
|
||||
return { { head, blame_hl } }
|
||||
end
|
||||
local summary = info.summary or ""
|
||||
if vim.api.nvim_strwidth(summary) > room then
|
||||
summary = vim.fn.strcharpart(summary, 0, room - 1) .. "…"
|
||||
end
|
||||
return { { head, blame_hl }, { " · " .. summary, blame_hl } }
|
||||
end
|
||||
|
||||
return {
|
||||
-- Git blame annotations in virtual text
|
||||
-- Shows git blame info at the end of each line
|
||||
-- Toggle with :GitBlameToggle
|
||||
{
|
||||
"f-person/git-blame.nvim",
|
||||
event = "VeryLazy",
|
||||
"lewis6991/gitsigns.nvim",
|
||||
opts = {
|
||||
enabled = true, -- Start enabled
|
||||
message_template = " <summary> • <date> • <author>",
|
||||
date_format = "%r",
|
||||
virtual_text_column = 80,
|
||||
-- Heavy bars in the sign column, VS Code style. Unstaged changes use
|
||||
-- GitSignsAdd/Change/Delete; staged ones get gitsigns' dimmer variants.
|
||||
signs = {
|
||||
add = { text = "┃" },
|
||||
change = { text = "┃" },
|
||||
delete = { text = "▁" },
|
||||
topdelete = { text = "▔" },
|
||||
changedelete = { text = "┃" },
|
||||
untracked = { text = "┆" },
|
||||
},
|
||||
signs_staged = {
|
||||
add = { text = "┃" },
|
||||
change = { text = "┃" },
|
||||
delete = { text = "▁" },
|
||||
topdelete = { text = "▔" },
|
||||
changedelete = { text = "┃" },
|
||||
},
|
||||
numhl = true, -- also color the line number of every changed line
|
||||
attach_to_untracked = true,
|
||||
current_line_blame = true,
|
||||
current_line_blame_opts = { virt_text_pos = "eol", delay = 300, ignore_whitespace = true },
|
||||
current_line_blame_formatter = blame_formatter,
|
||||
current_line_blame_formatter_nc = blame_formatter,
|
||||
},
|
||||
keys = {
|
||||
{ "<leader>gb", "<cmd>Gitsigns blame<cr>", desc = "Blame panel (every line)" },
|
||||
{ "<leader>gL", function() require("gitsigns").blame_line({ full = true }) end, desc = "Blame line (full commit)" },
|
||||
{ "<leader>uB", "<cmd>Gitsigns toggle_current_line_blame<cr>", desc = "Toggle inline blame" },
|
||||
{ "<leader>uN", "<cmd>Gitsigns toggle_numhl<cr>", desc = "Toggle git line-number colors" },
|
||||
},
|
||||
},
|
||||
|
||||
|
||||
@@ -23,6 +23,22 @@ local function image_debug(message)
|
||||
vim.fn.writefile({ line }, path, "a")
|
||||
end
|
||||
|
||||
-- Rendered mermaid/PlantUML rows all map to the block's CLOSING fence. If
|
||||
-- `lnum` is the closing fence of such a block, return the opening-fence line,
|
||||
-- else nil.
|
||||
local DIAGRAM_LANGS = { mermaid = true, plantuml = true, puml = true }
|
||||
local function diagram_open_fence(buf, lnum)
|
||||
local function get(l) return vim.api.nvim_buf_get_lines(buf, l - 1, l, false)[1] or "" end
|
||||
if not get(lnum):match("^%s*[`~][`~][`~]+%s*$") then return nil end
|
||||
for l = lnum - 1, math.max(1, lnum - 5000), -1 do
|
||||
local fence, info = get(l):match("^%s*([`~][`~][`~]+)%s*(%S*)")
|
||||
if fence then
|
||||
local lang = (info:match("^{?%.?([%w_-]+)") or ""):lower()
|
||||
return DIAGRAM_LANGS[lang] and l or nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return {
|
||||
{
|
||||
"delphinus/md-render.nvim",
|
||||
@@ -32,6 +48,10 @@ return {
|
||||
{ "nvim-tree/nvim-web-devicons", version = "*" },
|
||||
},
|
||||
init = function()
|
||||
-- Rendered width: follows the window, capped at this many columns. A
|
||||
-- per-call `max_width` would pin it instead and overflow narrow windows.
|
||||
vim.g.md_render_max_width = 100
|
||||
|
||||
-- Ghostty does not normally forward TERM_PROGRAM /
|
||||
-- GHOSTTY_RESOURCES_DIR into the remote shell. Neovim 0.12 therefore
|
||||
-- cannot prove Kitty graphics support from the remote side on its own.
|
||||
@@ -40,7 +60,9 @@ return {
|
||||
--
|
||||
-- Keep the terminal identity as Ghostty. md-render uses that identity to
|
||||
-- avoid Ghostty's flaky stored-image re-placement path during redraws.
|
||||
if use_direct_kitty_bytes() and not vim.env.TERM_PROGRAM then
|
||||
-- herdr >= 0.9.5 sets TERM_PROGRAM=herdr, which md-render doesn't know,
|
||||
-- so supports_kitty() went false and mermaid fell back to code blocks.
|
||||
if use_direct_kitty_bytes() and (not vim.env.TERM_PROGRAM or vim.env.TERM_PROGRAM == "herdr") then
|
||||
vim.env.TERM_PROGRAM = "ghostty"
|
||||
end
|
||||
|
||||
@@ -57,8 +79,21 @@ return {
|
||||
-- drops to source on the right line and performs the edit. (Pure-motion
|
||||
-- keys h/j/k/w/G/… are deliberately NOT mapped, so you can still navigate
|
||||
-- the render freely.) Yank keys stay in the read-only render buffer so
|
||||
-- copying text does not dismiss rendered diagrams. Visual-entry keys hop
|
||||
-- to source so the resulting selection can be changed safely.
|
||||
-- copying text does not dismiss rendered diagrams, but yy and linewise /
|
||||
-- multi-line Visual y/Y copy the markdown SOURCE behind those rows (see
|
||||
-- MdRenderSourceYank below). Visual-entry keys hop to source so the
|
||||
-- resulting selection can be changed safely. Redo,
|
||||
-- case, increment, filter and format keys (<C-r> U ~ <C-a> <C-x> & !
|
||||
-- gu gU g~ g? gq gw gJ gp gP) hop too; on the render buffer they would
|
||||
-- only fail with E21.
|
||||
--
|
||||
-- Diagram guard: every row of a rendered mermaid/PlantUML image maps to
|
||||
-- the block's closing fence, so a destructive key there (dd, x, J, …)
|
||||
-- would delete/alter that fence and the unbalanced fence would swallow
|
||||
-- the rest of the document. For those keys (DIAGRAM_UNSAFE) we hop to
|
||||
-- the OPENING fence instead and don't replay, so you can edit the
|
||||
-- diagram source deliberately. p/gp (paste below the fence), u/<C-r>/U
|
||||
-- and v/V are still replayed.
|
||||
-- NOTE: the plugin sets the render buffer's filetype under
|
||||
-- `eventignore=all` (preview.lua, so markdown ftplugins/treesitter don't
|
||||
-- clobber the pre-rendered content), so a `FileType md-render` autocmd
|
||||
@@ -68,7 +103,46 @@ return {
|
||||
local HOP_KEYS = {
|
||||
"d", "D", "c", "C", "x", "X", "s", "S", "r", "R",
|
||||
"p", "P", "J", ">", "<", "=", "u", "v", "V", ".",
|
||||
"<C-r>", "U", "~", "<C-a>", "<C-x>", "&", "!",
|
||||
"gu", "gU", "g~", "g?", "gq", "gw", "gJ", "gp", "gP",
|
||||
}
|
||||
local DIAGRAM_UNSAFE = {}
|
||||
for _, key in ipairs({
|
||||
"d", "D", "c", "C", "x", "X", "s", "S", "r", "R", "J", ">", "<", "=",
|
||||
".", "~", "<C-a>", "<C-x>", "&", "!",
|
||||
"gu", "gU", "g~", "g?", "gq", "gw", "gJ", "P", "gP",
|
||||
}) do
|
||||
DIAGRAM_UNSAFE[key] = true
|
||||
end
|
||||
|
||||
-- Auto mode only returns to render on InsertLeave, so a normal-mode hop
|
||||
-- (dd, x, u, p, V…d, .) used to strand you in raw source ("images
|
||||
-- disappear after editing"). After a hop, go back to render the next
|
||||
-- time Neovim is idle in Normal mode (CursorHold; LazyVim 'updatetime'
|
||||
-- = 200ms). Disable with: vim.g.md_render_hop_return = false
|
||||
local function arm_return_to_render(src_buf)
|
||||
if vim.g.md_render_hop_return == false then return end
|
||||
local group = vim.api.nvim_create_augroup("MdRenderHopReturn" .. src_buf, { clear = true })
|
||||
local function disarm() pcall(vim.api.nvim_del_augroup_by_id, group) end
|
||||
vim.api.nvim_create_autocmd("CursorHold", {
|
||||
group = group,
|
||||
buffer = src_buf,
|
||||
callback = function()
|
||||
if vim.api.nvim_get_mode().mode ~= "n" then return end -- e.g. still in Visual
|
||||
disarm()
|
||||
local preview = require("md-render").preview
|
||||
if type(preview._schedule_auto_transition) == "function" then
|
||||
preview._schedule_auto_transition(src_buf, "render") -- no-op unless auto mode is on
|
||||
elseif vim.b[src_buf].md_render_auto and vim.api.nvim_get_current_buf() == src_buf then
|
||||
preview.toggle()
|
||||
end
|
||||
end,
|
||||
})
|
||||
-- Insert-entering hops (c/s/C/S/R) return via md-render's own
|
||||
-- InsertLeave; leaving the buffer cancels.
|
||||
vim.api.nvim_create_autocmd({ "InsertEnter", "BufLeave" }, { group = group, buffer = src_buf, callback = disarm })
|
||||
end
|
||||
|
||||
local hop_group = vim.api.nvim_create_augroup("MdRenderEditHop", { clear = true })
|
||||
vim.api.nvim_create_autocmd({ "BufEnter", "BufWinEnter" }, {
|
||||
group = hop_group,
|
||||
@@ -93,10 +167,23 @@ return {
|
||||
-- before any follow-up keystroke. That keeps multi-key operators
|
||||
-- in order — `d` becomes operator-pending and your next key (e.g.
|
||||
-- the second `d`, or `w`, `ip`) completes it natively in source.
|
||||
-- (The plugin schedules its insert-entry hop because those are
|
||||
-- single keys that immediately switch to Insert mode; operators
|
||||
-- need the ordering guarantee a sync feed provides.)
|
||||
-- (md-render's own insert-entry hop scheduled its feed and lost
|
||||
-- keys typed in the same burst; patch_auto_insert_hop in
|
||||
-- `config` makes it feed the same way as this.)
|
||||
require("md-render").preview.toggle()
|
||||
local src_buf = vim.api.nvim_get_current_buf()
|
||||
if vim.bo[src_buf].filetype == "md-render" then return end -- toggle refused
|
||||
|
||||
if DIAGRAM_UNSAFE[key] then
|
||||
local fence = diagram_open_fence(src_buf, vim.api.nvim_win_get_cursor(0)[1])
|
||||
if fence then
|
||||
vim.api.nvim_win_set_cursor(0, { fence, 0 })
|
||||
vim.notify(("md-render: '%s' not applied to a rendered diagram; jumped to its source fence. "
|
||||
.. "Edit here (<leader>mr, or leaving Insert mode, re-renders)."):format(key), vim.log.levels.INFO)
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
if key == "v" or key == "V" then
|
||||
-- Enter Visual mode before the user's next queued key arrives.
|
||||
-- feedkeys() would put v/V behind that key, turning `Vd` into
|
||||
@@ -104,8 +191,13 @@ return {
|
||||
local visual_count = count > 0 and tostring(count) or ""
|
||||
vim.cmd("normal! " .. visual_count .. key)
|
||||
else
|
||||
vim.api.nvim_feedkeys(prefix .. key, "n", false)
|
||||
-- vim.keycode: <C-r>/<C-a>/<C-x> must be fed as keys, not text.
|
||||
-- "i" inserts at the FRONT of the typeahead: when the rest of
|
||||
-- the command is already queued (fast typing, `gUU`, `dw`), an
|
||||
-- appended replay would run after it (`gUU` became `U` + `gU`).
|
||||
vim.api.nvim_feedkeys(vim.keycode(prefix .. key), "ni", false)
|
||||
end
|
||||
arm_return_to_render(src_buf)
|
||||
end, {
|
||||
buffer = ev.buf,
|
||||
noremap = true,
|
||||
@@ -115,29 +207,114 @@ return {
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
-- Yanking in the render buffer used to copy the decorated text (icons,
|
||||
-- padding, reflowed paragraphs), which pastes as garbage into markdown.
|
||||
-- yy and Visual y/Y (except a charwise selection within one rendered
|
||||
-- line, which keeps the native yank) copy the SOURCE lines behind the
|
||||
-- rendered rows instead, linewise; the view stays rendered. A rendered
|
||||
-- diagram yanks its whole fenced block. These yanks are set with
|
||||
-- setreg(), so they don't fire TextYankPost / enter yanky's ring.
|
||||
local yank_ns = vim.api.nvim_create_namespace("md_render_source_yank")
|
||||
|
||||
local function render_ctx()
|
||||
local ok, state = pcall(vim.api.nvim_win_get_var, 0, "md_render_state")
|
||||
if not ok or type(state) ~= "table" or state.mode ~= "render" then return nil end
|
||||
local session = require("md-render").preview._toggle_sessions[state.source_buf]
|
||||
if not session or session.buf ~= vim.api.nvim_get_current_buf() then return nil end
|
||||
local map = session.content and session.content.source_line_map
|
||||
if type(map) ~= "table" or #map == 0 or not vim.api.nvim_buf_is_valid(state.source_buf) then return nil end
|
||||
return map, state.source_buf
|
||||
end
|
||||
|
||||
local function source_lines_for(map, src_buf, r1, r2)
|
||||
r1 = math.max(1, math.min(r1, #map))
|
||||
r2 = math.max(r1, math.min(r2, #map))
|
||||
local total = vim.api.nvim_buf_line_count(src_buf)
|
||||
local s1 = math.max(1, math.min(map[r1], total))
|
||||
s1 = diagram_open_fence(src_buf, s1) or s1
|
||||
-- The last row's block ends right before the next row that maps to a
|
||||
-- later source line (covers joined paragraph lines and fences).
|
||||
local s2 = total
|
||||
for r = r2 + 1, #map do
|
||||
if map[r] > map[r2] then
|
||||
s2 = map[r] - 1
|
||||
break
|
||||
end
|
||||
end
|
||||
s2 = math.max(s1, math.min(s2, total))
|
||||
local lines = vim.api.nvim_buf_get_lines(src_buf, s1 - 1, s2, false)
|
||||
while #lines > 1 and lines[#lines]:match("^%s*$") do table.remove(lines) end
|
||||
return lines
|
||||
end
|
||||
|
||||
local function yank_source(buf, r1, r2, reg)
|
||||
local map, src_buf = render_ctx()
|
||||
if not map then return false end
|
||||
vim.fn.setreg(reg, source_lines_for(map, src_buf, r1, r2), "l")
|
||||
pcall(vim.hl.range, buf, yank_ns, "IncSearch", { r1 - 1, 0 }, { r2 - 1, 0 }, { regtype = "V", timeout = 150 })
|
||||
return true
|
||||
end
|
||||
|
||||
local yank_group = vim.api.nvim_create_augroup("MdRenderSourceYank", { clear = true })
|
||||
vim.api.nvim_create_autocmd({ "BufEnter", "BufWinEnter" }, {
|
||||
group = yank_group,
|
||||
desc = "md-render: yank in render view copies markdown source",
|
||||
callback = function(ev)
|
||||
if vim.bo[ev.buf].filetype ~= "md-render" then return end
|
||||
if vim.b[ev.buf].md_render_yank_installed then return end
|
||||
vim.b[ev.buf].md_render_yank_installed = true
|
||||
|
||||
vim.keymap.set("n", "yy", function()
|
||||
local r, count, reg = vim.fn.line("."), vim.v.count1, vim.v.register
|
||||
if not yank_source(ev.buf, r, r + count - 1, reg) then
|
||||
vim.api.nvim_feedkeys('"' .. reg .. count .. "yy", "n", false)
|
||||
end
|
||||
end, { buffer = ev.buf, desc = "md-render: yank markdown source line(s)" })
|
||||
|
||||
local function visual_yank(always_source)
|
||||
return function()
|
||||
if not render_ctx() then return "y" end
|
||||
if not always_source and vim.fn.mode() == "v" and vim.fn.line("v") == vim.fn.line(".") then
|
||||
return "y" -- charwise within one rendered line: native yank
|
||||
end
|
||||
local a, b, reg = vim.fn.line("v"), vim.fn.line("."), vim.v.register
|
||||
local buf = ev.buf
|
||||
vim.schedule(function() yank_source(buf, math.min(a, b), math.max(a, b), reg) end)
|
||||
return "<Esc>"
|
||||
end
|
||||
end
|
||||
vim.keymap.set("x", "y", visual_yank(false), {
|
||||
buffer = ev.buf, expr = true, desc = "md-render: yank markdown source of selection",
|
||||
})
|
||||
vim.keymap.set("x", "Y", visual_yank(true), {
|
||||
buffer = ev.buf, expr = true, desc = "md-render: yank markdown source of selected rows",
|
||||
})
|
||||
end,
|
||||
})
|
||||
end,
|
||||
keys = {
|
||||
{
|
||||
"<leader>mp",
|
||||
function() require("md-render").preview.show({ max_width = 140 }) end,
|
||||
function() require("md-render").preview.show() end,
|
||||
ft = "markdown",
|
||||
desc = "Markdown preview (wide float toggle)",
|
||||
desc = "Markdown preview (float toggle)",
|
||||
},
|
||||
{
|
||||
"<leader>mt",
|
||||
function() require("md-render").preview.show_tab({ max_width = 140 }) end,
|
||||
function() require("md-render").preview.show_tab() end,
|
||||
ft = "markdown",
|
||||
desc = "Markdown preview (wide tab toggle)",
|
||||
desc = "Markdown preview (tab toggle)",
|
||||
},
|
||||
{
|
||||
"<leader>ms",
|
||||
function() require("md-render").preview.split({ max_width = 140 }) end,
|
||||
function() require("md-render").preview.split() end,
|
||||
ft = "markdown",
|
||||
desc = "Markdown source/render split",
|
||||
},
|
||||
{
|
||||
"<leader>mr",
|
||||
function() require("md-render").preview.toggle({ max_width = 140 }) end,
|
||||
function() require("md-render").preview.toggle() end,
|
||||
ft = "markdown",
|
||||
desc = "Markdown render toggle in-place",
|
||||
},
|
||||
@@ -329,6 +506,116 @@ return {
|
||||
|
||||
patch_offscreen_mermaid()
|
||||
|
||||
-- md-render bug (v3.11.1, content_builder.lua ~2616/~2693): when a
|
||||
-- mermaid/PlantUML block becomes an image, the builder pops the
|
||||
-- already-emitted code lines from self.lines but NOT from
|
||||
-- self.source_line_map, so every rendered line below the diagram maps
|
||||
-- #removed lines too early (render-mode dd/x/p/o edit the wrong line).
|
||||
-- All map writes go through add_line, so re-align there. No-op once
|
||||
-- fixed upstream (the map is then never longer than the lines).
|
||||
local function patch_source_line_map()
|
||||
local ok, mod = pcall(require, "md-render.content_builder")
|
||||
local CB = ok and type(mod) == "table" and mod.ContentBuilder or nil
|
||||
if not CB or CB._thembones_source_map_patch then return end
|
||||
if type(CB.add_line) ~= "function" or type(CB.result) ~= "function" then return end
|
||||
CB._thembones_source_map_patch = true
|
||||
local original_add_line, original_result = CB.add_line, CB.result
|
||||
|
||||
CB.add_line = function(self, ...)
|
||||
original_add_line(self, ...)
|
||||
local map, n = self.source_line_map, #self.lines
|
||||
if type(map) == "table" and #map > n then
|
||||
local newest = map[#map] -- entry just appended for line n
|
||||
for i = #map, n, -1 do map[i] = nil end -- drop the stale tail
|
||||
map[n] = newest
|
||||
end
|
||||
end
|
||||
|
||||
CB.result = function(self, ...)
|
||||
local map, n = self.source_line_map, #self.lines
|
||||
if type(map) == "table" then
|
||||
for i = #map, n + 1, -1 do map[i] = nil end
|
||||
end
|
||||
return original_result(self, ...)
|
||||
end
|
||||
end
|
||||
|
||||
patch_source_line_map()
|
||||
|
||||
-- Session:rendered_to_source() rounds a linear interpolation between
|
||||
-- sync points; across a multi-row image/diagram the lower rows round to
|
||||
-- the NEXT source line (dd on the bottom half of an image deleted the
|
||||
-- blank line after it). Callers of the integer version (toggle cursor
|
||||
-- placement, so every hop key; the float footer) want the exact line,
|
||||
-- so snap to the raw map. Scroll sync uses the *_f variants, untouched.
|
||||
local function patch_exact_rendered_to_source()
|
||||
local ok, preview = pcall(require, "md-render.preview")
|
||||
local S = ok and type(preview) == "table" and preview._Session or nil
|
||||
if not S or S._thembones_exact_source_patch then return end
|
||||
if type(S.rendered_to_source) ~= "function" then return end
|
||||
S._thembones_exact_source_patch = true
|
||||
local original_rendered_to_source = S.rendered_to_source
|
||||
|
||||
S.rendered_to_source = function(self, rendered_line, ...)
|
||||
local map = self.content and self.content.source_line_map
|
||||
if type(map) == "table" and #map > 0 and type(rendered_line) == "number" then
|
||||
local v = map[math.max(1, math.min(math.floor(rendered_line), #map))]
|
||||
if type(v) == "number" and v > 0 then return v end
|
||||
end
|
||||
return original_rendered_to_source(self, rendered_line, ...)
|
||||
end
|
||||
end
|
||||
|
||||
patch_exact_rendered_to_source()
|
||||
|
||||
-- md-render's auto mode hops i/I/a/A/o/O from the render view to source
|
||||
-- with buffer-local maps that toggle() and then vim.schedule() an
|
||||
-- appended feedkeys (preview.lua install_auto_insert_keymaps). Keys
|
||||
-- typed in the same burst (fast typing, a paste through typeahead) were
|
||||
-- already queued, so they ran first in source Normal mode: `ohi<Esc>`
|
||||
-- turned "# Title" into "o# Title". After auto_on() installs those maps,
|
||||
-- replace them with the same hop fed synchronously at the FRONT of the
|
||||
-- typeahead (as the editing-key hop in `init` does), keeping a count.
|
||||
-- Only maps md-render itself installed (matched by desc) are replaced,
|
||||
-- and auto_off() still removes them.
|
||||
local function patch_auto_insert_hop()
|
||||
local ok, preview = pcall(require, "md-render.preview")
|
||||
if not ok or type(preview) ~= "table" or preview._thembones_insert_hop_patch then return end
|
||||
if type(preview.auto_on) ~= "function" or type(preview._toggle_sessions) ~= "table" then return end
|
||||
preview._thembones_insert_hop_patch = true
|
||||
local original_auto_on = preview.auto_on
|
||||
|
||||
local function install(render_buf)
|
||||
local stock = {}
|
||||
for _, map in ipairs(vim.api.nvim_buf_get_keymap(render_buf, "n")) do
|
||||
stock[map.lhs] = map.desc
|
||||
end
|
||||
for _, key in ipairs({ "i", "I", "a", "A", "o", "O" }) do
|
||||
local desc = "md-render auto: switch to source then " .. key
|
||||
if stock[key] == desc then
|
||||
vim.keymap.set("n", key, function()
|
||||
local count = vim.v.count
|
||||
preview.toggle()
|
||||
if vim.bo.filetype == "md-render" then return end -- toggle refused
|
||||
vim.api.nvim_feedkeys((count > 0 and tostring(count) or "") .. key, "ni", false)
|
||||
end, { buffer = render_buf, noremap = true, silent = true, desc = desc .. " (in order)" })
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
preview.auto_on = function(...)
|
||||
original_auto_on(...)
|
||||
for src_buf, session in pairs(preview._toggle_sessions) do
|
||||
if vim.api.nvim_buf_is_valid(src_buf) and vim.b[src_buf].md_render_auto
|
||||
and session.buf and vim.api.nvim_buf_is_valid(session.buf) then
|
||||
install(session.buf)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
patch_auto_insert_hop()
|
||||
|
||||
-- md-render's Ghostty path intentionally re-transmits images on every
|
||||
-- placement so redraws stay visible. Its stock transport uses `t=f`,
|
||||
-- which means "the terminal reads this file path". Over SSH that path is
|
||||
@@ -753,6 +1040,84 @@ return {
|
||||
end
|
||||
end
|
||||
|
||||
-- md-render bug (v3.11.1, display_utils.lua place_images): image
|
||||
-- placements belong to a window, not to the render buffer in it. After
|
||||
-- :e / :b / a picker puts another file in that window, the window's
|
||||
-- WinScrolled/CursorMoved redraw keeps placing the images at the same
|
||||
-- rows over the new file. Only place them while the window still shows
|
||||
-- the buffer they were set up for, clear them when that buffer leaves
|
||||
-- the window, and put them back when it returns.
|
||||
local function patch_image_window_guard()
|
||||
local img = require("md-render.image")
|
||||
local du = require("md-render.display_utils")
|
||||
if img._thembones_win_guard_patch then return end
|
||||
img._thembones_win_guard_patch = true
|
||||
|
||||
local owner_buf = {} -- win -> buffer whose images that window shows
|
||||
local original_setup_images = du.setup_images
|
||||
du.setup_images = function(win, content, ns, opts)
|
||||
if vim.api.nvim_win_is_valid(win) then
|
||||
owner_buf[win] = opts and opts.buf or vim.api.nvim_win_get_buf(win)
|
||||
end
|
||||
return original_setup_images(win, content, ns, opts)
|
||||
end
|
||||
|
||||
local original_put_image = img.put_image
|
||||
img.put_image = function(image_id, win, ...)
|
||||
local owner = owner_buf[win]
|
||||
if owner and vim.api.nvim_win_is_valid(win) and vim.api.nvim_win_get_buf(win) ~= owner then
|
||||
return
|
||||
end
|
||||
return original_put_image(image_id, win, ...)
|
||||
end
|
||||
|
||||
local function session_for(buf)
|
||||
for _, session in pairs(require("md-render").preview._toggle_sessions or {}) do
|
||||
if session.buf == buf and session.image_state then return session end
|
||||
end
|
||||
end
|
||||
|
||||
local group = vim.api.nvim_create_augroup("MdRenderImageWindowGuard", { clear = true })
|
||||
vim.api.nvim_create_autocmd("BufWinLeave", {
|
||||
group = group,
|
||||
desc = "md-render: clear images when the render buffer leaves its window",
|
||||
callback = function(ev)
|
||||
local session = session_for(ev.buf)
|
||||
if not session then return end
|
||||
local state = session.image_state
|
||||
img.begin_batch()
|
||||
for _, id in pairs(state.image_ids or {}) do
|
||||
img.clear_placements(id)
|
||||
end
|
||||
for _, anim in pairs(state.anims or {}) do
|
||||
for _, id in ipairs(anim.frame_ids or {}) do
|
||||
img.clear_placements(id)
|
||||
end
|
||||
end
|
||||
img.flush_batch()
|
||||
end,
|
||||
})
|
||||
vim.api.nvim_create_autocmd("BufWinEnter", {
|
||||
group = group,
|
||||
desc = "md-render: re-place images when the render buffer returns",
|
||||
callback = function(ev)
|
||||
local session = session_for(ev.buf)
|
||||
if not session then return end
|
||||
local win = vim.api.nvim_get_current_win()
|
||||
if session.win == win then
|
||||
session.image_state.schedule_redraw()
|
||||
elseif not (vim.api.nvim_win_is_valid(session.win) and vim.api.nvim_win_get_buf(session.win) == session.buf) then
|
||||
-- Came back in a different window: move the images here, as
|
||||
-- md-render's own toggle does.
|
||||
session:cleanup_images()
|
||||
session:bind_window(win)
|
||||
end
|
||||
end,
|
||||
})
|
||||
end
|
||||
|
||||
patch_image_window_guard()
|
||||
|
||||
local function mermaid_sources(buf)
|
||||
local sources = {}
|
||||
local in_mermaid = false
|
||||
@@ -786,7 +1151,18 @@ return {
|
||||
|
||||
for _, source in ipairs(mermaid_sources(buf)) do
|
||||
if not image.get_mermaid_cached(source) then
|
||||
image.render_mermaid(source)
|
||||
-- Async so Esc / :w don't freeze for the mmdc run (~1s, up to 30s
|
||||
-- on the npx fallback). md-render's placement pass
|
||||
-- (display_utils.lua produce()) calls the same patched
|
||||
-- render_mermaid_async, which de-duplicates in-flight jobs per
|
||||
-- cache path (mermaid_inflight above), so it joins this job and
|
||||
-- rebuilds when the PNG lands. Until then the diagram shows
|
||||
-- md-render's "Rendering mermaid diagram..." placeholder.
|
||||
if image.render_mermaid_async then
|
||||
image.render_mermaid_async(source, function() end)
|
||||
else
|
||||
image.render_mermaid(source)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -794,6 +1170,10 @@ return {
|
||||
local function ensure_md_render_auto(buf)
|
||||
if not vim.api.nvim_buf_is_valid(buf) then return end
|
||||
if vim.bo[buf].filetype ~= "markdown" then return end
|
||||
-- Skip scratch markdown buffers (LSP hover, completion docs, noice) and
|
||||
-- buffers that aren't current: auto_on always targets the current buffer.
|
||||
if vim.bo[buf].buftype ~= "" then return end
|
||||
if vim.api.nvim_get_current_buf() ~= buf then return end
|
||||
|
||||
if not vim.b[buf].md_render_auto then
|
||||
local cache_group = vim.api.nvim_create_augroup("MdRenderMermaidCache" .. buf, { clear = true })
|
||||
@@ -803,7 +1183,7 @@ return {
|
||||
callback = function()
|
||||
prime_mermaid_cache(buf)
|
||||
end,
|
||||
desc = "Prime md-render Mermaid cache before redraw",
|
||||
desc = "Prime md-render Mermaid cache before redraw (async)",
|
||||
})
|
||||
end
|
||||
|
||||
@@ -818,7 +1198,7 @@ return {
|
||||
pcall(vim.api.nvim_win_del_var, win, "md_render_state")
|
||||
end
|
||||
|
||||
pcall(md.preview.auto_on, { max_width = 140 })
|
||||
pcall(md.preview.auto_on)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
-- Override LazyVim's indent-blankline for VS Code-like indent guides
|
||||
-- Disabled: LazyVim now draws indent guides (and the current scope) with
|
||||
-- snacks.indent ("│", toggle <leader>ug), so ibl only drew a second set.
|
||||
-- Delete the `enabled = false` line to bring ibl back.
|
||||
return {
|
||||
{
|
||||
"lukas-reineke/indent-blankline.nvim",
|
||||
enabled = false,
|
||||
main = "ibl", -- v3 module name
|
||||
opts = {
|
||||
indent = {
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
return {
|
||||
{
|
||||
"neovim/nvim-lspconfig",
|
||||
opts = function(_, opts)
|
||||
-- LazyVim maps gD unconditionally; tsgo has no textDocument/declaration.
|
||||
-- Gate it so servers without it keep Vim's built-in gD.
|
||||
table.insert(opts.servers["*"].keys, {
|
||||
"gD",
|
||||
vim.lsp.buf.declaration,
|
||||
desc = "Goto Declaration",
|
||||
has = "declaration",
|
||||
})
|
||||
-- Call hierarchy: the tool for understanding a call chain without editing.
|
||||
-- <leader>ci = who calls this (incoming); <leader>co = what this calls (outgoing).
|
||||
-- Uses Telescope's picker when present. Gated on callHierarchy support. Added 2026-10-23.
|
||||
table.insert(opts.servers["*"].keys, {
|
||||
"<leader>ci",
|
||||
function()
|
||||
local ok, tb = pcall(require, "telescope.builtin")
|
||||
if ok then tb.lsp_incoming_calls() else vim.lsp.buf.incoming_calls() end
|
||||
end,
|
||||
desc = "Incoming Calls (callers)",
|
||||
has = "callHierarchy",
|
||||
})
|
||||
table.insert(opts.servers["*"].keys, {
|
||||
"<leader>co",
|
||||
function()
|
||||
local ok, tb = pcall(require, "telescope.builtin")
|
||||
if ok then tb.lsp_outgoing_calls() else vim.lsp.buf.outgoing_calls() end
|
||||
end,
|
||||
desc = "Outgoing Calls (callees)",
|
||||
has = "callHierarchy",
|
||||
})
|
||||
end,
|
||||
},
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
return {
|
||||
{
|
||||
"mfussenegger/nvim-lint",
|
||||
optional = true,
|
||||
opts = {
|
||||
linters_by_ft = {
|
||||
markdown = {}, -- no linters for .md
|
||||
["markdown.mdx"] = {}, -- no linters for .mdx
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -21,6 +21,7 @@ return {
|
||||
opts = {
|
||||
linters_by_ft = {
|
||||
markdown = {},
|
||||
["markdown.mdx"] = {},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
-- meow.yarn.nvim — interactive, expandable call/type hierarchy TREE (like VS Code's
|
||||
-- Call Hierarchy panel), built on native LSP + nui.nvim. Added 2026-10-23 for reading
|
||||
-- call chains in the TS code-walkthrough prep. Telescope's lsp_*_calls is flat/one-level;
|
||||
-- this one expands recursively, previews code, and lets you drill in / switch direction.
|
||||
--
|
||||
-- Keys (<leader>y = "yarn"): put the cursor on a function, then
|
||||
-- <leader>yc callers (who calls this) <leader>yC callees (what this calls)
|
||||
-- <leader>yt supertypes <leader>yT subtypes
|
||||
-- <leader>yl re-open last hierarchy
|
||||
-- In the tree: <CR> jump, o/za expand, zO/zC expand/collapse all, / filter, <BS> back.
|
||||
return {
|
||||
{
|
||||
"retran/meow.yarn.nvim",
|
||||
dependencies = { "MunifTanjim/nui.nvim" },
|
||||
keys = {
|
||||
{ "<leader>y", "", desc = "+yarn (hierarchy)" },
|
||||
{ "<leader>yc", function() require("meow.yarn").open_tree("call_hierarchy", "callers") end, desc = "Yarn: callers (who calls this)" },
|
||||
{ "<leader>yC", function() require("meow.yarn").open_tree("call_hierarchy", "callees") end, desc = "Yarn: callees (what this calls)" },
|
||||
{ "<leader>yt", function() require("meow.yarn").open_tree("type_hierarchy", "supertypes") end, desc = "Yarn: supertypes" },
|
||||
{ "<leader>yT", function() require("meow.yarn").open_tree("type_hierarchy", "subtypes") end, desc = "Yarn: subtypes" },
|
||||
{ "<leader>yl", "<Plug>(MeowYarnLast)", desc = "Yarn: last hierarchy" },
|
||||
},
|
||||
opts = {},
|
||||
config = function(_, opts)
|
||||
require("meow.yarn").setup(opts)
|
||||
end,
|
||||
},
|
||||
}
|
||||
@@ -6,7 +6,7 @@ return {
|
||||
lazy = false,
|
||||
keys = {
|
||||
{ "<leader>um", "<cmd>Neominimap Toggle<cr>", desc = "Toggle minimap" },
|
||||
{ "<leader>uf", "<cmd>Neominimap Focus<cr>", desc = "Focus minimap" },
|
||||
{ "<leader>uM", "<cmd>Neominimap Focus<cr>", desc = "Focus minimap" },
|
||||
},
|
||||
init = function()
|
||||
vim.g.neominimap = {
|
||||
@@ -33,10 +33,14 @@ return {
|
||||
enabled = true,
|
||||
mode = "line", -- Highlight full line
|
||||
},
|
||||
-- Git changes come from gitsigns (see lua/plugins/git.lua).
|
||||
git = {
|
||||
enabled = true,
|
||||
mode = "line", -- Full line highlight for git changes
|
||||
},
|
||||
mini_diff = {
|
||||
enabled = false,
|
||||
},
|
||||
search = {
|
||||
enabled = true,
|
||||
mode = "line",
|
||||
|
||||
@@ -1,115 +0,0 @@
|
||||
-- Inline LLM (ghost-text) completion tuned for writing markdown/prose.
|
||||
-- Reuses ZAI_API_KEY from the environment (same key the :AI command uses).
|
||||
-- Suggestions are virtual text, auto-triggered behind a debounce delay.
|
||||
local PROSE_FT = {
|
||||
markdown = true,
|
||||
["md-render"] = true,
|
||||
text = true,
|
||||
rst = true,
|
||||
tex = true,
|
||||
gitcommit = true,
|
||||
mail = true,
|
||||
}
|
||||
|
||||
return {
|
||||
"milanglacier/minuet-ai.nvim",
|
||||
dependencies = { "nvim-lua/plenary.nvim" },
|
||||
-- Load eagerly: minuet only sets its buffer-local auto-trigger flag from a
|
||||
-- FileType autocmd registered in setup(). Lazy-loading on InsertEnter would
|
||||
-- register that autocmd *after* the current buffer's FileType already fired,
|
||||
-- so virtualtext would never auto-trigger on the buffer you're editing.
|
||||
lazy = false,
|
||||
opts = {
|
||||
provider = "openai_compatible",
|
||||
-- One natural continuation, not three alternatives — prose has a single
|
||||
-- "next sentence", and fewer candidates means less to read past.
|
||||
n_completions = 1,
|
||||
-- Give the model more of the text *before* the cursor (default 0.75).
|
||||
context_ratio = 0.85,
|
||||
-- Cap how much surrounding text is sent. Smaller = lower, steadier latency
|
||||
-- (the full default of 16000 chars is overkill for prose continuation and
|
||||
-- inflates time-to-first-token). 4000 chars ≈ plenty of preceding context.
|
||||
context_window = 4000,
|
||||
-- Delay knobs: wait for an idle pause, and rate-limit requests. Groq is fast
|
||||
-- and deterministic, so we can afford a snappier debounce than the cloud
|
||||
-- defaults; throttle stays moderate to respect the free-tier rate limit.
|
||||
throttle = 800, -- min ms between requests
|
||||
debounce = 400, -- ms of idle typing before a request fires
|
||||
provider_options = {
|
||||
openai_compatible = {
|
||||
api_key = "GROQ_API_KEY", -- env var NAME; minuet reads it at runtime
|
||||
name = "Groq",
|
||||
-- Groq's LPU inference gives ~80-100ms time-to-first-token with very low
|
||||
-- variance — that consistency is the whole reason for moving off Z.AI's
|
||||
-- hit-or-miss coding endpoint. OpenAI-compatible, so the schema is unchanged.
|
||||
end_point = "https://api.groq.com/openai/v1/chat/completions",
|
||||
-- llama-3.3-70b is Groq's flagship general model: strong prose, still fast
|
||||
-- on their hardware. If you ever want the absolute lowest latency, swap to
|
||||
-- "llama-3.1-8b-instant" (faster, slightly weaker prose).
|
||||
model = "llama-3.3-70b-versatile",
|
||||
-- Swap minuet's "code completion engine" system prompt for a prose one
|
||||
-- in writing filetypes; keep the default (string) for code. Guidelines
|
||||
-- and few-shots are left at defaults so minuet's <endCompletion> parsing
|
||||
-- still works.
|
||||
system = {
|
||||
prompt = function()
|
||||
if PROSE_FT[vim.bo.filetype] then
|
||||
return [[
|
||||
You are a prose writing assistant embedded in a text editor. Continue the
|
||||
author's text at the <cursorPosition> marker naturally and fluently, matching
|
||||
their voice, tone, and sentence rhythm.
|
||||
|
||||
- Output ONLY the continuation text — no preamble, no explanation.
|
||||
- Never wrap the output in markdown code fences or backticks.
|
||||
- Do not add headings, bullets, or numbering unless the surrounding text
|
||||
already uses them.
|
||||
- Keep it to at most 1-3 sentences and stop at a natural boundary.]]
|
||||
end
|
||||
return require("minuet.config").default_system_prefix_first.prompt
|
||||
end,
|
||||
},
|
||||
optional = {
|
||||
-- Short, focused completions. (No `thinking` field here — that was a
|
||||
-- Z.AI-specific param; Groq's Llama models 400 on unknown body fields.)
|
||||
max_tokens = 96,
|
||||
temperature = 0.3,
|
||||
},
|
||||
},
|
||||
},
|
||||
virtualtext = {
|
||||
auto_trigger_ft = { "*" },
|
||||
-- Alt keymaps are kept as a secondary path, but the primary accept key is
|
||||
-- <Tab>, wired in config() below (Alt+* doesn't fire in Ghostty without
|
||||
-- macos-option-as-alt, and Tab is the natural "accept" key for prose).
|
||||
keymap = {
|
||||
accept = "<A-y>", -- accept full suggestion
|
||||
accept_line = "<A-l>", -- accept one line
|
||||
prev = "<A-[>",
|
||||
next = "<A-]>",
|
||||
dismiss = "<A-e>",
|
||||
},
|
||||
},
|
||||
},
|
||||
config = function(_, opts)
|
||||
require("minuet").setup(opts)
|
||||
|
||||
-- Smart <Tab>: accept a visible minuet ghost-text suggestion; otherwise fall
|
||||
-- back to the exact super-tab behavior we had before (jump an active snippet,
|
||||
-- else insert a literal Tab). Blink's menu navigates with <C-n>/<C-p>, not
|
||||
-- Tab, so this doesn't fight the completion popup.
|
||||
local vt = require("minuet.virtualtext").action
|
||||
vim.keymap.set("i", "<Tab>", function()
|
||||
if vt.is_visible() then
|
||||
vt.accept()
|
||||
elseif vim.snippet.active({ direction = 1 }) then
|
||||
vim.snippet.jump(1)
|
||||
else
|
||||
vim.api.nvim_feedkeys(
|
||||
vim.api.nvim_replace_termcodes("<Tab>", true, false, true),
|
||||
"n",
|
||||
false
|
||||
)
|
||||
end
|
||||
end, { desc = "minuet: accept suggestion, else snippet jump / Tab" })
|
||||
end,
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
-- Navigation enhancement plugins
|
||||
-- (neoscroll removed due to conflicts with smear-cursor)
|
||||
return {}
|
||||
@@ -10,5 +10,9 @@ return {
|
||||
|
||||
opts.filesystem.filtered_items.always_show = opts.filesystem.filtered_items.always_show or {}
|
||||
table.insert(opts.filesystem.filtered_items.always_show, "*.log")
|
||||
|
||||
-- 60% of neo-tree's default 40-column width
|
||||
opts.window = opts.window or {}
|
||||
opts.window.width = 24
|
||||
end,
|
||||
}
|
||||
@@ -1,5 +1,9 @@
|
||||
-- Disabled: neo-tree (LazyVim editor.neo-tree extra, customised in
|
||||
-- neo-tree-extras.lua) is the file explorer. Both specs claimed <leader>e and
|
||||
-- which one won changed from start to start. Delete `enabled = false` to restore.
|
||||
return {
|
||||
"nvim-tree/nvim-tree.lua",
|
||||
enabled = false,
|
||||
dependencies = {
|
||||
"nvim-tree/nvim-web-devicons",
|
||||
},
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
-- Pin refactoring.nvim (LazyVim editor.refactoring extra) on Neovim < 0.12.5.
|
||||
--
|
||||
-- Since abdcad8 (2026-09-23) refactoring.nvim calls the core vim.pos(buf, row, col) and
|
||||
-- vim.range(buf, start_row, start_col, end_row, end_col). Neovim only takes buf first from
|
||||
-- 0.12.5 on (upstream README: "requires Neovim 0.12.5"); 0.12.0-0.12.4 expect
|
||||
-- vim.range(start_row, start_col, end_row, end_col, { buf = buf }), so every refactor fails
|
||||
-- with "vim/range.lua:98: attempt to index local 'opts' (a number value)".
|
||||
-- 8bcf893 is the parent of abdcad8 and the last upstream commit that ships its own
|
||||
-- refactoring.pos/refactoring.range with the buf-first API; the two commits after it on master
|
||||
-- are CI/docs only. Pinning in the spec (not just lazy-lock.json) keeps :Lazy update from
|
||||
-- moving it back to the broken commit.
|
||||
--
|
||||
-- Remove this file once Neovim is >= 0.12.5 (the guard below already stops pinning there),
|
||||
-- then run :Lazy update refactoring.nvim.
|
||||
if vim.fn.has("nvim-0.12.5") == 1 then
|
||||
return {}
|
||||
end
|
||||
|
||||
return {
|
||||
{ "ThePrimeagen/refactoring.nvim", commit = "8bcf893eb3871bc87b42adffe2fb9b0b7dc9d328" },
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
return {
|
||||
{
|
||||
"ThePrimeagen/refactoring.nvim",
|
||||
dependencies = {
|
||||
"nvim-lua/plenary.nvim",
|
||||
"nvim-treesitter/nvim-treesitter",
|
||||
"lewis6991/async.nvim",
|
||||
},
|
||||
ft = { "lua", "python", "javascript", "typescript", "go", "c", "cpp", "java", "php", "ruby" },
|
||||
config = function()
|
||||
require("refactoring").setup()
|
||||
end,
|
||||
},
|
||||
}
|
||||
@@ -7,8 +7,10 @@ return {
|
||||
event = "VeryLazy",
|
||||
enabled = true, -- Set to false to disable
|
||||
keys = {
|
||||
{ "n", [[<Cmd>execute('normal! ' . v:count1 . 'n')<CR><Cmd>lua require('hlslens').start()<CR>]], desc = "Next search result" },
|
||||
{ "N", [[<Cmd>execute('normal! ' . v:count1 . 'N')<CR><Cmd>lua require('hlslens').start()<CR>]], desc = "Previous search result" },
|
||||
-- n/N keep LazyVim's direction-stable behaviour (n always searches
|
||||
-- forward, N backward, even after `?`) and open folds (zv).
|
||||
{ "n", [[<Cmd>execute('normal! ' . v:count1 . 'Nn'[v:searchforward] . 'zv')<CR><Cmd>lua require('hlslens').start()<CR>]], desc = "Next Search Result" },
|
||||
{ "N", [[<Cmd>execute('normal! ' . v:count1 . 'nN'[v:searchforward] . 'zv')<CR><Cmd>lua require('hlslens').start()<CR>]], desc = "Prev Search Result" },
|
||||
{ "*", [[*<Cmd>lua require('hlslens').start()<CR>]], desc = "Search word under cursor" },
|
||||
{ "#", [[#<Cmd>lua require('hlslens').start()<CR>]], desc = "Search word under cursor (backward)" },
|
||||
{ "g*", [[g*<Cmd>lua require('hlslens').start()<CR>]], desc = "Search word under cursor (no boundary)" },
|
||||
@@ -37,22 +39,36 @@ return {
|
||||
default_replace_single_buffer_options = "gcI",
|
||||
default_replace_multi_buffer_options = "egcI",
|
||||
},
|
||||
-- Under <leader>R: <leader>r belongs to LazyVim's refactoring extra
|
||||
-- (<leader>rs and <leader>rf collided). Selection maps use mode "x", not
|
||||
-- "v", so typing a space over a Shift+arrow (Select mode) selection
|
||||
-- doesn't wait for a <leader> mapping.
|
||||
keys = {
|
||||
-- Single buffer replacements
|
||||
{ "<leader>rs", "<CMD>SearchReplaceSingleBufferSelections<CR>", desc = "Search/Replace Selections", mode = "v" },
|
||||
{ "<leader>ro", "<CMD>SearchReplaceSingleBufferOpen<CR>", desc = "Search/Replace Open" },
|
||||
{ "<leader>rw", "<CMD>SearchReplaceSingleBufferCWord<CR>", desc = "Search/Replace Word" },
|
||||
{ "<leader>rW", "<CMD>SearchReplaceSingleBufferCWORD<CR>", desc = "Search/Replace WORD" },
|
||||
{ "<leader>re", "<CMD>SearchReplaceSingleBufferCExpr<CR>", desc = "Search/Replace Expr" },
|
||||
{ "<leader>rf", "<CMD>SearchReplaceSingleBufferCFile<CR>", desc = "Search/Replace File" },
|
||||
{ "<leader>Rs", "<CMD>SearchReplaceSingleBufferSelections<CR>", desc = "Search/Replace Selections", mode = "x" },
|
||||
{ "<leader>Ro", "<CMD>SearchReplaceSingleBufferOpen<CR>", desc = "Search/Replace Open" },
|
||||
{ "<leader>Rw", "<CMD>SearchReplaceSingleBufferCWord<CR>", desc = "Search/Replace Word" },
|
||||
{ "<leader>RW", "<CMD>SearchReplaceSingleBufferCWORD<CR>", desc = "Search/Replace WORD" },
|
||||
{ "<leader>Re", "<CMD>SearchReplaceSingleBufferCExpr<CR>", desc = "Search/Replace Expr" },
|
||||
{ "<leader>Rf", "<CMD>SearchReplaceSingleBufferCFile<CR>", desc = "Search/Replace File" },
|
||||
|
||||
-- Multi buffer replacements
|
||||
{ "<leader>rbs", "<CMD>SearchReplaceMultiBufferSelections<CR>", desc = "Search/Replace Selections (Multi)", mode = "v" },
|
||||
{ "<leader>rbo", "<CMD>SearchReplaceMultiBufferOpen<CR>", desc = "Search/Replace Open (Multi)" },
|
||||
{ "<leader>rbw", "<CMD>SearchReplaceMultiBufferCWord<CR>", desc = "Search/Replace Word (Multi)" },
|
||||
{ "<leader>rbW", "<CMD>SearchReplaceMultiBufferCWORD<CR>", desc = "Search/Replace WORD (Multi)" },
|
||||
{ "<leader>rbe", "<CMD>SearchReplaceMultiBufferCExpr<CR>", desc = "Search/Replace Expr (Multi)" },
|
||||
{ "<leader>rbf", "<CMD>SearchReplaceMultiBufferCFile<CR>", desc = "Search/Replace File (Multi)" },
|
||||
{ "<leader>Rbs", "<CMD>SearchReplaceMultiBufferSelections<CR>", desc = "Search/Replace Selections (Multi)", mode = "x" },
|
||||
{ "<leader>Rbo", "<CMD>SearchReplaceMultiBufferOpen<CR>", desc = "Search/Replace Open (Multi)" },
|
||||
{ "<leader>Rbw", "<CMD>SearchReplaceMultiBufferCWord<CR>", desc = "Search/Replace Word (Multi)" },
|
||||
{ "<leader>RbW", "<CMD>SearchReplaceMultiBufferCWORD<CR>", desc = "Search/Replace WORD (Multi)" },
|
||||
{ "<leader>Rbe", "<CMD>SearchReplaceMultiBufferCExpr<CR>", desc = "Search/Replace Expr (Multi)" },
|
||||
{ "<leader>Rbf", "<CMD>SearchReplaceMultiBufferCFile<CR>", desc = "Search/Replace File (Multi)" },
|
||||
},
|
||||
},
|
||||
{
|
||||
"folke/which-key.nvim",
|
||||
optional = true,
|
||||
opts = {
|
||||
spec = {
|
||||
{ "<leader>R", group = "search/replace", mode = { "n", "x" } },
|
||||
{ "<leader>Rb", group = "multi-buffer", mode = { "n", "x" } },
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
-- TypeScript LSP: LazyVim's lang.typescript.tsc extra runs lspconfig's `tsc`
|
||||
-- server (`tsc --lsp`), which already prefers a project-local
|
||||
-- node_modules/.bin/tsc that supports --lsp (TypeScript >= 7) and disables
|
||||
-- tsgo, so no server override is needed here.
|
||||
return {
|
||||
{
|
||||
"nvim-neotest/neotest",
|
||||
optional = true,
|
||||
dependencies = { "marilari88/neotest-vitest" },
|
||||
opts = {
|
||||
adapters = {
|
||||
["neotest-vitest"] = {},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
-- Inlay hints: show inferred TYPES inline while reading code. LazyVim's tsc extra
|
||||
-- turns variableTypes/functionLikeReturnTypes OFF by default (noisy); for reading an
|
||||
-- unfamiliar TS codebase (interview walkthroughs) the inferred types inline are the
|
||||
-- point, so turn them back on. Toggle the whole thing live with <leader>uh.
|
||||
-- Added 2026-10-23.
|
||||
{
|
||||
"neovim/nvim-lspconfig",
|
||||
opts = {
|
||||
servers = {
|
||||
tsc = {
|
||||
settings = {
|
||||
["js/ts"] = {
|
||||
inlayHints = {
|
||||
variableTypes = { enabled = true },
|
||||
functionLikeReturnTypes = { enabled = true },
|
||||
parameterNames = { enabled = "all", suppressWhenArgumentMatchesName = true },
|
||||
parameterTypes = { enabled = true },
|
||||
propertyDeclarationTypes = { enabled = true },
|
||||
enumMemberValues = { enabled = true },
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
-- Turn inlay hints ON by default, but only for TS/JS buffers, so Go/Python/etc. are
|
||||
-- unaffected. <leader>uh still toggles per buffer.
|
||||
{
|
||||
"neovim/nvim-lspconfig",
|
||||
opts = function()
|
||||
vim.api.nvim_create_autocmd("LspAttach", {
|
||||
callback = function(args)
|
||||
local ft = vim.bo[args.buf].filetype
|
||||
if ft:match("^typescript") or ft:match("^javascript") then
|
||||
pcall(vim.lsp.inlay_hint.enable, true, { bufnr = args.buf })
|
||||
end
|
||||
end,
|
||||
})
|
||||
end,
|
||||
},
|
||||
}
|
||||
@@ -7,6 +7,11 @@ return {
|
||||
enabled = true,
|
||||
dependencies = { "nvim-treesitter/nvim-treesitter", "nvim-tree/nvim-web-devicons" },
|
||||
opts = {
|
||||
-- md-render.nvim (lua/plugins/image.lua) owns the rendered view of
|
||||
-- markdown files; the source buffer is what you edit, so keep it
|
||||
-- plain. render-markdown still decorates nofile floats (LSP hover,
|
||||
-- completion docs). Re-enable per buffer with :RenderMarkdown buf_toggle.
|
||||
overrides = { buftype = { [""] = { enabled = false } } },
|
||||
render_modes = { "n", "i", "c", "t" },
|
||||
heading = {
|
||||
enabled = true,
|
||||
|
||||
Reference in new issue
Block a user