habamax / vim-godot

Use vim and godot engine to make games
MIT License
498 stars 24 forks source link

GodotStart Opens a New Godot Editor #28

Closed rcoconnor closed 3 years ago

rcoconnor commented 3 years ago

I am running macOS catalina with neovim and iTerm 2. I have installed vim-godot and when I run ":GodotRun /path/to/scene.tscn" in vim, Godot will not only run the scene, but also open a whole new Godot editor. This frustrating because I have to close out of the new editor anytime I want to test my game, or else I end up with a lot of instances of godot running. I believe the error may be at lines 66-67 of autoload/godot.vim.

habamax commented 3 years ago

I don't have macOS so can't check it.

Could you try to (in terminal):

  1. navigate to the folder where your scene is.
  2. run godot scenename.tscn
rcoconnor commented 3 years ago

I just tested it and I got the following error:

image

However, If I just run "godot" from the directory, it runs the main scene without creating a new editor window. Not sure on how to make it work with a separate scene though.

I'm going to search around and see how to rectify this error to see if there are any other problems on my end.

Update: If I run "godot scenes/myscene.tscn" from where my whole project is located, it will open the correct scene without creating a new editor window.

habamax commented 3 years ago

Update: If I run "godot scenes/myscene.tscn" from where my whole project is located, it will open the correct scene without creating a new editor window.

What about open godot scenes/myscene.tscn?

Also, when you do it in vim, what is your :pwd? Does it match the godot project root dir?

rcoconnor commented 3 years ago

When I run open godot scenes/myscene.tscn: image

It appears that :open godot is not a command. And yes, my :pwd does match my godot project root, as in it is the same directory that my project.godot file is in.

habamax commented 3 years ago

When I run open godot scenes/myscene.tscn:

I mean do it from the command line, open is the OSX version of xdg-open of linux and start version of windows.

rcoconnor commented 3 years ago

Oh, my bad. I ran it while my Godot editor was closed and when I type open scenes/Level.tscn nothing happens. However, if I have the Godot editor already open, then it will display the scene correctly.

habamax commented 3 years ago

Oh, my bad. I ran it while my Godot editor was closed and when I type open scenes/Level.tscn nothing happens. However, if I have the Godot editor already open, then it will display the scene correctly.

Interesting. Do you mean the scene is run or is opened in an editor?

If you are able to run a scene with this, could you replace:

https://github.com/habamax/vim-godot/blob/7697cc88a9ae3e5da923a1739f9753ec4c47617b/autoload/godot.vim#L67

with

call system('open ' . shellescape(a:scene_name))

Run godot, restart vim, and try :GodotRun scenes/Level.tscn

rcoconnor commented 3 years ago

I meant that the scene is run without opening an editor. I will try this now.

rcoconnor commented 3 years ago

Update: so I've tested this and when I type :GodotRun Scenes/Level.tscn, nothing will happen strangely enough. From what I see, the problem is the "open" call. On the terminal, you should just type Godot /path/to/scene.tsn without the word "open", everything seems to work as expected.

ghost commented 3 years ago

@rcoconnor Did you follow the Command line tutorial in the Godot docs? It suggests adding the executable to the PATH environment variable; however, as I found in the related issue, opening directly from the executable (e.g. /Applications/Godot.app/Contents/MacOS/Godot) inside the app opens an extra instance. If you use let g:godot_executable=/Applications/Godot.app (adjust as necessary pertaining to where you have it installed, of course), it should work as expected.

@habamax I imagine adding the executable to PATH is fairly common, but for the sake of accessibility, I think you could fix it one of two ways:

  1. Keep the code as is and add documentation stating that Mac users should use the .app file for g:godot_executable
  2. Update the code to account for either case
habamax commented 3 years ago

@miltsghostrehab Does it mean that current implementation works if g:godot_executable is set to Godot.app?

ghost commented 3 years ago

Yeah, I'm pretty sure it does :)