ms-jpq / coq_nvim

Fast as FUCK nvim completion. SQLite, concurrent scheduler, hundreds of hours of optimization.
GNU General Public License v3.0
3.54k stars 101 forks source link

Coq.artifacts snippets suddendly not found on Windows 10 #476

Closed TheLeoP closed 2 years ago

TheLeoP commented 2 years ago

When I start Neovim the message ⚠️ No compatible snippets found, try updating coq.artifacts is printed even though coq.artifacts is installed and updated. All the LSP snippets work propertly, coq just doesn't seem to find the coq.artifacts' snippets

TheLeoP commented 2 years ago

Ok, so, I fount out that It hat something to do with me using the :COQsnips commands without knowing how to use them. Maybe I created an empty .json file and now coq is loading it instead of the default snippets for some reason? How could I debug this?

TheLeoP commented 2 years ago

@ms-jpq I finally found the probleeeeeeeeeeeeem, yaaaaaaaaaaaaaaaaaay. Ok, so, the problem was on the file coq_nvim/.vars/runtime/Lib/site-packages/pynvim_pp/lib.py on the function resolve_path. It uses the function urlsplit and then compares the parsed.scheme to verify if it's either '' or 'file' and, if it's not (which it never is in Windows because urlsplit returns c as the schema of every path on the C drive), it returns None.

So, we have to include "c" in the schema check:

def resolve_path(cwd: Optional[Path], path: Union[PathLike, str]) -> Optional[Path]:
    try:
        parsed = urlsplit(normcase(path))
    except ValueError:
        return None
    else:
        if parsed.scheme not in {"", "file", "c"}:
            return None
        else:
            safe_path = Path(normcase(parsed.path))

            if safe_path.is_absolute():
                return safe_path
            elif (resolved := _expanduser(safe_path)) != safe_path:
                return resolved
            elif cwd:
                return cwd / path
            else:
                return None

But it still returns None since all the checks in the final if statement return false (that happens because the paths don't have the c: part on them, they all look like \users\pcx\appdata\local\nvim-data\site\pack\packer\start\plenary.nvim)

Since coq thinks that every path it's None, it isn't finding the coq.artifacts snippets.

I wrongly thought that I had caused the issue while I try running :COQsnips, but the problem stayed even if I deleted and reinstalled all of the coq related plugins.

So, i changed the function to look like this (it's a roght solution, but I just wanted to check if it worked or not) and IT WORKS! 🥳🥳. Should I open a PR? 👉👈

def resolve_path(cwd: Optional[Path], path: Union[PathLike, str]) -> Optional[Path]:
    try:
        parsed = urlsplit(normcase(path))
    except ValueError:
        return None
    else:
        if parsed.scheme not in {"", "file", "c"}:
            return None
        else:
            safe_path = Path(normcase(parsed.path)) if parsed.scheme != 'c' else Path(normcase(parsed.scheme + ':' + parsed.path))
            # safe_path = Path(normcase(parsed.path))
            log.info("%s",safe_path)

            if safe_path.is_absolute():
                return safe_path
            elif (resolved := _expanduser(safe_path)) != safe_path:
                return resolved
            elif cwd:
                return cwd / path
            else:
                return None
ms-jpq commented 2 years ago

oh thank you, sorry ive been neglecting this project for a while now.

will patch it later today after work

ms-jpq commented 2 years ago

should be gucci now thank you so much