jdonaldson/vaxe

Can't get completion to work with Haxe 3

Closed this issue · 35 comments

Hi Justin,

I came back to Haxe after a long hiatus, and now I'm using Haxe 3. I have a test class:

screen shot 2013-09-05 at 6 37 38 pm

When I try to get the members of the js package by pressing C-x C-o, I get the message that you can see in the bottom:

"Omni completion - the only match"

Any ideas on how I could fix it?

Hey Marcelo, welcome back. Are you using neocc or YouCompleteMe?

I have no idea :/ ... how can I find out?

ah ok, those are plugins to automatically generate completions.... thought there might be a conflict.

Do you have a build.hxml file in your working directory? Does the :make command work correctly?

If so, try the :ToggleVaxeLogging command, and then re-do the completion attempt. Afterwards, check the :messages command for the output.

Does it look right?

Yeah, here are the contents of build.hxml:

-main Marcelo
-js marcelo.js

:make works as expected.

Marcelo

On Thursday, September 5, 2013 at 7:50 PM, Justin Donaldson wrote:

ah ok, those are plugins to automatically generate completions.... thought there might be a conflict.
Do you have a build.hxml file in your working directory? Does the :make command work correctly?
If so, try the :ToggleVaxeLogging command, and then re-do the completion attempt. Afterwards, check the :messages command for the output.
Does it look right?


Reply to this email directly or view it on GitHub (#27 (comment)).

Hmm.. ok, try those other commands then.

What commands?

Oh, just saw them. Sorry. I will try them out.

"Marcelo.hx" 33 lines --42%--
(1 of 2) error: Unknown identifier : js
"Marcelo.hx" 32L, 521C written
"Marcelo.hx" 32L, 521C written
"Marcelo.hx" 32L, 521C written
(1 of 2) error: Unknown identifier : js
1 more line; before #7  2 seconds ago
1 more line; before #6  4 seconds ago
"Marcelo.hx" 32L, 521C written
"Marcelo.hx" 32L, 521C written
--No lines in buffer--
1 more line; before #40  0 seconds ago
1 more line; before #39  0 seconds ago
1 more line; before #38  0 seconds ago
1 more line; before #37  1 seconds ago
1 more line; before #36  1 seconds ago
1 more line; before #35  1 seconds ago
1 more line; before #34  1 seconds ago
1 more line; before #33  1 seconds ago
1 more line; before #32  2 seconds ago
1 more line; before #31  2 seconds ago
1 more line; before #30  2 seconds ago
1 more line; before #29  2 seconds ago
1 more line; before #28  2 seconds ago
1 more line; before #27  2 seconds ago
1 more line; before #26  2 seconds ago
1 more line; before #25  2 seconds ago
1 more line; before #24  2 seconds ago
1 more line; before #23  2 seconds ago

It looks like it can't find the js package... strange.

That is strange, especially since I don't see the compiler command either. You should see something like:
cd "/Users/jjd/Scratch/test"&& haxe -main Main -js out.js --display /Users/jjd/Scratch/test/Main.hx@43 2>&1

You sure you toggled logging on?

I apologize. Scrolling down to the end of the bugger, I saw this:

cd "/Users/fullofcaffeine/workspace/code/haxe_test"&& haxe -main Marcelo -js marcelo.js --display /Users/fullofcaffeine/workspace/code/haxe_test/Marcelo.hx@134 2>&1

Marcelo

On Thursday, September 5, 2013 at 9:13 PM, Justin Donaldson wrote:

That is strange, especially since I don't see the compiler command either. You should see something like:
cd "/Users/jjd/Scratch/test"&& haxe -main Main -js out.js --display /Users/jjd/Scratch/test/Main.hx@43 2>&1
You sure you toggled logging on?


Reply to this email directly or view it on GitHub (#27 (comment)).

So, it looks like vaxe is working fine, but Haxe is the one that can't get the data, it seems.

That looks good to me. You should be able to run that same command from the terminal and see the raw completion output. I"ll try to think about what could be the problem here...

When I run it in the terminal, I get the following output:

➜  haxe_test  cd "/Users/fullofcaffeine/workspace/code/haxe_test"&& haxe -main Marcelo -js marcelo.js --display /Users/fullofcaffeine/workspace/code/haxe_test/Marcelo.hx@11  2>&1
Error: No completion point was found

Any ideas?

I would post some example code to the haxe mailing list. I can't spot the problem.

You could try to play around with the @11 number. You're doing a completion trying to import a package, no? Try @10, @12 or some of the numbers around there in a bash command? Maybe there's something strange with the encoding I'm not handling

Thanks Justin. The code is actually the one I posted in the screenshot above. The completion point is the one where the cursor is. Do you think it could be a bad Haxe 3 installation?

Hi Marcelo, I tried to recreate your file, and I notice that you're trying to get a completion for the @11 position. If I recreate your file (import after the dot in "import js."), I get position @10. I'm wondering if somehow there's an extra character thrown in. I do a check for byte order marks, but I might be missing something. Can you see if that terminal command works with @10? If it does, can you send me your Marcelo.hx as an attachment to jdonaldson at google mail? I'll try to see if there's any hidden characters.

Make sure that when you install YouCompleteMe you run the installation script in the plugin folder. ALSO VERY IMPORTANT. The haxe completer only works with files with DOS line endings. If you are not using windows then make sure your text editor is giving your files dos line endings.

In my vimrc this line give my .hx files dos line endings

autocmd BufRead,BufNewFile *.hx set ff=dos

I can get the completion (kind of) to work, I had forgotten to add the -lib for the libraries. However, I'm still having issues.

For example, take the following script:

import jQuery.*;
import feffects.Tween;
import EffectsList;
using feffects.Tween.TweenObject;
import js.*;


class Main {
  static var main_quote:JQuery = new JQuery('#quote');
  static var logo:JQuery       = new JQuery('#logo');

  static function main() {

    new JQuery(function():Void {

     // [for(x in [main_quote,logo]) x.fadeTo("slow",100)];

      logo. // I don't get anything here UNLESS I import jQuery.JQuery (without the wildcard)
      js. //I get a list here -- [Boot,Browser,Cookie,Error,JQuery,Lib,SWFObject,Selection,XMLSocket,html]
     //However, if I type:
     js.html. // don't get anything here. Doesn't work for other classes inside the package either.


    });


  }
}

I only get the tips for logo (an instance of JQuery) if I import jQuery.JQuery. It doesn't work when using a wildcard to import all classes.

For the std, the behavior seems inconsistent. Check the comments above.

Any hints appreciated.

That is very strange. Your example works fine.

Is there a chance that you have an older version of haxe somewhere? Are you setting HAXE_STD_PATH, etc. anywhere? How did you install haxe?

I did a find for haxe from the /, here's what I got:

/usr/bin/haxe
/usr/lib/haxe
/usr/lib/haxe/doc/content/haxe
/usr/lib/haxe/haxe
/usr/lib/haxe/lib/feffects/3,0,0/samples/export/html5/haxe
/usr/lib/haxe/lib/hxcocoa/git/demos/Busses/build/HelloWorld/haxe
/usr/lib/haxe/lib/hxcocoa/git/demos/Hello/build/HelloWorld/haxe
/usr/lib/haxe/lib/hxcocoa/git/demos/PiratePig/build/PiratePig/haxe
/usr/lib/haxe/lib/hxcocoa/git/demos/WWX/build/Wwx/haxe
/usr/lib/haxe/lib/hxcpp/3,0,2/java/org/haxe
/usr/lib/haxe/lib/jQueryExtern/2,0,0/jQuery/haxe
/usr/lib/haxe/lib/mlib/2,0,2/massive/haxe
/usr/lib/haxe/lib/mlib/2,0,2/massive/neko/haxe
/usr/lib/haxe/lib/mlib/2,0,2/massive/sys/haxe
/usr/lib/haxe/lib/openfl/1,0,0-rc,2/templates/flash/haxe
/usr/lib/haxe/lib/openfl/1,0,0-rc,2/templates/haxe
/usr/lib/haxe/lib/openfl/1,0,6/templates/flash/haxe
/usr/lib/haxe/lib/openfl/1,0,6/templates/haxe
/usr/lib/haxe/lib/openfl-native/1,0,0-rc,2/haxe
/usr/lib/haxe/lib/openfl-native/1,0,0-rc,2/templates/android/template/src/org/haxe
/usr/lib/haxe/lib/openfl-native/1,0,0-rc,2/templates/haxe
/usr/lib/haxe/lib/openfl-native/1,0,0-rc,2/templates/iphone/PROJ/haxe
/usr/lib/haxe/lib/openfl-tools/1,0,0-rc,3/src/haxe
/usr/lib/haxe/std/cpp/_std/haxe
/usr/lib/haxe/std/cs/_std/haxe
/usr/lib/haxe/std/flash/_std/haxe
/usr/lib/haxe/std/flash8/_std/haxe
/usr/lib/haxe/std/haxe
/usr/lib/haxe/std/java/_std/haxe
/usr/lib/haxe/std/js/_std/haxe
/usr/lib/haxe/std/neko/_std/haxe
/usr/lib/haxe/std/php/_std/haxe

Also:

➜  ~  which haxe
/usr/bin/haxe

And:

➜  ~  haxe
Haxe Compiler 3.1.0  (git build development @ ff57cd2) - (C)2005-2013 Haxe Foundation

➜  ~  /usr/bin/haxe
Haxe Compiler 3.1.0  (git build development @ ff57cd2) - (C)2005-2013 Haxe Foundation

Everything looks OK, unless I'm missing something I'm not aware about.

Thanks!

That all looks right .... hmm...

What happens when you run this? Can you paste the output here?

cd "/Users/fullofcaffeine/workspace/code/haxe_test"&& haxe -main Marcelo -js marcelo.js --display /Users/fullofcaffeine/workspace/code/haxe_test/Marcelo.hx@134  2>&1

@thecodethinker I can switch back and forth between :set ff = dos and :set ff = unix. Is it possible you had mixed line endings?

Just throwing some ideas out:

  • Try adding -D no_copt to your hxml ( I actually recommend adding this automatically through vaxe )

-D no-copt disables completion optimization. Is that a good thing?

-D no-copt optimizes a little too much, and most of the time you don't get completion while you should, it's the cause of it.

Thanks for the tip! Vaxe is getting pretty complex, so I think a good default is to ensure that everything has the highest probability of working right away, and then to provide options for more speed/efficiency later. I've added a config variable for automatically setting -D no-copt, which defaults to true. I've also done the same with -D absolute_path, since that is usually pretty useful as well.

@fullofcaffeine could you update and give this another chance when you get the time?

I have this same issue, the code completion seems not working for me either.
I am using https://github.com/Shougo/neocomplcache.vim (installed it via https://github.com/tpope/vim-pathogen)
I try first tutorial of OpenFL (http://www.openfl.org/developer/documentation/writing-your-first-application/) then try to autocomplete 'bitmap' variable. I've enabled the :ToggleVaxeLogging and result these

cd "/Users/giriputra/LAB/VIM/TESTO/MyApplication"&& haxe  -main ApplicationMain
-lib openfl -cp Source -D tools=1.2.6 -D display -D web --no-output  -swf-versio
n 11.2 -swf Export/flash/bin/MyApplication.swf -swf-header 800:600:30:FFFFFF -cp
 Export/flash/haxe  -D absolute_path -D no-copt --display /Users/giriputra/LAB/V
IM/TESTO/MyApplication/Source/Main.hx@335  2>&1

I tried to run that command direclty via terminal then it give me result

Expected a command name, got token of type 'Run job in background'. Did you mean 'COMMAND; and COMMAND'? See the help section for the 'and' builtin command by typing 'help and'.

🎉

Then I goofing around. Save the file, then try to run this (removed one & sign)

cd "/Users/giriputra/LAB/VIM/TESTO/MyApplication"& haxe  -main ApplicationMain -lib openfl -cp Source -D tools=1.2.6 -D display -D web --no-output  -swf-version 11.2 -swf Export/flash/bin/MyApplication.swf -swf-header 800:600:30:FFFFFF -cp Export/flash/haxe  -D absolute_path -D no-copt --display /Users/giriputra/LAB/VIM/TESTO/MyApplication/Source/Main.hx@335  2>&1

It gave me result

<list>
<i n="addEventListener"><t>type : String -&gt; listener : (Dynamic -&gt; Void) -&gt; ?useCapture : Bool -&gt; ?priority : Int -&gt; ?useWeakReference : Bool -&gt; Void</t><d>
     * Registers an event listener object with an EventDispatcher object so that
     * the listener receives notification of an event. You can register event
     * listeners on all nodes in the display list for a specific type of event,
     * phase, and priority.
     *
     * &lt;p&gt;After you successfully register an event listener, you cannot change

etc etc etc
....
Job 1, 'cd "/Users/giriputra/LAB/VIM/TESTO/MyApplication"& ' has ended

By that, I think the code completion should work but have somehow syntax error (maybe? I am newbie of this kind of thing 😄 )

Looking forward your reply

[update]
I think I figure it out, it's my haxe path problem.

Hmm... are you on fish shell? I changed the '&&' command to ';', which should function fine for what I'm doing here.

Yep, that's right, I am using fish shell

I've pulled the new commit, then tried several cases, and it's really strange

The first file that I test out and generate the result succeed
screen shot 2014-01-04 at 12 06 13 am

But it only succeed if I do ctrl-x ctrl-o only at that line. The autocomplete don't show up if I do it in another line
screen shot 2014-01-04 at 12 10 29 am

Then I try to do the same thing with new project, but strangely, it won't show up 😕
screen shot 2014-01-04 at 12 09 51 am

And I can't recreate the autocomplete like I post before. It's so strange.
Ask me if you need something for me to test out.

I'll try using fish shell and see if I'm missing anything there...

Oh! I figure it out, you have to save it first to show the autocomplete. It always show 'pattern not found' if the file hadn't saved yet

Here is the example of autocompletion from a class inherited from sprite

screen shot 2014-01-04 at 1 01 47 am

Ah yes, I mention that in the readme. I guess I should have a check and a warning message at startup. You need set autowrite or set autowriteall in your vimrc. Check the help for those for more details.

Oh right! I didn't read that line, I'm sorry 😁
Should I close this issue? (since not me issued this)

This is an older issue, and I think it may be related to autowrite. I've pushed another updated that requires autowrite by default (and lets you override this via a config variable if you know what you are doing). I'll close this, and if @fullofcaffeine is still having problems he can re-open with an update.