local map = vim.api.nvim_set_keymap -- Avoid infinitely recursive definitions options = { noremap = true } -- Copy/paste map('n', 'y', '"+y', options) map('v', 'y', '"+y', options) -- WINDOW MANAGEMENT -- Navigate windows map('n', '', 'h', options) map('n', '', 'j', options) map('n', '', 'k', options) map('n', '', 'l', options) -- Move windows TODO -- Terminal map('t', '', '', options) -- Exit Terminal mode enter Normal -- FILE NAVIGATION map('n', '', 'Telescope git_files', options) map('n', '', 'Telescope find_files', options) -- Grep for prompted str project wide map('n', 'ps', "lua require('telescope.builtin').grep_string({ search = vim.fn.input(\"Grep For > \")})", options) -- Telescope fuzzy search for buffers map('n', 'pb', "lua require('telescope.builtin').buffers()", options) -- CODE NAVIGATOIN -- Quick Fix Lists -- global -- using control map('n', 'J', 'cnextzz', options) -- Go to next item in global qfixlist map('n', 'K', 'cprevzz', options) -- Go to previous item in global qfixlist -- Toggle the window if there are items in the qfixlist; allow recursive map('n', 'Q', 'call ToggleQFList(1)', {}) -- see plugin/navigation.vim for ToggleQFList definition -- local -- using leader map('n', 'j', 'lnextzz', options) -- Go to next item in local qfixlist map('n', 'k', 'lprevzz', options) -- Go to previous item in global qfixlist -- Toggle the window if there are items in the qfixlist; allow recursive map('n', 'q', 'call ToggleQFList(0)', {}) -- see plugin/navigation.vim for ToggleQFList definition -- git map('n', 'gs', 'G', options) -- Show git status map('n', 'gc', 'G commit', options) -- git commit map('n', 'gP', 'G push', {}) -- git push -- LSP -- Use an on_attach function to only map the following keys -- after the language server attaches to the current buffer local on_attach = function(client, bufnr) local function buf_set_keymap(...) vim.api.nvim_buf_set_keymap(bufnr, ...) end local function buf_set_option(...) vim.api.nvim_buf_set_option(bufnr, ...) end -- Enable completion triggered by buf_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc') -- Mappings. local opts = { noremap=true, silent=true } buf_set_keymap('n', 'gD', 'lua vim.lsp.buf.declaration()', options) buf_set_keymap('n', 'gd', 'lua vim.lsp.buf.definition()', options) buf_set_keymap('n', '', 'lua vim.lsp.buf.hover()', options) buf_set_keymap('n', 'gi', 'lua vim.lsp.buf.implementation()', options) buf_set_keymap('n', 's', 'lua vim.lsp.buf.signature_help()', options) buf_set_keymap('n', 'rn', 'lua vim.lsp.buf.rename()', options) buf_set_keymap('n', 'ga', 'lua vim.lsp.buf.code_action()', { noremap = true }) buf_set_keymap('n', 'gr', 'lua vim.lsp.buf.references()', options) buf_set_keymap('n', 'd', 'lua vim.lsp.diagnostic.show_line_diagnostics()', options) -- buf_set_keymap('n', '[d', 'lua vim.lsp.diagnostic.goto_prev()', options) -- buf_set_keymap('n', ']d', 'lua vim.lsp.diaoNostic.goto_next()', options) buf_set_keymap('n', 'q', 'lua vim.diagnostic.set_qflist()', options) buf_set_keymap('n', 'f', 'lua vim.lsp.buf.formatting()', options) end -- Code actions map('n', 't', 'CargoTest', options) -- Run test under cursor return { on_attach = on_attach }