vim, pathogen, and load order of ftplugin files - vim

I've been using Vim and pathogen for a while, and things were working fine, but recently I've started having load order issues with my ftplugin configuration.
The specific problem I'm having right now is that python-mode is overriding my ftplugin settings. I've got a ~/.vim/ftplugin/python.vim that contains the following line:
setlocal textwidth=119
python-mode comes with its own ftplugin file, which also sets textwidth, in ~/.vim/bundle/python-mode/ftplugin/python/pymode.vim.
The problem is that Vim is now loading python-mode's ftplugin file after my ftplugin file, so I'm ending up with its textwidth=79. I recently had to reinstall MacPorts, and I think something must have changed in the stock configuration.
I've tried various tricks involving turning filetype/plugin detection off before invoking pathogen, per various other answers, but none of them are helping.
Through the use of verbose set textwidth? and some echomsg debugging, I know that both ftplugin files are being invoked, and that they're being invoked in the wrong (for my needs) order.
Is there any way to force Vim/pathogen to invoke my ftplugin files after those of the plugins?
I've even tried putting my settings into ~/.vim/after/plugin/pymode.vim, but that's loaded immediately after pathogen sets up the plugin, so it still runs before ftplugin files, which only get loaded once I edit a Python file.

It turns out that maybe this never worked the way I thought. I didn't realize that Vim also supported ~/.vim/after/ftplugin, so I was able to move my overrides to ~/.vim/after/ftplugin/python.vim and get the behavior I was expecting. I'm loath to answer my own questions on SO, but hopefully this will help someone else.

Plain Vim loads the plugin scripts in alphabetical order. This is from :help load-plugins
... all directories in the 'runtimepath' option will be
searched for the "plugin" sub-directory and all files ending in ".vim"
will be sourced (in alphabetical order per directory), also in
subdirectories.
So you can set plugin loading order by renaming <filetype>_plugin.vim to <filetype>/35plugin.vim. 35 is your desired loading order. I think this should work with Pathogen too by renaming the plugin directories inside bundle, but I haven't tested it.

I'm still looking for a more general answer to this load-order issue
As far as I know, you can't really do it with Pathogen. It is really easy with NeoBundle. Pathogen is really minimal, it doesn't provide you with a lot of flexibility - it does only one thing and does it well. If you're looking for configurability, I think you're using the wrong tool.
EDIT: Not really sure about ftplugins, but bundles in general are loaded as you specify them (with Vundle/NeoBundle). So I realise that this maybe is not the most relevant of answers.

Related

cannot get SASS (indent style!) syntax highlighting to work in VIM 8

