vim-cucumber doesn't find definitions - vim

I'm trying to switch to Vim from Sublime. I do a lot of Cucumber work. A Sublime plugin allows me to jump from the step in feature file to the corresponding step definition. It looks like vim-cucumber is designed for that purpose as well. I've installed vim-cucumber using Vundle. However, when I use any of the commands in the vim-cucumber readme (e.g. [<C-d> or <C-W>d) I always get E388: Couldn't find definition. Is there some prior command or configuration I need to run to load the existing definitions for vim-cucumber to work?

The mappings used by that plugin override buit-in mappings that do more or less the same thing (but not for cucumber so that's alright).
The error message you get is associated with those buit-in mappings (:help e388) so it looks like the buit-in mappings are not overriden and thus that your plugin is not installed correctly.

romani, thanks for pointing me in the right direction. To fix the issue:
I removed vim-cucumber from my Vundle plugin list in .vimrc
executed :PluginClean
removed some references to cucumber.vim in my .vim directory that I think I added either via pathogen or manually at some point
added the plugin back in to .vimrc
executed :PluginInstall
Looks like jumping to definitions is working. Thanks.

Related

Vim not recognizing some commands from vim-latex

I have vim-latex installed via Vundle and I'm trying to disable some annoying mapping that it sets up by default. From the docs I know that, for example, I can use the following command to unmap FEM:
call IUNMAP('FEM','tex')
But when I type that I get the error E117: Unknown function: IUNMAP.
I have installed vim-latex with Vundle by including Plugin 'LaTeX-Suite-aka-Vim-LaTeX' in my vimrc and I have just used the PluginUpdate command to update everything, which runs with no error, so I should have the latest version of the package.
Am I missing something here?
Actually, the problem you're having is related to where you're getting your vim-latex from.
With:
Plug 'LaTeX-Suite-aka-Vim-LaTeX'
You're getting it from here, which you'll notice hasn't been updated since 2010. Looking at the plugin/imaps.vim file in that repository, you'll see there's a definition for function IMAP(), but not for IUNMAP(), which was probably introduced after the last date that repository was synced...
Use this source instead:
Plug 'vim-latex/vim-latex'
Which will get it from here which is an official maintained location for this plug-in.
If you look at plugin/imaps.vim in that source tree, you'll notice function! IUNMAP is defined there.
Updating to the correct plug-in location should fix this problem for you (together with probably quite a few fixes from the last 10 years!)
The functions IMAP() and IUNMAP() are loaded by the vim-latex plug-in only after your vimrc is processed. So you need to execute them from a context where they're available.
Furthermore, in order to have your unmapping succeed, you need to actually execute it after the mapping was created, and mappings are typically created when the filetype is set.
The documentation mentions that these overriding rules should be done in specific files:
An important thing to note is that if you wish to over-ride macros created by Latex-Suite rather than merely create new macros, you should place the IMAP() (or IUNMAP()) calls in a script which gets sourced after the files in Latex-Suite.
A good place typically is as a file-type plugin file in the ~/.vim/after/ftplugin/ directory. [...]
For example, to delete a mapping, you can use
call IUNMAP('FEM', 'tex')
in ~/.vim/after/ftplugin/tex_macros.vim.
The documentation mentions that you should use a file in ftplugin after the filetype you use. Check :set ft? to confirm yours is indeed tex, in which case you can use tex.vim, tex_something.vim (like the suggested tex_macros.vim) or tex/something.vim (a subdirectory.)

vim81 configuration wrong after I added .vimrc

I uninstalled vim74 and compiled vim81 and installed it. However I found it strange, comparing to vim74. When there's no .vimrc file under HOME dir, I open a c++ file and syntax highlight is working and I can use Backspace to delete letters. However when I add a .vimrc under HOME dir and just put set number into it, when the c++ source file is opened, no highlight, and Backspace not working. Why is that ? I used to add some configurations in .vimrc under vim74 before, and this situation never happens.
After complaints that Vim in its default configuration is hard to use (especially for beginners), it was decided to enable a default configuration if the user hasn't created his own ~/.vimrc (yet). This was introduced with Vim 8.0, and explains what you're seeing (namely: syntax highlighting and sensible backspace behavior). Read more about the details at :help defaults.vim.
The help also has instructions how to keep the defaults when adding your own ~/.vimrc configuration:
If you create your own .vimrc, it is recommended to add these lines somewhere
near the top:
unlet! skip_defaults_vim
source $VIMRUNTIME/defaults.vim
Then Vim works like before you had a .vimrc.
Tip: Don't go all crazy with adding various snippets (especially not those you don't fully understand) and plugins to your ~/.vimrc, even though the Internet is full of them. Rather, build it up gradually, depending on needs, and back up your understanding with careful studying of the excellent :help. Also, avoid pre-packaged Vim distributions; they're even worse.

How to create my custom vim snippets?

I want to create some snippets when writting c++.
for example:
create a file, cpp.snippets.
priority -1
snippet exam
This is an example!
endsnippet
and put it in ~/.vim/my-snippets/snippets/.
then, add following statement in ~/.vimrc:
set runtimepath+=~/.vim/my-snippets/
let g:UltiSnipsSnippetsDir='~/.vim/my-snippets/'
let g:UltiSnipsSnippetDirectories=["snippets"]
But it not work, how can i fix it ?
UltiSnips plugin includes detailed documentation. Have you read the following help page?
:help UltiSnips-snippet-search-path
Update:
One of the things that was obvious when I read that help section was that in UltiSnips the name "snippets" can't be used in g:UltiSnipsSnippetDirectories because it is reserved for snipMate compatible snippets. This does not happen in the link shared in the comment below, where the name "my-snippets" is used instead.
I do not use UltiSnips, but from the documentation I would suggest the following approach:
Do not set g:UltiSnipsSnippetsDir nor g:UltiSnipsSnippetDirectories.
Keep the runtimepath+= configuration.
Create the following directory: ~/.vim/my-snippets/UltiSnips.
Place the personal snippets under this new directory.
Reasoning:
By default UltiSnips searches for all UltiSnips directories under your runtime paths, so no configuration is required if this name is used.
Although the runtime setting is required for personal snippets, this configuration is automatically maintained if a plugin manager is used.
The last point allows the installation of vim plugins that contain snippets. For example, this plugin contains various snippets for both snipMate and UltiSnips, including C++.
If you are using the sirver/ultisnips plugin (UltiSnips) the correct way to do this is simply run the :UltiSnipsEdit command which opens up a custom snippets file for the current language / filetype.
I had so much grief with this. Here is an answer for future reference for those of you who do not want to suffer headaches.
I have a shared .vimrc served on a samba share. Both Windows gViM and ViM use this file.
Relevant Part of .vimrc for Windows
I have a samba share mounted under L:. Note that I actually had to use POSIX for the path, not Windows backslashes \ despite being a path for Windows.
if has('win32') || has('win64') "If gVim under Windows"
let g:UltiSnipsSnippetDirectories=["L:/.vim/custom_snippets"]
endif
Relevant Part of .vimrc for Unix
My terminal opens xterm-256color for more colors, but you could exchange that with xterm. Here the path can expand ~ correctly, since this is the real home directory where my ``.vim` lives.
if $TERM == "xterm-256color"
let g:UltiSnipsSnippetDirectories=["~/.vim/custom_snippets"]
endif
Finishing Touches to Load custom_snippets
You don't need any! The following changes are NOT necessary:
"let g:UltiSnipsSnippetDirectories=["custom_snippets"]
"let g:UltiSnipsSnippetsDir="~/.vim/snippets_custom/"
However, Putty does not pass the tab key or control key properly it seems, despite all paths working fine. I tested the paths with :UltiSnipsEdit while in a file type environment set ft=tex and it took me to ~/.vim/snippets_custom/tex.snippets as it should (both in gvim on Windows and from my unix console).
Perhaps Useful for enabling in Putty
Patch: Creating a ctrl+tab keybinding in PuTTY
How to solve the collision of TAB key mapping of `UltiSnips` plugin in the Vim
https://unix.stackexchange.com/questions/53581/sending-function-keys-f1-f12-over-ssh

vim, pathogen, and load order of ftplugin files

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.

share eclim -friendly .vimrc

I am trying to to use eclim for my daily development requirements. My .vimrc has some issues preventing few functionalities like code completion etc.
It would be great if anyone using eclim regularly share your .vimrc.
You can find my vim setup on github. I use eclim to do Android development.
See visualstudioinvoke.vim for how I launch Vim from eclim. This isn't necessary, but it's useful to start at the current line in the current file. It also sets up my eclim menu, bindings, and settings.
It's best to start the eclim server (by opening the "Eclim" eclipse tab) before you start gvim.
I have eclim's code completion mapped to Ctrl-Space.
You won't get any code completion for classes that aren't in the scope of the current file. To import, I have a menu option under Eclim > ImportMissing.
However, my vimrc might be pretty alien to you, so you might be better served whittling down your vimrc until you figure out what's breaking things. The default map for completions is Ctrl-x Ctrl-u. You can use :verb map <C-x> to search for maps that start the same way and it will show you where they're defined.
If you use SuperTab, try disabling it. SuperTab and eclim are both maintained by
Eric Van Dewoestine so they should be compatible, but you may have a SuperTab configuration problem.
You could also try updating all of your plugins.

Resources