123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- local opts = { silent = true }
- -- ; as :
- vim.keymap.set({'n', 'v'}, ';', ':')
- -- leave insert mode via jj
- vim.keymap.set('i', 'jj', '<ESC>', opts)
- -- j/k with wraps
- vim.keymap.set({'n', 'v'}, 'j', 'gj', opts)
- vim.keymap.set({'n', 'v'}, 'k', 'gk', opts)
- -- leave insert mode with <ESC><ESC>
- vim.keymap.set('t', '<ESC><ESC>', '<C-\\><C-N>', opts)
- -- allow pressing enter to autocomplete
- vim.keymap.set('i', '<CR>', 'pumvisible() ? "\\<C-y>" : "\\<CR>"', { expr = true })
- -- pickers
- vim.keymap.set('n', '<C-P>', '<cmd>lua project_files()<CR>', opts)
- vim.keymap.set('n', '<C-O>', '<cmd>Telescope buffers<CR>', opts)
- vim.keymap.set('n', '<Leader>ff', '<cmd>Telescope live_grep<CR>', opts)
- -- cursor display
- vim.keymap.set('n', '<Leader>c', '<cmd>set cursorline! cursorcolumn!<CR>', opts)
- -- git
- vim.keymap.set('n', '<Leader>gs', '<cmd>Git<CR>', opts)
- vim.keymap.set('n', '<Leader>gll', '<cmd>Git log --oneline origin/HEAD..HEAD<CR>', opts)
- vim.keymap.set('n', '<Leader>gb', '<cmd>Telescope git_branches<CR>', opts)
- -- undotree
- vim.keymap.set('n', '<Leader>ut', '<cmd>UndotreeToggle<CR>', opts)
- -- opening terminals
- vim.keymap.set('n', '<Leader>tv', '<cmd>vsp term://$SHELL<CR>', opts)
- vim.keymap.set('n', '<Leader>to', '<cmd>term<CR>', opts)
- -- delete buffer
- vim.keymap.set('n', '<Leader>q', '<cmd>lua MiniBufremove.delete()<CR>', opts)
- -- diagnostics
- vim.keymap.set('n', '<space>e', '<cmd>lua vim.diagnostic.open_float()<CR>', opts)
- vim.keymap.set('n', '[d', '<cmd>lua vim.diagnostic.goto_prev()<CR>', opts)
- vim.keymap.set('n', ']d', '<cmd>lua vim.diagnostic.goto_next()<CR>', opts)
- vim.keymap.set('n', '<space>q', '<cmd>lua vim.diagnostic.setqflist({ severity = { min = vim.diagnostic.severity.WARN } })<CR>', opts)
- function on_attach(client, bufnr)
- local opts = { silent = true, buffer = bufnr }
- -- Enable completion triggered by <c-x><c-o>
- vim.bo.omnifunc = 'v:lua.MiniCompletion.completefunc_lsp'
- -- LSP-specific mappings
- vim.keymap.set('n', 'gD', '<cmd>lua vim.lsp.buf.declaration()<CR>', opts)
- vim.keymap.set('n', 'gd', '<cmd>lua vim.lsp.buf.definition()<CR>', opts)
- vim.keymap.set('n', 'K', '<cmd>lua vim.lsp.buf.hover()<CR>', opts)
- vim.keymap.set('n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<CR>', opts)
- vim.keymap.set('n', '<C-k>', '<cmd>lua vim.lsp.buf.signature_help()<CR>', opts)
- vim.keymap.set('n', '<space>wa', '<cmd>lua vim.lsp.buf.add_workspace_folder()<CR>', opts)
- vim.keymap.set('n', '<space>wr', '<cmd>lua vim.lsp.buf.remove_workspace_folder()<CR>', opts)
- vim.keymap.set('n', '<space>wl', '<cmd>lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<CR>', opts)
- vim.keymap.set('n', '<space>D', '<cmd>lua vim.lsp.buf.type_definition()<CR>', opts)
- vim.keymap.set('n', '<space>rn', '<cmd>lua vim.lsp.buf.rename()<CR>', opts)
- vim.keymap.set('n', '<space>ca', '<cmd>lua vim.lsp.buf.code_action()<CR>', opts)
- vim.keymap.set('v', '<space>ca', '<cmd>lua vim.lsp.buf.range_code_action()<CR><ESC>', opts)
- vim.keymap.set('n', 'gr', '<cmd>Telescope lsp_references<CR>', opts)
- vim.keymap.set('n', '<space>f', '<cmd>lua vim.lsp.buf.formatting()<CR>', opts)
- vim.keymap.set('n', '<Leader>fs', '<cmd>Telescope lsp_document_symbols<CR>', opts)
- end
|