local map = vim.keymap.set map('n', '', '', { silent = true }) map('i', ',m', '', { silent = true }) for _, mode in ipairs({ 'n', 'i', 'v', 's', 'x', 'c', 'o', 't' }) do map(mode, '', '', { silent = true }) end map('i', '', '', { silent = true }) for _, direction in ipairs({ 'h', 'j', 'k', 'l' }) do map('n', 'w' .. direction, '' .. direction, { desc = 'Move to window ' .. direction }) end map('n', 'fw', 'write', { desc = 'Write file' }) map('n', '', '', { desc = 'Alternate buffer' }) map('n', 'ff', 'Telescope find_files', { desc = 'Find files' }) map('n', 'fb', 'Oil .', { desc = 'Browse current directory' }) map('n', 'fc', 'Oil', { desc = 'Browse file directory' }) map('n', 'fo', 'Oil', { desc = 'Open file directory' }) map('n', 'ps', 'Telescope live_grep', { desc = 'Search text' }) map('n', 'bs', 'Telescope buffers', { desc = 'Search buffers' }) map('n', 'sr', 'GrugFar', { desc = 'Search and replace' }) map('n', 'rsr', 'GrugFarWithin', { desc = 'Open range replacement' }) map({ 'n', 'x' }, 'ca', vim.lsp.buf.code_action, { desc = 'Code action' }) map('n', 'lgd', vim.lsp.buf.definition, { desc = 'Go to definition' }) map('n', 'lgD', vim.lsp.buf.declaration, { desc = 'Go to declaration' }) map('n', 'lgr', vim.lsp.buf.references, { desc = 'Find references' }) map('n', 'lgi', vim.lsp.buf.implementation, { desc = 'Go to implementation' }) map('n', 'lr', vim.lsp.buf.rename, { desc = 'Rename symbol' }) map('n', 'lf', function() require('conform').format({ async = true, lsp_format = 'fallback' }) end, { desc = 'Format buffer' }) map('x', 'lrf', vim.lsp.buf.format, { desc = 'Format selection' }) map('n', 'K', function() vim.lsp.buf.hover({ border = 'rounded', max_width = 80 }) end, { desc = 'Hover documentation' }) map('n', 'lld', function() vim.diagnostic.open_float({ scope = 'line', border = 'rounded' }) end, { desc = 'Line diagnostics' }) map('n', 'lwd', 'Trouble diagnostics toggle', { desc = 'Workspace diagnostics' }) map('n', 'ldd', 'Trouble diagnostics toggle filter.buf=0', { desc = 'Buffer diagnostics' })