Skip to content

Latest commit

 

History

5 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 

Repository files navigation

unity-ping.nvim

Neovim plugin that syncs the active buffer to the Unity Editor Project window.

Requires Rival/com.walcht.ide.neovim — a fork of com.walcht.ide.neovim that adds multi-instance port support. Hopefully this will be merged into the upstream repo soon.

Commands

Command Description
:UnityPing [file] Flash-highlight the current (or given) file in Unity's Project window
:UnitySelect [file] Select the file in Unity (appears in Inspector, highlighted in Project window)
:UnityFollowToggle Toggle auto-select on BufEnter (off by default)

Both :UnityPing and :UnitySelect accept an optional file path; defaults to the current buffer.

Follow Active mode

When Follow Active is enabled, switching buffers in nvim automatically selects the corresponding asset in Unity's Project window — the same effect as :UnitySelect, but triggered on every BufEnter for files matching the configured patterns (*.cs, *.shader, etc.).

This keeps Unity's Project window in sync with whatever file you are editing, so you never have to manually navigate to an asset to inspect it, ping it, or drag it into a scene.

Toggle it at runtime with :UnityFollowToggle, or enable it permanently in your config:

opts = {
  follow_active = true,
  debounce_ms = 300, -- delay before firing, to avoid flickering when cycling buffers quickly
}

The debounce timer is reset on each BufEnter, so rapid buffer switches (e.g. scrolling through the buffer list) only trigger one select on the file you actually land on.

Setup

lazy.nvim

{
  dir = "path/to/unity-ping.nvim",  -- or use the GitHub URL once published
  ft = { "cs", "shader", "cginc", "hlsl" },
  opts = {
    port = 54321,          -- fallback port if Library/.unity-ping-port is not found
    debounce_ms = 300,     -- debounce for follow-active mode
    follow_active = false, -- set true to auto-select on BufEnter
  },
}

Manual

require("unity-ping").setup({
  follow_active = false,
})

How it works

Unity runs a small HTTP server (NeovimAssetPingServer) and writes its actual port to Library/.unity-ping-port inside the project root. This allows multiple Unity editors to run simultaneously on different ports without conflicts.

When sending a ping, the plugin walks up from the current buffer's path to find the Unity project root (the directory containing Assets/), reads the port from Library/.unity-ping-port, and sends a POST to /ping-asset or /select-asset with the absolute file path. Unity resolves the path to an asset via AssetDatabase and calls PingObject / sets Selection.activeObject on the main thread. Falls back to config.port if the port file is not found.

Requirements

  • Neovim 0.10+
  • curl available in $PATH
  • Unity project open with com.walcht.ide.neovim package installed

About

Neovim plugin — sync active buffer to Unity Editor Project window (ping/select asset)

Resources

Stars

3 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages