From 4cb24991d53ad6f0f01f069496422c4094c55a89 Mon Sep 17 00:00:00 2001 From: John te Bokkel Date: Sat, 13 Apr 2024 09:31:39 -0700 Subject: [PATCH 1/3] fix: UpdateRemotePlugins not finding specs on windows Specs were being found with a normalized path, but being requested without normalization. We now normalize the path we responding to spec requests. --- pynvim/plugin/host.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pynvim/plugin/host.py b/pynvim/plugin/host.py index ea4c1df6..e0f7b950 100644 --- a/pynvim/plugin/host.py +++ b/pynvim/plugin/host.py @@ -276,6 +276,7 @@ def _copy_attributes(self, fn, fn2): def _on_specs_request(self, path): path = decode_if_bytes(path) + path = os.path.normpath(path) if path in self._load_errors: self.nvim.out_write(self._load_errors[path] + '\n') return self._specs.get(path, 0) From a2bc40ed5ae865c7eb5da99226c68e2eb6558480 Mon Sep 17 00:00:00 2001 From: John te Bokkel Date: Sat, 13 Apr 2024 14:52:46 -0700 Subject: [PATCH 2/3] fix: change to pathlib for resolving paths so we can use posix paths This should be a more consistent way of handling paths between both neovim and this plugin. --- pynvim/plugin/host.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pynvim/plugin/host.py b/pynvim/plugin/host.py index e0f7b950..4de69648 100644 --- a/pynvim/plugin/host.py +++ b/pynvim/plugin/host.py @@ -5,7 +5,7 @@ import inspect import logging import os -import os.path +import pathlib import re import sys from functools import partial @@ -173,7 +173,7 @@ def _load(self, plugins: Sequence[str]) -> None: # self.nvim.err_write("host init _load\n", async_=True) has_script = False for path in plugins: - path = os.path.normpath(path) # normalize path + path = pathlib.Path(path).resolve().as_posix() # normalize path err = None if path in self._loaded: warn('{} is already loaded'.format(path)) @@ -276,7 +276,7 @@ def _copy_attributes(self, fn, fn2): def _on_specs_request(self, path): path = decode_if_bytes(path) - path = os.path.normpath(path) + path = pathlib.Path(path).resolve().as_posix() # normalize path if path in self._load_errors: self.nvim.out_write(self._load_errors[path] + '\n') return self._specs.get(path, 0) From 68250cb55e749151541e60a92757d53ece5d720f Mon Sep 17 00:00:00 2001 From: John te Bokkel Date: Sat, 13 Apr 2024 18:38:45 -0700 Subject: [PATCH 3/3] fix: take a hybrid approach to restore tests Path.resolve() also returns the absolute path, while os.path.normpath did not. We need to both normalize the path and convert it to standard posix style to fix the issue. --- pynvim/plugin/host.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pynvim/plugin/host.py b/pynvim/plugin/host.py index 4de69648..4a5a209b 100644 --- a/pynvim/plugin/host.py +++ b/pynvim/plugin/host.py @@ -5,6 +5,7 @@ import inspect import logging import os +import os.path import pathlib import re import sys @@ -173,7 +174,7 @@ def _load(self, plugins: Sequence[str]) -> None: # self.nvim.err_write("host init _load\n", async_=True) has_script = False for path in plugins: - path = pathlib.Path(path).resolve().as_posix() # normalize path + path = pathlib.Path(os.path.normpath(path)).as_posix() # normalize path err = None if path in self._loaded: warn('{} is already loaded'.format(path)) @@ -276,7 +277,7 @@ def _copy_attributes(self, fn, fn2): def _on_specs_request(self, path): path = decode_if_bytes(path) - path = pathlib.Path(path).resolve().as_posix() # normalize path + path = pathlib.Path(os.path.normpath(path)).as_posix() # normalize path if path in self._load_errors: self.nvim.out_write(self._load_errors[path] + '\n') return self._specs.get(path, 0)