vim-leader-guide icon indicating copy to clipboard operation
vim-leader-guide copied to clipboard

help: how to create a top dict with vim-leader-guide

Open ScrumpyJack opened this issue 7 years ago • 1 comments

All i need is a single dict for a bunch of custom maps.

I've tried this minimal setup

let g:lmap = { 'name' : 'Awesome Leader' }
nmap <silent> <Leader>R zR
let g:lmap.R = ['R', 'Open all folds']
nmap <silent> <Leader>M zM
let g:lmap.M = ['M', 'Close all folds']

call leaderGuide#register_prefix_descriptions('', 'g:lmap')

but that doesn't show the values in the guide, i still only see

[R] zR [M] zM

What am i doing wrong?

ScrumpyJack avatar Jun 27 '18 15:06 ScrumpyJack

I finally took the time to figure this out today. With <Space> as my leader key:

" Set <Space> as leader
nnoremap <Space> <Nop>
let mapleader = "\<Space>"

" Register top-level dictionary
let g:lmap = {}
call leaderGuide#register_prefix_descriptions('<Space>', 'g:lmap')
nnoremap <silent> <leader> :<c-u>LeaderGuide '<Space>'<CR>

" Set a command and add it to the dictionary
nnoremap <leader>f :CtrlP<CR>
let g:lmap.f = ['CtrlP', 'File Search']

IMO this is the most basic use case for this plugin, and the readme should start with this first, then go on to explain how to expand it with nested dictionaries, etc.

Fantastic plugin, by the way!

pfernandez avatar Sep 19 '18 19:09 pfernandez