chore: use lua as much as possible

This commit is contained in:
2026-09-14 21:02:46 +02:00
parent 987a52e779
commit 9853ec0dbb
2 changed files with 59 additions and 59 deletions
+58 -58
View File
@@ -34,21 +34,21 @@ local close_invisible_buffers = function()
:each(function(buf) pcall(vim.api.nvim_buf_delete, buf, { force = false }) end)
end
nmap_leader('bd', '<Cmd>bdelete<CR>', 'Delete')
nmap_leader('bD', '<Cmd>bdelete!<CR>', 'Delete!')
nmap_leader('bd', vim.cmd.bdelete, 'Delete')
nmap_leader('bD', function() vim.cmd('bdelete!') end, 'Delete!')
nmap_leader('bs', new_scratch_buffer, 'Scratch')
nmap_leader('bw', '<Cmd>bwipeout<CR>', 'Wipeout')
nmap_leader('bW', '<Cmd>bwipeout!<CR>', 'Wipeout!')
nmap_leader('bw', vim.cmd.bwipeout, 'Wipeout')
nmap_leader('bW', function() vim.cmd('bwipeout!') end, 'Wipeout!')
nmap_leader('bo', close_invisible_buffers, 'Close invisible buffers')
-- Debug
nmap_leader('db', '<Cmd>lua require("dap").toggle_breakpoint()<CR>', 'Toggle Breakpoint')
nmap_leader('dl', '<Cmd>lua require("dap").set_breakpoint(nil, nil, vim.fn.input("Log point: "))<CR>', 'Log point')
nmap_leader('dc', '<Cmd>lua require("dap").continue()<CR>', 'Run/Continue')
nmap_leader('dC', '<Cmd>lua require("dap").run_to_cursor()<CR>', 'Run to Cursor')
nmap_leader('de', '<Cmd>lua require("dap.ui.widgets").hover()<CR>', 'Inspect')
nmap_leader('dr', '<Cmd>lua require("dap").repl.open()<CR>', 'Open REPL')
nmap_leader('dt', '<Cmd>lua require("dap").terminate()<CR>', 'Terminate')
nmap_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')
nmap_leader('dc', function() require('dap').continue() end, 'Run/Continue')
nmap_leader('dC', function() require('dap').run_to_cursor() end, 'Run to Cursor')
nmap_leader('de', function() require('dap.ui.widgets').hover() end, 'Inspect')
nmap_leader('dr', function() require('dap').repl.open() end, 'Open REPL')
nmap_leader('dt', function() require('dap').terminate() end, 'Terminate')
-- Explore
local explore_at_file = function()
@@ -56,75 +56,75 @@ local explore_at_file = function()
MiniFiles.open(vim.uv.fs_stat(file) and file or nil)
end
nmap_leader('ed', '<Cmd>lua MiniFiles.open()<CR>', 'Directory')
nmap_leader('ed', function() MiniFiles.open() end, 'Directory')
nmap_leader('ef', explore_at_file, 'File directory')
nmap_leader('ey', '<Cmd>lua vim.fn.setreg("+", vim.fn.fnamemodify(vim.api.nvim_buf_get_name(0), ":."))<CR>', 'Yank absolute path')
nmap_leader('eY', '<Cmd>lua vim.fn.setreg("+", vim.api.nvim_buf_get_name(0))<CR>', 'Yank relative path')
nmap_leader('en', '<Cmd>messages<CR>', 'Notifications')
nmap_leader('ey', function() vim.fn.setreg('+', vim.fn.fnamemodify(vim.api.nvim_buf_get_name(0), ':.')) end, 'Yank relative path')
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')
-- Find
nmap_leader('fb', '<Cmd>Pick buffers<CR>', 'Buffers')
nmap_leader('fc', '<Cmd>Pick git_commits<CR>', 'Commits (all)')
nmap_leader('fC', '<Cmd>Pick git_commits path="%"<CR>', 'Commits (buf)')
nmap_leader('fd', '<Cmd>Pick diagnostic scope="all"<CR>', 'Diagnostic workspace')
nmap_leader('fD', '<Cmd>Pick diagnostic scope="current"<CR>', 'Diagnostic buffer')
nmap_leader('ff', '<Cmd>Pick files<CR>', 'Files')
nmap_leader('fg', '<Cmd>Pick grep_live<CR>', 'Grep live')
nmap_leader('fG', '<Cmd>Pick grep pattern="<cword>"<CR>', 'Grep word')
nmap_leader('fh', '<Cmd>Pick help<CR>', 'Help tags')
nmap_leader('fl', '<Cmd>Pick buf_lines scope="all"<CR>', 'Lines (all)')
nmap_leader('fL', '<Cmd>Pick buf_lines scope="current"<CR>', 'Lines (buf)')
nmap_leader('fm', '<Cmd>Pick git_status<CR>', 'Modified / changed files')
nmap_leader('fo', '<Cmd>Pick oldfiles<CR>', 'Old / recent files')
nmap_leader('fr', '<Cmd>Pick resume<CR>', 'Resume')
nmap_leader('fs', '<Cmd>Pick lsp scope="workspace_symbol_live"<CR>', 'Symbols workspace')
nmap_leader('fS', '<Cmd>Pick lsp scope="document_symbol"<CR>', 'Symbols document')
nmap_leader('f:', '<Cmd>Pick history scope=":"<CR>', 'Command history')
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 = vim.fn.expand('%') }) 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 word')
nmap_leader('fh', function() MiniPick.builtin.help() end, 'Help tags')
nmap_leader('fl', function() MiniExtra.pickers.buf_lines({ scope = 'all' }) end, 'Lines (all)')
nmap_leader('fL', function() MiniExtra.pickers.buf_lines({ scope = 'current' }) end, 'Lines (buf)')
nmap_leader('fm', function() require('git').status() end, 'Modified / changed files')
nmap_leader('fo', function() MiniExtra.pickers.oldfiles() end, 'Old / recent files')
nmap_leader('fr', function() MiniPick.builtin.resume() end, 'Resume')
nmap_leader('fs', function() MiniExtra.pickers.lsp({ scope = 'workspace_symbol_live' }) end, 'Symbols workspace')
nmap_leader('fS', function() MiniExtra.pickers.lsp({ scope = 'document_symbol' }) end, 'Symbols document')
nmap_leader('f:', function() MiniExtra.pickers.history({ scope = ':' }) end, 'Command history')
-- Git
nmap_leader('ga', '<Cmd>Git add %<CR>', 'Add current file')
nmap_leader('go', '<Cmd>lua MiniDiff.toggle_overlay()<CR>', 'Toggle overlay')
nmap_leader('gs', '<Cmd>lua MiniGit.show_at_cursor()<CR>', 'Show at cursor')
xmap_leader('gs', '<Cmd>lua MiniGit.show_at_cursor()<CR>', 'Show at selection')
nmap_leader('ga', function() vim.cmd('Git add %') end, 'Add current file')
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')
-- Language
nmap_leader('la', '<Cmd>lua vim.lsp.buf.code_action()<CR>', 'Actions')
nmap_leader('ld', '<Cmd>lua vim.diagnostic.open_float()<CR>', 'Diagnostic popup')
nmap_leader('lf', '<Cmd>lua require("conform").format({ async = true })<CR>', 'Format')
xmap_leader('lf', '<Cmd>lua require("conform").format({ async = true })<CR>', 'Format selection')
nmap_leader('li', '<Cmd>lua vim.lsp.buf.implementation()<CR>', 'Implementation')
nmap_leader('lh', '<Cmd>lua vim.lsp.buf.hover()<CR>', 'Hover')
nmap_leader('ll', '<Cmd>lua vim.lsp.codelens.run()<CR>', 'Lens')
nmap_leader('lr', '<Cmd>lua vim.lsp.buf.rename()<CR>', 'Rename')
nmap_leader('lR', '<Cmd>lua vim.lsp.buf.references()<CR>', 'References')
nmap_leader('ls', '<Cmd>lua vim.lsp.buf.definition()<CR>', 'Source definition')
nmap_leader('lt', '<Cmd>lua vim.lsp.buf.type_definition()<CR>', 'Type definition')
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', '<Cmd>lua require("kulala").run()<CR>', 'Send HTTP 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', '<Cmd>horizontal term<CR>', 'Terminal (horizontal)')
nmap_leader('tt', '<Cmd>vertical term<CR>', 'Terminal (vertical)')
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', '<Cmd>lua require("terminal").open(vim.o.shell)<CR>', 'Terminal (popup)')
nmap_leader('tg', '<Cmd>lua require("terminal").open("lazygit")<CR>', 'LazyGit')
nmap_leader('ts', '<Cmd>lua require("terminal").open("lazysql")<CR>', 'LazySQL')
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>', '<Cmd>tabnew<CR>', 'New tab')
nmap_leader('<Tab>d', '<Cmd>tabclose<CR>', 'Close tab')
nmap_leader('<Tab>]', '<Cmd>tabnext<CR>', 'Next tab')
nmap_leader('<Tab>[', '<Cmd>tabprevious<CR>', 'Previous tab')
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>', '<Cmd>nohlsearch<CR>', { desc = 'Clear highlights', silent = true })
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 })
+1 -1
View File
@@ -16,7 +16,7 @@ Config.now_if_args(function()
local filetypes = {
'html', 'css', 'lua', 'go', 'php', 'blade', 'sql', 'javascript',
'typescript', 'typescriptreact', 'svelte', 'dockerfile', 'yaml', 'markdown', 'dart',
'json', 'xml', 'toml', 'sh', 'bash', 'zsh', 'just', 'gitcommit', 'diff', 'regex', 'http'
'json', 'xml', 'toml', 'sh', 'zsh', 'just', 'gitcommit', 'diff', 'regex', 'http'
}
Config.autocmd('FileType', filetypes, function(ev)