Compare commits

..
1 Commits
Author SHA1 Message Date
Job79 8f6e78bc02 feat: add extra debugger shortcuts 2026-08-29 17:29:58 +02:00
12 changed files with 526 additions and 382 deletions

No files matched your search

+17 -13
View File
@@ -1,20 +1,24 @@
-- Modules
-- Modules =====================================================================
vim.loader.enable()
vim.opt.runtimepath:remove('/usr/share/nvim/site')
vim.g.loaded_netrwPlugin = 1
vim.opt.runtimepath:remove("/usr/share/nvim/site")
vim.opt.runtimepath:remove("/usr/share/nvim/site/after")
for _, m in ipairs({ "netrw", "netrwPlugin", "gzip", "tarPlugin", "zipPlugin", "tutor_mode_plugin" }) do
vim.g["loaded_" .. m] = 1 -- Block unused built-in modules
end
-- Config Global
vim.pack.add({ 'https://github.com/nvim-mini/mini.nvim' })
local misc = require('mini.misc')
local gr = vim.api.nvim_create_augroup('custom-config', {})
-- Config Global ===============================================================
vim.pack.add({ "https://github.com/nvim-mini/mini.nvim" })
local misc = require("mini.misc")
local gr = vim.api.nvim_create_augroup("custom-config", {})
_G.Config = {
now = function(f) misc.safely('now', f) end,
later = function(f) misc.safely('later', f) end,
now = function(f) misc.safely("now", f) end,
later = function(f) misc.safely("later", f) end,
on_event = function(ev, f) misc.safely("event:" .. ev, f) end,
on_filetype = function(ft, f) misc.safely("filetype:" .. ft, f) end,
autocmd = function(event, pattern, callback, desc, once)
vim.api.nvim_create_autocmd(event, { group = gr, pattern = pattern, callback = callback, desc = desc, once = once })
end,
command = function(name, callback, desc, opts)
vim.api.nvim_create_user_command(name, callback, vim.tbl_extend('force', { desc = desc }, opts or {}))
end,
end
}
Config.now_if_args = vim.fn.argc(-1) > 0 and Config.now or Config.later
-106
View File
@@ -1,106 +0,0 @@
local ns = vim.api.nvim_create_namespace('git')
local status_hl = { M = 'DiagnosticWarn', A = 'DiagnosticOk', D = 'DiagnosticError', ['?'] = 'DiagnosticInfo' }
local function git(args)
local result = vim.system(vim.list_extend({ 'git', '-c', 'core.quotepath=false' }, args)):wait()
if result.code ~= 0 then error(vim.trim(result.stderr), 0) end
return result.stdout
end
-- Picker lines look like ' M path'; colour the status letter
local function show(buf, items, query)
MiniPick.default_show(buf, items, query)
vim.api.nvim_buf_clear_namespace(buf, ns, 0, -1)
for i, item in ipairs(items) do
vim.api.nvim_buf_set_extmark(buf, ns, i - 1, 1, { end_col = 2, hl_group = status_hl[item.status], priority = 202, hl_mode = 'combine' })
end
end
-- Diff the current file against its staged version
local function diff()
vim.cmd('diffthis')
vim.cmd('vertical Git show :./%')
vim.cmd('diffthis')
end
-- Pick an unstaged file; picking a deleted file stages the deletion
local function status()
local items = {}
for _, line in ipairs(vim.split(git({ 'status', '--short', '--untracked-files' }), '\n', { trimempty = true })) do
local s = line:sub(2, 2)
local path = line:sub(4):gsub('.* %-> ', ''):gsub('^"(.*)"$', '%1')
if s ~= ' ' then table.insert(items, { status = s, path = path, text = ' ' .. s .. ' ' .. path }) end
end
local function choose(item)
if vim.uv.fs_stat(item.path) then return MiniPick.default_choose(item) end
git({ 'add', '--', item.path })
end
MiniPick.start({ source = { name = 'Git status', items = items, show = show, choose = choose } })
end
-- Write `path` as it is at `rev` to a temp file (empty if it doesn't exist there)
local function file_at(rev, path)
local file = vim.fn.tempname() .. '/' .. path
vim.fn.mkdir(vim.fs.dirname(file), 'p')
local content = rev and vim.F.npcall(git, { 'show', rev .. ':' .. path }) or ''
vim.fn.writefile(vim.split(content, '\n'), file, 'b')
return file
end
-- Open `right` in the current window and diff it against `left` in a split, replacing the previous split
local split
local function open_diff(left, right)
if split and vim.api.nvim_win_is_valid(split) then vim.api.nvim_win_close(split, true) end
vim.cmd('edit ' .. vim.fn.fnameescape(right))
vim.cmd('leftabove vertical diffsplit ' .. vim.fn.fnameescape(left))
split = vim.api.nvim_get_current_win()
vim.cmd('wincmd p')
end
-- Last review, refreshed by `review()` without args
local last = {}
-- Review changes since the merge-base with `base` (default @{upstream}, i.e. unpushed commits) up to `head`.
-- Without `head` the working tree is used, so the right side is your real, editable file.
local function review(base, head)
if base or not last.base then last = { base = base or '@{upstream}', head = head, seen = {} } end
local root = vim.trim(git({ 'rev-parse', '--show-toplevel' }))
local merge_base = vim.trim(git({ 'merge-base', last.base, last.head or 'HEAD' }))
local range = last.head and (merge_base .. '..' .. last.head) or merge_base
local items = {}
for _, line in ipairs(vim.split(git({ 'diff', '--name-status', '--no-renames', range }), '\n', { trimempty = true })) do
local s, path = line:match('^(%a)\t(.*)$')
table.insert(items, { status = s, path = path, text = ' ' .. s .. ' ' .. path })
end
-- ✓ is drawn on display (not part of the text) so it stays current when the picker is resumed
local function show_seen(buf, shown, query)
show(buf, shown, query)
for i, item in ipairs(shown) do
if last.seen[item.path] then
vim.api.nvim_buf_set_extmark(buf, ns, i - 1, 3, { virt_text = { { '✓' } }, virt_text_pos = 'overlay' })
end
end
end
local function preview(buf, item)
vim.api.nvim_buf_set_lines(buf, 0, -1, false, vim.split(git({ 'diff', range, '--', ':/' .. item.path }), '\n'))
vim.bo[buf].filetype = 'diff'
end
local function choose(item)
last.seen[item.path] = true
local real_file = root .. '/' .. item.path
local left = file_at(merge_base, item.path)
local right = (not last.head and vim.uv.fs_stat(real_file)) and real_file or file_at(last.head, item.path)
vim.schedule(function() open_diff(left, right) end)
end
local name = 'Review ' .. last.base .. '..' .. (last.head or 'worktree')
MiniPick.start({ source = { name = name, items = items, show = show_seen, preview = preview, choose = choose } })
end
return { status = status, diff = diff, review = review }
+41
View File
@@ -0,0 +1,41 @@
local M = {}
local function run_task(cmd)
vim.notify("󰑮 Running: " .. cmd)
vim.cmd("enew")
local buf = vim.api.nvim_get_current_buf()
pcall(vim.api.nvim_buf_set_name, buf, "just://" .. cmd)
vim.fn.termopen(cmd, {
on_exit = function(_, code)
if code == 0 then
vim.notify("󰄬 " .. cmd .. " success")
pcall(vim.cmd, "bdelete!")
else
vim.notify("󰅚 " .. cmd .. " failed (" .. code .. ")", vim.log.levels.ERROR)
end
end,
})
end
--- Interactive picker for selecting and running tasks defined in a Justfile.
function M.pick_just_task()
local obj = vim.system({ "just", "--summary" }, { text = true }):wait()
if obj.code ~= 0 or not obj.stdout or obj.stdout == "" then
return vim.notify("No recipes or justfile found", vim.log.levels.WARN)
end
local recipes = vim.split(vim.trim(obj.stdout), "%s+")
require("mini.pick").start({
source = {
items = recipes,
name = "󱁤 Just Tasks",
choose = function(choice)
run_task("just " .. choice)
end,
},
})
end
return M
+13
View File
@@ -0,0 +1,13 @@
local M = {}
--- Opens a TUI application in a new scratch buffer and deletes the buffer on exit.
function M.open_terminal_app(cmd)
vim.cmd("enew")
vim.fn.termopen(cmd, {
on_exit = function()
pcall(vim.cmd, "bdelete!")
end,
})
end
return M
+13 -9
View File
@@ -4,25 +4,29 @@
"rev": "016802de402556da54c36bd7359b441266b01cdd",
"src": "https://github.com/stevearc/conform.nvim"
},
"mason.nvim": {
"rev": "2a6940af80375532e5e9e7c1f2fc6319a1b7a69d",
"src": "https://github.com/mason-org/mason.nvim"
},
"mini.nvim": {
"rev": "6d5a29e86a7352739506c28e0bc50fe214b5216f",
"rev": "fb2bbae327f3c306f3c825031345b89dd176ce60",
"src": "https://github.com/nvim-mini/mini.nvim"
},
"nvim-dap": {
"rev": "cfa2d58f4537aca6ca83e2de1a0d9f1491121264",
"src": "https://github.com/mfussenegger/nvim-dap"
"neovim": {
"rev": "ff483051a47e27d84bdef47703538df1ed9f4a47",
"src": "https://github.com/rose-pine/neovim"
},
"nvim-lspconfig": {
"rev": "d8d2fda7aae57030452ce8cd6e770b1eb704514e",
"rev": "684cb45c2faa24ce463b4fe9aaf011bfe1e0fb26",
"src": "https://github.com/neovim/nvim-lspconfig"
},
"nvim-treesitter": {
"rev": "a9c4e1457e2e59f1b82c8f78dcdb3b2517555200",
"rev": "857651fce37eba032ebe28f3a206283cdc65c45a",
"src": "https://github.com/nvim-treesitter/nvim-treesitter"
},
"rose-pine": {
"rev": "ff483051a47e27d84bdef47703538df1ed9f4a47",
"src": "https://github.com/rose-pine/neovim"
"nvim-treesitter-textobjects": {
"rev": "898ee307df58f854d11cd7edd06472574d48014e",
"src": "https://github.com/nvim-treesitter/nvim-treesitter-textobjects"
}
}
}
+67 -41
View File
@@ -1,58 +1,84 @@
-- General
vim.g.mapleader = ' ' -- Use <Space> as <Leader> key
vim.o.undofile = true -- Keep undo history after closing files
vim.o.shada = "'50,<20,s10,:100,/50,@50,h,r/tmp/" -- Fewer saved items (faster startup), skip /tmp files
-- General =====================================================================
vim.g.mapleader = ' ' -- Use `<Space>` as <Leader> key
vim.o.undofile = true -- Enable persistent undo
vim.o.shada = "'100,<50,s10,:1000,/100,@100,h" -- Limit ShaDa file (for startup)
-- UI
vim.o.number = true -- Show line numbers
vim.o.cursorline = true -- Highlight the line the cursor is on
vim.o.signcolumn = 'yes' -- Always show sign column (no text shifting)
vim.o.wrap = false -- Don't wrap long lines
vim.o.list = true -- Show tabs, trailing spaces and nbsp
vim.o.listchars = 'tab:→ ,trail:·,nbsp:␣' -- Symbols used for those characters
vim.o.fillchars = 'eob: ' -- Hide `~` on lines after end of buffer
vim.o.splitbelow = true -- Open horizontal splits below
vim.o.splitright = true -- Open vertical splits to the right
vim.o.splitkeep = 'screen' -- Keep text in place when opening splits
vim.o.cmdheight = 0 -- Hide command line when not typing a command
vim.o.shortmess = 'CFOSWacou' -- Hide completion, search count, undo and write messages
vim.cmd.syntax('off') -- Disable legacy syntax (treesitter handles highlighting)
require('vim._core.ui2').enable({ -- New message/cmdline UI, messages in float (nightly)
msg = { targets = 'msg' }
-- UI ==========================================================================
vim.o.breakindent = true -- Indent wrapped lines to match line start
vim.o.breakindentopt = 'list:-1' -- Add padding for lists (if 'wrap' is set)
vim.o.cursorline = true -- Enable current line highlighting
vim.o.linebreak = true -- Wrap lines at 'breakat' (if 'wrap' is set)
vim.o.list = true -- Show helpful text indicators
vim.o.number = true -- Show line numbers
vim.o.pumheight = 10 -- Make popup menu smaller
vim.o.pummaxwidth = 100 -- Make popup menu not too wide
vim.o.shortmess = 'CFOSWaco' -- Disable some built-in completion messages
vim.o.signcolumn = 'yes' -- Always show signcolumn (less flicker)
vim.o.splitbelow = true -- Horizontal splits will be below
vim.o.splitkeep = 'screen' -- Reduce scroll during window split
vim.o.splitright = true -- Vertical splits will be to the right
vim.o.wrap = false -- Don't visually wrap lines (toggle with \w)
vim.o.cmdheight = 0 -- Hide the command line when not in use
vim.cmd('syntax off') -- Disable legacy syntax highlighting
require("vim._core.ui2").enable({ -- Enable new ui (requires nightly)
msg = { targets = "msg" }
})
-- Editing
vim.o.expandtab = true -- Insert spaces when pressing <Tab>
vim.o.shiftwidth = 2 -- Spaces per indent level (>>, <<, autoindent)
vim.o.tabstop = 2 -- Display width of a tab character
vim.o.ignorecase = true -- Ignore case when searching
vim.o.smartcase = true -- ...unless the pattern contains uppercase
vim.o.virtualedit = 'block' -- Allow cursor past end of line in visual block
vim.o.spelloptions = 'camel' -- Spell-check camelCase words per part
-- Editing =====================================================================
vim.o.expandtab = true -- Convert tabs to spaces
vim.o.formatoptions = 'rqnl1j' -- Improve comment editing
vim.o.ignorecase = true -- Ignore case during search
vim.o.infercase = true -- Infer case in built-in completion
vim.o.shiftwidth = 2 -- Use this number of spaces for indentation
vim.o.smartcase = true -- Respect case if search pattern has upper case
vim.o.spelloptions = 'camel' -- Treat camelCase word parts as separate words
vim.o.tabstop = 2 -- Show tab as this number of spaces
vim.o.virtualedit = 'block' -- Allow going past end of line in blockwise mode
vim.opt.autoread = true -- Do not prompt to reread files on update
-- Completion
vim.o.complete = '.,w,b,kspell' -- Complete from buffer, windows, buffers, spell
vim.o.completeopt = 'menuone,noselect,fuzzy,popup' -- Show menu for one match, don't preselect, fuzzy match, description popup
vim.o.pumheight = 10 -- Max items visible in completion popup
vim.o.pummaxwidth = 120 -- Max width of completion popup
-- Pattern for a start of numbered list (used in `gw`).
vim.o.formatlistpat = [[^\s*[0-9\-\+\*]\+[\.\)]*\s\+]]
-- Autocommands
-- Built-in completion
vim.o.complete = '.,w,b,kspell' -- Use less sources
vim.o.completeopt = 'menuone,noselect,fuzzy,nosort' -- Use custom behavior
vim.o.completetimeout = 100 -- Limit sources delay
-- Autocommands ================================================================
Config.autocmd('TextYankPost', '*', function() vim.hl.hl_op() end, 'Highlight yanked text')
Config.autocmd('TermOpen', '*', function() vim.cmd('startinsert') end, 'Start insert mode when terminal opens')
Config.autocmd('LspAttach', '*', function(ev) vim.bo[ev.buf].complete = 'o' end, 'Use lsp completions')
-- Diagnostics
-- Diagnostics =================================================================
Config.later(function()
vim.diagnostic.config({
jump = { on_jump = vim.diagnostic.open_float },
signs = {
priority = 9999,
severity = { min = vim.diagnostic.severity.INFO },
severity = { min = 'WARN', max = 'ERROR' },
text = {
[vim.diagnostic.severity.ERROR] = '',
[vim.diagnostic.severity.WARN] = '',
[vim.diagnostic.severity.INFO] = '',
[vim.diagnostic.severity.ERROR] = ' ',
[vim.diagnostic.severity.WARN] = ' ',
[vim.diagnostic.severity.INFO] = ' ',
[vim.diagnostic.severity.HINT] = '',
},
},
underline = { severity = { min = 'HINT', max = 'ERROR' } },
virtual_lines = false,
virtual_text = {
current_line = true,
severity = { min = 'ERROR', max = 'ERROR' },
},
update_in_insert = false,
})
local dap_signs = {
DapBreakpoint = { text = '', texthl = 'DapBreakpoint', linehl = '', numhl = '' },
DapBreakpointCondition = { text = '', texthl = 'DapBreakpointCondition', linehl = '', numhl = '' },
DapLogPoint = { text = '', texthl = 'DapLogPoint', linehl = '', numhl = '' },
DapStopped = { text = '', texthl = 'DapStopped', linehl = 'DapStoppedLine', numhl = '' },
DapBreakpointRejected = { text = '', texthl = 'DapBreakpointRejected', linehl = '', numhl = '' },
}
for name, sign in pairs(dap_signs) do
vim.fn.sign_define(name, sign)
end
end)
+121 -44
View File
@@ -1,55 +1,132 @@
-- Clues
-- Clues =======================================================================
Config.leader_group_clues = {
{ mode = 'n', keys = '<Leader>d', desc = '+Debug' },
{ mode = 'n', keys = '<Leader>e', desc = '+Explore' },
{ mode = 'n', keys = '<Leader>f', desc = '+Find' },
{ mode = { 'n', 'x' }, keys = '<Leader>g', desc = '+Git' },
{ mode = "n", keys = "<Leader>b", desc = "+Buffer" },
{ mode = "n", keys = "<Leader>d", desc = "+Debug" },
{ mode = "n", keys = "<Leader>e", desc = "+Explore" },
{ mode = "n", keys = "<Leader>f", desc = "+Find" },
{ mode = "n", keys = "<Leader>g", desc = "+Git" },
{ mode = "n", keys = "<Leader>h", desc = "+Http" },
{ mode = "n", keys = "<Leader>l", desc = "+Language" },
{ mode = "n", keys = "<Leader>r", desc = "+Run" },
{ mode = "n", keys = "<Leader>s", desc = "+Session" },
{ mode = "n", keys = "<Leader>t", desc = "+Terminal" },
{ mode = "x", keys = "<Leader>g", desc = "+Git" },
{ mode = "x", keys = "<Leader>l", desc = "+Language" },
}
-- Keymap Helpers
local leader = function(suffix, rhs, desc, mode)
vim.keymap.set(mode or 'n', '<Leader>' .. suffix, rhs, { desc = desc, silent = true })
-- Helpers =====================================================================
local function lazy_wrap(name, action)
return function()
if Config["setup_" .. name] then Config["setup_" .. name]() end
action()
end
end
-- Debug
leader('db', function() require('dap').toggle_breakpoint() end, 'Toggle Breakpoint')
leader('dc', function() require('dap').continue() end, 'Run/Continue')
leader('dC', function() require('dap').run_to_cursor() end, 'Run to Cursor')
leader('di', function() require('dap.ui.widgets').hover() end, 'Inspect')
leader('dt', function() require('dap').terminate() end, 'Terminate')
-- Explore
local explore_at_file = function()
local file = vim.api.nvim_buf_get_name(0)
MiniFiles.open(vim.uv.fs_stat(file) and file or nil)
local nmap = function(lhs, rhs, desc, plugin)
local final_rhs = plugin and lazy_wrap(plugin, rhs) or rhs
vim.keymap.set("n", lhs, final_rhs, { desc = desc })
end
local yank_path = function(modifier)
return function() vim.fn.setreg('+', vim.fn.fnamemodify(vim.api.nvim_buf_get_name(0), modifier)) end
local tmap = function(lhs, rhs, desc, plugin)
local final_rhs = plugin and lazy_wrap(plugin, rhs) or rhs
vim.keymap.set("t", lhs, final_rhs, { desc = desc })
end
leader('ef', explore_at_file, 'File directory')
leader('ey', yank_path(':.'), 'Yank relative path')
leader('eY', yank_path(':p'), 'Yank absolute path')
local nmap_leader = function(suffix, rhs, desc, plugin)
local final_rhs = plugin and lazy_wrap(plugin, rhs) or rhs
vim.keymap.set("n", "<Leader>" .. suffix, final_rhs, { desc = desc })
end
-- Find
leader('fb', function() MiniPick.builtin.buffers() end, 'Buffers')
leader('fc', function() MiniExtra.pickers.git_commits() end, 'Commits (all)')
leader('fC', function() MiniExtra.pickers.git_commits({ path = vim.fn.expand('%') }) end, 'Commits (buf)')
leader('fd', function() MiniExtra.pickers.diagnostic({ scope = 'all' }) end, 'Diagnostic workspace')
leader('fD', function() MiniExtra.pickers.diagnostic({ scope = 'current' }) end, 'Diagnostic buffer')
leader('ff', function() MiniPick.builtin.files() end, 'Files')
leader('fg', function() MiniPick.builtin.grep_live() end, 'Grep live')
leader('fG', function() MiniPick.builtin.grep({ pattern = vim.fn.expand('<cword>') }) end, 'Grep word')
leader('fl', function() MiniExtra.pickers.buf_lines({ scope = 'all' }) end, 'Lines (all)')
leader('fL', function() MiniExtra.pickers.buf_lines({ scope = 'current' }) end, 'Lines (buf)')
leader('fm', function() require('git').status() end, 'Modified / changed files')
leader('fo', function() MiniExtra.pickers.oldfiles() end, 'Old / recent files')
leader('fr', function() MiniPick.builtin.resume() end, 'Resume')
leader('fs', function() MiniExtra.pickers.lsp({ scope = 'workspace_symbol_live' }) end, 'Symbols workspace')
leader('fS', function() MiniExtra.pickers.lsp({ scope = 'document_symbol' }) end, 'Symbols document')
leader('f:', function() MiniExtra.pickers.history({ scope = ':' }) end, 'Command history')
local xmap_leader = function(suffix, rhs, desc, plugin)
local final_rhs = plugin and lazy_wrap(plugin, rhs) or rhs
vim.keymap.set("x", "<Leader>" .. suffix, final_rhs, { desc = desc })
end
-- Git
leader('gd', function() require('git').diff() end, 'Diff unstaged')
leader('gs', function() MiniGit.show_at_cursor() end, 'Show at cursor', { 'n', 'x' })
-- Buffers =====================================================================
nmap_leader("bd", function() pcall(vim.cmd, "bdelete") end, "Delete")
nmap_leader("bD", function() pcall(vim.cmd, "bdelete!") end, "Delete!")
nmap_leader("bw", function() pcall(vim.cmd, "bwipeout") end, "Wipeout")
nmap_leader("bW", function() pcall(vim.cmd, "bwipeout!") end, "Wipeout!")
nmap_leader("bo", function()
local current = vim.api.nvim_get_current_buf()
for _, buf in ipairs(vim.api.nvim_list_bufs()) do
if buf ~= current and vim.api.nvim_buf_is_loaded(buf) and vim.bo[buf].buflisted then
pcall(vim.api.nvim_buf_delete, buf, { force = false })
end
end
end, "Close all but current")
-- Debug =======================================================================
nmap_leader("db", function() require("dap").toggle_breakpoint() end, "Toggle Breakpoint", "dap")
nmap_leader("dc", function() require("dap").continue() end, "Run/Continue", "dap")
nmap_leader("dC", function() require("dap").run_to_cursor() end, "Run to Cursor", "dap")
nmap_leader("de", function() require("dap.ui.widgets").hover() end, "Inspect", "dap")
nmap_leader("dt", function() require("dap").terminate() end, "Terminate", "dap")
nmap_leader("dl", function() require("dap").set_breakpoint(nil, nil, vim.fn.input("Log point message: ")) end,
"log point", "dap")
nmap_leader("dr", function() require("dap").repl.open() end, "open repl", "dap")
-- Explore =====================================================================
nmap_leader("ed", function() MiniFiles.open() end, "Directory")
nmap_leader("ef",
function() MiniFiles.open(vim.uv.fs_stat(vim.api.nvim_buf_get_name(0)) and vim.api.nvim_buf_get_name(0) or nil) end,
"File directory")
-- Find ========================================================================
nmap_leader("fb", function() MiniPick.builtin.buffers() end, "Buffers")
nmap_leader("fc", function() MiniExtra.pickers.git_commits() end, "Commits (all)")
nmap_leader("fC", function() MiniExtra.pickers.git_commits({ path = "%" }) end, "Commits (buf)")
nmap_leader("fd", function() MiniExtra.pickers.diagnostic({ scope = "all" }) end, "Diagnostic workspace")
nmap_leader("fD", function() MiniExtra.pickers.diagnostic({ scope = "current" }) end, "Diagnostic buffer")
nmap_leader("ff", function() MiniPick.builtin.files() end, "Files")
nmap_leader("fg", function() MiniPick.builtin.grep_live() end, "Grep live")
nmap_leader("fG", function() MiniPick.builtin.grep({ pattern = vim.fn.expand("<cword>") }) end, "Grep current word")
nmap_leader("fh", function() MiniPick.builtin.help() end, "Help tags")
nmap_leader("fl", function() MiniPick.builtin.buf_lines({ scope = "all" }) end, "Lines (all)")
nmap_leader("fL", function() MiniPick.builtin.buf_lines({ scope = "current" }) end, "Lines (buf)")
nmap_leader("fr", function() MiniPick.builtin.resume() end, "Resume")
nmap_leader("fs", function() MiniExtra.pickers.lsp({ scope = "workspace_symbol_live" }) end, "Symbols workspace (live)")
nmap_leader("fS", function() MiniExtra.pickers.lsp({ scope = "document_symbol" }) end, "Symbols document")
nmap_leader("f:", function() MiniExtra.pickers.history({ scope = ":" }) end, '":" history')
nmap_leader("f;", function() MiniExtra.pickers.history({ scope = ":" }) end, "Command history")
-- Git =========================================================================
nmap_leader("go", function() MiniDiff.toggle_overlay() end, "Toggle overlay")
nmap_leader("gs", function() MiniGit.show_at_cursor() end, "Show at cursor")
xmap_leader("gs", function() MiniGit.show_at_cursor() end, "Show at selection")
-- HTTP ========================================================================
nmap_leader("hr", function() require("kulala").run() end, "Send HTTP request", "kulala")
-- Language ====================================================================
nmap_leader("la", function() vim.lsp.buf.code_action() end, "Actions")
nmap_leader("ld", function() vim.diagnostic.open_float() end, "Diagnostic popup")
nmap_leader("lf", function() require("conform").format({ async = true }) end, "Format")
nmap_leader("li", function() vim.lsp.buf.implementation() end, "Implementation")
nmap_leader("lh", function() vim.lsp.buf.hover() end, "Hover")
nmap_leader("ll", function() vim.lsp.codelens.run() end, "Lens")
nmap_leader("lr", function() vim.lsp.buf.rename() end, "Rename")
nmap_leader("lR", function() vim.lsp.buf.references() end, "References")
nmap_leader("ls", function() vim.lsp.buf.definition() end, "Source definition")
nmap_leader("lt", function() vim.lsp.buf.type_definition() end, "Type definition")
xmap_leader("lf", function() require("conform").format({ async = true }) end, "Format selection")
-- Run =========================================================================
nmap_leader("r", function() require("just").pick_just_task() end, "Run Just Task")
-- Session =====================================================================
nmap_leader("sd", function() MiniSessions.select("delete") end, "Delete")
nmap_leader("sn", function() vim.ui.input({ prompt = "Session name: " }, MiniSessions.write) end, "New")
nmap_leader("sr", function() MiniSessions.select("read") end, "Read")
nmap_leader("sR", function() MiniSessions.restart() end, "Restart")
nmap_leader("sw", function() MiniSessions.write() end, "Write current")
-- Terminal ====================================================================
nmap_leader("tT", function() vim.cmd("horizontal term") end, "Terminal (horizontal)")
nmap_leader("tt", function() vim.cmd("vertical term") end, "Terminal (vertical)")
nmap_leader("tg", function() require("terminal").open_terminal_app("lazygit") end, "LazyGit")
nmap_leader("ts", function() require("terminal").open_terminal_app("lazysql") end, "LazySQL")
-- Overwrites ==================================================================
nmap("<Esc>", function() vim.cmd("nohlsearch") end, "Clear search highlights")
tmap("<C-w>", "<C-\\><C-n><C-w>", "Terminal window navigation")
-6
View File
@@ -1,6 +0,0 @@
-- :Review [base] [head] e.g. `:Review origin/develop`, `:Review origin/main origin/feat-x`
-- Without args it refreshes the last review (or starts one against @{upstream}: unpushed commits)
Config.command('Review', function(o) require('git').review(o.fargs[1], o.fargs[2]) end, 'Review changes against merge-base', {
nargs = '*',
complete = function() return vim.fn.systemlist('git branch -a --format=%(refname:short)') end,
})
+122
View File
@@ -0,0 +1,122 @@
-- UI ==========================================================================
Config.now(function()
-- Global icon provider.
require('mini.icons').setup()
Config.later(MiniIcons.tweak_lsp_kind)
-- Start screen.
require('mini.starter').setup()
-- Statusline.
require('mini.statusline').setup()
-- Statuscolumn.
require('mini.statuscolumn').setup()
-- Session management.
require('mini.sessions').setup()
end)
Config.later(function()
-- Git diff indicators.
require('mini.diff').setup()
require('mini.git').setup()
-- Keymap hints.
local miniclue = require('mini.clue')
miniclue.setup({
clues = {
Config.leader_group_clues,
miniclue.gen_clues.builtin_completion(),
miniclue.gen_clues.g(),
miniclue.gen_clues.marks(),
miniclue.gen_clues.registers(),
miniclue.gen_clues.square_brackets(),
miniclue.gen_clues.windows({ submode_resize = true }),
miniclue.gen_clues.z(),
},
triggers = {
{ mode = { 'n', 'x' }, keys = '<Leader>' }, -- Leader triggers
{ mode = 'n', keys = '\\' }, -- mini.basics
{ mode = { 'n', 'x' }, keys = '[' }, -- mini.bracketed
{ mode = { 'n', 'x' }, keys = ']' },
{ mode = 'i', keys = '<C-x>' }, -- Built-in completion
{ mode = { 'n', 'x' }, keys = 'g' }, -- `g` key
{ mode = { 'n', 'x' }, keys = "'" }, -- Marks
{ mode = { 'n', 'x' }, keys = '`' },
{ mode = { 'n', 'x' }, keys = '"' }, -- Registers
{ mode = { 'i', 'c' }, keys = '<C-r>' },
{ mode = 'n', keys = '<C-w>' }, -- Window commands
{ mode = { 'n', 'x' }, keys = 's' }, -- `s` key (mini.surround, etc.)
{ mode = { 'n', 'x' }, keys = 'z' }, -- `z` key
},
})
end)
-- Editing =====================================================================
Config.later(function()
-- Enhanced text objects (a/i).
require('mini.ai').setup()
-- Auto-close brackets and quotes.
require('mini.pairs').setup()
-- Surround functionality (add/delete/replace).
require('mini.surround').setup()
end)
-- Navigation ==================================================================
Config.now_if_args(function()
-- File system explorer.
require('mini.files').setup()
local add_marks = function()
MiniFiles.set_bookmark('c', vim.fn.stdpath('config'), { desc = 'Config' })
MiniFiles.set_bookmark('d', vim.fn.expand('~/Documents'), { desc = 'Documents' })
MiniFiles.set_bookmark('w', vim.fn.getcwd, { desc = 'Working directory' })
end
Config.autocmd('User', 'MiniFilesExplorerOpen', add_marks, 'Add default marks')
end)
Config.later(function()
-- Fuzzy picker.
require('mini.pick').setup()
-- Square bracket navigation.
require('mini.bracketed').setup()
end)
-- Completion ==================================================================
Config.now_if_args(function()
-- Autocompletion and signature help.
require('mini.completion').setup({
lsp_completion = {
source_func = 'omnifunc',
auto_setup = false,
process_items = function(items, base)
return MiniCompletion.default_process_items(items, base, { kind_priority = { Text = -1 } })
end,
},
})
-- Set 'omnifunc' for LSP completion only when needed.
local on_attach = function(ev)
vim.bo[ev.buf].omnifunc = 'v:lua.MiniCompletion.completefunc_lsp'
end
Config.autocmd('LspAttach', nil, on_attach, "Set 'omnifunc'")
-- Advertise to servers that Neovim supports certain set of completion features.
vim.lsp.config('*', { capabilities = MiniCompletion.get_lsp_capabilities() })
end)
-- Utilities ===================================================================
Config.now_if_args(function()
-- Miscellaneous utility functions.
require('mini.misc').setup()
MiniMisc.setup_auto_root()
MiniMisc.setup_restore_cursor()
end)
Config.later(function()
-- Extra functionality (pickers, clues).
require('mini.extra').setup()
end)
-79
View File
@@ -1,79 +0,0 @@
-- UI
Config.now(function()
-- Global icon provider
require('mini.icons').setup()
Config.later(MiniIcons.tweak_lsp_kind)
require('mini.statusline').setup()
local starter = require('mini.starter')
starter.setup({
items = {
function()
local dirs = vim.fn.glob('~/Code/*/', false, true)
return vim.tbl_map(function(p)
return {
name = vim.fn.fnamemodify(p, ':h:t'),
section = 'Projects',
action = function()
vim.fn.chdir(p)
MiniStarter.close()
end,
}
end, dirs)
end,
starter.sections.builtin_actions(),
},
})
end)
Config.later(function()
-- Git diff indicators
require('mini.diff').setup()
require('mini.git').setup()
-- Keymap hints
local miniclue = require('mini.clue')
miniclue.setup({
clues = {
Config.leader_group_clues,
miniclue.gen_clues.builtin_completion(),
miniclue.gen_clues.g(),
miniclue.gen_clues.marks(),
miniclue.gen_clues.registers(),
miniclue.gen_clues.square_brackets(),
miniclue.gen_clues.windows({ submode_resize = true }),
miniclue.gen_clues.z(),
},
triggers = {
{ mode = { 'n', 'x' }, keys = '<Leader>' },
{ mode = { 'n', 'x' }, keys = '[' },
{ mode = { 'n', 'x' }, keys = ']' },
{ mode = 'i', keys = '<C-x>' },
{ mode = { 'n', 'x' }, keys = 'g' },
{ mode = { 'n', 'x' }, keys = "'" },
{ mode = { 'n', 'x' }, keys = '`' },
{ mode = { 'n', 'x' }, keys = '"' },
{ mode = { 'i', 'c' }, keys = '<C-r>' },
{ mode = 'n', keys = '<C-w>' },
{ mode = { 'n', 'x' }, keys = 'z' },
},
})
end)
-- Editing & Navigation
Config.later(function()
require('mini.ai').setup()
require('mini.pairs').setup()
require('mini.pick').setup()
require('mini.extra').setup()
end)
-- File Explorer & auto root
Config.now(function()
require('mini.files').setup()
Config.autocmd('User', 'MiniFilesExplorerOpen', function()
MiniFiles.set_bookmark('c', vim.fn.stdpath('config'), { desc = 'Config' })
MiniFiles.set_bookmark('w', vim.fn.getcwd, { desc = 'Working directory' })
end, 'Add default marks')
end)
+132
View File
@@ -0,0 +1,132 @@
-- Colortheme ==================================================================
Config.now(function()
vim.pack.add({ "https://github.com/rose-pine/neovim" })
require("rose-pine").setup({
enable = {
legacy_highlights = false,
migrations = false,
},
})
vim.cmd("colorscheme rose-pine")
end)
-- Treesitter ==================================================================
Config.now_if_args(function()
vim.pack.add({
'https://github.com/nvim-treesitter/nvim-treesitter',
'https://github.com/nvim-treesitter/nvim-treesitter-textobjects',
})
vim.treesitter.language.register('tsx', { 'typescriptreact' })
local filetypes = {
'html', 'css', 'lua', 'go', 'php', 'blade', 'sql', 'javascript',
'typescript', 'typescriptreact', 'dockerfile', 'yaml', 'markdown', 'dart',
'json', 'xml', 'toml', 'sh', 'bash', 'zsh', 'gitcommit', 'diff', 'regex', 'http'
}
Config.autocmd('FileType', filetypes, function(ev)
if pcall(vim.treesitter.start, ev.buf) then
if vim.bo[ev.buf].filetype == 'php' then
-- fixes broken indentation on `o` in php buffers
vim.bo[ev.buf].indentexpr = "v:lua.require'nvim-treesitter'.indentexpr()"
end
end
end, 'Start tree-sitter')
Config.later(function()
require('nvim-treesitter').install(vim.tbl_map(function(ft)
return vim.treesitter.language.get_lang(ft) or ft
end, filetypes))
end)
end)
-- Mason =======================================================================
Config.now_if_args(function()
vim.pack.add({ "https://github.com/mason-org/mason.nvim" })
require("mason").setup()
end)
-- LSP =========================================================================
Config.now_if_args(function()
vim.pack.add({ "https://github.com/neovim/nvim-lspconfig" })
vim.lsp.enable({
"ansiblels",
"gopls",
"intelephense",
"lua_ls",
"tailwindcss",
"tsc",
"dartls"
})
end)
-- Formatting ==================================================================
Config.now_if_args(function()
vim.pack.add({ "https://github.com/stevearc/conform.nvim" })
require("conform").setup({
default_format_opts = { lsp_format = "fallback" },
format_on_save = {
lsp_format = "fallback",
timeout_ms = 1000,
},
formatters_by_ft = {
go = { "gofumpt", "goimports" },
php = { "php_cs_fixer" },
},
})
end)
-- DAP =========================================================================
function Config.setup_dap()
Config.setup_dap = nil
vim.pack.add({ "https://github.com/mfussenegger/nvim-dap" })
local dap = require("dap")
dap.adapters.php = {
type = "executable",
command = "node",
args = { vim.fn.stdpath("data") .. "/mason/packages/php-debug-adapter/extension/out/phpDebug.js" },
}
dap.adapters.go = {
type = "server",
host = "127.0.0.1",
port = "${port}",
}
end
-- Kulala ======================================================================
function Config.setup_kulala()
Config.setup_kulala = nil
vim.pack.add({ "https://github.com/mistweaverco/kulala.nvim" })
require("kulala").setup({ default_env = "dev" })
end
-- Laravel =====================================================================
function Config.setup_laravel()
Config.setup_laravel = nil
vim.pack.add({
"https://github.com/MunifTanjim/nui.nvim",
"https://github.com/nvim-lua/plenary.nvim",
"https://github.com/nvim-neotest/nvim-nio",
"https://github.com/adalessa/laravel.nvim",
})
require("laravel").setup({})
end
-- Flutter =====================================================================
function Config.setup_flutter()
Config.setup_flutter = nil
vim.pack.add({
"https://github.com/nvim-lua/plenary.nvim",
"https://github.com/nvim-flutter/flutter-tools.nvim",
})
require("flutter-tools").setup({ lsp = { color_capabilities = true } })
end
Config.autocmd('FileType', 'php', Config.setup_laravel, "Setup laravel", true)
Config.autocmd('FileType', 'dart', Config.setup_flutter, "Setup flutter", true)
-84
View File
@@ -1,84 +0,0 @@
-- Colortheme
Config.now(function()
vim.pack.add({ { src = 'https://github.com/rose-pine/neovim', name = 'rose-pine' } })
require('rose-pine').setup({
enable = { terminal = false, legacy_highlights = false, migrations = false, },
styles = { italic = false },
groups = { git_change = 'gold', git_text = 'gold' },
})
vim.cmd.colorscheme('rose-pine')
end)
-- Treesitter
Config.now(function()
vim.pack.add({ 'https://github.com/nvim-treesitter/nvim-treesitter' })
local filetypes = {
'html', 'css', 'lua', 'go', 'php', 'blade', 'sql', 'javascript',
'typescript', 'typescriptreact', 'svelte', 'dockerfile', 'yaml', 'markdown', 'dart',
'json', 'xml', 'toml', 'sh', 'zsh', 'just', 'gitcommit', 'diff', 'regex', 'http', 'kotlin'
}
Config.autocmd('FileType', filetypes, function(ev)
if pcall(vim.treesitter.start, ev.buf) and vim.bo[ev.buf].filetype == 'php' then
vim.bo[ev.buf].indentexpr = "v:lua.require'nvim-treesitter'.indentexpr()"
end
end, 'Start tree-sitter')
Config.later(function()
require('nvim-treesitter').install(vim.iter(filetypes):map(vim.treesitter.language.get_lang):totable())
end)
end)
-- LSP
Config.later(function()
vim.pack.add({ 'https://github.com/neovim/nvim-lspconfig' })
vim.lsp.enable({ 'ansiblels', 'gopls', 'phpantom_lsp', 'svelte', 'tailwindcss', 'tsc', 'biome' })
end)
-- Formatting
Config.later(function()
vim.pack.add({ 'https://github.com/stevearc/conform.nvim' })
require('conform').setup({
default_format_opts = { lsp_format = 'fallback' },
format_on_save = { timeout_ms = 1000 },
formatters_by_ft = {
go = { 'gofumpt', 'goimports' },
php = { 'php_cs_fixer' },
json = { 'jq' },
javascript = { 'biome' },
typescript = { 'biome' },
javascriptreact = { 'biome' },
typescriptreact = { 'biome' },
svelte = { 'biome' },
},
})
end)
-- DAP
Config.later(function()
vim.pack.add({ 'https://github.com/mfussenegger/nvim-dap' })
local dap_signs = {
DapBreakpoint = { text = '', texthl = 'DapBreakpoint' },
DapBreakpointCondition = { text = '', texthl = 'DapBreakpointCondition' },
DapStopped = { text = '', texthl = 'DapStopped', linehl = 'DapStoppedLine' },
DapBreakpointRejected = { text = '', texthl = 'DapBreakpointRejected' },
}
for name, sign in pairs(dap_signs) do
vim.fn.sign_define(name, sign)
end
require('dap').adapters.go = { type = 'server', host = '127.0.0.1', port = '${port}' }
end)
-- Flutter
Config.autocmd('FileType', 'dart', function()
vim.pack.add({
'https://github.com/nvim-lua/plenary.nvim',
'https://github.com/nvim-flutter/flutter-tools.nvim',
})
require('flutter-tools').setup({ lsp = { color_capabilities = true } })
end, 'Setup flutter', true)