How to debug when using external editor?

Hello,

I’m using neovim as external editor.
I’d like to use internal editor of Defold when it’s time to debug.
In the « Assets » tab, i’ve tried to right click on a script file, and « open as code » but it is still opened in neovim.

The only way is to erase the configuration of the external editor. Is it possible to avoid this ?

Thank you.

Currently no, but it would make a good feature request on GitHub!

I will open a request on github, thank you for the suggestion.

As a workaround, i was thinking of saving my editor configuration and replacing with the default Defold config when i want to debug. With a script of course, not by hand.
But i didn’t find the config location. I have searched the string of my external editor (/usr/bin/nvr), in those locations:

~/.config/*
~/.local/*
~/.defold/*

I wonder if Java would have its own locations for storing small amount of data like this.

Yes, I believe we’re using the Java Preferences API which stores values in user-home/.java/.userPrefs

1 Like

Thank you. Here is my neovim launcher script updated, to preserve original configuration. That way, you can debug with internal Defold editor, or use neovim as external editor.

Ok, it’s « DIY spirit » , but it’s better than nothing and at least it works :slight_smile:

You need to generate two files, in the defold config path:

  • copy original config (without external editor) to prefs.xml.org

  • then configure external editor support and copy the config file to prefs.xml.nvim

For neovim, the configuration in Defold preferences is:

 Custom editor: /usr/bin/nvr
 Open file: --servername /tmp/defold_nvim --remote-tab {file}
 Open file at line: {file}:{line}

You will need to install neovim-remote , which provides the nvr command.

When you want to debug, just launch Defold executable.
If you want to use neovim, launch the script below.

#!/bin/bash

projectpath="$PWD"
project="${projectpath}/game.project"
defoldpath="$HOME"/defold
defoldprefs="$HOME"/.java/.userPrefs/defold
nvim_servername="/tmp/defold_nvim"

# must be in Defold directory, otherwise problem for installing updates
# (may be fixed today ?)
cd $defoldpath

# if a nvim session is found, load it.
session_nvim="$projectpath"/session.nvim
if [ -f "$session_nvim" ]; then
  session_nvim="-S $session_nvim"
else
  session_nvim=""
fi

NVIM_LISTEN_ADDRESS="$nvim_servername" nvim "$session_nvim" -c "au BufEnter,BufNew,BufRead *.script setlocal ft=lua" & #runtime syntax/lua.vim" &

cp "$defoldprefs"/prefs.xml.nvim "$defoldprefs"/prefs.xml
if [ -f "$project" ]; then
  ./Defold "$project"
else
  ./Defold
fi

# restore vanilla configuraton
cp "$defoldprefs"/prefs.xml.org "$defoldprefs"/prefs.xml
# and close nvim.
nvr --servername "$nvim_servername" -c 'wqa'
1 Like