Search Issue Tracker

By Design

Votes

0

Found in

2017.4.0f1

2018.4.0f1

2019.2.0a1

2019.2.3f1

2019.3.0a1

2020.1.0a1

Issue ID

1181875

Regression

No

[macOS] '$(Line)' External Script Editor Argument is passed as a filename when using MacVim

CodeEditors

-

How to reproduce:
1. Install MacVim
2. Create a new Unity project
3. Set MacVim as the External Script Editor
4. Set the Args to "$(File) +$(Line)"
5. Create and open a new C# Script

Expected results: A script is opened in MacVim without any issues
Actual results: A script is opened in MacVim and a new file called '0' is created

Reproducible with: 2017.4.32f1, 2018.4.9f1, 2019.2.7f2, 2019.3.0b4, 2020.1.0a5

Additional notes:
1. Several MacVim windows may be opened at the same time
2. On Unity 2019.3.0a12 and earlier Win32 Exceptions are thrown

  1. Resolution Note (2020.1.X):

    The way the default code editor support works, is specific for each platform. On OSX the arguments works by using
    NSRunningApplication.
    The result you should see is similar to the one that you would get from writing open -n Path/to/Macvim.app --args $(File) +$(Line). I can see that this is not supported by macvim, so you would have to ask them to support this for you.
    Another approach is to create a small package, implement https://docs.unity3d.com/2020.1/Documentation/ScriptReference/Unity.CodeEditor.IExternalCodeEditor.html and register it using CodeEditor.Register. This will override the default support, and you can implement your own way of opening files etc.

Comments (4)

  1. davidklei

    Jul 09, 2020 00:10

    I spoke too soon. I figured out the double clicking prefabs. unity-vimeditor works pretty nicely.

  2. davidklei

    Jul 08, 2020 23:46

    I ran into this and followed the RESOLUTION NOTE's suggestion to implement IExternalCodeEditor: https://github.com/idbrii/unity-vimeditor

    To install, add this line to your project's Packages/manifest.json:

    "com.github.idbrii.unity-vimeditor": "https://github.com/idbrii/unity-vimeditor.git#v0.1",

    So far, I've only tested on macOS Catalina 10.15.5 with MacVim installed via brew.

    Works for my use case: clicking files in Project, Inspector, and Console open them in a single MacVim instance at the correct file, line, and column. However, it also opens prefabs if you double click them (so you have to single click to select and then use Open Prefab to edit). I don't know how to fix that.

  3. frarees

    Feb 02, 2020 19:19

    I workaround this with a custom setup that relies on the mvim:// url handler.

    Check out my implementation here: https://github.com/frarees/dotvim (read the README and look at mvimhelper).

  4. duhprey

    Dec 22, 2019 06:02

    After 10 years of using Unity with vim this is a really frustrating change that is suddenly by design.

Add comment

Log in to post comment

All about bugs

View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.