~theorytoe/nii-nvim

3d71ebd4f5b622cb4b1f21d85bec4e1fbeb60691 — TheoryToE 1 year, 5 months ago 1eda80a
feat: add which key interface

Adds neat key helpers when hitting a key and waiting,
similar to emacs.
2 files changed, 88 insertions(+), 0 deletions(-)

A lua/config/plug/which-key.lua
M lua/plug.lua
A lua/config/plug/which-key.lua => lua/config/plug/which-key.lua +84 -0
@@ 0,0 1,84 @@
local wk = require('which-key')

wk.setup({
	plugins = {
		spelling = {
			enabled = true,
			suggestions = 40,
		},
	},
	key_labels = {
		['<space>'] = 'SPC',
		['<CR>'] = 'ENTR',
		['<tab>'] = 'TAB',
		['<bs>'] = 'BKSPC',
	},
	layout = {
		align = 'center',
	},
})

local keymap = {
	a = {
		name = 'hop.nvim',
		h = { 'hop by word' },
		k = { 'hop by word (before cursor)' },
		j = { 'hop by word (after cursor)' },
		l = { 'hop by word (all windows)' },
		f = { 'hop by word (current line)' },
		c = { 'hop by given char' },
		C = { 'hop by 2 given chars' },
		g = { 'hop by pattern' },
		n = { 'hop by line start' },
	},

	b = {
		name = 'buffers',
		h = { 'focus first buffer in buflist' },
		j = { 'focus previous buffer in buflist' },
		k = { 'focus next buffer in buflist' },
		l = { 'focus last buffer in buflist' },
	},

	f = {
		name = 'telescope',
		f = { 'fuzzy file finder' },
		w = { 'fuzzy word search' },
		g = { 'fizzy git commit finder'},
		G = { 'fizzy git branch finder'},
	},

	g = {
		name = 'gitsigns',
		s = { 'stage hunk' },
		u = { 'undo stage hunk' },
		r = { 'reset hunk' },
		R = { 'reset buffer' },
		p = { 'preview hunk' },
		b = { 'blame line' },
		S = { 'stage buffer' },
		U = { 'reset buffer index' },
	},

	n = {
		f = { 'format buffer' },
	},

	h = { 'Win focus left' },
	j = { 'Win focus up' },
	k = { 'Win focus down' },
	l = { 'Win focus right' },
	s = { 'Buffer picker' },

	y = {
		name = 'yank',
		a = { 'yank entire buffer to system clipboard' },
		l = { 'yank line to system clipboard' },
	},
	['<cr>'] = { 'Term vsplit' },
	['\\'] = { 'Term split' },
}

wk.register(keymap, {
	prefix = '<leader>',
})

M lua/plug.lua => lua/plug.lua +4 -0
@@ 35,6 35,10 @@ require('packer').startup({
		use('sbdchd/neoformat')
		use('phaazon/hop.nvim')
		use({ 'lewis6991/gitsigns.nvim', requires = { 'nvim-lua/plenary.nvim' } })
		use({
			'folke/which-key.nvim',
			config = require('config.plug.which-key'),
		})
		-- }}}

		-- {{{ imporved syntax plugins