unable to use cscope multi key stroke via vim editor - linux

I am using VIM 7.0 on RHEL release 5.4, and downloaded cscope plugin from: http://cscope.sourceforge.net/cscope_maps.vim
and copied it to path(one instance at a time): ~/.vim/plugin/cscope_maps.vim & /usr/share/vim/vim70/autoload
and generated cscope -qbR from root dir of source files, & opening *.C files from same dir.
According to this(point 5) & cscope_maps.vim, I should be able to do keyword search by multiple keystroke: CTRL-\ <option> or CTRL-# <option> by placing the cursor under the keyword as we do for ctags. But I am able to access the cscope keyword search only through the vim's command line argument (ie., :cs f d or :cs f c) and not with multiple key stroke shortcut.
I've also tried pasting all the contents of cscope_maps.vim to ~/.vimrc, but it didn't help
Is there something I am doing wrong/ any other way to make it work?

As described in the plugin's documentation, copy the plugin to
~/.vim/plugin/cscope_maps.vim
The autoload directory you've chosen is wrong, this is for plugins' on-demand functionality.
Also, /usr/share/vim/vim70/ is owned by the default Vim package, don't touch anything there (in general), or you'll run into problems when reinstalling / upgrading packages! If you do need to have a system-wide plugin, check :help runtimepath and find / add a proper location that you own on the system.

Probably your code base is other then .c files. I was facing same issue as my code base includes c and c++ both. I was trying with c++ functions and was facing same issue you mentioned.
Hint- Build cscope data base with all required files.

Probably, you are missing the CSCOPE_DB environment variable - i.e, it should point to the valid cscope.out file
To check, once you are in vim, run :echo $CSCOPE_DB, mine shows:
/home/me/views/myrepo/cscope.out

I had the same problem with cscope and Vim 7.4. I could solve it in Arch uncommenting in cscope_maps.vim the bellow lines:
set timeoutlen=4000
set ttimeout
BTW I followed this tutorial to install cscope vim plugin on Arch:
https://wiki.archlinux.org/index.php/vim#cscope

Related

nvim finds the function but vim does not

I am using a vim/nvim plugin asyncrun that enables an API call that works fine in nvim if I implement it in ~/.config/nvim/init.vim using a line:
call asyncrun#run("", "cwd", "firefox")
Now this same line does not work for vim if I try to use it inside ~/.vimrc. I always get a warning:
Unknown finction: asyncrun#run
What needs to be changed in order for this to also work for vim?
Following the #doopNudles comment I also clarify that vim plugin is manually installed in the folder ~/.vim/pack/my-plugins/start/vim-asyncrun/asyncrun.vim/plugin/asyncrun.vim. I install all my vim plugins the same way (using the vim v8 native ability to detect plugins).
The problem was that ~/.vim/pack/my-plugins/start/vim-asyncrun/asyncrun.vim/plugin/asyncrun.vim has one extra folder!
It works if I delete the extra folder asyncrun.vim like this ~/.vim/pack/my-plugins/start/vim-asyncrun/plugin/asyncrun.vim

Vim picking up Cscope command instead of ctags?

I have installed ctags but not installed cscope.
When I press Ctrl-], vim correctly takes me to the definition.
However, when I press Ctrl-t, it replies back with error - "E567: no cscope connections".
vim --version has +cscope in it.
I tried setting "set nocst" in my vimrc, but to no avail.
Try:
:set csto=1
From the documentation http://vimdoc.sourceforge.net/htmldoc/if_cscop.html#csto
The value of 'csto' determines the order in which |:cstag| performs a search.
If 'csto' is set to zero, cscope database(s) are searched first, followed
by tag file(s) if cscope did not return any matches. If 'csto' is set to
one, tag file(s) are searched before cscope database(s). The default is zero.
I hope this will help you.
You may have cscope_maps.vim installed. Or, perhaps another related cscope related plugin/bundle. If so, you'll need to remove it.
If you already have ctags installed and you are trying to use an outline viewer for your code, I would recommend using https://github.com/majutsushi/tagbar. It works really well with just ctags.
If you are are using Vundle, install using
Plugin 'majutsushi/tagbar'

Cannot load CoqIDE plugin for vim

I'm trying to use the CoqIDE for vim plugin I found on this page.
I put the coq_IDE.vim file in ~/.vim/ftplugin folder. My current .vimrc file is:
set showcmd
set number
imap hl <Esc>
filetype plugin on
But when I start vim CoqIDE doesn't load automatically (I see no change whatsoever compared to normal vim, so I don't think it did). And when I try to load it manually by the command :source coq_IDE.vim, I get the following error message:
E484: Can't open file coq_IDE.vim
What could be the source of this error?
Here are some additional information that might be relevant:
1) I am running Ubuntu 14.04.
2) I checked that :version in vim shows +perl.
2) I am running vim from terminal, not gvim.
3) I tried removing and reinstalling different versions of vim (vim, vim-gtk, vim-gnome)
4) The CoqIDE installation guide says that coqtop.opt should be accessible via the PATH variable. Since I'm not even sure what this means, this might be the problem here, but that seems unlikely. From what I understand vim is getting errors when trying to read coq_IDE.vim, so it's not even getting to the part where it's looking for coqtop.opt.
5) I have CoqIDE installed from Ubuntu Software Center.
6) With :echo &runtimepath I get: ~/.vim,/var/lib/vim/addons,/usr/share/vim/vimfiles,/usr/share/vim/vim74,/usr/share/vim/vimfiles/after,/var/lib/vim/addons/after,~/.vim/after
The instructions are bad.
Put the file in ~/.vim/plugin not ~/.vim/ftplugin
The file layout should look exactly like the file layout found in this mirror for the plugin. https://github.com/vim-scripts/CoqIDE. (Maybe take a look at pathogen or vundle,).
The reason the :source coq_IDE.vim fails is vim is looking for the file coq_IDE.vim in the current directory and it isn't there. Use the full path to file if you are going to source it manually. (You shouldn't need to though.)

