-
Notifications
You must be signed in to change notification settings - Fork 17
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
picker#Register() is not available at startup #45
Comments
This was another weird bug for me. One minute it was there, and the next it was gone. The following two If I remove the " Save as init1.vim
" Run as `nvim --noplugin -u ./init1.vim`
" No plugin manager.
set nocompatible " otherwise Vim 8 complains about script syntax.
set runtimepath=./repo
runtime! plugin/**/*.vim
nmap <leader>pb <Plug>PickerBuffer
call picker#Register(
\ 'recent-notes',
\ 'file',
\ 'edit',
\ 'find . -path ./git -prune -o -iname "*.md" -printf "%T@ %p\n" | sort -n | cut -d" " -f2-',
\ )
nmap <leader>pr :call picker#Execute('recent-notes')<cr> " Save as init2.vim
" Run as `nvim --noplugin -u ./init2.vim`
" Load plugins with vim-plug.
set nocompatible " otherwise Vim 8 complains about script syntax.
set runtimepath=~/.config/nvim
source ~/.config/nvim/autoload/plug.vim
au!
call plug#begin('~/.config/nvim/plugged')
Plug 'srstevenson/vim-picker'
call plug#end()
runtime! plugin/**/*.vim
nmap <leader>pb <Plug>PickerBuffer
call picker#Register(
\ 'recent-notes',
\ 'file',
\ 'edit',
\ 'find . -path ./git -prune -o -iname "*.md" -printf "%T@ %p\n" | sort -n | cut -d" " -f2-',
\ )
nmap <leader>pr :call picker#Execute('recent-notes')<cr> |
The documentation regarding "autoloading" scripts suggests that vim/neovim should Just Work™. I'll continue trying to identify what we're missing that causing this bug.
|
I'm chasing my tail a bit, because now I can't reproduce the error. I'm not sure why, but autoloading appears to be working. Apparently, not reading the docs beforehand was my issue, cause autoloading appears to work as expected now that I reread the docs. sigh To debug, I added the following Without So far, the diff --git a/autoload/picker.vim b/autoload/picker.vim
index 2d83e8d..0a06758 100644
--- a/autoload/picker.vim
+++ b/autoload/picker.vim
@@ -2,6 +2,8 @@
" Maintainer: Scott Stevenson <scott@stevenson.io>
" Source: https://github.com/srstevenson/vim-picker
+echom 'Loading autoload/picker.vim'
+
if !exists('s:command_registry')
let s:picker_command_registry = {}
endif
diff --git a/plugin/picker.vim b/plugin/picker.vim
index 4ddc19e..0cffbaa 100644
--- a/plugin/picker.vim
+++ b/plugin/picker.vim
@@ -2,49 +2,21 @@
" Maintainer: Scott Stevenson <scott@stevenson.io>
" Source: https://github.com/srstevenson/vim-picker
+echom 'Loading plugin/picker.vim'
+
if exists('g:loaded_picker')
finish
endif
" Save as ./init3.vim
" Run as `nvim --noplugin -u ./init3.vim
set nocompatible " otherwise Vim 8 complains about script syntax.
set runtimepath^=./repo
" Without runtime!, plugin/picker.vim does not load. Autoloading won't load plugin/picker.vim later.
runtime! plugin/**/*.vim
" nmap definitions don't trigger autoloading.
"nmap <leader>pb <Plug>PickerBuffer
let g:picker_find_executable = 'fd'
let g:picker_find_flags = '--color=never'
" Uncomment and picker#Register will trigger loading of autoload/picker.vim as expected.
"call picker#Register(
" \ 'recent-notes',
" \ 'file',
" \ 'edit',
" \ 'find . -path ./git -prune -o -iname "*.md" -printf "%T@ %p\n" | sort -n | cut -d" " -f2-',
" \ )
"
" nmap does not trigger autoload, but executing the keybinding <leader>pr does
" trigger loading of autoload/picker.vim.
"nmap <leader>pr :call picker#Execute('recent-notes')<cr> |
@srstevenson before the error occurs at line 76, could you So long as I have vim-picker in Apologies for all the noise. My inadequate understanding and interpretation of observations has led me on a merry chase. |
I think this is due to the way the native packages support works, which is what I'm using, with vim-picker cloned to
Which is actually what the documentation says, now I've read it again (emphasis mine):
Printing
However, after Vim has started:
The documentation also says:
After adding
Therefore I don't think this is a bug in vim-picker (or Vim), but is just me not initially being aware of the difference in how this is handled with the native packages support versus the established third party tools like vim-plug and Vundle. |
The autoloaded
picker#Register()
function isn't known to Vim at startup. This means a line such asin your vimrc leads to the following error:
This can be worked around until fixed by defining an autocommand on the
VimEnter
event:The text was updated successfully, but these errors were encountered: