Vim: command of a plugin are not recognized with minimal_vimrc - vim

I am debugging a plugin and start vim with vim --servername VIM -u minimal.vim minimal.tex. The plugin is loaded automatically and the plugin's name is in the output of :scriptnames, :h local-additions and :set runtimepath? commands, but no command defined by the plugin works: E492: Not an editor command:. Issuing a :packadd <packagename> does not change the situation.
What am I doing wrong? What do I need to do to load that plugin? How to use a plugin with as pure vim config as possible?
The minimal vimrc:
set nocompatible
let &runtimepath = '~/.vim/bundle/vimtex,' . &runtimepath
let &runtimepath .= ',~/.vim/bundle/vimtex/after'
filetype plugin indent on
syntax enable
Update: When I looked a little deeper into it next day, I realized that other plugins are working. Since it reduces the issue from a general vim debug question to a plugin specific one, I would contact the creator of the plugin. I will post the solution when I will have one. (The plugin in question is vimtex)

Related

GoLang Highlighting in vim not working

I've seen multiple places(including here) that to add syntax highlighting you have to add certain lines to the .vimrc:
"Stuff for GoLang"
filetype off
filetype plugin indent off
set runtimepath+=$GOROOT/misc/vim
filetype plugin indent on
syntax on
That is what's currently in my .vimrc
Restarted vim, terminal, system, and still no highlighting. Any suggestions?
Okay guys, I go the answer:
$GOROOT needs to be defined or you can simply put the location of your go installation.
Ensure that the corresponding runtime files are actually there.
$GOROOT must be defined; check with :echo $GOROOT
There must a syntax plugin (syntax/go.vim) below $GOROOT/misc/vim. Check with :echo filereadable($GOROOT . '/misc/vim/syntax/go.vim').
After opening a Go file, you can check again via :scriptnames and :syntax list.

Why won't vim recognise a plugin command in the vimrc, but it will recognise it when running?

I've installed the vim-gitgutter plugin with pathogen.
I can type :GitGutterLineHighlightsEnable from inside vim and line highlights are turned on, great.
But I want line highlights to be automatically enabled at startup, so I added the command to my ~/.vimrc. However when I start vim, I get "E492: Not an editor command: GitGutterLineHighlightsEnable". Once vim has started up, I can run the command.
My vimrc looks like this:
execute pathogen#infect()
colorscheme railscasts
.. snip tabs and colors etc ..
GitGutterLineHighlightsEnable
hi GitGutterAddLine guibg=#222F22
hi GitGutterChangeLine guibg=#222239
hi GitGutterDeleteLine guibg=#2F2222
Figured it out.
.vimrc is executed before plugins are loaded. From this related question, I changed the commands to:
autocmd VimEnter * GitGutterLineHighlightsEnable
This executes the command after vim has started up.
Use
let g:gitgutter_highlight_lines = 1
instead of
GitGutterLineHighlightsEnable
As you determined yourself, plugins are processed after the .vimrc.
What you can do if you don't like using a VimEnter autocmd, is put a file in your ~/.vim/after/plugin directory for any commands that should run after plugins are loaded.

ctags not working as expected with Vim plus general setup problems (C programming)

I have installed cvim and NodeTree plugins and generated an exuberant ctags file for my build tree.
This is what my ~/.vim/.vimrc file looks like:
:noremap :TlistToggle
:let Tlist_Show_One_File = 1
:let Tlist_Exit_OnlyWindow = 1
:let Tlist_Use_Right_Window = 1
set tags=./tags;/
set number
set tabstop=4
set incsearch
When I start editing a file, I notice that Ctrl ] does not work and I have to resort to typing ta: funcname - which gets tiring after a while. Interestingly enough, Ctrl T pops me off the tag stack as expected - I don't understand whats going on - how do I fix this?
Incidentally, vim (appears to) completely ignores the contents of my .vimrc file and I always have to type the same commands in the editor, so as to get the settings I want - very annoying.
Last but not the least, I used to be able to type :make in the editor window, drop to the console and then have the build results displayed in a little window which I can then go to and select a line (with an error or warning say), and then have the editor automagically take me to the offending line - unfortunately, I don't remember the plugin (or commands) I used to allow me to build from within vim.
So, how do I:
Fix my vim setup so that I can move to definitions/declarations using Ctrl-]
Fix my .vimrc file so that contents are actually applied to my vim session.
Find the appropriate plugin to install to allow builds (using make) from within vim
You're asking about a weird mix of problems.
Fix my vim setup so that I can move to definitions/declarations using Ctrl-]
The tags functionality is working; I suspect that you have a mapping blocking Ctrl-]. Try
:verbose nmap <C-]>
and
:nunmap <C-]>
Fix my .vimrc file so that contents are actually applied to my vim session.
:echo $MYVIMRC
will tell you the location of the .vimrc that Vim uses. Also, check the output of :scriptnames which scripts get loaded, and read :help vimrc to understand the logic Vim applies.
Find the appropriate plugin to install to allow builds (using make) from within vim
That's built into Vim. With the appropriate 'makeprg' set (it defaults to make), you can run :make. Vim parses the output (through the 'errorformat' option), and you can open the quickfix list via :copen.
Your vimrc is:
~/.vim/.vimrc
If you run Vim 7.4, it should be:
~/.vim/vimrc
or
~/.vimrc
If you run Vim 7.3 or older, it should be:
~/.vimrc
And... what Ingo said.

Pathogen ignoring ftplugin scripts

I'm trying to use Pathogen to manage Vim plugins. I had a couple of scripts I made in .vim/ftplugins.
I installed Pathogen but now none of the scripts in ftplugins runs.
I tried adding a directory inside .vim/bundle with the scripts but it didn't work (it was .vim/bundle/local/ftplugin/python.vim)
Any idea how can I make Pathogen load the scripts in ftplugin directory?
First lines of my .vimrc:
set nocompatible
syntax on
filetype plugin indent on
"execute pathogen#infect()
Only works with that line commented out.
I am running gvim from a Bash prompt with the filename as first parameter like this:
$ gvim some/path/somefile.py
I expect to see the file with my predefined colorscheme for Python files defined in ~/.vim/ftplugin/python.vim and all the other settings defined in that script.
The ~/.vim/bundle directory is empty.
Pathogen is in ~/.vim/autoload and there is nothing more there.
$ ls ~/.vim/ftplugin/
css.vim html.vim javascript.vim python_pep8.vim python_pyflakes.vim python.vim rst.vim xml.vim
$ ls ~/.vim
autoload bundle colors doc ftdetect ftplugin plugins ScrollColor.vim spell syntax
It was a problem with filetype detection, this is the Pathogen issue.
The work around in my case was simple, use this to enable Pathogen:
set nocompatible
"execute pathogen#infect() " breaks filetype detection
call pathogen#runtime_append_all_bundles()
filetype plugin indent on
syntax on
What I did to find out was to remove my ~/.vim directory and start with a clean one. Adding things one by one and checking the results. I realized it was not detecting the correct filetype (when I opened an empty file detection was ok, but it was not when opening an existing file).
Putting my comment here:
Wondering whether it works if you put :filetype and :syntax calls after :execute? Official README suggest doing just this in the second section: first :execute, second :syntax, third :filetype. Note: DO NOT disable filetype prior to :execute like #Eduan suggested, just don’t enable it until :execute is called:
set nocompatible
execute pathogen#infect()
syntax on
filetype plugin indent on
And, by the way, never use *map.
I think I can see your problem, putting this in an answer instead of a comment for the sake of the example code's clarity.
Try this:
" Set the filetype stuff to off, required for Pathogen
filetype off
filetype plugin indent off
execute pathogen#infect()
" You can now turn it on again
filetype on
filetype plugin indent on
Instead of your current setup.

How to turn-off a plugin in Vim temporarily?

I have multiple plugins in Vim and some of them modify the default behavior of Vim. For example I use Vimacs plugin, which makes Vim behave like emacs in the insert mode alone. Sometime I want to turn off the Vimacs plugin without moving the vimacs.vim out of the plugins directory. Is there a way to do it?
You can do this if you use a plugin manager like Vundle or Pathogen, which will keep the plugin in its own directory underneath the ~/.vim/bundle/ directory.
In that case, just find out the runtimepath of the vimacs plugin with the following command:
set runtimepath?
Let's say it's ~/.vim/bundle/vimacs.
Then, put this command in your .vimrc:
set runtimepath-=~/.vim/bundle/vimacs
To load vimacs, just comment that line out and relaunch Vim (or source your .vimrc).
See which variable vimacs check on start. On the begin of the script file find something Like if exists('g:vimacs_is_loaded").... Then set this variable in your .vimrc or while start vim with vim --cmd "let g:vimacs_is_loaded = 1".
In case you are using pathogen, this post gives a better answer, in my opinion. Since I have frequent need to disable snippets when using latex, also added this in my ~/.config/ranger/rc.conf:
map bs shell vim --cmd "let g:pathogen_blacklist = [ 'ultisnips', 'vim-snipmate' ]" %f
This way, whenever I want to open a file with snippets disabled, it is easy.

Resources