Compare commits

...
16 Commits
9 changed files with 182 additions and 249 deletions

No files matched your search

+5 -18
View File
@@ -1,21 +1,7 @@
-- Modules -- Modules
vim.loader.enable() vim.loader.enable()
vim.opt.runtimepath:remove('/usr/share/nvim/site') vim.opt.runtimepath:remove('/usr/share/nvim/site')
for _, m in ipairs({ vim.g.loaded_netrwPlugin = 1
'netrw', 'netrwPlugin',
'gzip', 'tarPlugin',
'tutor_mode_plugin',
'remote_plugins',
'nvim_zip_plugin',
'nvim_net_plugin',
'spellfile_plugin',
}) do
vim.g['loaded_' .. m] = 1
end
for _, p in ipairs({ 'node', 'python3', 'perl', 'ruby' }) do
vim.g['loaded_' .. p .. '_provider'] = 0
end
-- Config Global -- Config Global
vim.pack.add({ 'https://github.com/nvim-mini/mini.nvim' }) vim.pack.add({ 'https://github.com/nvim-mini/mini.nvim' })
@@ -27,7 +13,8 @@ _G.Config = {
later = function(f) misc.safely('later', f) end, later = function(f) misc.safely('later', f) end,
autocmd = function(event, pattern, callback, desc, once) autocmd = function(event, pattern, callback, desc, once)
vim.api.nvim_create_autocmd(event, { group = gr, pattern = pattern, callback = callback, desc = desc, once = once }) vim.api.nvim_create_autocmd(event, { group = gr, pattern = pattern, callback = callback, desc = desc, once = once })
end end,
command = function(name, callback, desc, opts)
vim.api.nvim_create_user_command(name, callback, vim.tbl_extend('force', { desc = desc }, opts or {}))
end,
} }
Config.now_if_args = vim.fn.argc(-1) > 0 and Config.now or Config.later
+96 -38
View File
@@ -1,48 +1,106 @@
local ns = vim.api.nvim_create_namespace('git_status') local ns = vim.api.nvim_create_namespace('git')
local hls = { M = 'DiagnosticWarn', ['?'] = 'DiagnosticInfo', A = 'DiagnosticOk', D = 'DiagnosticError', R = 'DiagnosticWarn' } local status_hl = { M = 'DiagnosticWarn', A = 'DiagnosticOk', D = 'DiagnosticError', ['?'] = 'DiagnosticInfo' }
local function show(buf_id, items, query) local function git(args)
MiniPick.default_show(buf_id, items, query) local result = vim.system(vim.list_extend({ 'git', '-c', 'core.quotepath=false' }, args)):wait()
vim.api.nvim_buf_clear_namespace(buf_id, ns, 0, -1) 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 for i, item in ipairs(items) do
if item.hl then 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' })
vim.api.nvim_buf_set_extmark(buf_id, ns, i - 1, 1, { end_col = 3, hl_group = item.hl, priority = 202, hl_mode = 'combine' })
end
end end
end end
return { -- Diff the current file against its staged version
status = function() local function diff()
local lines = vim.fn.systemlist('git status -s -u') vim.cmd('diffthis')
if vim.v.shell_error ~= 0 then vim.cmd('vertical Git show :./%')
return vim.notify('Not a git repository', vim.log.levels.WARN) 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 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 = {} local items = {}
for _, l in ipairs(lines) do for _, line in ipairs(vim.split(git({ 'diff', '--name-status', '--no-renames', range }), '\n', { trimempty = true })) do
local s = l:sub(1, 2):match('%S+') local s, path = line:match('^(%a)\t(.*)$')
local p = l:sub(4):gsub('.* %-> ', ''):gsub('^"(.*)"$', '%1') table.insert(items, { status = s, path = path, text = ' ' .. s .. ' ' .. path })
local hl = l:sub(1, 1) ~= ' ' and l:sub(1, 1) ~= '?' and 'DiagnosticOk' or hls[s:sub(1, 1)]
items[#items + 1] = {
text = string.format(' %-2s %s', s == '??' and '?' or s, p),
path = p,
hl = hl,
}
end end
if #items == 0 then return vim.notify('No changes', vim.log.levels.INFO) end
MiniPick.start({ -- ✓ is drawn on display (not part of the text) so it stays current when the picker is resumed
source = { items = items, name = 'Git Status', show = show }, local function show_seen(buf, shown, query)
mappings = { show(buf, shown, query)
quickfix = { for i, item in ipairs(shown) do
char = '<C-q>', if last.seen[item.path] then
func = function() vim.api.nvim_buf_set_extmark(buf, ns, i - 1, 3, { virt_text = { { '✓' } }, virt_text_pos = 'overlay' })
local m = MiniPick.get_picker_matches() end
MiniPick.default_choose_marked(#m.marked > 0 and m.marked or m.all) end
return true 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, 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 }
-19
View File
@@ -1,19 +0,0 @@
local function open(cmd)
local lines = vim.o.lines - vim.o.cmdheight - (vim.o.laststatus > 0 and 1 or 0)
local w, h = math.floor(vim.o.columns * 0.95), math.floor(lines * 0.95)
local buf = vim.api.nvim_create_buf(false, true)
vim.bo[buf].bufhidden = 'wipe'
local win = vim.api.nvim_open_win(buf, true, {
relative = 'editor',
width = w,
height = h,
row = math.floor((lines - h) / 2),
col = math.floor((vim.o.columns - w) / 2),
border = 'rounded',
})
vim.fn.termopen(cmd, { on_exit = function() pcall(vim.api.nvim_win_close, win, true) end })
end
return { open = open }
+3 -3
View File
@@ -5,7 +5,7 @@
"src": "https://github.com/stevearc/conform.nvim" "src": "https://github.com/stevearc/conform.nvim"
}, },
"mini.nvim": { "mini.nvim": {
"rev": "ac5dffcc52b8378fbb15efeb0497a83e57a0b01c", "rev": "6d5a29e86a7352739506c28e0bc50fe214b5216f",
"src": "https://github.com/nvim-mini/mini.nvim" "src": "https://github.com/nvim-mini/mini.nvim"
}, },
"nvim-dap": { "nvim-dap": {
@@ -13,11 +13,11 @@
"src": "https://github.com/mfussenegger/nvim-dap" "src": "https://github.com/mfussenegger/nvim-dap"
}, },
"nvim-lspconfig": { "nvim-lspconfig": {
"rev": "ac9d2f7c4757db6320cab6697fe73e5e8adb2457", "rev": "d8d2fda7aae57030452ce8cd6e770b1eb704514e",
"src": "https://github.com/neovim/nvim-lspconfig" "src": "https://github.com/neovim/nvim-lspconfig"
}, },
"nvim-treesitter": { "nvim-treesitter": {
"rev": "9a168f6357ed21c3a636e1727bc7d382abc451b8", "rev": "a9c4e1457e2e59f1b82c8f78dcdb3b2517555200",
"src": "https://github.com/nvim-treesitter/nvim-treesitter" "src": "https://github.com/nvim-treesitter/nvim-treesitter"
}, },
"rose-pine": { "rose-pine": {
+28 -34
View File
@@ -1,45 +1,40 @@
-- General -- General
vim.g.mapleader = ' ' -- Use `<Space>` as <Leader> key vim.g.mapleader = ' ' -- Use <Space> as <Leader> key
vim.o.undofile = true -- Enable persistent undo vim.o.undofile = true -- Keep undo history after closing files
vim.o.shada = "'50,<20,s10,:100,/50,@50,h" -- Limit ShaDa file (for startup) vim.o.shada = "'50,<20,s10,:100,/50,@50,h,r/tmp/" -- Fewer saved items (faster startup), skip /tmp files
-- UI -- 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.listchars = 'tab:→ ,trail:·,nbsp:␣' -- Characters for list mode
vim.o.number = true -- Show line numbers vim.o.number = true -- Show line numbers
vim.o.pumheight = 10 -- Make popup menu smaller vim.o.cursorline = true -- Highlight the line the cursor is on
vim.o.pummaxwidth = 80 -- Make popup menu not too wide vim.o.signcolumn = 'yes' -- Always show sign column (no text shifting)
vim.o.shortmess = 'CFOSWacou' -- Disable some built-in completion messages vim.o.wrap = false -- Don't wrap long lines
vim.o.signcolumn = 'yes' -- Always show signcolumn (less flicker) vim.o.list = true -- Show tabs, trailing spaces and nbsp
vim.o.splitbelow = true -- Horizontal splits will be below vim.o.listchars = 'tab:→ ,trail:·,nbsp:␣' -- Symbols used for those characters
vim.o.splitkeep = 'screen' -- Reduce scroll during window split vim.o.fillchars = 'eob: ' -- Hide `~` on lines after end of buffer
vim.o.splitright = true -- Vertical splits will be to the right vim.o.splitbelow = true -- Open horizontal splits below
vim.o.wrap = false -- Don't visually wrap lines vim.o.splitright = true -- Open vertical splits to the right
vim.o.winborder = 'rounded' -- Use border in floating windows vim.o.splitkeep = 'screen' -- Keep text in place when opening splits
vim.o.pumborder = 'rounded' -- Use border in popup menu vim.o.cmdheight = 0 -- Hide command line when not typing a command
vim.o.cmdheight = 0 -- Hide the command line when not in use vim.o.shortmess = 'CFOSWacou' -- Hide completion, search count, undo and write messages
vim.cmd('syntax off') -- Disable legacy syntax highlighting vim.cmd.syntax('off') -- Disable legacy syntax (treesitter handles highlighting)
require('vim._core.ui2').enable({ -- Enable new ui (requires nightly) require('vim._core.ui2').enable({ -- New message/cmdline UI, messages in float (nightly)
msg = { targets = 'msg' } msg = { targets = 'msg' }
}) })
-- Editing -- Editing
vim.o.expandtab = true -- Convert tabs to spaces vim.o.expandtab = true -- Insert spaces when pressing <Tab>
vim.o.formatoptions = 'rqnl1j' -- Improve comment editing vim.o.shiftwidth = 2 -- Spaces per indent level (>>, <<, autoindent)
vim.o.ignorecase = true -- Ignore case during search vim.o.tabstop = 2 -- Display width of a tab character
vim.o.infercase = true -- Infer case in built-in completion vim.o.ignorecase = true -- Ignore case when searching
vim.o.shiftwidth = 2 -- Use this number of spaces for indentation vim.o.smartcase = true -- ...unless the pattern contains uppercase
vim.o.smartcase = true -- Respect case if search pattern has upper case vim.o.virtualedit = 'block' -- Allow cursor past end of line in visual block
vim.o.spelloptions = 'camel' -- Treat camelCase word parts as separate words vim.o.spelloptions = 'camel' -- Spell-check camelCase words per part
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.o.complete = '.,w,b,kspell' -- Use less sources -- Completion
vim.o.completeopt = 'menuone,noselect,fuzzy' -- Use custom behavior 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
-- Autocommands -- Autocommands
Config.autocmd('TextYankPost', '*', function() vim.hl.hl_op() end, 'Highlight yanked text') Config.autocmd('TextYankPost', '*', function() vim.hl.hl_op() end, 'Highlight yanked text')
@@ -59,6 +54,5 @@ Config.later(function()
[vim.diagnostic.severity.INFO] = '', [vim.diagnostic.severity.INFO] = '',
}, },
}, },
virtual_text = false,
}) })
end) end)
+33 -112
View File
@@ -1,52 +1,22 @@
-- Clues -- Clues
Config.leader_group_clues = { Config.leader_group_clues = {
{ mode = 'n', keys = '<Leader>b', desc = '+Buffer' },
{ mode = 'n', keys = '<Leader>d', desc = '+Debug' }, { mode = 'n', keys = '<Leader>d', desc = '+Debug' },
{ mode = 'n', keys = '<Leader>e', desc = '+Explore' }, { mode = 'n', keys = '<Leader>e', desc = '+Explore' },
{ mode = 'n', keys = '<Leader>f', desc = '+Find' }, { mode = 'n', keys = '<Leader>f', desc = '+Find' },
{ mode = 'n', keys = '<Leader>g', desc = '+Git' }, { mode = { 'n', 'x' }, keys = '<Leader>g', desc = '+Git' },
{ mode = 'n', keys = '<Leader>l', desc = '+Language' },
{ mode = 'n', keys = '<Leader>r', desc = '+Request' },
{ mode = 'n', keys = '<Leader>t', desc = '+Terminal' },
{ mode = 'n', keys = '<Leader><Tab>', desc = '+Tab' },
{ mode = 'x', keys = '<Leader>g', desc = '+Git' },
{ mode = 'x', keys = '<Leader>l', desc = '+Language' },
} }
-- Keymap Helpers -- Keymap Helpers
local nmap_leader = function(suffix, rhs, desc) local leader = function(suffix, rhs, desc, mode)
vim.keymap.set('n', '<Leader>' .. suffix, rhs, { desc = desc, silent = true }) vim.keymap.set(mode or 'n', '<Leader>' .. suffix, rhs, { desc = desc, silent = true })
end end
local xmap_leader = function(suffix, rhs, desc)
vim.keymap.set('x', '<Leader>' .. suffix, rhs, { desc = desc, silent = true })
end
-- Buffers
local new_scratch_buffer = function()
vim.api.nvim_win_set_buf(0, vim.api.nvim_create_buf(true, true))
end
local close_invisible_buffers = function()
local visible = vim.iter(vim.api.nvim_list_wins()):map(vim.api.nvim_win_get_buf):totable()
vim.iter(vim.api.nvim_list_bufs())
:filter(function(buf) return not vim.list_contains(visible, buf) end)
:each(function(buf) pcall(vim.api.nvim_buf_delete, buf, { force = false }) end)
end
nmap_leader('bd', vim.cmd.bdelete, 'Delete')
nmap_leader('bs', new_scratch_buffer, 'Scratch')
nmap_leader('bw', vim.cmd.bwipeout, 'Wipeout')
nmap_leader('bo', close_invisible_buffers, 'Close invisible buffers')
-- Debug -- Debug
nmap_leader('db', function() require('dap').toggle_breakpoint() end, 'Toggle Breakpoint') leader('db', function() require('dap').toggle_breakpoint() end, 'Toggle Breakpoint')
nmap_leader('dl', function() require('dap').set_breakpoint(nil, nil, vim.fn.input('Log point: ')) end, 'Log point') leader('dc', function() require('dap').continue() end, 'Run/Continue')
nmap_leader('dc', function() require('dap').continue() end, 'Run/Continue') leader('dC', function() require('dap').run_to_cursor() end, 'Run to Cursor')
nmap_leader('dC', function() require('dap').run_to_cursor() end, 'Run to Cursor') leader('di', function() require('dap.ui.widgets').hover() end, 'Inspect')
nmap_leader('de', function() require('dap.ui.widgets').hover() end, 'Inspect') leader('dt', function() require('dap').terminate() end, 'Terminate')
nmap_leader('dr', function() require('dap').repl.open() end, 'Open REPL')
nmap_leader('dt', function() require('dap').terminate() end, 'Terminate')
-- Explore -- Explore
local explore_at_file = function() local explore_at_file = function()
@@ -54,81 +24,32 @@ local explore_at_file = function()
MiniFiles.open(vim.uv.fs_stat(file) and file or nil) MiniFiles.open(vim.uv.fs_stat(file) and file or nil)
end end
nmap_leader('ed', function() MiniFiles.open() end, 'Directory') local yank_path = function(modifier)
nmap_leader('ef', explore_at_file, 'File directory') return function() vim.fn.setreg('+', vim.fn.fnamemodify(vim.api.nvim_buf_get_name(0), modifier)) end
nmap_leader('ey', function() vim.fn.setreg('+', vim.fn.fnamemodify(vim.api.nvim_buf_get_name(0), ':.')) end, 'Yank relative path') end
nmap_leader('eY', function() vim.fn.setreg('+', vim.api.nvim_buf_get_name(0)) end, 'Yank absolute path')
nmap_leader('en', vim.cmd.messages, 'Notifications') leader('ef', explore_at_file, 'File directory')
leader('ey', yank_path(':.'), 'Yank relative path')
leader('eY', yank_path(':p'), 'Yank absolute path')
-- Find -- Find
nmap_leader('fb', function() MiniPick.builtin.buffers() end, 'Buffers') leader('fb', function() MiniPick.builtin.buffers() end, 'Buffers')
nmap_leader('fc', function() MiniExtra.pickers.git_commits() end, 'Commits (all)') leader('fc', function() MiniExtra.pickers.git_commits() end, 'Commits (all)')
nmap_leader('fC', function() MiniExtra.pickers.git_commits({ path = vim.fn.expand('%') }) end, 'Commits (buf)') leader('fC', function() MiniExtra.pickers.git_commits({ path = vim.fn.expand('%') }) end, 'Commits (buf)')
nmap_leader('fd', function() MiniExtra.pickers.diagnostic({ scope = 'all' }) end, 'Diagnostic workspace') leader('fd', function() MiniExtra.pickers.diagnostic({ scope = 'all' }) end, 'Diagnostic workspace')
nmap_leader('fD', function() MiniExtra.pickers.diagnostic({ scope = 'current' }) end, 'Diagnostic buffer') leader('fD', function() MiniExtra.pickers.diagnostic({ scope = 'current' }) end, 'Diagnostic buffer')
nmap_leader('ff', function() MiniPick.builtin.files() end, 'Files') leader('ff', function() MiniPick.builtin.files() end, 'Files')
nmap_leader('fg', function() MiniPick.builtin.grep_live() end, 'Grep live') leader('fg', function() MiniPick.builtin.grep_live() end, 'Grep live')
nmap_leader('fG', function() MiniPick.builtin.grep({ pattern = vim.fn.expand('<cword>') }) end, 'Grep word') leader('fG', function() MiniPick.builtin.grep({ pattern = vim.fn.expand('<cword>') }) end, 'Grep word')
nmap_leader('fh', function() MiniPick.builtin.help() end, 'Help tags') leader('fl', function() MiniExtra.pickers.buf_lines({ scope = 'all' }) end, 'Lines (all)')
nmap_leader('fl', function() MiniExtra.pickers.buf_lines({ scope = 'all' }) end, 'Lines (all)') leader('fL', function() MiniExtra.pickers.buf_lines({ scope = 'current' }) end, 'Lines (buf)')
nmap_leader('fL', function() MiniExtra.pickers.buf_lines({ scope = 'current' }) end, 'Lines (buf)') leader('fm', function() require('git').status() end, 'Modified / changed files')
nmap_leader('fm', function() require('git').status() end, 'Modified / changed files') leader('fo', function() MiniExtra.pickers.oldfiles() end, 'Old / recent files')
nmap_leader('fo', function() MiniExtra.pickers.oldfiles() end, 'Old / recent files') leader('fr', function() MiniPick.builtin.resume() end, 'Resume')
nmap_leader('fr', function() MiniPick.builtin.resume() end, 'Resume') leader('fs', function() MiniExtra.pickers.lsp({ scope = 'workspace_symbol_live' }) end, 'Symbols workspace')
nmap_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')
nmap_leader('fS', function() MiniExtra.pickers.lsp({ scope = 'document_symbol' }) end, 'Symbols document') leader('f:', function() MiniExtra.pickers.history({ scope = ':' }) end, 'Command history')
nmap_leader('f:', function() MiniExtra.pickers.history({ scope = ':' }) end, 'Command history')
-- Git -- Git
local diff_unstaged = function() leader('gd', function() require('git').diff() end, 'Diff unstaged')
vim.cmd.diffthis() leader('gs', function() MiniGit.show_at_cursor() end, 'Show at cursor', { 'n', 'x' })
vim.cmd('vert Git show :./%')
vim.cmd.diffthis()
end
nmap_leader('ga', function() vim.cmd('Git add %') end, 'Add current file')
nmap_leader('gd', diff_unstaged, 'Diff unstaged')
nmap_leader('gs', function() MiniGit.show_at_cursor() end, 'Show at cursor')
xmap_leader('gs', function() MiniGit.show_at_cursor() end, 'Show at selection')
-- 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')
xmap_leader('lf', function() require('conform').format({ async = true }) end, 'Format selection')
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')
-- Request
nmap_leader('rs', function() require('kulala').run() end, 'Send HTTP request')
-- Terminal
local open_ai = function()
vim.cmd('vertical term ' .. (vim.fn.executable('pi') == 1 and 'pi' or 'claude'))
end
nmap_leader('tT', function() vim.cmd('horizontal term') end, 'Terminal (horizontal)')
nmap_leader('tt', function() vim.cmd('vertical term') end, 'Terminal (vertical)')
nmap_leader('ta', open_ai, 'AI')
nmap_leader('tf', function() require('terminal').open(vim.o.shell) end, 'Terminal (popup)')
nmap_leader('tg', function() require('terminal').open('lazygit') end, 'LazyGit')
nmap_leader('ts', function() require('terminal').open('lazysql') end, 'LazySQL')
-- Tabs
nmap_leader('<Tab><Tab>', vim.cmd.tabnew, 'New tab')
nmap_leader('<Tab>d', vim.cmd.tabclose, 'Close tab')
nmap_leader('<Tab>]', vim.cmd.tabnext, 'Next tab')
nmap_leader('<Tab>[', vim.cmd.tabprevious, 'Previous tab')
-- Brackets
vim.keymap.set('n', ']d', function() vim.diagnostic.jump({ count = 1 }) end, { desc = 'Next diagnostic' })
vim.keymap.set('n', '[d', function() vim.diagnostic.jump({ count = -1 }) end, { desc = 'Previous diagnostic' })
-- Overwrites
vim.keymap.set('n', '<Esc>', vim.cmd.nohlsearch, { desc = 'Clear highlights', silent = true })
vim.keymap.set('t', '<C-w>', '<C-\\><C-n><C-w>', { desc = 'Terminal window navigation', silent = true })
+6
View File
@@ -0,0 +1,6 @@
-- :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,
})
+8 -16
View File
@@ -9,20 +9,17 @@ Config.now(function()
starter.setup({ starter.setup({
items = { items = {
function() function()
return vim.iter({ vim.fn.glob('~/Code/*', 0, 1), vim.fn.glob('~/Documents/*/*', 0, 1) }) local dirs = vim.fn.glob('~/Code/*/', false, true)
:flatten() return vim.tbl_map(function(p)
:filter(function(p) return vim.fn.isdirectory(p) == 1 end)
:map(function(p)
return { return {
name = vim.fn.fnamemodify(p, ':t'), name = vim.fn.fnamemodify(p, ':h:t'),
section = 'Projects',
action = function() action = function()
vim.fn.chdir(p) vim.fn.chdir(p)
require('mini.files').open(p) MiniStarter.close()
end, end,
section = 'Projects',
} }
end) end, dirs)
:totable()
end, end,
starter.sections.builtin_actions(), starter.sections.builtin_actions(),
@@ -72,16 +69,11 @@ Config.later(function()
require('mini.extra').setup() require('mini.extra').setup()
end) end)
-- File Explorer -- File Explorer & auto root
Config.now_if_args(function() Config.now(function()
require('mini.files').setup() require('mini.files').setup()
Config.autocmd('User', 'MiniFilesExplorerOpen', function() Config.autocmd('User', 'MiniFilesExplorerOpen', function()
MiniFiles.set_bookmark('c', vim.fn.stdpath('config'), { desc = 'Config' }) MiniFiles.set_bookmark('c', vim.fn.stdpath('config'), { desc = 'Config' })
MiniFiles.set_bookmark('w', vim.fn.getcwd, { desc = 'Working directory' }) MiniFiles.set_bookmark('w', vim.fn.getcwd, { desc = 'Working directory' })
end, 'Add default marks') end, 'Add default marks')
end) end)
-- Utilities
Config.now_if_args(function()
require('mini.misc').setup_auto_root()
end)
@@ -11,7 +11,7 @@ Config.now(function()
end) end)
-- Treesitter -- Treesitter
Config.now_if_args(function() Config.now(function()
vim.pack.add({ 'https://github.com/nvim-treesitter/nvim-treesitter' }) vim.pack.add({ 'https://github.com/nvim-treesitter/nvim-treesitter' })
local filetypes = { local filetypes = {
@@ -32,7 +32,7 @@ Config.now_if_args(function()
end) end)
-- LSP -- LSP
Config.now_if_args(function() Config.later(function()
vim.pack.add({ 'https://github.com/neovim/nvim-lspconfig' }) vim.pack.add({ 'https://github.com/neovim/nvim-lspconfig' })
vim.lsp.enable({ 'ansiblels', 'gopls', 'phpantom_lsp', 'svelte', 'tailwindcss', 'tsc', 'biome' }) vim.lsp.enable({ 'ansiblels', 'gopls', 'phpantom_lsp', 'svelte', 'tailwindcss', 'tsc', 'biome' })
end) end)
@@ -63,10 +63,10 @@ Config.later(function()
local dap_signs = { local dap_signs = {
DapBreakpoint = { text = '', texthl = 'DapBreakpoint' }, DapBreakpoint = { text = '', texthl = 'DapBreakpoint' },
DapBreakpointCondition = { text = '', texthl = 'DapBreakpointCondition' }, DapBreakpointCondition = { text = '', texthl = 'DapBreakpointCondition' },
DapLogPoint = { text = '', texthl = 'DapLogPoint' },
DapStopped = { text = '', texthl = 'DapStopped', linehl = 'DapStoppedLine' }, DapStopped = { text = '', texthl = 'DapStopped', linehl = 'DapStoppedLine' },
DapBreakpointRejected = { text = '', texthl = 'DapBreakpointRejected' }, DapBreakpointRejected = { text = '', texthl = 'DapBreakpointRejected' },
} }
for name, sign in pairs(dap_signs) do for name, sign in pairs(dap_signs) do
vim.fn.sign_define(name, sign) vim.fn.sign_define(name, sign)
end end
@@ -74,12 +74,6 @@ Config.later(function()
require('dap').adapters.go = { type = 'server', host = '127.0.0.1', port = '${port}' } require('dap').adapters.go = { type = 'server', host = '127.0.0.1', port = '${port}' }
end) end)
-- Kulala
Config.autocmd('FileType', 'http', function()
vim.pack.add({ 'https://github.com/mistweaverco/kulala.nvim' })
require('kulala').setup({ default_env = 'dev' })
end, 'Setup Kulala', true)
-- Flutter -- Flutter
Config.autocmd('FileType', 'dart', function() Config.autocmd('FileType', 'dart', function()
vim.pack.add({ vim.pack.add({