Add which-key plugin and descriptions for all custom keymaps
This commit is contained in:
parent
9b831f0e3a
commit
8b714fabfa
3
init.lua
3
init.lua
@ -13,7 +13,6 @@ end
|
|||||||
vim.opt.rtp:prepend(lazypath)
|
vim.opt.rtp:prepend(lazypath)
|
||||||
vim.g.mapleader = " "
|
vim.g.mapleader = " "
|
||||||
require("lazy").setup("plugins")
|
require("lazy").setup("plugins")
|
||||||
require("maps").init()
|
|
||||||
require("commands")
|
require("commands")
|
||||||
|
|
||||||
vim.opt.backup = false
|
vim.opt.backup = false
|
||||||
@ -43,3 +42,5 @@ vim.opt.expandtab = false
|
|||||||
vim.opt.autoindent = true
|
vim.opt.autoindent = true
|
||||||
vim.opt.smartindent = true
|
vim.opt.smartindent = true
|
||||||
vim.opt.completeopt = { "menu", "menuone", "noselect" }
|
vim.opt.completeopt = { "menu", "menuone", "noselect" }
|
||||||
|
|
||||||
|
-- TODO replace config with opts in every plugin
|
||||||
|
@ -36,5 +36,6 @@
|
|||||||
"telescope-ui-select.nvim": { "branch": "master", "commit": "6e51d7da30bd139a6950adf2a47fda6df9fa06d2" },
|
"telescope-ui-select.nvim": { "branch": "master", "commit": "6e51d7da30bd139a6950adf2a47fda6df9fa06d2" },
|
||||||
"telescope.nvim": { "branch": "master", "commit": "a0bbec21143c7bc5f8bb02e0005fa0b982edc026" },
|
"telescope.nvim": { "branch": "master", "commit": "a0bbec21143c7bc5f8bb02e0005fa0b982edc026" },
|
||||||
"trouble.nvim": { "branch": "main", "commit": "6efc446226679fda0547c0fd6a7892fd5f5b15d8" },
|
"trouble.nvim": { "branch": "main", "commit": "6efc446226679fda0547c0fd6a7892fd5f5b15d8" },
|
||||||
"vimwiki": { "branch": "dev", "commit": "705ad1e0dded0e3b7ff5fac78547ab67c9d39bdf" }
|
"vimwiki": { "branch": "dev", "commit": "705ad1e0dded0e3b7ff5fac78547ab67c9d39bdf" },
|
||||||
|
"which-key.nvim": { "branch": "main", "commit": "bfec3d6bc0a9b0b2cb11644642f78c2c3915eef0" }
|
||||||
}
|
}
|
||||||
|
55
lua/maps.lua
55
lua/maps.lua
@ -1,55 +0,0 @@
|
|||||||
-- maps.lua
|
|
||||||
|
|
||||||
local maps = {}
|
|
||||||
|
|
||||||
local function map(mode, lhs, rhs, opts)
|
|
||||||
local options = { noremap = true }
|
|
||||||
if opts then options = vim.tbl_extend('force', options, opts) end
|
|
||||||
vim.api.nvim_set_keymap(mode, lhs, rhs, options)
|
|
||||||
end
|
|
||||||
|
|
||||||
function maps.term()
|
|
||||||
-- Open and move to resized terminal
|
|
||||||
map('n', '<leader>t', '<C-w>s<C-w>j :terminal<CR>:res 5<CR>i', { noremap = false })
|
|
||||||
-- Enter normal mode in terminal
|
|
||||||
map('t', 'ß<C-N>', '<C-\\><C-N>')
|
|
||||||
end
|
|
||||||
|
|
||||||
function maps.telescope()
|
|
||||||
map('n', '<Leader>ff', '<cmd>lua require(\'telescope.builtin\').git_files()<CR>')
|
|
||||||
map('n', '<Leader>fg', '<cmd>lua require(\'telescope.builtin\').live_grep()<CR>')
|
|
||||||
map('n', '<Leader>fb', '<cmd>lua require(\'telescope.builtin\').buffers()<CR>')
|
|
||||||
map('n', '<Leader>fh', '<cmd>lua require(\'telescope.builtin\').help_tags()<CR>')
|
|
||||||
end
|
|
||||||
|
|
||||||
function maps.fixIndent()
|
|
||||||
map('v', '<', '<gv')
|
|
||||||
map('v', '>', '>gv')
|
|
||||||
end
|
|
||||||
|
|
||||||
function maps.moveByRow()
|
|
||||||
-- When text is wrapped, move by terminal rows, not lines, unles a count is provided
|
|
||||||
map('n', 'j', 'v:count == 0 ? \'gj\' : \'j\'', { silent = true, expr = true })
|
|
||||||
map('n', 'k', 'v:count == 0 ? \'gk\' : \'k\'', { silent = true, expr = true })
|
|
||||||
end
|
|
||||||
|
|
||||||
function maps.centeredSearch()
|
|
||||||
map('n', 'n', 'nzzzv')
|
|
||||||
map('n', 'N', 'Nzzzv')
|
|
||||||
end
|
|
||||||
|
|
||||||
function maps.init()
|
|
||||||
vim.g.mapleader = " "
|
|
||||||
|
|
||||||
-- map('n', '<leader>b', '<cmd>NvimTreeToggle<CR>')
|
|
||||||
map('n', '<leader>b', '<cmd>Lexplore | vert res 30<CR>')
|
|
||||||
map('n', '<leader>cc', '<cmd>Telescope colorscheme<CR>')
|
|
||||||
|
|
||||||
maps.term()
|
|
||||||
maps.telescope()
|
|
||||||
maps.fixIndent()
|
|
||||||
maps.moveByRow()
|
|
||||||
maps.centeredSearch()
|
|
||||||
end
|
|
||||||
|
|
||||||
return maps
|
|
@ -1,12 +1,29 @@
|
|||||||
return {
|
return {
|
||||||
{
|
{
|
||||||
'mfussenegger/nvim-dap',
|
'mfussenegger/nvim-dap',
|
||||||
dependencies = { 'nvim-lua/plenary.nvim' }
|
dependencies = { 'nvim-lua/plenary.nvim' },
|
||||||
|
config = function()
|
||||||
|
local wk = require("which-key")
|
||||||
|
local dap = require("dap")
|
||||||
|
wk.add({
|
||||||
|
{ '<leader>d', group = "dap" },
|
||||||
|
{ '<leader>db', dap.toggle_breakpoint, desc = "Toggle breakpoint" },
|
||||||
|
{ '<leader>dc', dap.continue, desc = "Launch/resume debug session" },
|
||||||
|
{ '<leader>do', dap.step_over, desc = "Step over" },
|
||||||
|
{ '<leader>di', dap.step_into, desc = "Step into" },
|
||||||
|
{ '<leader>du', dap.step_out, desc = "Step out" },
|
||||||
|
})
|
||||||
|
end
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'rcarriga/nvim-dap-ui',
|
'rcarriga/nvim-dap-ui',
|
||||||
config = function()
|
config = function()
|
||||||
require("dapui").setup()
|
local dapui = require("dapui")
|
||||||
|
dapui.setup()
|
||||||
|
local wk = require("which-key")
|
||||||
|
wk.add({
|
||||||
|
{ '<leader>dd', dapui.toggle, desc = "Toggle dap ui" }
|
||||||
|
})
|
||||||
end,
|
end,
|
||||||
dependencies = { 'mfussenegger/nvim-dap', 'nvim-neotest/nvim-nio' }
|
dependencies = { 'mfussenegger/nvim-dap', 'nvim-neotest/nvim-nio' }
|
||||||
},
|
},
|
||||||
|
@ -5,26 +5,23 @@ local lsp_attach = function(client, buf)
|
|||||||
|
|
||||||
vim.lsp.inlay_hint.enable(true, nil)
|
vim.lsp.inlay_hint.enable(true, nil)
|
||||||
|
|
||||||
local opts = { noremap = true, silent = true }
|
|
||||||
vim.keymap.set('n', '<S-C-e>', require("telescope.builtin").diagnostics, opts)
|
|
||||||
|
|
||||||
|
|
||||||
local bufopts = { noremap = true, silent = true, buffer = buf }
|
local bufopts = { noremap = true, silent = true, buffer = buf }
|
||||||
|
local wk = require("which-key")
|
||||||
|
|
||||||
vim.keymap.set('n', '<space>e', vim.diagnostic.open_float, bufopts)
|
wk.add({
|
||||||
vim.keymap.set('n', '<C-e>', require("telescope.builtin").diagnostics, bufopts)
|
{ '<leader>e', vim.diagnostic.open_float, bufopts, desc = "Show diagnostics in buffer" },
|
||||||
vim.keymap.set('n', '<C-ü>d', vim.diagnostic.goto_prev, bufopts)
|
{ '<C-e>', require("telescope.builtin").diagnostics, bufopts, desc = "Show diagnostics under cursor" },
|
||||||
vim.keymap.set('n', '<C-¨>d', vim.diagnostic.goto_next, bufopts)
|
{ '<C-ü>d', vim.diagnostic.goto_prev, bufopts },
|
||||||
|
{ '<C-¨>d', vim.diagnostic.goto_next, bufopts },
|
||||||
|
|
||||||
vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, bufopts)
|
{ 'gD', vim.lsp.buf.declaration, bufopts, desc = "Go to declaration" },
|
||||||
vim.keymap.set('n', 'gd', vim.lsp.buf.definition, bufopts)
|
{ 'gd', vim.lsp.buf.definition, bufopts, desc = "Go to definition" },
|
||||||
vim.keymap.set('n', 'K', vim.lsp.buf.hover, bufopts)
|
{ 'gi', vim.lsp.buf.implementation, bufopts, desc = "Go to implementation" },
|
||||||
vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, bufopts)
|
{ '<C-k>', vim.lsp.buf.signature_help, bufopts, desc = "Show signature" },
|
||||||
vim.keymap.set('n', '<C-k>', vim.lsp.buf.signature_help, bufopts)
|
{ '<leader>rn', vim.lsp.buf.rename, bufopts, desc = "Rename" },
|
||||||
vim.keymap.set('n', '<space>D', vim.lsp.buf.type_definition, bufopts)
|
{ '<leader>ca', vim.lsp.buf.code_action, bufopts, desc = "Show code actions" },
|
||||||
vim.keymap.set('n', '<space>rn', vim.lsp.buf.rename, bufopts)
|
{ 'gr', require("telescope.builtin").lsp_references, bufopts, desc = "Shwo references" },
|
||||||
vim.keymap.set('n', '<space>ca', vim.lsp.buf.code_action, bufopts)
|
})
|
||||||
vim.keymap.set('n', 'gr', require("telescope.builtin").lsp_references, bufopts)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local mason_path = vim.fn.glob(vim.fn.stdpath "data" .. "/mason/packages/codelldb/extension/")
|
local mason_path = vim.fn.glob(vim.fn.stdpath "data" .. "/mason/packages/codelldb/extension/")
|
||||||
|
@ -8,6 +8,11 @@ return {
|
|||||||
vim.keymap.set("n", "<leader>gh", require("telescope.builtin").git_bcommits, opts)
|
vim.keymap.set("n", "<leader>gh", require("telescope.builtin").git_bcommits, opts)
|
||||||
vim.keymap.set("n", "<leader>gb", require("telescope.builtin").git_branches, opts)
|
vim.keymap.set("n", "<leader>gb", require("telescope.builtin").git_branches, opts)
|
||||||
vim.keymap.set("n", "<leader>gs", require("telescope.builtin").git_status, opts)
|
vim.keymap.set("n", "<leader>gs", require("telescope.builtin").git_status, opts)
|
||||||
|
vim.keymap.set('n', '<Leader>ff', '<cmd>lua require(\'telescope.builtin\').git_files()<CR>', opts)
|
||||||
|
vim.keymap.set('n', '<Leader>fg', '<cmd>lua require(\'telescope.builtin\').live_grep()<CR>', opts)
|
||||||
|
vim.keymap.set('n', '<Leader>fb', '<cmd>lua require(\'telescope.builtin\').buffers()<CR>', opts)
|
||||||
|
vim.keymap.set('n', '<Leader>fh', '<cmd>lua require(\'telescope.builtin\').help_tags()<CR>', opts)
|
||||||
|
vim.keymap.set('n', '<leader>cc', '<cmd>Telescope colorscheme<CR>')
|
||||||
end
|
end
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
60
lua/plugins/wk.lua
Normal file
60
lua/plugins/wk.lua
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
-- maps.lua
|
||||||
|
|
||||||
|
local maps = {}
|
||||||
|
|
||||||
|
function maps.term()
|
||||||
|
vim.api.nvim_set_keymap('n', '<leader>t', '<C-w>s<C-w>j :terminal<CR>:res 5<CR>i',
|
||||||
|
{ noremap = false, desc = "Open and move to terminal" })
|
||||||
|
vim.api.nvim_set_keymap('t', 'ß<C-N>', '<C-\\><C-N>', { noremap = true, desc = "Enter normal mode in terminal" })
|
||||||
|
end
|
||||||
|
|
||||||
|
function maps.fixIndent()
|
||||||
|
vim.api.nvim_set_keymap('v', '<', '<gv', { noremap = true, desc = "Remove identation level" })
|
||||||
|
vim.api.nvim_set_keymap('v', '>', '>gv', { noremap = true, desc = "Add identation level" })
|
||||||
|
end
|
||||||
|
|
||||||
|
function maps.moveByRow()
|
||||||
|
-- When text is wrapped, move by terminal rows, not lines, unles a count is provided
|
||||||
|
vim.api.nvim_set_keymap('n', 'j', 'v:count == 0 ? \'gj\' : \'j\'',
|
||||||
|
{ silent = true, expr = true, desc = "Go down 1 line" })
|
||||||
|
vim.api.nvim_set_keymap('n', 'k', 'v:count == 0 ? \'gk\' : \'k\'',
|
||||||
|
{ silent = true, expr = true, desc = "Go up 1 line" })
|
||||||
|
end
|
||||||
|
|
||||||
|
function maps.centeredSearch()
|
||||||
|
vim.api.nvim_set_keymap('n', 'n', 'nzzzv', { noremap = true, desc = "Search next" })
|
||||||
|
vim.api.nvim_set_keymap('n', 'N', 'Nzzzv', { noremap = true, desc = "Search previous" })
|
||||||
|
end
|
||||||
|
|
||||||
|
function maps.init()
|
||||||
|
vim.g.mapleader = " "
|
||||||
|
|
||||||
|
vim.api.nvim_set_keymap('n', '<leader>b', '<cmd>Lexplore | vert res 30<CR>',
|
||||||
|
{ noremap = true, desc = "Open file explorer" })
|
||||||
|
|
||||||
|
maps.term()
|
||||||
|
maps.fixIndent()
|
||||||
|
maps.moveByRow()
|
||||||
|
maps.centeredSearch()
|
||||||
|
end
|
||||||
|
|
||||||
|
return {
|
||||||
|
"folke/which-key.nvim",
|
||||||
|
event = "VeryLazy",
|
||||||
|
keys = {
|
||||||
|
{
|
||||||
|
"<leader>?",
|
||||||
|
function()
|
||||||
|
require("which-key").show({ global = false })
|
||||||
|
end,
|
||||||
|
desc = "Buffer Local Keymaps (which-key)",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
config = function()
|
||||||
|
require("which-key").setup({
|
||||||
|
preset = "helix"
|
||||||
|
})
|
||||||
|
local wk = require("which-key")
|
||||||
|
maps.init()
|
||||||
|
end
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user