Skip to content

Instantly share code, notes, and snippets.

@jkopano
Forked from lincore81/godot_lazyvim.md
Created November 10, 2024 14:37
Show Gist options
  • Select an option

  • Save jkopano/095720d6ad78968d60bea8a2ee4af233 to your computer and use it in GitHub Desktop.

Select an option

Save jkopano/095720d6ad78968d60bea8a2ee4af233 to your computer and use it in GitHub Desktop.
Godot + Lazyvim

How to set up LazyVim/Neovim for Godot (Linux)

External Editor Setup

When clicking on a button or error message that opens a gdscript file in Godot, we want it to open in nvim instead. There are many ways to do this, this is mine:

  • Create a bash script nvim-broadcast on your path (e. g. ~/.local/bin/). Content:
#!/usr/bin/env bash

# Find all nvim servers and blast 'em with our command line args
# Make sure $XDG_RUNTIME_DIR is set.
# Or figure out where nvim stores sockets on your system and adjust the path.
sockets=$(ls $XDG_RUNTIME_DIR/nvim*)

for socket in $sockets; do
  nvim --server $socket --remote-send "$@"
done
  • Make sure to make the script executable (e. g. chmod +x ~/.local/bin/nvim-broadcast).
  • Open Godot's editor settings and navigate to external text editor (Editor -> Editor Settings -> Text Editor -> External).
  • Tick "Use external editor"
  • Change "Exec Path" to your bash script (/home/USER/.local/bin/nvim-broadcast)
  • Set "Exec Flags" to "<C-\><C-N>:n {file}<CR>{line}G{col}|"

This means that when you try to open a script from within Godot:

  • ALL nvim instances currently running will open that file at the requested position
  • if no instances are open, nothing happens.

Using Godot's Language Server

This is piss-easy:

  • Open the config dir in telescope (start nvim and press c).
  • If you already have one or more .lua files in the plugin dir, you can add to those, otherwise create a new one.
  • In your lua file, paste the following (or extend nvim-lspconfig if it already exists):
  {
    "neovim/nvim-lspconfig",
    opts = {
      inlay_hints = { enabled = false },
      servers = {
        gdscript = {},
        gdshader_lsp = {},
      },
    },
  },
  • Save, quit, restart
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment