jdonaldson / vaxe

A modern, modular vim mode for Haxe.
219 stars 36 forks source link

Autocomplete isn't complete #16

Closed benbot closed 11 years ago

benbot commented 11 years ago

When I try loading something from a lib like haxepunk, the autocomplete shows me com.* and com.haxepunk.* but not things like com.haxepunk.graphics.*.

I am not sure if this is vaxe or omnicomplete or neocomplcache but... yeah that happens.

jdonaldson commented 11 years ago

Hmm, my earlier comment looks like it got deleted.

I remember having a similar problem with neocc. Check out the documentation for neocc: https://github.com/Shougo/neocomplcache/blob/master/doc/neocomplcache.txt

In particular, look for the settings variables: g:neocomplcache_max_list g:neocomplcache_skip_auto_completion_time

I have the latter set to 1, and it fixed the problem IIRC.

As an FYI, I'm currently experimenting with YouCompleteMe: https://github.com/Valloric/YouCompleteMe

It has more straightforward defaults, and is a little bit faster, but is missing some of the extra features of neocc.

benbot commented 11 years ago

I looked at those variables and played around with them but still no luck. I'll try out YouCompleteMe. Do I need anything added to my vimrc?

benbot commented 11 years ago

But I don't think I can build it for haxe so... I guess I won't try that out :D

benbot commented 11 years ago

It seems like neocomplcache only caches the haxe.* classes. I have been messing around with it and that is all that is fully shown. not even sys.* shows up.

jdonaldson commented 11 years ago

I will switch back to vanilla neo cc and try to reproduce... Once I have a bit more time.

jdonaldson commented 11 years ago

Neocc still works pretty well, but i have a lot of extra options and settings. Does completion work everywhere else? E.g, after strings, arrays, etc.? Or, is it just a problem with modules?

Can you try adding my "extra" neocc options here: https://github.com/jdonaldson/dotfiles/blob/master/vim/after/plugin/neocomplcache.vim

You can put that in an "after" directory in your .vim folder, or you can just copy and paste them in your vimrc (remove the last line referencing the :NeoComplCacheEnable command in that case)

benbot commented 11 years ago

I works with everything else as far as I have noticed. I really only need the auto complete for the modules though.

Using those settings the autocomplete is a bit more stable BUT the original problem still exists. And I need to have that last line in the vimrc for it to work.

benbot commented 11 years ago

I restarted vim and those settings seem to have lost their magic effect

jdonaldson commented 11 years ago

very strange.

One last thought is to turn on logging: :let g:vaxe_logging=1

And then to trigger a completion via c-x c-o in front of a problematic module. The raw response will be printed to the message buffer, which you can read with :message.

Would you mind taking a look at that?

benbot commented 11 years ago

Sorry for taking so long to reply... I had to hold off on haxe for a bit but now... im back. I took off neocompl cache.. I also was reading the autocompletion docs for the haxe compiler I found out that the line endings need to be CRLF and in vim for unis it is just LF be default. I am going to change the endings to CRLF and give it another shot.

benbot commented 11 years ago

I used unix2dos to convert the file to CRLF and that did the trick. Autocompletion works like a charm now :D It seems to be a restrictive feature of haxe rather than a problem with vaxe.

I'm going to close this issue and see if I can make a pull request to change ff to dos when a .hx file is open.

Thanks for the great plugin :D

jdonaldson commented 11 years ago

Hey that is good news, and sounds like it might be at the root of some other problems I have seen. Thanks for the report.

jdonaldson commented 11 years ago

This is strange... I've switched some haxe files to/from unix/dos format, and it works fine for me. If you have another problematic file, can you send it to me? Are you on windows?

benbot commented 11 years ago

I'm on linux. If I have a project using nme with a .nmml file autocompletion works fine (for standards lib but things like haxepunk require a symlink in the project dir to detect correctly) but if I have a .hxml for openfl it doesn't work. I am going to be working on my game all weekend so I will see if I can find out why this is happening.

jdonaldson commented 11 years ago

For openfl, it defaults to looking for "project.xml". The new default hxml routine will look up the parent directories for "project.xml", ".nmml", and "build.hxml". It will use the first one it finds as it moves up the parent directory chain (and generate hxml from nmml/xml as necessary). You can change those up if you want, e.g. introducing wildcards: (.xml, etc.) See :h g:vaxe_default_parent_search_patterns for more details. I just added some more docs on that.

I decided to use "project.xml" since it was the default in most openfl projects I've seen, and xml is a very generic file extension, and I didn't want a non-openfl file picked up by mistake.

Here's some more simple things that you probably have already tried: What is the build file used for completions? :echo b:vaxe_hxml For nme, is the lib referenced in your nmml file? ? Is it generating a lib reference in .nmml.hxml file?

Thanks for the report!

benbot commented 11 years ago

I have the project.xml in there. In fact, I took my nmml and changed the extension to .xml and it won't work, but if I change it back to nmml the completion works fine. I am going to make a new project today so I could have a clean test.

benbot commented 11 years ago

I just made a new openfl project and as soon as I went in vim I compiled it then typed "import" then hit C-x C-o and this message was given to me

Error detected while processing function vaxe#HaxeComplete..71_FormatDisplayCompletion..71_RawCompletion: line 18: E484: Can't open file /tmp/v4wo97Z/7 Error detected while processing function vaxe#HaxeComplete..71_FormatDisplayCompletion: line 10: E777: String or List expected

It looks like something isn't being made but I'm not sure.

jdonaldson commented 11 years ago

The problem is in the "Can't open file" error (the rest of the errors follow through that). Here's two things to try, in order of what I think is likely to be causing the problem:

The system command (in RawCompletion) is calling the haxe compiler command. Maybe that is failing and the tmp file is never created. I would look at that and see if it looks wrong. Turn on vaxe logging (:ToggleVaxeLogging) and retry that completion. Then check the result in the messages (:message). You should see the compiler command "cd && haxe " somewhere in there. Try running that same command from your working directory, and see if it works correctly.

Vim opens tmp files to capture output from system commands. Either those tmp files cannot be created for some reason, or the system command isn't working correctly. You can try and see if you have something that is clearing tmp files (e.g. a cron or a tmp cleaner), that was one of the recommendations from here: http://vim.1045645.n5.nabble.com/vim-script-can-t-create-tmp-file-td5712418.html

The completion script is a little more advanced than the build script, so my bet is that this is what is going wrong. Let me know if you see anything, and thanks again.

jsbeckr commented 11 years ago

@jdonaldson Do have news for YouCompleteMe? Would be very nice if you know a way of how to get haxe completion with ycm.

jdonaldson commented 11 years ago

I just tried YouCompleteMe again, and it seems to have improved a lot since last time. I'm adding some default configuration for it as part of the vaxe config. It should work automatically now once you install the YouCompleteMe bundle and compiled the helpers. I've updated the docs accordingly.

jdonaldson commented 11 years ago

One more idea @thecodethinker... you could try to specify a different swap directory for vim in your vimrc. Here's how mine looks:

" Save your swp files to a less annoying place than the current directory.
" If you have .vim-swap in the current directory, it'll use that.
" Otherwise it saves it to ~/.vim/swap, ~/tmp or .
if isdirectory($HOME . '/.vim/swap') == 0
  :silent !mkdir -p ~/.vim/swap >/dev/null 2>&1
endif
set directory=./.vim-swap//
set directory+=~/.vim/swap//
set directory+=~/tmp//
set directory+=.
benbot commented 11 years ago

This specific issue seems to have been fixed with openfl... shrug

Sorry for the long absence.

jdonaldson commented 11 years ago

No worries. Thanks for checking in again.