Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion Editor/Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ namespace NvimUnity
public class Config
{
public string last_project = "";
public void MergeMissingDefaults(Config defaults) { }
#if UNITY_EDITOR_WIN
public string neovimLocation = "C:\\Program Files\\Neovim\\bin\\nvim.exe";
#endif
public void MergeMissingDefaults(Config defaults) { }
}

public static class ConfigManager
Expand Down
36 changes: 30 additions & 6 deletions Editor/NeovimEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,26 +60,32 @@ public bool OpenProject(string path, int line, int column)
{
if (OS == "Windows")
{

#if UNITY_EDITOR_WIN
var psi = new ProcessStartInfo
{
FileName = defaultApp,
Arguments = $"{path} {line}",
Arguments = $"{path} {line} {config.neovimLocation}",
UseShellExecute = true,
CreateNoWindow = false,
};

if(debugging)
UnityEngine.Debug.Log($"[NvimUnity] Executing: {psi.FileName} {psi.Arguments}");
Process.Start(defaultApp, $"{path} {line}");
Process.Start(defaultApp, $"{path} {line} {config.neovimLocation}");
#endif
}
else
{
// Original behavior for other OSes

#if !UNITY_EDITOR_WIN
// Original behavior for other OSes
ProcessStartInfo psi = Utils.BuildProcessStartInfo(defaultApp, path, line);
if(debugging)
UnityEngine.Debug.Log($"[NvimUnity] Executing in terminal: {psi.FileName} {psi.Arguments}");
Process.Start(psi);
}
#endif
}
return true;
}
catch (Exception ex)
Expand All @@ -100,7 +106,13 @@ public bool OpenFile(string filePath, int line)
{
string cmd = $"<CMD>e +{line} {filePath}<CR>";
string nvimArgs = $"--server {Socket} --remote-send \"{cmd}\"";
string nvimPath = Utils.GetNeovimPath();
string nvimPath =

#if UNITY_EDITOR_WIN
config.neovimLocation;
#else
Utils.GetNeovimPath();
#endif

var psi = new ProcessStartInfo
{
Expand Down Expand Up @@ -134,7 +146,19 @@ public void OnGUI()
}

EditorGUILayout.EndHorizontal();


#if UNITY_EDITOR_WIN
EditorGUILayout.BeginHorizontal();

GUILayout.Label("Neovim location", EditorStyles.boldLabel, GUILayout.Width(250));
config.neovimLocation = GUILayout.TextField(config.neovimLocation);
if(GUILayout.Button("Browse", GUILayout.Width(80))){
config.neovimLocation = EditorUtility.OpenFilePanel("Select neovim", "", "exe");
ConfigManager.SaveConfig(config);
}
EditorGUILayout.EndHorizontal();
#endif
GUILayout.Space(10);
}

Expand Down Expand Up @@ -189,7 +213,7 @@ public bool TryGetInstallationForPath(string editorPath, out CodeEditor.Installa
return true;
}

public void Save()
public static void Save()
{
if (needSaveConfig)
{
Expand Down
11 changes: 5 additions & 6 deletions Editor/Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,10 @@ public static void EnsureLauncherExecutable()
}
#endif
}
#if !UNITY_EDITOR_WIN

public static ProcessStartInfo BuildProcessStartInfo(string defaultApp, string path, int line)
{
#if !UNITY_EDITOR_WIN
string preferredTerminal = NeovimPreferences.GetPreferredTerminal();

string fileName = "/usr/bin/env";
Expand Down Expand Up @@ -183,13 +183,12 @@ public static ProcessStartInfo BuildProcessStartInfo(string defaultApp, string p
UseShellExecute = true,
CreateNoWindow = false
};
#endif
return null;
}
#endif
#if !UNITY_EDITOR_WIN

public static bool IsTerminalAvailable(string terminalName)
{
#if !UNITY_EDITOR_WIN
UnityEngine.Debug.Log($"[NvimUnity] Checking if terminal is available: {terminalName}");
try
{
Expand All @@ -213,9 +212,9 @@ public static bool IsTerminalAvailable(string terminalName)
{
return false;
}
#endif
return true;
}
#endif

}
}