Get ocamlmerlin autocomplete in vim

I'm trying to get autocompletion for OCaml. I like using Vim and I found this plugin:
https://github.com/the-lambda-church/merlin
I installed it using OPAM and added the required lines to load it to my .vimrc
I made sure that OPAM bin folder (which contains ocamlmerlin) is in my .profile file and
checked that I can access it from the terminal and for vim I printed the PATH variable using "Ctrl-r =$PATH" and it shows that it contains OPAM bin folder.
It still doesn't work, I have no clue what else to do to make it work. I get syntax highlighting but that exists without merlin anyway. I want autocompletion to work.
If I press Ctrl-N to show completion suggestion I get "normal" vim completion which is basically just a list of words that are mentioned in the document.
Checking the startup log file, I can see that Vim did indeed load merlin:
chdir(/home/incraved/.opam/system/share/ocamlmerlin/vim/plugin)
fchdir() to previous dir
sourcing "/home/incraved/.opam/system/share/ocamlmerlin/vim/plugin/merlin.vim"
finished sourcing /home/incraved/.opam/system/share/ocamlmerlin/vim/plugin/merlin.vim
Searching for "/home/incraved/.opam/system/share/ocamlmerlin/vimbufsync/plugin/**/*.vim"
Any ideas?
Ctrl-N is the default completion; its sources are configured by the 'complete' option, but cannot include custom sources.
The Merlin plugin uses Omni completion, which is triggered with Ctrl-X Ctrl-O; see :help compl-omni.

Unite.vim file_rec/async

I'm getting started using vim for a week and many things still new to me. During the research, I found Unite.vim is extremely great. However, I cannot manage to get this command works:
nnoremap <leader>f :<C-u>Unite -start-insert file_rec/async.
I looked into doc file and it says the following:
file_rec/async Same as |unite-source-file_rec|, but get files asynchronously.
Note: This source requires vimproc.
Note: This source requires "ag" or "find" command.
Note: Windows "find" command is not supported.
I'm using vim windows and don't find the way to have Ag or find compatible commands (I guess it would be for mac/linux)
Any instructions would be appreciate. Tks :)
All of this is assuming you have cygwin, and vim with pathogen managing your plugins:
Before you use the file_rec/async command, you need to have vimproc, because what happens is Unite runs the search in another process, and then searches through the results with your vim process:
mkdir -p ~/.vim/bundle
git clone https://github.com/Shougo/vimproc.vim.git ~/.vim/bundle/vimproc.vim
cd ~/.vim/bundle/vimproc.vim
make -f make_cygwin.mak # <-- This is directly from the vimproc readme
Next, ensure that it works by running vi, and staying in command mode and entering:
:Unite -start-insert file_rec/async
If that works, then I would advise you to setup your binding in ~/.vimrc like this:
nnoremap <C-u> :Unite file_rec/async<cr>
Getting ag on your machine might be difficult, as the documentation states that it's "Complicated" and advises you to install a package manager for windows and some libs: https://github.com/ggreer/the_silver_searcher/wiki/Windows
However, if you do manage to get ag on your machine, here is the configuration I've gotten it to work with Unite.vim with in my ~/.vimrc:
" Use ag for search
if executable('ag')
let g:unite_source_grep_command = 'ag'
let g:unite_source_grep_default_opts = '--nogroup --nocolor --column'
let g:unite_source_grep_recursive_opt = ''
endif
Ag (a.k.a. the Silver Searcher) is a utility like ack, you can find it here, there also seems to be a dedicated Windows port.
Alternatively, you can try the GNU find Windows port from the unxutils project, or use Cygwin for Windows.
Get vimproc neccesary dll from http://www.kaoriya.net/software/vim/. On website there are 32 and 64bits version downloads.
http://files.kaoriya.net/goto/vim74w32
http://files.kaoriya.net/goto/vim74w64
Inside each zip there is a plugins directory (example with 64bits): "vim74-kaoriya-win64-20150628.zip\vim74-kaoriya-win64\plugins\vimproc\autoload\" where you can find it without compile.
For ag use windows port as #Ingo Karkat says.
NOTE: ag suffers from searchs on paths long than 256 chars (at this time). Use platinum searcher if that is a problem in your case.

Resources