VIM VERSION: VIM - Vi IMproved 8.0 (2016 Sep 12, compiled May 2 2017 03:55:34)
I'm using a number of plugins with vim in order to make things work. I install them via the package manager Vundle, my .vimrc can be found in my dotfiles repository on github
Today, I tried to edit a SASS file with vim, however - the SASS file looks like a color-circus:
I've followed some steps from this answer which include:
Does enabling syntax explicitly fix your problem? :syntax enable
Is filetype detection on? :filetype
Does vim recognize this as a sass file? :set filetype?
Check to make sure your script directories are in the runtime path :set runtimepath?
Does manually loading the syntax file change anything? :runtime! vimfiles/syntax/sass.vim
Also check if syntax highlighting works for other filetypes.
The answers to each point are:
Nothing changed, syntax remains exactly the same.
running :filetype returns filetype detection:ON plugin:ON indent:ON
running :set filetype? returns filetype=sass
running :set runtimepath? returns a long list of ~/.vim/bundle/[PATH] entries of which none include sass in any form
running :runtime! ~/.vim/bundle/vim-haml/syntax/sass.vim also changes nothing
Syntax highlighting works for everything except SASS so far.
Additionally, I've tried adding some plugins from http://vimawesome.com/.
They all seem to be packages that either support a different package which should be supported by default or they do not support SASS (in addition to SCSS) highlighting.
This is, what I came up with in the end, still making no difference:
Plugin 'tpope/vim-haml'
Plugin 'JulesWang/css.vim'
Plugin 'hail2u/vim-css3-syntax'
The plugin tpope/vim-haml however, does have a sass.vim file with it's syntax rules, it's actually the only up-to-date one compared to the rest which all seem to hang at "last updated 5+ years ago".
I basically have two questions, which I hope, more experienced vimologists will be able to answer, or point me in the right direction of fixing it myself:
Is there any known properly updated SASS (indent syntax) plugin that I missed?
If the above question is "no", then how could I get the tpope/vim-haml sass syntax file loaded for all my sass files?
I'm using SASS since, coming from Atom, it is less typing. I would prefer to keep the sass syntax if possible! (I am aware of conversion plugins but for the sake of my colleagues I would like to refrain from using any)
Thanks in advance!
Answer
It was the colorscheme I was using, it caused severe formatting issues for my SASS files.
TLDR;
I was using roosta/srcery and just tried an alternate colorscheme to test if the sass file would look more "sane", it now looks like this (using a random colorscheme):
What we see here is still not perfect, but at least "sane" (I can understand why CSS3 flex properties aren't highlighted yet for instance), I'm simply going to try inform the author of the (really nice nonetheless) colorscheme to see if he is interested in improving it for SASS.
My lesson here, is that one should look at every aspect, I was thinking in the wrong direction and kept on going for too long as a result. When #romainl pointed out it looked fine using just regular-builtin-vim I started expecting a Plugin (a colorscheme) to be the suspect which solved my issue :)

Julia syntax highlighting in julia-vim

I use gvim with julia-vim for editing julia code. I am using julia 0.5 on a mac and installed julia-vim with vundle.
My problem is that files with the .jl extension do not have appropriate highlighting. For example, if is highlighted but for is not. Any solution for this?
.jl files are sometimes recognized as lisp files by default, (blame Sawfish) so that's probably the syntax highlighting you're getting. (type defun and progn and etc and see if the pretty colors pop up)
You were close when you said the correct solution was :set syntax=julia, what you need is to set filetype plus some autocmd magicks to make that happen every time you open a .jl file.
Put something like this in some file (e.g. jl.vim) in your ftdetect directory:
autocmd BufRead,BufNewFile *.jl :set filetype=julia
And that should do it.
Addendum 1: Changing filetype instead of syntax may be required to trigger additional features like the LaTeX expansions depending on the root of your problem, so that's what I am using.
Addendum 2: Note that this should've been handled by the julia-vim plugin, but conflicts with other scripts can mess with that. You can use :scriptnames to see what scripts have been loaded and in what order, and try to debug what could be causing the conflict, if you think that's worth the trouble.
Addendum 3: Also related is that Vundle has some specific configurations that need to be made when it comes to filetypes, so that could also be causing this. However, I've seen this and similar problems happen outside Vundle for any number of reasons so I still believe that the solution at the top is the best one, and will possibly prevent some future headaches.
After testing julia-vim I think the issue is likely with the color scheme you are using.
Try using a different one.
:colorscheme desert
I tried it with the built-in desert and both if and for were highlighted (see below).
I found that the instructions here worked a treat. Namely
git clone https://github.com/JuliaEditorSupport/julia-vim.git
mkdir -p ~/.vim
cp -R julia-vim/* ~/.vim
Note: I realise that the OP claims to have already installed Julia-Vim using Vundle, but I came to this question because Vim was automatically using LISP syntax highlighting for me, and the above was enough for me. So I am sharing in case anyone comes from the same boat as me (i.e. the problem is not Vundle related) :)

Does anyone have extra «» generated from lh-brackets

Can't seem to find any reason for this, but I have been using Ycm, syntastic, and all the lh- plugins with vim for a while now. In the case of lh-brackets, I used to have a problem with it generating "«»" every time it 'automatically' generated the other bracket, paren, quote, etc. But it was only happening in .vim files, so i turned it off for vim files in my vimrc. Now nothing has changed, no new scripts installed, and all of the sudden, this happens with ALL files (cpp, h, pl, py, etc). Like i said, not using heavy customization, and everything is default except the disabling of lh-brackets when editing vim files, but that has now become a hotkey since i cant use it anywhere.
My Question is this: does anyone have this or similar problem with lh-brackets, and if so, any idea how to fix it, or is there some setting I am missing?
My first thoughts are to go though and check any updated vim scripts (this just happened a day ago) that could have been updated when doing an apt-get upgrade (like debian.vim) but after that I've got nothing...
The placeholders characters can be jumped to (:h <Plug>MarkersJumpF -> <C-J> with vim, <m-ins> with gvim). That's their purpose.
If you have installed lh-cpp, see :h lh-cpp-first-steps, you'll find a quick guide to my C++ suite (and lh-brackets incidentally).
EDIT: The plugin was badly designed. I've patched the plugin to rely on g:usemarks in order to fix the ergonomic of plugin .
In the (now-) past, if you wanted to set b:usemarks to 0, you'd have needed to add an autocommand that'd set b:usemarks to 0 in all new buffers.
Now, (lh-brackets v2.2.0), if you want to always disable the placeholders/marker characters, you need to set g:usemarks to 0, not b:usemarks. Buffer-local variables are meant to be set from ftplugins, or tree/project-local plugins which are supported thanks to plugins like local_vimrc.
And as romainl has pointed out, don't hesitate to use the bug trackers, or even to contact me.
hmm found it:
:let b:usemarks=0
now needs to be set, apparently that was a marker for integration to another plugin, though i dont use it.

Vim directory with macvim/terminalvim

I am using mac vim in terminal via /Applications/MacVim.app/Contents/vim
By now I didn't really care about what was in the MacVim directory in /Applications/MacVim.app/Contents/Resources/vim/runtime
and still somehow I had proper syntax highlighting etc.. I guess my vim loaded the files from macvim?
Somehow I messed arround with snipmate and all the syntax highlighting stopped to work. Filetypes are correct, but no highlighting. So I copied the syntax folder from the macvim app to my ~/.vim/syntax and it worked like a charm. Is there a way how I can use the ones from the app again?
Thanks for any help
Copying the syntax to your own ~/.vim/ directory effectively forks the factory-defaults. The downside is that you now have to update your copy whenever Macvim is updated.
The key to figuring out the problems is the 'runtimepath' setting. By modifying that (in your ~/.vimrc), you should be able to include the proper runtime files (and that is not just syntax, but also filetype plugins, should you have :filetype plugin on). BTW, it's unlikely this is caused by snipMate.
:set runtimepath?
Also, the :scriptnames command tells you exactly which scripts have been sourced so far.

javacomplete plugin for vim

I have two questions but they are both related to the use of same plugin so I decided to ask them in the same question.
I have started using javacomplete plugin for omnicomplete in vim. I have set omnicomplete using:
setlocal omnifunc=javacomplete#Complete
and it seems to be working with C-xC-o but there is also a mention of completefunc in the documentation such as:
setlocal completefunc=javacomplete#CompleteParamsInfo
which doesn't seem to be doing anything with C-xC-u and I'm not sure what it is supposed to do anyways. Has anyone managed to set this up?
Also I was wondering if it's possible to move Reflection.class somehow from $HOME to ~/.vim so that it won't pollute the system?
That's <C-x><C-o> and <C-x><C-u>, not <C-o>/<C-u>.
The doc says to put javacomplete.vim, java_parser.vim and Reflection.java in ~/.vim/autoload/, did you do that?
The plugin doesn't seem to include an option for the path to Reflection.class but, reading the GetJavaCompleteClassPath function at line 1748 of javacomplete.vim it looks like the script is expecting that file to be in one of two locations: ~/.vim/autoload/Reflection.class or ~/Reflection.class.
So yes. You can move it safely to ~/.vim/autoload, with its friends.

Resources