2022-06-19 08:13:11 +00:00
|
|
|
-- n, v, i, t = mode names
|
2021-08-22 07:49:15 +00:00
|
|
|
|
2022-05-14 10:53:02 +00:00
|
|
|
local function termcodes(str)
|
2022-07-22 16:00:00 +00:00
|
|
|
return vim.api.nvim_replace_termcodes(str, true, true, true)
|
2022-05-14 10:53:02 +00:00
|
|
|
end
|
|
|
|
|
2022-04-27 15:42:28 +00:00
|
|
|
local M = {}
|
|
|
|
|
2022-05-12 12:56:01 +00:00
|
|
|
M.general = {
|
2022-07-22 16:00:00 +00:00
|
|
|
i = {
|
|
|
|
-- go to beginning and end
|
2022-08-09 01:19:38 +00:00
|
|
|
["<C-b>"] = { "<ESC>^i", "beginning of line" },
|
|
|
|
["<C-e>"] = { "<End>", "end of line" },
|
2022-07-22 16:00:00 +00:00
|
|
|
|
|
|
|
-- navigate within insert mode
|
2022-08-09 01:19:38 +00:00
|
|
|
["<C-h>"] = { "<Left>", "move left" },
|
|
|
|
["<C-l>"] = { "<Right>", "move right" },
|
|
|
|
["<C-j>"] = { "<Down>", "move down" },
|
|
|
|
["<C-k>"] = { "<Up>", "move up" },
|
2022-07-22 16:00:00 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
n = {
|
2022-08-09 01:19:38 +00:00
|
|
|
["<ESC>"] = { "<cmd> noh <CR>", "no highlight" },
|
2022-07-22 16:00:00 +00:00
|
|
|
|
|
|
|
-- switch between windows
|
2022-08-09 01:19:38 +00:00
|
|
|
["<C-h>"] = { "<C-w>h", "window left" },
|
|
|
|
["<C-l>"] = { "<C-w>l", "window right" },
|
|
|
|
["<C-j>"] = { "<C-w>j", "window down" },
|
|
|
|
["<C-k>"] = { "<C-w>k", "window up" },
|
2022-07-22 16:00:00 +00:00
|
|
|
|
|
|
|
-- save
|
2022-08-09 01:19:38 +00:00
|
|
|
["<C-s>"] = { "<cmd> w <CR>", "save file" },
|
2022-07-22 16:00:00 +00:00
|
|
|
|
|
|
|
-- Copy all
|
2022-08-09 01:19:38 +00:00
|
|
|
["<C-c>"] = { "<cmd> %y+ <CR>", "copy whole file" },
|
2022-07-22 16:00:00 +00:00
|
|
|
|
|
|
|
-- line numbers
|
2022-08-09 01:19:38 +00:00
|
|
|
["<leader>n"] = { "<cmd> set nu! <CR>", "toggle line number" },
|
|
|
|
["<leader>rn"] = { "<cmd> set rnu! <CR>", "toggle relative number" },
|
2022-07-22 16:00:00 +00:00
|
|
|
|
|
|
|
-- update nvchad
|
2022-08-09 01:19:38 +00:00
|
|
|
["<leader>uu"] = { "<cmd> :NvChadUpdate <CR>", "update nvchad" },
|
2022-07-22 16:00:00 +00:00
|
|
|
|
|
|
|
["<leader>tt"] = {
|
|
|
|
function()
|
|
|
|
require("base46").toggle_theme()
|
|
|
|
end,
|
2022-08-09 01:19:38 +00:00
|
|
|
"toggle theme",
|
2022-07-22 16:00:00 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
-- Allow moving the cursor through wrapped lines with j, k, <Up> and <Down>
|
|
|
|
-- http://www.reddit.com/r/vim/comments/2k4cbr/problem_with_gj_and_gk/
|
|
|
|
-- empty mode is same as using <cmd> :map
|
|
|
|
-- also don't use g[j|k] when in operator pending mode, so it doesn't alter d, y or c behaviour
|
|
|
|
["j"] = { 'v:count || mode(1)[0:1] == "no" ? "j" : "gj"', opts = { expr = true } },
|
|
|
|
["k"] = { 'v:count || mode(1)[0:1] == "no" ? "k" : "gk"', opts = { expr = true } },
|
|
|
|
["<Up>"] = { 'v:count || mode(1)[0:1] == "no" ? "k" : "gk"', opts = { expr = true } },
|
|
|
|
["<Down>"] = { 'v:count || mode(1)[0:1] == "no" ? "j" : "gj"', opts = { expr = true } },
|
|
|
|
|
2022-08-04 14:32:16 +00:00
|
|
|
-- new buffer
|
2022-08-23 13:24:04 +00:00
|
|
|
["<leader>b"] = { "<cmd> enew <CR>", "new buffer" },
|
2022-07-22 16:00:00 +00:00
|
|
|
},
|
|
|
|
|
2022-08-09 01:19:38 +00:00
|
|
|
t = { ["<C-x>"] = { termcodes "<C-\\><C-N>", "escape terminal mode" } },
|
2022-08-04 14:32:16 +00:00
|
|
|
|
2022-07-22 16:00:00 +00:00
|
|
|
v = {
|
|
|
|
["<Up>"] = { 'v:count || mode(1)[0:1] == "no" ? "k" : "gk"', opts = { expr = true } },
|
|
|
|
["<Down>"] = { 'v:count || mode(1)[0:1] == "no" ? "j" : "gj"', opts = { expr = true } },
|
2022-09-08 10:45:35 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
x = {
|
2022-09-08 10:55:15 +00:00
|
|
|
["j"] = { 'v:count || mode(1)[0:1] == "no" ? "j" : "gj"', opts = { expr = true } },
|
|
|
|
["k"] = { 'v:count || mode(1)[0:1] == "no" ? "k" : "gk"', opts = { expr = true } },
|
2022-07-22 16:00:00 +00:00
|
|
|
-- Don't copy the replaced text after pasting in visual mode
|
|
|
|
-- https://vim.fandom.com/wiki/Replace_a_word_with_yanked_text#Alternative_mapping_for_paste
|
|
|
|
["p"] = { 'p:let @+=@0<CR>:let @"=@0<CR>', opts = { silent = true } },
|
|
|
|
},
|
2022-05-12 12:56:01 +00:00
|
|
|
}
|
|
|
|
|
2022-06-24 13:54:59 +00:00
|
|
|
M.tabufline = {
|
2022-08-04 14:32:16 +00:00
|
|
|
plugin = true,
|
2022-08-09 01:19:38 +00:00
|
|
|
|
2022-07-22 16:00:00 +00:00
|
|
|
n = {
|
|
|
|
-- cycle through buffers
|
2022-08-02 14:51:40 +00:00
|
|
|
["<TAB>"] = {
|
|
|
|
function()
|
2022-09-15 02:21:13 +00:00
|
|
|
require("nvchad_ui.tabufline").tabuflineNext()
|
2022-08-02 14:51:40 +00:00
|
|
|
end,
|
2022-08-09 01:19:38 +00:00
|
|
|
"goto next buffer",
|
2022-08-02 14:51:40 +00:00
|
|
|
},
|
2022-07-22 16:00:00 +00:00
|
|
|
|
2022-08-02 14:51:40 +00:00
|
|
|
["<S-Tab>"] = {
|
|
|
|
function()
|
2022-09-15 02:21:13 +00:00
|
|
|
require("nvchad_ui.tabufline").tabuflinePrev()
|
2022-08-02 14:51:40 +00:00
|
|
|
end,
|
2022-08-09 01:19:38 +00:00
|
|
|
"goto prev buffer",
|
2022-08-02 14:51:40 +00:00
|
|
|
},
|
2022-07-22 16:00:00 +00:00
|
|
|
|
2022-08-02 15:41:18 +00:00
|
|
|
-- pick buffers via numbers
|
2022-08-09 01:19:38 +00:00
|
|
|
["<Bslash>"] = { "<cmd> TbufPick <CR>", "Pick buffer" },
|
2022-09-15 02:21:13 +00:00
|
|
|
|
|
|
|
-- close buffer + hide terminal buffer
|
|
|
|
["<leader>x"] = {
|
|
|
|
function()
|
|
|
|
require("nvchad_ui.tabufline").close_buffer()
|
|
|
|
end,
|
|
|
|
"close buffer",
|
|
|
|
},
|
2022-07-22 16:00:00 +00:00
|
|
|
},
|
2022-05-12 12:56:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
M.comment = {
|
2022-08-04 14:32:16 +00:00
|
|
|
plugin = true,
|
2022-08-09 01:19:38 +00:00
|
|
|
|
2022-07-22 16:00:00 +00:00
|
|
|
-- toggle comment in both modes
|
|
|
|
n = {
|
|
|
|
["<leader>/"] = {
|
|
|
|
function()
|
2022-08-13 00:22:33 +00:00
|
|
|
require("Comment.api").toggle.linewise.current()
|
2022-07-22 16:00:00 +00:00
|
|
|
end,
|
2022-08-09 01:19:38 +00:00
|
|
|
"toggle comment",
|
2022-07-22 16:00:00 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
v = {
|
|
|
|
["<leader>/"] = {
|
2022-08-13 00:22:33 +00:00
|
|
|
"<ESC><cmd>lua require('Comment.api').toggle.linewise(vim.fn.visualmode())<CR>",
|
2022-08-09 01:19:38 +00:00
|
|
|
"toggle comment",
|
2022-07-22 16:00:00 +00:00
|
|
|
},
|
|
|
|
},
|
2022-05-12 12:56:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
M.lspconfig = {
|
2022-08-04 14:32:16 +00:00
|
|
|
plugin = true,
|
2022-08-09 01:19:38 +00:00
|
|
|
|
2022-07-22 16:00:00 +00:00
|
|
|
-- See `<cmd> :help vim.lsp.*` for documentation on any of the below functions
|
|
|
|
|
|
|
|
n = {
|
|
|
|
["gD"] = {
|
|
|
|
function()
|
|
|
|
vim.lsp.buf.declaration()
|
|
|
|
end,
|
2022-08-09 01:19:38 +00:00
|
|
|
"lsp declaration",
|
2022-07-22 16:00:00 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
["gd"] = {
|
|
|
|
function()
|
|
|
|
vim.lsp.buf.definition()
|
|
|
|
end,
|
2022-08-09 01:19:38 +00:00
|
|
|
"lsp definition",
|
2022-07-22 16:00:00 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
["K"] = {
|
|
|
|
function()
|
|
|
|
vim.lsp.buf.hover()
|
|
|
|
end,
|
2022-08-09 01:19:38 +00:00
|
|
|
"lsp hover",
|
2022-07-22 16:00:00 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
["gi"] = {
|
|
|
|
function()
|
|
|
|
vim.lsp.buf.implementation()
|
|
|
|
end,
|
2022-08-09 01:19:38 +00:00
|
|
|
"lsp implementation",
|
2022-07-22 16:00:00 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
["<leader>ls"] = {
|
|
|
|
function()
|
|
|
|
vim.lsp.buf.signature_help()
|
|
|
|
end,
|
2022-08-09 01:19:38 +00:00
|
|
|
"lsp signature_help",
|
2022-07-22 16:00:00 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
["<leader>D"] = {
|
|
|
|
function()
|
|
|
|
vim.lsp.buf.type_definition()
|
|
|
|
end,
|
2022-08-09 01:19:38 +00:00
|
|
|
"lsp definition type",
|
2022-07-22 16:00:00 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
["<leader>ra"] = {
|
|
|
|
function()
|
|
|
|
require("nvchad_ui.renamer").open()
|
|
|
|
end,
|
2022-08-09 01:19:38 +00:00
|
|
|
"lsp rename",
|
2022-07-22 16:00:00 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
["<leader>ca"] = {
|
|
|
|
function()
|
|
|
|
vim.lsp.buf.code_action()
|
|
|
|
end,
|
2022-08-09 01:19:38 +00:00
|
|
|
"lsp code_action",
|
2022-07-22 16:00:00 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
["gr"] = {
|
|
|
|
function()
|
2022-08-08 08:28:49 +00:00
|
|
|
vim.lsp.buf.references()
|
2022-07-22 16:00:00 +00:00
|
|
|
end,
|
2022-08-09 01:19:38 +00:00
|
|
|
"lsp references",
|
2022-07-22 16:00:00 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
["<leader>f"] = {
|
|
|
|
function()
|
|
|
|
vim.diagnostic.open_float()
|
|
|
|
end,
|
2022-08-09 01:19:38 +00:00
|
|
|
"floating diagnostic",
|
2022-07-22 16:00:00 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
["[d"] = {
|
|
|
|
function()
|
|
|
|
vim.diagnostic.goto_prev()
|
|
|
|
end,
|
2022-08-09 01:19:38 +00:00
|
|
|
"goto prev",
|
2022-07-22 16:00:00 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
["d]"] = {
|
|
|
|
function()
|
|
|
|
vim.diagnostic.goto_next()
|
|
|
|
end,
|
2022-08-09 01:19:38 +00:00
|
|
|
"goto_next",
|
2022-07-22 16:00:00 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
["<leader>q"] = {
|
|
|
|
function()
|
|
|
|
vim.diagnostic.setloclist()
|
|
|
|
end,
|
2022-08-09 01:19:38 +00:00
|
|
|
"diagnostic setloclist",
|
2022-07-22 16:00:00 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
["<leader>fm"] = {
|
|
|
|
function()
|
2022-08-04 14:32:16 +00:00
|
|
|
vim.lsp.buf.formatting {}
|
2022-07-22 16:00:00 +00:00
|
|
|
end,
|
2022-08-09 01:19:38 +00:00
|
|
|
"lsp formatting",
|
2022-07-22 16:00:00 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
["<leader>wa"] = {
|
|
|
|
function()
|
|
|
|
vim.lsp.buf.add_workspace_folder()
|
|
|
|
end,
|
2022-08-09 01:19:38 +00:00
|
|
|
"add workspace folder",
|
2022-07-22 16:00:00 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
["<leader>wr"] = {
|
|
|
|
function()
|
|
|
|
vim.lsp.buf.remove_workspace_folder()
|
|
|
|
end,
|
2022-08-09 01:19:38 +00:00
|
|
|
"remove workspace folder",
|
2022-07-22 16:00:00 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
["<leader>wl"] = {
|
|
|
|
function()
|
|
|
|
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
|
|
|
|
end,
|
2022-08-09 01:19:38 +00:00
|
|
|
"list workspace folders",
|
2022-07-22 16:00:00 +00:00
|
|
|
},
|
|
|
|
},
|
2022-05-12 12:56:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
M.nvimtree = {
|
2022-08-04 14:32:16 +00:00
|
|
|
plugin = true,
|
2022-08-09 01:19:38 +00:00
|
|
|
|
2022-07-22 16:00:00 +00:00
|
|
|
n = {
|
|
|
|
-- toggle
|
2022-08-09 01:19:38 +00:00
|
|
|
["<C-n>"] = { "<cmd> NvimTreeToggle <CR>", "toggle nvimtree" },
|
2022-05-12 12:56:01 +00:00
|
|
|
|
2022-07-22 16:00:00 +00:00
|
|
|
-- focus
|
2022-08-09 01:19:38 +00:00
|
|
|
["<leader>e"] = { "<cmd> NvimTreeFocus <CR>", "focus nvimtree" },
|
2022-07-22 16:00:00 +00:00
|
|
|
},
|
2022-05-12 12:56:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
M.telescope = {
|
2022-08-04 14:32:16 +00:00
|
|
|
plugin = true,
|
2022-08-09 01:19:38 +00:00
|
|
|
|
2022-07-22 16:00:00 +00:00
|
|
|
n = {
|
|
|
|
-- find
|
2022-08-09 01:19:38 +00:00
|
|
|
["<leader>ff"] = { "<cmd> Telescope find_files <CR>", "find files" },
|
|
|
|
["<leader>fa"] = { "<cmd> Telescope find_files follow=true no_ignore=true hidden=true <CR>", "find all" },
|
|
|
|
["<leader>fw"] = { "<cmd> Telescope live_grep <CR>", "live grep" },
|
|
|
|
["<leader>fb"] = { "<cmd> Telescope buffers <CR>", "find buffers" },
|
|
|
|
["<leader>fh"] = { "<cmd> Telescope help_tags <CR>", "help page" },
|
|
|
|
["<leader>fo"] = { "<cmd> Telescope oldfiles <CR>", "find oldfiles" },
|
|
|
|
["<leader>tk"] = { "<cmd> Telescope keymaps <CR>", "show keys" },
|
2022-07-22 16:00:00 +00:00
|
|
|
|
|
|
|
-- git
|
2022-08-09 01:19:38 +00:00
|
|
|
["<leader>cm"] = { "<cmd> Telescope git_commits <CR>", "git commits" },
|
|
|
|
["<leader>gt"] = { "<cmd> Telescope git_status <CR>", "git status" },
|
2022-07-22 16:00:00 +00:00
|
|
|
|
|
|
|
-- pick a hidden term
|
2022-08-09 01:19:38 +00:00
|
|
|
["<leader>pt"] = { "<cmd> Telescope terms <CR>", "pick hidden term" },
|
2022-07-22 16:00:00 +00:00
|
|
|
|
|
|
|
-- theme switcher
|
2022-08-09 01:19:38 +00:00
|
|
|
["<leader>th"] = { "<cmd> Telescope themes <CR>", "nvchad themes" },
|
2022-07-22 16:00:00 +00:00
|
|
|
},
|
2022-05-12 12:56:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
M.nvterm = {
|
2022-08-04 14:32:16 +00:00
|
|
|
plugin = true,
|
2022-08-09 01:19:38 +00:00
|
|
|
|
2022-07-22 16:00:00 +00:00
|
|
|
t = {
|
|
|
|
-- toggle in terminal mode
|
|
|
|
["<A-i>"] = {
|
|
|
|
function()
|
|
|
|
require("nvterm.terminal").toggle "float"
|
|
|
|
end,
|
2022-08-09 01:19:38 +00:00
|
|
|
"toggle floating term",
|
2022-07-22 16:00:00 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
["<A-h>"] = {
|
|
|
|
function()
|
|
|
|
require("nvterm.terminal").toggle "horizontal"
|
|
|
|
end,
|
2022-08-09 01:19:38 +00:00
|
|
|
"toggle horizontal term",
|
2022-07-22 16:00:00 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
["<A-v>"] = {
|
|
|
|
function()
|
|
|
|
require("nvterm.terminal").toggle "vertical"
|
|
|
|
end,
|
2022-08-09 01:19:38 +00:00
|
|
|
"toggle vertical term",
|
2022-07-22 16:00:00 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
n = {
|
|
|
|
-- toggle in normal mode
|
|
|
|
["<A-i>"] = {
|
|
|
|
function()
|
|
|
|
require("nvterm.terminal").toggle "float"
|
|
|
|
end,
|
2022-08-09 01:19:38 +00:00
|
|
|
"toggle floating term",
|
2022-07-22 16:00:00 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
["<A-h>"] = {
|
|
|
|
function()
|
|
|
|
require("nvterm.terminal").toggle "horizontal"
|
|
|
|
end,
|
2022-08-09 01:19:38 +00:00
|
|
|
"toggle horizontal term",
|
2022-07-22 16:00:00 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
["<A-v>"] = {
|
|
|
|
function()
|
|
|
|
require("nvterm.terminal").toggle "vertical"
|
|
|
|
end,
|
2022-08-09 01:19:38 +00:00
|
|
|
"toggle vertical term",
|
2022-07-22 16:00:00 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
-- new
|
|
|
|
|
|
|
|
["<leader>h"] = {
|
|
|
|
function()
|
|
|
|
require("nvterm.terminal").new "horizontal"
|
|
|
|
end,
|
2022-08-09 01:19:38 +00:00
|
|
|
"new horizontal term",
|
2022-07-22 16:00:00 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
["<leader>v"] = {
|
|
|
|
function()
|
|
|
|
require("nvterm.terminal").new "vertical"
|
|
|
|
end,
|
2022-08-09 01:19:38 +00:00
|
|
|
"new vertical term",
|
2022-07-22 16:00:00 +00:00
|
|
|
},
|
|
|
|
},
|
2022-05-12 12:56:01 +00:00
|
|
|
}
|
2021-08-22 07:49:15 +00:00
|
|
|
|
2022-05-12 20:13:00 +00:00
|
|
|
M.whichkey = {
|
2022-08-04 14:32:16 +00:00
|
|
|
plugin = true,
|
2022-08-09 01:19:38 +00:00
|
|
|
|
2022-07-22 16:00:00 +00:00
|
|
|
n = {
|
|
|
|
["<leader>wK"] = {
|
|
|
|
function()
|
|
|
|
vim.cmd "WhichKey"
|
|
|
|
end,
|
2022-08-09 01:19:38 +00:00
|
|
|
"which-key all keymaps",
|
2022-07-22 16:00:00 +00:00
|
|
|
},
|
|
|
|
["<leader>wk"] = {
|
|
|
|
function()
|
|
|
|
local input = vim.fn.input "WhichKey: "
|
|
|
|
vim.cmd("WhichKey " .. input)
|
|
|
|
end,
|
2022-08-09 01:19:38 +00:00
|
|
|
"which-key query lookup",
|
2022-07-22 16:00:00 +00:00
|
|
|
},
|
|
|
|
},
|
2022-05-12 20:13:00 +00:00
|
|
|
}
|
|
|
|
|
2022-06-18 04:27:17 +00:00
|
|
|
M.blankline = {
|
2022-08-04 14:32:16 +00:00
|
|
|
plugin = true,
|
2022-08-09 01:19:38 +00:00
|
|
|
|
2022-07-22 16:00:00 +00:00
|
|
|
n = {
|
2022-08-23 13:24:04 +00:00
|
|
|
["<leader>cc"] = {
|
2022-07-22 16:00:00 +00:00
|
|
|
function()
|
|
|
|
local ok, start = require("indent_blankline.utils").get_current_context(
|
|
|
|
vim.g.indent_blankline_context_patterns,
|
|
|
|
vim.g.indent_blankline_use_treesitter_scope
|
|
|
|
)
|
|
|
|
|
|
|
|
if ok then
|
|
|
|
vim.api.nvim_win_set_cursor(vim.api.nvim_get_current_win(), { start, 0 })
|
|
|
|
vim.cmd [[normal! _]]
|
|
|
|
end
|
|
|
|
end,
|
|
|
|
|
2022-08-09 01:19:38 +00:00
|
|
|
"Jump to current_context",
|
2022-07-22 16:00:00 +00:00
|
|
|
},
|
|
|
|
},
|
2022-06-18 04:27:17 +00:00
|
|
|
}
|
|
|
|
|
2021-08-22 07:49:15 +00:00
|
|
|
return M
|