javacomplete plugin for vim - 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.

Related

Can you view the default Vim settings?

I’m starting to learn about creating my own .vimrc file and I keep noticing features that are missing with my custom version that were present in the default setup.
I was wondering if it is possible to view the default settings, so I can compare them to my own and look up all the standard inclusions I don't know to learn more about them.
I searched and couldn’t find an answer online, and if the reason why there isn’t one is that the answer to this question is glaringly obvious, I’m really sorry; I’m still a bit of a noob :p
No worries, it’s a perfectly valid question. Unfortunately, the answer is a bit complicated. First of all, Vim has certain defaults that are documented in the built-in help system.
Some of them are only used when Vi compatibility mode is disabled, and that’s the first customisation most people make:
:set nocompatible
On top of that, many distributions provide their own custom config, for example Debian/Ubuntu comes with /etc/vim/vimrc. To makes things even more confusing, Vim 8 comes with a sane configuration (called default.vim) that only gets applied when ~/.vimrc is not found. Not to mention that NeoVim comes with its own set of defaults.
In practice, I suggest to explicitly set any options you care about to make sure your config is portable between systems and versions of Vim. To see the current value of a given option, use a question mark:
:set showcmd?
To learn more about a given option (including the default value), use Vim’s comprehensive help system:
:help showcmd
Finally, you might want to check my annotated .vimrc for some inspiration, and there is also the vim-sensible plugin that provides some sane defaults most people would agree to.
The easiest way to see “vanilla” Vim options is to start it using:
$ vim -u NONE -N
It will start Vim without any of your customizations or plugins, but still in ‘nocompatible’ mode (i.e., basically, running full-fledged Vim, instead of its stripped down version emulating Vi).
Then, you can execute the following commands:
:set all
:map
:command
:let
:function
:autocmd
to see all options, mappings, commands, variables, functions, and auto-commands, respectively, that are currently in effect. (I cannot promise I haven’t forgotten a customization category.)
Vim also comes with a bunch of basic configurations that is skipped by the -u NONE option, that you can also include while still excluding your .vimrc, by using -u NORC, instead.
Based on #Amadan's answer, I came up with this file (ShowAllDefaults.vim) and command to run it and capture the output.
. In the mean time, learning that, if you have files under ~/.vim, they get executed if you use this:
vim -u ShowAllDefaults.vim -N +q
So the correct way to do it is:
vim -u NONE -N +"source ShowAllDefaults.vim" +q
Contents of ShowAllDefaults.vim:
set verbosefile=/tmp/ShowAllDefaults.log
set all
map
command
let
function
autocmd
I am trying after long time to get familiar with vim also, and I came across this because I had same question.
How I found answer from within vim was to pull up help on defaults and it explained to get defaults along with .vimrc for newer users and also gave the path to default script so you could open it right up in your editor and read & compare it.
I am not going to give my exact path because that might change in different versions, so best to get it from help documents inside vim.

Command-T: Is it possible to have project-specific ignore-patterns?

so I read through the documentation and a couple of search-results on google but I can't seem to find a solution for my problem.
I'm using Command-T and set up a "global" ignore pattern in my vimrc:
let g:CommandTWildIgnore="**/*.min.*,**/*.jpg,**/*.png,*/dist,*/docs,*/node_modules,*/nginx,*/tmp"
This works fine so far.
Now I wanted to add to this global-pattern a project-specific setting so the global one wouldn't get too long.
For example I have set up something similiar for AG where I have a "global" .agignore-file in my vimrc-folder and then a project-specific .agignore-file in the project-folder.
Is this possible with Command-T too? I know I can add to the global-pattern using the vim-commandline but this only lasts until I close vim. I would like a similiar setup to AG but I don't know where to put the command or how to name the file.
Any ideas? :)
Greetings.
Not sure if this is possible with stand alone command-T, but a workaround might be the use of this plugin:
http://www.vim.org/scripts/script.php?script_id=1860
It allows you to define project-specific vim settings, so you could use it to override or add to your command-T ignore cases.
Or perhaps an eaiser way, for each project add something like this to your .vimrc:
autocmd BufNewFile,BufRead /path/to/project/* let g:CommandTWildIgnore="..."

Neocomplete does not work with vim files

I just installed Neocomplete and tried it for C files, ruby and python and it works perfectly.
I have problems with vim files as I don't get any omnicompletion at all. I tried C-x C-o and got omnifunc is not set error
What am I doing wrong? I thought this would work from scratch.
You aren't doing anything wrong. It isn't neocomplete's job to provide omnifunc.
Neocomplete does work well with omni completion: it uses omnifunc to provide good candidates for completion, along with other completions provided by vim. However, neocomplete itself does not provide or set omnifunc for differnt filetypes. That's why its configuration example has multiple lines with set omnifunc=...
It works with python etc. because the corresponding functions are provided by vim runtime files (e.g. /usr/local/share/vim/vim74/autoload/pythoncomplete.vim) or other plugins (like jedi-vim), and the omnifunc options are set accordingly (If you want to know where, try :verbose set omnifunc?).
Sadly, no function for omni completion for Vim script is provided by default, so you'll need to i) find one and ii) set omnifunc=(that function). After that, neocomplete will be able to use that function to provide omni completion.
Edit: as #Martin Macak pointed out, neocomplete-vim's github page does show something like omni-completion. After some digging, it seems these completions come from Shougo/neco-vim, mentioned briefly in the doc. i_CTRL-X_CTRL-V mentioned there is also worth trying.

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.

How to add another file extension (e.g. 'style.less') to Vim's snipMate plugin?

I would like to write snippets for Less (.less) and Stylus (.styl) and use then in Vim's snipMate plugin. How can I accomplish that?
EDIT: I know that the first step is to create a file inside the snippets folder with a name like this: less.snippets or stylus.snippets but after that I'm not sure what to do.
Yes right that is the first step. And after that you have to set the filetype of the files you want to edit with multiple snippets to:
set filetype=less.styl
or
set filetype=styl.less
I've just tested it with the snipmate "official" fork and it works fine but I'm sure enough it should work with the original plugin too.

Resources