From 7e33f25983cee523cf62a7e51c4488da9caa67dd Mon Sep 17 00:00:00 2001 From: SolidSolar <46050106+SolidSolar@users.noreply.github.com> Date: Sun, 8 Jun 2025 15:31:07 +0300 Subject: [PATCH 1/3] fix: fixed ihcorrect placed preprocessors for windows platform --- Editor/NeovimEditor.cs | 9 ++++++--- Editor/Utils.cs | 11 +++++------ 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/Editor/NeovimEditor.cs b/Editor/NeovimEditor.cs index cabc7d6..accd5f0 100644 --- a/Editor/NeovimEditor.cs +++ b/Editor/NeovimEditor.cs @@ -71,12 +71,15 @@ public bool OpenProject(string path, int line, int column) } else { - // Original behavior for other OSes + +#if !UNITY_EDITOR_WIN + // Original behavior for other OSes ProcessStartInfo psi = Utils.BuildProcessStartInfo(defaultApp, path, line); UnityEngine.Debug.Log($"[NvimUnity] Executing in terminal: {psi.FileName} {psi.Arguments}"); Process.Start(psi); - } +#endif + } return true; } catch (Exception ex) @@ -186,7 +189,7 @@ public bool TryGetInstallationForPath(string editorPath, out CodeEditor.Installa return true; } - public void Save() + public static void Save() { if (needSaveConfig) { diff --git a/Editor/Utils.cs b/Editor/Utils.cs index 8625241..5d78a79 100644 --- a/Editor/Utils.cs +++ b/Editor/Utils.cs @@ -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"; @@ -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 { @@ -213,9 +212,9 @@ public static bool IsTerminalAvailable(string terminalName) { return false; } -#endif - return true; } +#endif + } } From 17b3a5c85e71789bbc78d8627179ef9a88aeae60 Mon Sep 17 00:00:00 2001 From: SolidSolar <46050106+SolidSolar@users.noreply.github.com> Date: Sun, 8 Jun 2025 17:30:00 +0300 Subject: [PATCH 2/3] feat: added nvim.exe path selection to external editor preferences --- Editor/Config.cs | 1 + Editor/NeovimEditor.cs | 26 +++++++++++++++++++++----- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/Editor/Config.cs b/Editor/Config.cs index d18559b..0996911 100644 --- a/Editor/Config.cs +++ b/Editor/Config.cs @@ -9,6 +9,7 @@ namespace NvimUnity public class Config { public string last_project = ""; + public string neovimLocation = "C:\\Program Files\\Neovim\\bin\\nvim.exe"; public void MergeMissingDefaults(Config defaults) { } } diff --git a/Editor/NeovimEditor.cs b/Editor/NeovimEditor.cs index accd5f0..84eab30 100644 --- a/Editor/NeovimEditor.cs +++ b/Editor/NeovimEditor.cs @@ -61,13 +61,13 @@ public bool OpenProject(string path, int line, int column) var psi = new ProcessStartInfo { FileName = defaultApp, - Arguments = $"{path} {line}", + Arguments = $"{path} {line} {config.neovimLocation}", UseShellExecute = true, CreateNoWindow = false, }; - + UnityEngine.Debug.Log($"[NvimUnity] Executing: {psi.FileName} {psi.Arguments}"); - Process.Start(defaultApp, $"{path} {line}"); + Process.Start(defaultApp, $"{path} {line} {config.neovimLocation}"); } else { @@ -79,7 +79,7 @@ public bool OpenProject(string path, int line, int column) UnityEngine.Debug.Log($"[NvimUnity] Executing in terminal: {psi.FileName} {psi.Arguments}"); Process.Start(psi); #endif - } + } return true; } catch (Exception ex) @@ -100,7 +100,13 @@ public bool OpenFile(string filePath, int line) { string cmd = $"e +{line} {filePath}"; 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 { @@ -134,6 +140,16 @@ public void OnGUI() } EditorGUILayout.EndHorizontal(); + + 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(); GUILayout.Space(10); } From 1998a607aeba74afe778078dd1589b04c3b6d931 Mon Sep 17 00:00:00 2001 From: SolidSolar <46050106+SolidSolar@users.noreply.github.com> Date: Sun, 8 Jun 2025 18:03:55 +0300 Subject: [PATCH 3/3] fix: added preprocessors for neovimLocation field in Config to make sure changes affect only windows platform --- Editor/Config.cs | 4 +++- Editor/NeovimEditor.cs | 7 ++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/Editor/Config.cs b/Editor/Config.cs index 0996911..77b8cff 100644 --- a/Editor/Config.cs +++ b/Editor/Config.cs @@ -9,8 +9,10 @@ namespace NvimUnity public class Config { public string last_project = ""; +#if UNITY_EDITOR_WIN public string neovimLocation = "C:\\Program Files\\Neovim\\bin\\nvim.exe"; - public void MergeMissingDefaults(Config defaults) { } +#endif + public void MergeMissingDefaults(Config defaults) { } } public static class ConfigManager diff --git a/Editor/NeovimEditor.cs b/Editor/NeovimEditor.cs index b53e2de..b18ef56 100644 --- a/Editor/NeovimEditor.cs +++ b/Editor/NeovimEditor.cs @@ -60,6 +60,8 @@ public bool OpenProject(string path, int line, int column) { if (OS == "Windows") { + +#if UNITY_EDITOR_WIN var psi = new ProcessStartInfo { FileName = defaultApp, @@ -71,6 +73,7 @@ public bool OpenProject(string path, int line, int column) if(debugging) UnityEngine.Debug.Log($"[NvimUnity] Executing: {psi.FileName} {psi.Arguments}"); Process.Start(defaultApp, $"{path} {line} {config.neovimLocation}"); +#endif } else { @@ -144,6 +147,8 @@ public void OnGUI() EditorGUILayout.EndHorizontal(); + +#if UNITY_EDITOR_WIN EditorGUILayout.BeginHorizontal(); GUILayout.Label("Neovim location", EditorStyles.boldLabel, GUILayout.Width(250)); @@ -153,7 +158,7 @@ public void OnGUI() ConfigManager.SaveConfig(config); } EditorGUILayout.EndHorizontal(); - +#endif GUILayout.Space(10); }