Skip to content

Cretezy/godot-server.nvim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

godot-server.nvim

This project aims to integrate the Godot editor and Neovim. It contains 2 components:

  • A script to launch Neovim from Godot
  • An optional (but recommended) Neovim plugin to connect Godot to previously running Neovim instances

Features:

  • Open files from Godot into Neovim automatically
  • Step-by-step setup instructions
  • Supports launching Neovim from Godot or from terminal

How It Works

To connect the Godot editor and Neovim, we must start a Neovim server which Godot can send "open file" commands to. This can be done with the --listen Neovim option, or with vim.fn.serverstart within Neovim. We configure Godot to run a script which launches Neovim if it's not running, or connects to an previously launched instance of Neovim.

The launch script does exactly this. When opening a file from Godot configured to run the script, it will check a Neovim server is running for the current project. If it is, it will open the file inside that instance of Neovim. If no Neovim servers is running for the project, it will launch Neovim in a new terminal window and open the file.

With the optional Neovim plugin, opening a Godot project inside Neovim will automatically start the server as well.

Godot Launch Script Setup

The script is required for Godot to open files in Neovim

  1. Download the launch script to your computer. I recommend placing it in ~/.config/godot. You can do this automatically with: curl -o ~/.config/godot/godot-neovim.sh https://raw.githubusercontent.com/Cretezy/godot-server.nvim/refs/heads/main/godot-neovim.sh Make sure the script is executable as well: chmod +x ~/.config/godot/godot-neovim.sh
  2. Modify the downloaded script's $term_exec parameter to point to your terminal emulator. If your terminal emulator requires parameters, add them in the start_server function. You may also opt to set this to an empty string if you will only be pre-launching Neovim from your terminal using the plugin.
  3. Open Godot's editor settings under Editor -> Editor Settings and go to Text Editor -> External.
  4. Enable Advanced Settings in the top right of the window.
  5. Enable Use External Editor.
  6. Set Exec Path to the full path of your downloaded (and executable) launch script path, e.g. /home/$USER/.config/godot/godot-neovim.sh (replace $USER with your username). You can use the file browser (file icon to the right of the text input) to get the full path.
  7. Set Exec Flags to: "{file}" "{line}" "{col}"
Step-by-step with images
  1. Download the launch script to your computer. image

  2. Modify the downloaded script's $term_exec image image

  3. Open Godot's text editor settings and configure editor image image

Neovim Plugin Setup

With the plugin, opening a Godot project in Neovim (outside of launching from Godot itself) will automatically start the server.

lazy.nvim:

{
  "Cretezy/godot-server.nvim"
}

Reloading

If Neovim doesn't close properly (e.g. SIGKILL), it's possible it will won't cleanup the server socket file. The plugin provides the :GodotServerReload command to force the cleanup and restart the server. You can also manually do this with rm .godot/server.pipe if not using the plugin.

Credits

Launch script based on niscolas/nvim-godot.

About

Integrate Godot editor and Neovim

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published