diff --git a/plugin/20_keymaps.lua b/plugin/20_keymaps.lua index eeb6807..8da0c1f 100644 --- a/plugin/20_keymaps.lua +++ b/plugin/20_keymaps.lua @@ -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', 'bdelete', 'Delete') -nmap_leader('bD', 'bdelete!', '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', 'bwipeout', 'Wipeout') -nmap_leader('bW', 'bwipeout!', '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', 'lua require("dap").toggle_breakpoint()', 'Toggle Breakpoint') -nmap_leader('dl', 'lua require("dap").set_breakpoint(nil, nil, vim.fn.input("Log point: "))', 'Log point') -nmap_leader('dc', 'lua require("dap").continue()', 'Run/Continue') -nmap_leader('dC', 'lua require("dap").run_to_cursor()', 'Run to Cursor') -nmap_leader('de', 'lua require("dap.ui.widgets").hover()', 'Inspect') -nmap_leader('dr', 'lua require("dap").repl.open()', 'Open REPL') -nmap_leader('dt', 'lua require("dap").terminate()', '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', 'lua MiniFiles.open()', 'Directory') +nmap_leader('ed', function() MiniFiles.open() end, 'Directory') nmap_leader('ef', explore_at_file, 'File directory') -nmap_leader('ey', 'lua vim.fn.setreg("+", vim.fn.fnamemodify(vim.api.nvim_buf_get_name(0), ":."))', 'Yank absolute path') -nmap_leader('eY', 'lua vim.fn.setreg("+", vim.api.nvim_buf_get_name(0))', 'Yank relative path') -nmap_leader('en', 'messages', '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', 'Pick buffers', 'Buffers') -nmap_leader('fc', 'Pick git_commits', 'Commits (all)') -nmap_leader('fC', 'Pick git_commits path="%"', 'Commits (buf)') -nmap_leader('fd', 'Pick diagnostic scope="all"', 'Diagnostic workspace') -nmap_leader('fD', 'Pick diagnostic scope="current"', 'Diagnostic buffer') -nmap_leader('ff', 'Pick files', 'Files') -nmap_leader('fg', 'Pick grep_live', 'Grep live') -nmap_leader('fG', 'Pick grep pattern=""', 'Grep word') -nmap_leader('fh', 'Pick help', 'Help tags') -nmap_leader('fl', 'Pick buf_lines scope="all"', 'Lines (all)') -nmap_leader('fL', 'Pick buf_lines scope="current"', 'Lines (buf)') -nmap_leader('fm', 'Pick git_status', 'Modified / changed files') -nmap_leader('fo', 'Pick oldfiles', 'Old / recent files') -nmap_leader('fr', 'Pick resume', 'Resume') -nmap_leader('fs', 'Pick lsp scope="workspace_symbol_live"', 'Symbols workspace') -nmap_leader('fS', 'Pick lsp scope="document_symbol"', 'Symbols document') -nmap_leader('f:', 'Pick history scope=":"', '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('') }) 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', 'Git add %', 'Add current file') -nmap_leader('go', 'lua MiniDiff.toggle_overlay()', 'Toggle overlay') -nmap_leader('gs', 'lua MiniGit.show_at_cursor()', 'Show at cursor') -xmap_leader('gs', 'lua MiniGit.show_at_cursor()', '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', 'lua vim.lsp.buf.code_action()', 'Actions') -nmap_leader('ld', 'lua vim.diagnostic.open_float()', 'Diagnostic popup') -nmap_leader('lf', 'lua require("conform").format({ async = true })', 'Format') -xmap_leader('lf', 'lua require("conform").format({ async = true })', 'Format selection') -nmap_leader('li', 'lua vim.lsp.buf.implementation()', 'Implementation') -nmap_leader('lh', 'lua vim.lsp.buf.hover()', 'Hover') -nmap_leader('ll', 'lua vim.lsp.codelens.run()', 'Lens') -nmap_leader('lr', 'lua vim.lsp.buf.rename()', 'Rename') -nmap_leader('lR', 'lua vim.lsp.buf.references()', 'References') -nmap_leader('ls', 'lua vim.lsp.buf.definition()', 'Source definition') -nmap_leader('lt', 'lua vim.lsp.buf.type_definition()', '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', 'lua require("kulala").run()', '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', 'horizontal term', 'Terminal (horizontal)') -nmap_leader('tt', 'vertical term', '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', 'lua require("terminal").open(vim.o.shell)', 'Terminal (popup)') -nmap_leader('tg', 'lua require("terminal").open("lazygit")', 'LazyGit') -nmap_leader('ts', 'lua require("terminal").open("lazysql")', '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('', 'tabnew', 'New tab') -nmap_leader('d', 'tabclose', 'Close tab') -nmap_leader(']', 'tabnext', 'Next tab') -nmap_leader('[', 'tabprevious', 'Previous tab') +nmap_leader('', vim.cmd.tabnew, 'New tab') +nmap_leader('d', vim.cmd.tabclose, 'Close tab') +nmap_leader(']', vim.cmd.tabnext, 'Next tab') +nmap_leader('[', 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', '', 'nohlsearch', { desc = 'Clear highlights', silent = true }) +vim.keymap.set('n', '', vim.cmd.nohlsearch, { desc = 'Clear highlights', silent = true }) vim.keymap.set('t', '', '', { desc = 'Terminal window navigation', silent = true }) diff --git a/plugin/40_plugins.lua b/plugin/40_plugins.lua index f1555aa..adf26d8 100644 --- a/plugin/40_plugins.lua +++ b/plugin/40_plugins.lua @@ -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)