Skip to content

Mathijs-Bakker/godotdev.nvim-node-copy

Repository files navigation

BuyMeACoffee

BuyMeACoffee Godot License Release

godotdev.nvim-node-copy

godotdev.nvim-node-copy is a small Godot editor addon for users of godotdev.nvim.

It adds node-reference actions for the currently selected node and can either copy the generated text to the clipboard or, experimentally, insert it directly at the current cursor position in the active Neovim buffer.

Features

  • Copy the selected node path relative to the current scene root
  • Copy a $Node/Child reference
  • Copy a get_node("Node/Child") expression
  • Copy a typed @onready var snippet
  • Copy a typed GetNode<T>() C# expression
  • Copy a C# property snippet
  • Works from the current editor selection
  • Clipboard workflow for manual paste
  • Experimental direct insertion at the current cursor in the active Neovim buffer through Neovim's editor server

Install

From AssetLib in the Godot editor

  1. Open your project in Godot.
  2. Go to the AssetLib tab.
  3. Search for godotdev.nvim node copy.
  4. Open the asset page and click Download.
  5. Keep the install destination as your project root so Godot imports the addon into res://addons/godotdev_nvim_node_copy.
  6. After import, go to Project > Project Settings > Plugins and enable godotdev.nvim-node-copy.

Manual install

Copy the addons/godotdev_nvim_node_copy folder into your Godot project:

res://addons/godotdev_nvim_node_copy

Then enable the plugin in:

Project > Project Settings > Plugins

Usage

Select a node in the Scene dock, then use either:

  • the Scene Tree right-click menu
  • the 2D editor right-click menu
  • or the Project > Tools menu

Available actions:

  • Project > Tools > godotdev.nvim: Copy Node Path
  • Project > Tools > godotdev.nvim: Copy $ Reference
  • Project > Tools > godotdev.nvim: Copy get_node()
  • Project > Tools > godotdev.nvim: Copy @onready Var
  • Project > Tools > godotdev.nvim: Copy C# GetNode<T>()
  • Project > Tools > godotdev.nvim: Copy C# Property

By default, the generated text is copied to your clipboard. You can also configure the addon to use an experimental insert-at-cursor mode for an already-open Neovim buffer.

Example Output

For a selected Player node:

Player
$Player
get_node("Player")
@onready var player: CharacterBody2D = $Player
GetNode<CharacterBody2D>("Player")
private CharacterBody2D Player => GetNode<CharacterBody2D>("Player");

Notes

  • The addon uses the selected node relative to the currently edited scene root.
  • If the selected node is the scene root itself, the generated snippets use self where appropriate.
  • The addon supports both GDScript and C# snippet output.

Configuration

The addon can be configured in Project Settings with:

  • godotdev_nvim_node_copy/enable_gdscript
  • godotdev_nvim_node_copy/enable_csharp
  • godotdev_nvim_node_copy/output/mode
  • godotdev_nvim_node_copy/output/neovim_executable
  • godotdev_nvim_node_copy/output/neovim_server_address
  • godotdev_nvim_node_copy/output/fallback_to_clipboard

This controls which language-specific copy actions appear in:

  • Project > Tools
  • the Scene Tree right-click menu
  • the 2D editor right-click menu

Copy Node Path remains available regardless of language selection.

Output settings:

  • godotdev_nvim_node_copy/output/mode: clipboard or neovim_remote
  • godotdev_nvim_node_copy/output/neovim_executable: the executable used for remote insertion, default nvr
  • godotdev_nvim_node_copy/output/neovim_server_address: the Neovim server address to target, default /tmp/godot.nvim on Linux/macOS and \\.\pipe\godot.nvim on Windows
  • godotdev_nvim_node_copy/output/fallback_to_clipboard: if enabled, failed remote insertion falls back to the clipboard

Experimental Neovim Insert Mode

godotdev.nvim-node-copy supports an experimental neovim_remote output mode.

Instead of only copying generated node snippets to the clipboard, the addon can send them directly to the current cursor position in an already open Neovim buffer through Neovim's editor server.

This is experimental because it is not drag-and-drop. It is a cursor-based insertion workflow and depends on your Neovim server setup being correct.

What it is for

  • inserting multiple node references into the same file while that file is already open in Neovim
  • staying inside a fast Godot → Neovim workflow without manual paste each time
  • letting godotdev.nvim and gdscript-formatter --reorder-code reorganize inserted @onready lines on save

What it is not

  • a replacement for Godot's internal-editor drag-and-drop
  • aware of the best location in your file to insert code
  • guaranteed to work unless Godot and Neovim both point to the same active server address

It inserts text at the current Neovim cursor position.

Requirements

To use neovim_remote mode:

  1. Start the Neovim session you want Godot to target with a stable server address, for example:

    nvim --listen /tmp/godot.nvim
  2. Install nvr and make sure it is available:

    which nvr
  3. Configure the Godot addon Project Settings:

    • godotdev_nvim_node_copy/output/mode = neovim_remote
    • godotdev_nvim_node_copy/output/neovim_server_address = /tmp/godot.nvim
    • godotdev_nvim_node_copy/output/neovim_executable = /full/path/to/nvr

Notes

  • Clipboard mode remains the default and most predictable workflow.
  • If remote insertion fails, the addon can fall back to the clipboard.
  • Inserted snippets end with a newline so repeated inserts do not stack on the same line.
  • The remote insertion flow works on Linux and macOS with the same nvr plus --listen setup.
  • Windows is intended to work through a named pipe server address, but it has not been verified in this repository yet.

Windows setup

For Windows, start Neovim with a named pipe, for example:

nvim --listen \\\\.\\pipe\\godot.nvim

Then configure:

  • godotdev_nvim_node_copy/output/mode = neovim_remote
  • godotdev_nvim_node_copy/output/neovim_server_address = \\\\.\\pipe\\godot.nvim
  • godotdev_nvim_node_copy/output/neovim_executable = /full/path/to/nvr.exe

Icon Import

  • Commit the SVG .import file for the addon icon so users get consistent editor import settings.
  • The icon is intended to use editor/scale_with_editor_scale=true for proper HiDPI behavior.
  • The current icon import keeps fixed colors with editor/convert_colors_with_editor_theme=false.

Roadmap

  • Support %UniqueNode when appropriate
  • Add C# snippet variants
  • Let users choose snippet style in plugin settings

Releasing

Release steps are documented in RELEASING.md.

About

Godot editor addon for godotdev.nvim that copies node references and ready-to-paste GDScript snippets for use in Neovim.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors