2

Take a plugin like Flake8. It instructs users to install using Vim 8's package manager by:

mkdir -p ~/.vim/pack/flake8/start/
cd ~/.vim/pack/flake8/start/
git clone https://github.com/nvie/vim-flake8.git

On Windows, this brings up some questions about the compatibility of these paths. What is ~ here? Should the files actually go in ~/.vim, or should they go in the Windows equivalent - ~/vimfiles?

You can answer these questions by:

  1. Using :echo expand('~') and :echo $HOME to learn what ~ and $HOME mean.
  2. Using :set packpath to show your packpath.

These are the answers I get on my copy of Windows 10, with a fresh install of Vim 8.1:

:set packpath

packpath=~/vimfiles,C:\Program Files (x86)\Vim/vimfiles,C:\Program Files (x86) \Vim\vim81,C:\Program Files (x86)\Vim/vimfiles/after,~/vimfiles/after

:echo expand('~')

C:\Users\user.name

:echo $HOME

C:\Users\user.name

From those answers, it seems like the place to make the pack/*/start directories is in C:\Users\user.name\vimfiles.

However, that doesn't work! If I put the Flake8 files in C:\Users\user.name\vimfiles\pack\flake8\start, they don't get automatically loaded. And this problem doesn't seem to be with just with Flake8 - this doesn't work with any plugin I've tried.

Looking at :scriptnames, the only scripts that are picked up are in C:\Program Files (x86). Nothing in ~.

Note that there is no _vimrc or .vimrc file in ~ or ~/vimfiles or ~/.vim at this time.

I can verify that Flake8 works just fine if it's sourced manually, like so:

:source ~\vimfiles\pack\flake8\start\autoload\flake8.vim
:source ~\vimfiles\pack\flake8\start\ftplugin\python_flake8.vim 

Is it possible to use the Vim 8 package manager on a per-user basis when Vim is running on Windows? If it is, what am I doing wrong?

  • Excellent detailed question! You happened to include the bit that exposed the issue you're likely having. – filbranden Aug 6 '19 at 23:18
1

The bit you quoted about sourcing the files manually gave it away:

I can verify that Flake8 works just fine if it's sourced manually, like so:

:source ~\vimfiles\pack\flake8\start\autoload\flake8.vim
:source ~\vimfiles\pack\flake8\start\ftplugin\python_flake8.vim 

You need to have a plug-in directory under start/ and the plug-in contents inside that directory.

In your case, you should have a vim-flake8/ under start/ and autoload/ and ftplugin/ under that subdirectory:

~\vimfiles\pack\flake8\start\vim-flake8\autoload\flake8.vim
~\vimfiles\pack\flake8\start\vim-flake8\ftplugin\python_flake8.vim

If you follow the git clone instructions you referred to (adapting to ~/vimfiles), you should end up with a tree such as this one here.

| improve this answer | |
  • 1
    Thank you! I missed that when I got caught up in the difference between ~/.vim and ~\vimfiles. – EchoLynx Aug 6 '19 at 23:28
  • 1
    I find that while vim in Powershell can find these plugins, when vim is launched from git like git rebase -i ... it doesn't find the relevant plugins anymore. – CMCDragonkai Mar 29 at 5:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.