dot/config/nvim/lua/config_mappings.lua

97 lines
3.8 KiB
Lua

require('utils')
local wk = require("which-key")
wk.register({
f = {
name = "find",
f = { "<cmd>Telescope find_files<cr>", "File" },
r = { "<cmd>Telescope live_grep<cr>", "Rip Grep" },
b = { "<cmd>Telescope buffers<cr>", "Buffers" },
h = { "<cmd>Telescope help_tags<cr>", "Help Tags" },
s = { "<cmd>Telescope colorscheme<cr>", "Colorscheme" },
c = { "<cmd>Telescope commands<cr>", "Commands" },
g = { "<cmd>Telescope find_files search_dirs={'~/owc/gpt'}<CR>", "GPT" },
},
}, { prefix = "<leader>" })
wk.register({
b = {
name = "buffer",
q = { "<cmd>enew | bd #<CR>", "Quit" },
n = { "<cmd>bnext<cr>", "Next" },
p = { "<cmd>bprevious<cr>", "Prev" },
a = { "<cmd>unhide<cr>", "Show All" },
o = { "<cmd>Telescope buffers<cr>", "Open" },
e = { "<cmd>Oil<cr>", "Explorer" },
g = { "<cmd>GptCompleteFile<cr>", "GPT Complete" },
},
}, { prefix = "<leader>" })
wk.register({
w = {
name = "vim",
e = { "<cmd>edit ~/.config/nvim/init.lua<cr>", "Edit init.lua" },
r = { "<cmd>luafile ~/.config/nvim/init.lua<cr>|<cmd>source %<cr>", "Reload config" },
q = { "<cmd>q!<cr>", "Quit" },
a = { "<cmd>quitall!<cr>", "Quit All" },
w = { "<cmd>w<cr>", "Write" },
l = { "<cmd>SplitOrMove l<cr>", "Split or move right" },
h = { "<cmd>SplitOrMove h<cr>", "Split or move left" },
j = { "<cmd>SplitOrMove j<cr>", "Split or move down" },
k = { "<cmd>SplitOrMove k<cr>", "Split or move up" },
s = {
name = "resize", -- this does not stay open which makes it useless
k = { "<cmd>horizontal resize +5<cr>", "Resize up" },
j = { "<cmd>horizontal resize -5<cr>", "Resize down" },
h = { "<cmd>vertical resize +5<cr>", "Resize right" },
l = { "<cmd>vertical resize -5<cr>", "Resize left" },
}
},
}, { prefix = "<leader>" })
wk.register({
v = {
name = "Votion",
n = { "<cmd>VotionNew<cr>", "New" },
o = { "<cmd>VotionOpen<cr>", "Open" },
g = { "<cmd>VotionGrep<cr>", "Grep" },
i = { "<cmd>VotionInsert<cr>", "Insert" },
r = { "<cmd>VotionRename<cr>", "Rename" },
f = { "<cmd>VotionFollow<cr>", "Follow" },
d = { "<cmd>VotionDelete<cr>", "Delete" },
},
}, { prefix = "<leader>" })
vim.api.nvim_create_autocmd('LspAttach', {
group = vim.api.nvim_create_augroup('UserLspConfig', {}),
callback = function(ev)
-- Enable completion triggered by <c-x><c-o>
vim.bo[ev.buf].omnifunc = 'v:lua.vim.lsp.omnifunc'
require("which-key").register({
l = {
name = "LSP",
D = { "<cmd>lua vim.lsp.buf.declaration()<CR>", "Go to declaration" },
d = { "<cmd>lua vim.lsp.buf.definition()<CR>", "Go to definition" },
K = { "<cmd>lua vim.lsp.buf.hover()<CR>", "Show hover" },
i = { "<cmd>lua vim.lsp.buf.implementation()<CR>", "Go to implementation" },
k = { "<cmd>lua vim.lsp.buf.signature_help()<CR>", "Show signature help" },
-- a = { "<cmd>lua vim.lsp.buf.add_workspace_folder()<CR>", "Add workspace folder" },
-- r = { "<cmd>lua vim.lsp.buf.remove_workspace_folder()<CR>", "Remove workspace folder" },
-- l = { "<cmd>lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<CR>", "List workspace folders" },
t = { "<cmd>lua vim.lsp.buf.type_definition()<CR>", "Go to type definition" },
r = { "<cmd>lua vim.lsp.buf.rename()<CR>", "Rename" },
c = { "<cmd>lua vim.lsp.buf.code_action()<CR>", "Code action" },
r = { "<cmd>lua vim.lsp.buf.references()<CR>", "Show references" },
f = { "<cmd>lua vim.diagnostic.open_float()<CR>", "Diagnostics float" },
p = { "<cmd>lua vim.diagnostic.goto_prev()<CR>", "Go to prev error" },
n = { "<cmd>lua vim.diagnostic.goto_next()<CR>", "Go to next error" },
l = { "<cmd>lua vim.diagnostic.setloclist()<CR>", "Set location list" },
},
}, { prefix = "<leader>" })
end,
})