Skip to content

Repository files navigation

unity-lens.nvim

English | 한국어

Editor-free Unity 6 serialized asset Code Lens for Neovim. It opens a dedicated two-pane browser with folder/Prefab/GameObject hierarchy on the left and the selected component's serialized values on the right.

The indexer reads .meta, .prefab, .unity, .asset, .cs, and compiled enum metadata directly. It never asks Unity to scan assets, never calls AssetDatabase or SerializedObject, and never schedules indexing work on the Unity main thread. The tiny Unity package opens an asset only on explicit Enter and otherwise only forwards bounded add/move/delete path hints.

Features

  • Rider-style class asset/component counts and inline Serializable, Unchanged, or actual serialized field values
  • [SerializeField], [SerializeReference], public serialized fields, and [FormerlySerializedAs] support
  • dedicated two-pane usage browser opened directly by <Space>cu
  • folder → serialized asset → GameObject hierarchy, j/k navigation, and Tab pane switching
  • Scenes, Prefabs, and ScriptableObject .asset files, including arrays, lists, nested values, object references, Asset GUIDs, and 64-bit file IDs
  • semantic SerializeReference trees that show concrete class names and data instead of Unity rid/RefIds metadata, with long values wrapped to the info-pane width
  • ID-free UI: GUIDs, file IDs, and local object IDs resolve through SQLite to asset paths, hierarchy paths, component types, and script names; missing object maps are indexed incrementally from disk
  • sparse and 64-bit enum names such as Hard (10), plus [Flags] values such as Read | Write (5)
  • base Prefabs, Prefab Variants, removed components, and nested Prefabs
  • project-local SQLite/WAL cache with fingerprints and incremental file watching
  • a bounded single parser worker, 256-path queue, 8 MiB/s pacing, and 160/256 MiB memory guards
  • interactive preemption: parsing and SQLite writes pause while you type in Neovim
  • progress notifications, statusline component, error list, pause/resume, and manual reindex

Supported platforms

Platform Release daemon
macOS Apple Silicon osx-arm64
macOS Intel osx-x64
Linux x86-64 linux-x64
Linux ARM64 linux-arm64
Windows x86-64 win-x64

Release daemons are self-contained and include the native SQLite library. A .NET SDK is not required for normal use.

Requirements

  • Neovim 0.10+
  • Unity 6.0+
  • Unity Asset Serialization Mode: Force Text
  • curl, or PowerShell on Windows, for the Lazy.nvim download step

Neovim installation

{
  "ToxicTrigger/unity-lens.nvim",
  build = function(plugin)
    vim.opt.runtimepath:append(plugin.dir)
    require("unity-lens.installer").install(plugin.dir)
  end,
  opts = {},
}

To use a locally built daemon instead, set opts.daemon.command to a command list. For source development:

dotnet publish daemon/UnityLens.Daemon/UnityLens.Daemon.csproj \
  -c Release -r osx-arm64 --self-contained true \
  -p:PublishSingleFile=true -o bin/osx-arm64

Unity package installation

The Unity bridge lives in this same repository; a second repository is not required. Unity 6 Package Manager supports a package in a Git repository subfolder through the path query parameter.

Add this entry to your Unity project's Packages/manifest.json:

"com.unity-lens.editor": "https://github.com/ToxicTrigger/unity-lens.nvim.git?path=/unity-package"

You can also use Package Manager → Install package from git URL with the same stable URL. Release tags remain available for reproducible builds, but normal installations should keep this unversioned URL so package updates never require editing the manifest. The package includes every required Unity .meta file. It opens a background loopback socket but performs no indexing or editor polling; only an explicit open action dispatches a Scene, Prefab, or ScriptableObject to Unity.

Run :checkhealth unity-lens from a Unity project after installation.

Usage

Class lines show asset/component usage totals, while serialized fields show Serializable, Unchanged, the actual value, or a compact multi-value summary. Press <Space>cu on a serialized field for field-filtered usages, or elsewhere in the class for all class usages. The two-pane hierarchy/info popup opens immediately:

  • j / k: select the previous or next usage
  • Tab / Shift-Tab: switch panes
  • l in the info pane: load the next 100 serialized properties
  • Enter: open the selected Scene, Prefab, or ScriptableObject in the running Unity Editor
  • Esc / q: close the popup

Commands:

  • :UnityLensUsages
  • :UnityLensStatus
  • :UnityLensPause / :UnityLensResume
  • :UnityLensReindex
  • :UnityLensErrors

Statusline integrations can call:

require("unity-lens").status()

Performance and editor isolation

The daemon is per-project and stores its endpoint and database under Library/UnityLens. Queries are asynchronous and framed at 256 KiB; usage results page at 200 rows and serialized details at 100 properties. Directory enumeration streams, the serialized asset queue is bounded, oversized YAML lines are rejected at 1 MiB, and only one Scene, Prefab, or ScriptableObject is parsed at a time.

Neovim activity sends a coalesced interactive lease at most four times per second. While the lease is active, the daemon pauses background parsing and database writes. File watcher bursts wait for a two-second quiet window. The Unity bridge has no EditorApplication.update, AssetDatabase, or SerializedObject indexing path. Its AssetPostprocessor only forwards bounded add/move/delete path hints to the daemon; it performs no lookup, parsing, or indexing in Unity. The filesystem watcher remains authoritative when the Editor is closed.

See DESIGN.md for the full architecture and SQLite/RPC model.

Verification

dotnet format daemon/UnityLens.Daemon/UnityLens.Daemon.csproj --verify-no-changes
dotnet run --project tests/UnityLens.Daemon.Tests/UnityLens.Daemon.Tests.csproj -c Release
dotnet build tests/UnityBridge.Compile/UnityBridge.Compile.csproj -c Release
nvim --headless -u NONE --cmd 'set runtimepath+=.' '+lua require("unity-lens").setup()' +qa

The suite covers a real RPC daemon, SQLite enum/reference rendering, Variant/nested inheritance, watcher updates, interactive preemption, a 20,000-component Prefab memory case, and oversized scalar rejection. The Unity bridge was also compiled and its generated base/Variant/nested Prefabs were indexed against Unity 6000.3.10f1.

License

MIT

About

Editor-free Unity 6 Prefab usage Code Lens for Neovim

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages