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
What is a good way to check if a package is loaded? #146
Comments
In the meantime, I found the following solution:
I wish there was a cleaner solution, but I am closing this. Sorry for the noise. |
I take it back. What I actually wanted to write as the pattern is |
@bzp99 Normally you should add your colorschemes under function! SetColors(name) abort
execute 'silent! colorscheme' a:name
return exists('g:colors_name') && g:colors_name is# a:name
endfunction
...
eval SetColors('gruvbox') || SetColors('peachpuff') |
@matveyt thank you, that is good to know. But what about more generic cases? For example, setting mappings if a plugin is loaded. For example, I currently have if IsPluginLoaded('cosco')
nmap <silent> <leader>; <plug>(cosco-commaOrSemicolon)
endif Is there a better or more efficient way to do this or to implement |
@bzp99 Plugins are normally loaded after vimrc, so it is a bit harder than you probably think. Especially, for a totally generic recommendation. Speaking of mappings, I suggest not to check anything at all. If you won't have the plugin then the mapping will not do anything, so why bother? |
I see, thank you. I realized there is really no need for the checks I had sought. In all cases, I could either skip the whole check and in some others, I switched to |
I have been using constructs like
But this suddenly stopped working since I just updated
neovim
andminpac
.I see that
&rtp
looks like this:So I guess this method is no longer suitable. Is there a recommended way to do this?
The text was updated successfully, but these errors were encountered: