Closed Z2h-A6n closed 6 years ago
What is result of set rtp?
FastFold is added to rtp
in both cases (set rtp+=...
before or after the filetype ...
line).
With set runtimepath+=...
before filetype ...
, SimpylFold works and `:set rtp? gives:
runtimepath=~/.config/nvim,/etc/xdg/nvim,~/.local/share/nvim/site,/usr/local/share/nvim/site,/usr/share/nvim/site,/usr/share/nvim/runtime,/usr/share/nvim/site/after,/usr/local/share/nvim/site/after,~/.local/share/nvim/site/after,/etc/xdg/nvim/after,~/.config/nvim/after,~/.config/nvim/plugins/vim-airline,~/.config/nvim/plugins/vim-airline-themes,~/.config/nvim/plugins/vim-fugitive,~/.config/nvim/plugins/vim-gitgutter,~/.config/nvim/plugins/vim-accio,~/.config/nvim/plugins/FastFold,~/.config/nvim/ftplugins/python/SimpylFold
With set runtimepath+=...
after filetype ...
SimplyFold doesn't work and :set rtp?
gives:
runtimepath=~/.config/nvim,/etc/xdg/nvim,~/.local/share/nvim/site,/usr/local/share/nvim/site,/usr/share/nvim/site,/usr/share/nvim/runtime,/usr/share/nvim/site/after,/usr/local/share/nvim/site/after,~/.local/share/nvim/site/after,/etc/xdg/nvim/after,~/.config/nvim/after,~/.config/nvim/plugins/vim-airline,~/.config/nvim/plugins/vim-airline-themes,~/.config/nvim/plugins/vim-fugitive,~/.config/nvim/plugins/vim-gitgutter,~/.config/nvim/plugins/vim-accio,~/.config/nvim/plugins/FastFold,~/.config/nvim/ftplugins/python/SimpylFold
Interestingly, the commands (e.g :SimpylFoldDocstrings
) and help (:h SimpylFold
) don't seem to be available in either configuration, but the folding still works properly in the first configuration.
Editing your runtimepath in order to load plugins on the fly is pretty unusual. I don't immediately see a reason why that wouldn't work, but I can't help but wonder if your problems have something to do with that unconventional approach to managing your configuration. You're essentially duplicating functionality which is already built in to Vim.
Files and directories under ftplugins
are meant to be named after the filetype which Vim assigns to the file you want the plugin to apply to. So for plugins which should be loaded in Python buffers, you would want a structure like ftplugins/python/SimpylFold
, rather than ftplugins/SimpylFold
. If you organize things the expected way, then Vim will automatically load the python plugins when you edit a Python buffer; you don't need to define that logic yourself. You seem to be trying to reimplement Vim's built-in filetype plugin mechanism with autocommands. I suppose this ought to work even if you aren't using the expected directory structure, but it's unnecessary to do this, since Vim has this functionality built in if you just organize things correctly.
I suspect that this problem is caused by some issue with the order in which scripts are being loaded due to the way you're changing the runtimepath in autocommands. Is there some reason why you can't let Vim manage your plugins for you?
Unless I'm missing something, my directory structure is exactly as you describe it should be, i.e. I cloned the SympylFold repository to ~/.config/nvim/ftplugins/python/SimpylFold
, and the same directory is appended to rtp
.
If I don't add the plugin path to rtp
, the plugin is not loaded at all (this is true of other plugins and ftplugins that I use successfully). Perhaps this indicates a separate problem with my configuration, or with neovim.
It's my understanding that this method of rtp
management is how some (but not all) vim plugin managers work. That said, I haven't used any of them recently.
Unless I'm missing something, my directory structure is exactly as you describe it should be, i.e. I cloned the SympylFold repository to ~/.config/nvim/ftplugins/python/SimpylFold, and the same directory is appended to rtp.
When I wrote that, you hadn't yet posted your second comment. In your first comment, your config excerpt showed the directory structure that I mentioned (without the python
subdirectory). Apparently that was a typo.
What Vim "expects" you to do, third-party plugin managers notwithstanding, is to place your base config directory on the runtimepath. In your case, that would be ~/.config/nvim
. Underneath that, you have plugin/
for "global" plugins, ftplugin/
for filetype-specific plugins, etc. You don't have to manually manage the runtimepath below that base directory, though.
That being said, I think I missed the fact that you're cloning the plugin repository directly into ftplugin
. That's not what Vim expects. The directory structure that would work out of the box would look roughly like this:
~/.config/nvim/
ftplugin/
python/
SimpylFold.vim
otherPythonPlugin.vim
autoload/
SimpylFold.vim
The above requires you to mix files from different plugins into the same directories, which a lot of people don't like, so the various plugin managers do try to do something similar to what you're doing, so that each plugin's files are kept separate. But using the ftplugins
directory as you're doing is certainly not a typical case; usually the standalone plugin directories would live in a separate structure altogether. ftplugin
is not intended to house cloned repos this way.
Since somewhat recently (Vim 8, I think), Vim has builtin support for siloed plugin directories. I would recommend using that instead of trying to roll your own. See :help packages
.
Let me know if you can reproduce this problem using a standard directory layout and/or with Vim's builtin package support.
You're right, there was a typo in my first comment, I fixed it.
This issue is a result of me trying to set up neovim. When I used SimpylFold with regular vim, I installed it from the Arch User Repository, which places SimpylFold.vim
in /usr/share/vim/vimfiles/ftplugin/python/SimpylFold.vim
, and everything worked fine. With the new features of Vim 8, I'm reconsidering whether or not I want to set up neovim, but so far I haven't looked to carefully at the new package system.
Thanks for the help, I'll look into other package management schemes.
Ah, it looks like the AUR package is out of date, and comes from a time when there was only one script file in the plugin, which could just be dropped into ftplugin/python/
and it would work. There was a rewrite several months ago, after which there are now multiple files involved in different directories, so the installation would be more complicated if you don't use Vim packages or a third-party plugin manager. That may explain some of the differences you're seeing between the AUR version and the version in this repository.
It looks like Neovim supports the same package mechanism that Vim does. At least it is included in their documentation: https://neovim.io/doc/user/repeat.html#packages.
I set up Neovim using built in plugin/package management and everything works fine.
Thanks for pointing me in the right direction, and for SimpylFold!
I enable plugins by adding the relevant path to my runtimepath in init.vim (I'm using neovim). For example, the following lines are in my init.vim:
It seems that SympylFold doesn't load if it is added to the runtime path on a line that comes after
filetype plugin indent on
in init.vim. Changing the order of the lines causes SympylFold to load properly.Is this expected behavior? Should this be added to the documentation?
This is easy to work around by reorganizing my init.vim file, but it seems worth documenting or fixing, as it took me a while to figure out what the problem was.