create and configure whichkey module

This commit is contained in:
Nick Burt 2024-01-08 18:36:07 -06:00
parent 26b5b21aa4
commit bee32df567
3 changed files with 20 additions and 22 deletions

View File

@ -1,9 +1,6 @@
-- Set <space> as the leader key
vim.g.mapleader = ' ' vim.g.mapleader = ' '
vim.g.maplocalleader = ' ' vim.g.maplocalleader = ' '
-- [[ Install `lazy.nvim` plugin manager ]]
-- https://github.com/folke/lazy.nvim
local lazypath = vim.fn.stdpath 'data' .. '/lazy/lazy.nvim' local lazypath = vim.fn.stdpath 'data' .. '/lazy/lazy.nvim'
if not vim.loop.fs_stat(lazypath) then if not vim.loop.fs_stat(lazypath) then
vim.fn.system { vim.fn.system {
@ -16,7 +13,6 @@ if not vim.loop.fs_stat(lazypath) then
} }
end end
vim.opt.rtp:prepend(lazypath) vim.opt.rtp:prepend(lazypath)
require('lazy').setup('plugins'); require('lazy').setup('plugins');
-- [[ Setting options ]] -- [[ Setting options ]]
@ -272,23 +268,6 @@ local on_attach = function(_, bufnr)
end, { desc = 'Format current buffer with LSP' }) end, { desc = 'Format current buffer with LSP' })
end end
-- document existing key chains
require('which-key').register {
['<leader>c'] = { name = '[C]ode', _ = 'which_key_ignore' },
['<leader>d'] = { name = '[D]ocument', _ = 'which_key_ignore' },
['<leader>g'] = { name = '[G]it', _ = 'which_key_ignore' },
['<leader>h'] = { name = 'Git [H]unk', _ = 'which_key_ignore' },
['<leader>r'] = { name = '[R]ename', _ = 'which_key_ignore' },
['<leader>s'] = { name = '[S]earch', _ = 'which_key_ignore' },
['<leader>t'] = { name = '[T]oggle', _ = 'which_key_ignore' },
['<leader>w'] = { name = '[W]orkspace', _ = 'which_key_ignore' },
}
-- register which-key VISUAL mode
require('which-key').register({
['<leader>'] = { name = 'VISUAL <leader>' },
['<leader>h'] = { 'Git [H]unk' },
}, { mode = 'v' })
-- mason-lspconfig requires that these setup functions are called in this order -- mason-lspconfig requires that these setup functions are called in this order
-- before setting up the servers. -- before setting up the servers.
require('mason').setup() require('mason').setup()

View File

@ -2,7 +2,6 @@ return {
'tpope/vim-fugitive', 'tpope/vim-fugitive',
'tpope/vim-rhubarb', 'tpope/vim-rhubarb',
'tpope/vim-sleuth', 'tpope/vim-sleuth',
{ 'folke/which-key.nvim', opts = {} },
{ 'numToStr/Comment.nvim', opts = {} }, { 'numToStr/Comment.nvim', opts = {} },
-- require 'kickstart.plugins.autoformat', -- require 'kickstart.plugins.autoformat',

20
lua/plugins/whichkey.lua Normal file
View File

@ -0,0 +1,20 @@
return { 'folke/which-key.nvim', opts = {},
config = function()
-- document existing key chains
require('which-key').register {
['<leader>c'] = { name = '[C]ode', _ = 'which_key_ignore' },
['<leader>d'] = { name = '[D]ocument', _ = 'which_key_ignore' },
['<leader>g'] = { name = '[G]it', _ = 'which_key_ignore' },
['<leader>h'] = { name = 'Git [H]unk', _ = 'which_key_ignore' },
['<leader>r'] = { name = '[R]ename', _ = 'which_key_ignore' },
['<leader>s'] = { name = '[S]earch', _ = 'which_key_ignore' },
['<leader>t'] = { name = '[T]oggle', _ = 'which_key_ignore' },
['<leader>w'] = { name = '[W]orkspace', _ = 'which_key_ignore' },
}
-- register which-key VISUAL mode
require('which-key').register({
['<leader>'] = { name = 'VISUAL <leader>' },
['<leader>h'] = { 'Git [H]unk' },
}, { mode = 'v' })
end
}