Skip to content
This repository has been archived by the owner on Aug 3, 2024. It is now read-only.

Fixed documentation to reflect more robust code #392

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Fixed documentation to reflect more robust code #392

wants to merge 1 commit into from

Conversation

eastwood
Copy link

As describes here:
https://bitbucket.org/ns9tks/vim-autocomplpop/issue/51/a-z-a-z-auto-completes-to-acp-onpopuppost

It's common for problems to occur, one of the main causes was that java files outside of eclim projects were throwing exceptions and causing the issue. I added a check to ensure this doesn't happen.

=acp#onPopupPost()

As describes here:
https://bitbucket.org/ns9tks/vim-autocomplpop/issue/51/a-z-a-z-auto-completes-to-acp-onpopuppost

It's common for problems to occur, one of the main causes was that java files outside of eclim projects were throwing exceptions and causing the issue. I added a check to ensure this doesn't happen.

=acp#onPopupPost()
@ervandew
Copy link
Owner

From your comment on the autocomplpop issue:

This can be caused by many things, but the most common case would be the current file not being in a eclim project. In order to fix this, I checked for the existence of the project in my function and don't have this issue anymore.

Checking exists(':Java') wouldn't validate that your file is in an eclipse project, it would just validate that that eclim might be installed and loaded (some other plugin could define :Java).

If you want to check if the file is in an eclim project, then you should use:

function! MeetsForJavaEclim(context)
  if !eclim#project#util#IsCurrentFileInProject(0)
    return 0
  endif
  return g:acp_behaviourJavaEclimLength >= 0 &&
        \ a:context =~ '\k\.\k\{' . g:acp_behaviourJavaEclimLength . ',}$'
endfunction

If you are sharing this config amongst machines were eclim may or may not be installed, then I think the best way to handle that would be to catch the error thrown when the function doesn't exist:

function! MeetsForJavaEclim(context)
  try
    if !eclim#project#util#IsCurrentFileInProject(0)
      return 0
    endif
  catch /E117/
    return 0
  endtry
  return g:acp_behaviourJavaEclimLength >= 0 &&
        \ a:context =~ '\k\.\k\{' . g:acp_behaviourJavaEclimLength . ',}$'
endfunction

@eastwood
Copy link
Author

Oh great suggestion, I'm really new to vimscript world.

One thing I have been playing around with, is getting the autocomplete to trigger when after 3 letters have been types (i.e like IntelliJ). So I've tried to use:

\ a:context =~ '\k\{' . g:acp_behaviorJavaEclimLength . ',}$'

But when I type:

if ( foo.equals("bar

I get the error:

if ( foo.equals("bar=acp#onPopupPost()

Unfortunately, it looks like my fix, doesn't solve this problem :( Have you got any suggestions on how to achieve this? This error is occurring when eclim can't find something to complete on. So in your function that you provided on the website if you typed:

foo.equals("bar.baz

You'll also get the error:

foo.equals("bar.baz=acp#onPopupPost()

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants