Addition (patch) for eclim to achieve painless autocompletion after dot

96 views
Skip to first unread message

Dmitry Frank

unread,
Mar 19, 2012, 2:08:48 AM3/19/12
to ecli...@googlegroups.com
Hello!

Personally i'm annoyed by pressing <C-X><C-U> every time i want to execute completion. I want completion to be fired automatically when i press dot ".", like modern IDEs do that.

I have made an addition for the eclim: when you press dot "." in java file, completion is executed automatically. It is NOT executed when you are in the comment or in the string, so it will not annoy you.
Please test it, you have not to modify any original eclim's files, you just need to put several additional files to your vimfiles dir (personally i use pathogen plugin, so this addition is stored in completely separated directory)

So, you need to download this archive, there's directory "eclim_dotcomplete" in it. Unpack all contents of this directory to your vimfiles dir, and that's all. Dotcomplete should work out-of-the-box (assume you have eclimd started) : restart Vim, open some Java file, and try to press "." after some symbol.

I found this very useful for me.

What do you think?
Thanks.

--
Dmitry.
Встроенное изображение 1

Eric Van Dewoestine

unread,
Mar 24, 2012, 1:34:52 AM3/24/12
to ecli...@googlegroups.com
On 2012-03-19 10:08:48, Dmitry Frank wrote:
> Hello!
>
> Personally i'm annoyed by pressing <C-X><C-U> every time i want to execute
> completion. I want completion to be fired automatically when i press dot
> ".", like modern IDEs do that.
>
> I have made an addition for the eclim: when you press dot "." in java file,
> completion is executed automatically. It is NOT executed when you are in
> the comment or in the string, so it will not annoy you.
> Please test it, you have not to modify any original eclim's files, you just
> need to put several additional files to your vimfiles dir (personally i use
> pathogen plugin, so this addition is stored in completely separated
> directory)
>
> So, you need to download this archive <http://goo.gl/lMqIl>, there's

> directory "eclim_dotcomplete" in it. Unpack all contents of this directory
> to your vimfiles dir, and that's all. Dotcomplete should work
> out-of-the-box (assume you have eclimd started) : restart Vim, open some
> Java file, and try to press "." after some symbol.
>
> I found this very useful for me.
>
> What do you think?
> Thanks.

Sorry for not replying sooner, but it's been a busy week.

I personally use supertab[1] to avoid typing <c-x><c-u> (I took over
its development years ago, so I'm biased). However, I'm sure there are
plenty of users who would like the more traditional auto triggering of
the completion pop like a typical IDE.

While your plugin looks good (thanks for submitting it!), there is an
existing plugin which provides this feature: autocomplpop[2]

I just spent a little time playing with autocomplpop just to make sure
it could be configured to work with eclim and after finding the magic
settings, I added an example to eclim's code completion docs[3].

Here is the code/config I came up with to trigger completion after
typing at least 3 characters following a dot (can be tweaked to suit
individual tastes):

let g:acp_behaviorJavaEclimLength = 3
function MeetsForJavaEclim(context)
return g:acp_behaviorJavaEclimLength >= 0 &&
\ a:context =~ '\k\.\k\{' . g:acp_behaviorJavaEclimLength . ',}$'
endfunction
let g:acp_behavior = {
\ 'java': [{
\ 'command': "\<c-x>\<c-u>",
\ 'completefunc' : 'eclim#java#complete#CodeComplete',
\ 'meets' : 'MeetsForJavaEclim',
\ }]
\ }

[1] http://www.vim.org/scripts/script.php?script_id=1643
[2] http://www.vim.org/scripts/script.php?script_id=1879
[3] https://github.com/ervandew/eclim/commit/ccd4bf2a3964a9a5a9ddd59da41cc22b27cf26f0

--
eric

Reply all
Reply to author
Forward
0 new messages