2022-02-28 03:11:17 +00:00
|
|
|
local opts = { noremap = true, silent = true }
|
|
|
|
local map = vim.api.nvim_set_keymap
|
|
|
|
|
|
|
|
map("", "<Space>", "<Nop>", opts)
|
|
|
|
vim.g.mapleader = " "
|
|
|
|
vim.g.maplocalleader = " "
|
|
|
|
|
|
|
|
-- Window Navigation without needing <C-w> first
|
|
|
|
map("n", "<C-h>", "<C-w>h", opts)
|
|
|
|
map("n", "<C-j>", "<C-w>j", opts)
|
|
|
|
map("n", "<C-k>", "<C-w>k", opts)
|
|
|
|
map("n", "<C-l>", "<C-w>l", opts)
|
|
|
|
|
2022-03-01 00:15:55 +00:00
|
|
|
-- Stay in visual mode when indenting
|
|
|
|
map("v", "<", "<gv", opts)
|
|
|
|
map("v", ">", ">gv", opts)
|
|
|
|
|
2022-02-28 03:11:17 +00:00
|
|
|
-- Resize with C-arrow
|
|
|
|
map("n", "<C-Up>", "<cmd>resize -2<CR>", opts)
|
|
|
|
map("n", "<C-Down>", "<cmd>resize +2<CR>", opts)
|
|
|
|
map("n", "<C-Left>", "<cmd>vertical resize -2<CR>", opts)
|
|
|
|
map("n", "<C-Right>", "<cmd>vertical resize +2<CR>", opts)
|
|
|
|
|
2022-03-01 02:58:43 +00:00
|
|
|
-- Close context menus
|
|
|
|
map('n', '<leader>w', '<cmd>cclose<CR>', opts)
|
|
|
|
|
2022-03-01 00:37:09 +00:00
|
|
|
-- Navigate buffers
|
2022-02-28 05:45:40 +00:00
|
|
|
map("n", "<S-l>", "<cmd>bnext<CR>", opts)
|
|
|
|
map("n", "<S-h>", "<cmd>bprevious<CR>", opts)
|
2022-03-01 02:58:43 +00:00
|
|
|
map("n", "<leader>q", "<cmd>Bdelete!<CR>", opts)
|
2022-02-28 05:45:40 +00:00
|
|
|
|
|
|
|
-- NvimTree
|
|
|
|
map('n', '<leader>e', '<cmd>NvimTreeToggle<CR>', opts)
|
|
|
|
map('n', '<leader>o', '<cmd>NvimTreeFocus<CR>', opts)
|
|
|
|
|
2022-02-28 14:41:22 +00:00
|
|
|
-- Comment
|
|
|
|
map('n', '<leader>/', '<cmd>lua require(\'Comment.api\').toggle_current_linewise()<CR>', opts)
|
|
|
|
map('v', '<leader>/', '<esc><cmd>lua require(\'Comment.api\').toggle_linewise_op(vim.fn.visualmode())<CR>', opts)
|
2022-02-28 05:45:40 +00:00
|
|
|
|
2022-03-01 00:07:07 +00:00
|
|
|
-- Telescope (See also configs/telescope.lua)
|
|
|
|
map("n", "<leader>ff", "<cmd>Telescope find_files<CR>", opts)
|
2022-03-01 02:58:43 +00:00
|
|
|
map("n", "<leader>fw", "<cmd>Telescope live_grep<CR>", opts)
|
2022-03-01 00:07:07 +00:00
|
|
|
map("n", "<leader>fb", "<cmd>Telescope buffers<CR>", opts)
|
|
|
|
map("n", "<leader>fh", "<cmd>Telescope help_tags<CR>", opts)
|
2022-03-01 02:58:43 +00:00
|
|
|
map("n", "<leader>fo", "<cmd>Telescope oldfiles<CR>", opts) -- This wasn't working for some reason in astrovim
|
2022-03-01 07:25:09 +00:00
|
|
|
map("n", "<leader>fs", "<cmd>Telescope git_status<CR>", opts)
|
|
|
|
map("n", "<leader>fc", "<cmd>Telescope git_commits<CR>", opts)
|
2022-03-01 00:07:07 +00:00
|
|
|
|
2022-05-01 17:43:11 +00:00
|
|
|
map("n", "gr", "<cmd>Telescope lsp_references<CR>", opts)
|
|
|
|
|
2022-03-01 02:58:43 +00:00
|
|
|
-- Lspsaga (See also configs/lspsaga.lua)
|
2022-05-01 17:43:11 +00:00
|
|
|
--map("n", "gl", "<cmd>Lspsaga show_line_diagnostics<CR>", opts)
|
2022-03-01 06:25:44 +00:00
|
|
|
map("n", "gpd", "<cmd>Lspsaga preview_definition<CR>", opts)
|
2022-05-01 17:43:11 +00:00
|
|
|
map("n", "gs", "<cmd>Lspsaga signature_help<CR>", opts)
|
2022-03-01 06:25:44 +00:00
|
|
|
map("i", "<C-s>", "<cmd>Lspsaga signature_help<CR>", opts)
|
|
|
|
map("n", "<leader>lr", "<cmd>Lspsaga rename<CR>", opts)
|
2022-05-01 17:43:11 +00:00
|
|
|
map("n", "<leader>la", "<cmd>Lspsaga code_action<CR>", opts)
|
2022-03-01 06:25:44 +00:00
|
|
|
map("n", "<C-u>", "<cmd>lua require('lspsaga.action').smart_scroll_with_saga(-1)<CR>", opts)
|
|
|
|
map("n", "<C-d>", "<cmd>lua require('lspsaga.action').smart_scroll_with_saga(1)<CR>", opts)
|
2022-03-01 02:58:43 +00:00
|
|
|
|
|
|
|
-- LSP (See also configs/lsp-installer.lua)
|
2022-05-01 17:43:11 +00:00
|
|
|
-- vim.api.nvim_buf_set_keymap(bufnr, "n", "K", "<cmd>lua vim.lsp.buf.hover()<CR>", opts)
|
|
|
|
-- vim.api.nvim_buf_set_keymap(bufnr, "n", "gl", "<cmd>lua vim.diagnostic.open_float({ source = true, prefix = function(d, i, ttl) return string.rep(' ', #tostring(ttl) - #tostring(i)) .. tostring(i) .. ': ', nil end })<CR>")
|
2022-03-01 06:25:44 +00:00
|
|
|
-- vim.api.nvim_buf_set_keymap(bufnr, "n", "gD", "<cmd>lua vim.lsp.buf.declaration()<CR>", opts)
|
|
|
|
-- vim.api.nvim_buf_set_keymap(bufnr, "n", "gd", "<cmd>lua vim.lsp.buf.definition()<CR>", opts)
|
|
|
|
-- vim.api.nvim_buf_set_keymap(bufnr, "n", "gi", "<cmd>lua vim.lsp.buf.implementation()<CR>", opts)
|
|
|
|
-- vim.api.nvim_buf_set_keymap(bufnr, "n", "go", "<cmd>lua vim.diagnostic.open_float()<CR>", opts)
|
|
|
|
-- vim.api.nvim_buf_set_keymap(bufnr, "n", "[d", '<cmd>lua vim.diagnostic.goto_prev({ border = "rounded" })<CR>', opts)
|
|
|
|
-- vim.api.nvim_buf_set_keymap(bufnr, "n", "]d", '<cmd>lua vim.diagnostic.goto_next({ border = "rounded" })<CR>', opts)
|
2022-05-01 17:43:11 +00:00
|
|
|
-- vim.api.nvim_buf_set_keymap(bufnr, "n", "<leader>ll", "<cmd>lua vim.diagnostic.setloclist()<CR>", opts)
|
|
|
|
-- vim.api.nvim_buf_set_keymap(bufnr, "n", "<leader>lf", "<cmd>lua vim.lsp.buf.formatting_sync()<CR>", opts)
|
|
|
|
|