2022-09-19 07:47:06 -04:00
|
|
|
local wk = require('which-key')
|
|
|
|
local map = vim.keymap.set
|
|
|
|
|
2022-09-19 08:01:46 -04:00
|
|
|
vim.cmd([[
|
|
|
|
augroup keys_user_config
|
|
|
|
autocmd!
|
|
|
|
autocmd BufWritePost keys.lua source <afile>
|
|
|
|
augroup end
|
|
|
|
]])
|
|
|
|
|
2022-09-19 07:47:06 -04:00
|
|
|
wk.setup({
|
|
|
|
key_labels = {
|
|
|
|
['<space>'] = 'SPC',
|
|
|
|
['<cr>'] = 'RET',
|
|
|
|
['<tab>'] = 'TAB'
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
vim.opt.timeoutlen = 500
|
|
|
|
|
|
|
|
vim.g.mapleader = ' '
|
|
|
|
|
2022-09-19 08:01:46 -04:00
|
|
|
-- Handy to remap semi-colon to colon
|
2022-09-19 07:47:06 -04:00
|
|
|
map({ 'n', 'v' }, ';', ':')
|
|
|
|
map({ 'n', 'v' }, 'q;', 'q:')
|
|
|
|
|
2022-09-19 08:01:46 -04:00
|
|
|
-- System clipboard via <leader> -> y | p
|
|
|
|
map({ 'n', 'v' }, '<leader>y', '"+y')
|
|
|
|
map( 'n', 'Y', '"+Y')
|
|
|
|
map({ 'n', 'v' }, '<leader>p', '"+p')
|
|
|
|
map({ 'n', 'v' }, '<leader>P', '"+P')
|
|
|
|
|
|
|
|
-- Common short-hands
|
|
|
|
map('n', '<leader>w', '<cmd>w<cr>')
|
2022-12-12 10:34:24 -05:00
|
|
|
map('n', '<leader>q', '<cmd>q<cr>')
|
2022-09-19 08:01:46 -04:00
|
|
|
map('n', '<leader>o', '<cmd>only<cr>')
|
2022-12-12 10:34:24 -05:00
|
|
|
map('n', '<esc>', '<cmd>nohlsearch<cr>')
|
2022-09-19 08:01:46 -04:00
|
|
|
|
2022-09-19 07:47:06 -04:00
|
|
|
wk.register({
|
2023-11-03 13:09:39 -04:00
|
|
|
['<space>'] = { '<cmd>Telescope find_files<cr>', 'File file in project' },
|
2022-09-19 07:47:06 -04:00
|
|
|
['/'] = { '<cmd>Telescope live_grep<cr>', 'Search project' },
|
|
|
|
['<tab>'] = { '<cmd>NERDTreeToggle<cr>', 'Toggle NERDTree' },
|
|
|
|
|
|
|
|
f = {
|
|
|
|
name = 'file',
|
|
|
|
e = { '<cmd>Telescope find_files cwd=~/.config/nvim<cr>', 'Find file in .config/nvim' },
|
|
|
|
E = { '<cmd>e ~/.config/nvim<cr>', 'Browse .config/nvim' },
|
2023-04-05 07:57:14 -04:00
|
|
|
f = { '<cmd>Telescope find_files cwd=~/ hidden=true no_ignore=true no_ignore_parent=true follow=true theme=dropdown<cr>', 'Find file' },
|
|
|
|
F = { '<cmd>Telescope find_files theme=dropdown<cr>', 'File file from here' },
|
2022-09-19 07:47:06 -04:00
|
|
|
l = { '<cmd>NERDTreeFind<cr>', 'Locate file' },
|
|
|
|
r = { '<cmd>Telescope oldfiles<cr>', 'Recent files' },
|
|
|
|
},
|
|
|
|
|
|
|
|
e = {
|
|
|
|
name = 'editor',
|
|
|
|
p = {
|
|
|
|
name = 'packer',
|
|
|
|
s = { '<cmd>PackerSync<cr>', 'Packer Sync' },
|
|
|
|
c = { '<cmd>PackerCompile<cr>', 'Packer Compile' },
|
|
|
|
l = { '<cmd>PackerClean<cr>', 'Packer Clean' },
|
|
|
|
}
|
2022-09-19 08:01:46 -04:00
|
|
|
},
|
|
|
|
|
|
|
|
g = {
|
|
|
|
name = 'git',
|
|
|
|
s = { '<cmd>Git<cr>', 'Status' },
|
2023-08-31 13:19:30 -04:00
|
|
|
p = { '<cmd>Git push<cr>', 'Push' },
|
|
|
|
P = { '<cmd>Git push --force-with-lease<cr>', 'Push (force with lease)' },
|
2023-08-29 12:25:43 -04:00
|
|
|
f = { '<cmd>Git fetch<cr>', 'Fetch' },
|
2023-06-30 10:21:58 -04:00
|
|
|
r = {
|
2022-09-19 08:01:46 -04:00
|
|
|
name = 'rebase',
|
2023-04-05 07:57:14 -04:00
|
|
|
o = { '<cmd>Git rebase origin/main<cr>', 'origin/main' },
|
|
|
|
O = { '<cmd>Git rebase --interactive origin/main<cr>', '-i origin/main' },
|
2023-08-29 12:25:43 -04:00
|
|
|
m = { '<cmd>Git rebase origin/master<cr>', 'origin/master' },
|
|
|
|
M = { '<cmd>Git rebase --interactive origin/master<cr>', '-i origin/master' },
|
|
|
|
r = { '<cmd>Git rebase ', 'rebase ...' },
|
2022-09-19 08:01:46 -04:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2023-04-05 07:57:14 -04:00
|
|
|
i = {
|
|
|
|
name = 'insert',
|
|
|
|
e = { '<cmd>Telescope emoji theme=dropdown<cr>', 'emoji' },
|
|
|
|
},
|
|
|
|
|
2023-11-03 13:09:39 -04:00
|
|
|
n = {
|
|
|
|
name = 'line numbers',
|
|
|
|
a = { '<cmd>set number norelativenumber<cr>', 'absolute' },
|
|
|
|
r = { '<cmd>set number relativenumber<cr>', 'relative' },
|
|
|
|
}
|
|
|
|
|
2022-09-19 07:47:06 -04:00
|
|
|
}, { prefix = '<leader>' })
|
2023-08-17 10:20:21 -04:00
|
|
|
|
|
|
|
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'
|
|
|
|
|
|
|
|
-- Buffer local mappings.
|
|
|
|
-- See `:help vim.lsp.*` for documentation on any of the below functions
|
|
|
|
local opts = { buffer = ev.buf }
|
|
|
|
vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, opts)
|
|
|
|
vim.keymap.set('n', 'gd', vim.lsp.buf.definition, opts)
|
|
|
|
-- vim.keymap.set('n', 'K', vim.lsp.buf.hover, opts)
|
|
|
|
vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, opts)
|
|
|
|
-- vim.keymap.set('n', '<C-k>', vim.lsp.buf.signature_help, opts)
|
|
|
|
-- vim.keymap.set('n', '<space>wa', vim.lsp.buf.add_workspace_folder, opts)
|
|
|
|
-- vim.keymap.set('n', '<space>wr', vim.lsp.buf.remove_workspace_folder, opts)
|
|
|
|
-- vim.keymap.set('n', '<space>wl', function()
|
|
|
|
-- print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
|
|
|
|
-- end, opts)
|
|
|
|
-- vim.keymap.set('n', '<space>D', vim.lsp.buf.type_definition, opts)
|
|
|
|
-- vim.keymap.set('n', '<space>rn', vim.lsp.buf.rename, opts)
|
|
|
|
-- vim.keymap.set({ 'n', 'v' }, '<space>ca', vim.lsp.buf.code_action, opts)
|
|
|
|
vim.keymap.set('n', 'gr', vim.lsp.buf.references, opts)
|
2023-08-29 12:25:43 -04:00
|
|
|
vim.keymap.set('n', '<leader>F', function()
|
|
|
|
vim.lsp.buf.format { async = true }
|
|
|
|
end, opts)
|
2023-08-17 10:20:21 -04:00
|
|
|
end,
|
|
|
|
})
|