Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug/Regression with autocommand #39

Open
ctjhoa opened this issue Mar 18, 2017 · 1 comment
Open

Bug/Regression with autocommand #39

ctjhoa opened this issue Mar 18, 2017 · 1 comment

Comments

@ctjhoa
Copy link

ctjhoa commented Mar 18, 2017

Hi,

A few months ago, I notice a bug with vim-leader-guide (ctjhoa/spacevim#32) and I didn't take the time to look at it until now.

Here is what I've found.
With the current version of vim-leader-guide calling register_prefix_description from an autocommand will lead to a bug where the name of your entry does not show.
If I rollback to the commit bade1b9 it works as intended.

I did a .vimrc which show the issue:

call plug#begin('~/.vim/plugged')

Plug 'hecal3/vim-leader-guide'

call plug#end()

let mapleader = ' '
let g:leaderGuide_vertical = 1


" THIS WORKS
" ==========
" call leaderGuide#register_prefix_descriptions("<Space>", "g:lmap")
" nnoremap <silent> <leader> :<c-u>LeaderGuide '<Space>'<CR>
" vnoremap <silent> <leader> :<c-u>LeaderGuideVisual '<Space>'<CR>
" ==========

" THIS DON'T
" ==========
function! s:vim_enter()
        call leaderGuide#register_prefix_descriptions("<Space>", "g:lmap")
        nnoremap <silent> <leader> :<c-u>LeaderGuide '<Space>'<CR>
        vnoremap <silent> <leader> :<c-u>LeaderGuideVisual '<Space>'<CR>
endfunction

augroup delayed
  autocmd!
  autocmd VimEnter * call s:vim_enter()
augroup END
" ==========

let g:lmap = get(g:, 'lmap', {})
let g:lmap.a = { 'name': '+applications' }

Thanks

@hecal3
Copy link
Owner

hecal3 commented Oct 6, 2018

This is probably a bit late for you, but for completion's sake:

If the plugin is unable to find a configuration dictionary on startup it will initialise an empty one:

if !leaderGuide#has_configuration()
    let g:leaderGuide_map = {}
    call leaderGuide#register_prefix_descriptions('', 'g:leaderGuide_map')
endif

The autocmd is apparently executed after this little snippet.

It's possible to hook the g:lmap dictionary into the top-level one like this:

function! s:vim_enter()
        let g:leaderGuide_map[' '] = g:lmap
        " registering is no longer necessary
        "call leaderGuide#register_prefix_descriptions("<Space>", "g:lmap")
        nnoremap <silent> <leader> :<c-u>LeaderGuide '<Space>'<CR>
        vnoremap <silent> <leader> :<c-u>LeaderGuideVisual '<Space>'<CR>
endfunction

augroup delayed
  autocmd!
  autocmd VimEnter * call s:vim_enter()
augroup END

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants