Olical / conjure

Interactive evaluation for Neovim (Clojure, Fennel, Janet, Racket, Hy, MIT Scheme, Guile, Python and more!)
https://conjure.oli.me.uk
The Unlicense
1.73k stars 109 forks source link

Go to definition fails on windows #515

Open AbhinavOmprakash opened 1 year ago

AbhinavOmprakash commented 1 year ago

whenever I try to go to the definition of a word using gd I run into an error

; localhost:51602 (...gged\conjure/lua/conjure/client/clojure/nrepl/action.lua:337: Cursor position outside buffer): .nrepl-port

I have been facing this issue on windows I'm on conjure v4.45.0

when I enable conjure debugging this is the output I get

; def (word): first
; debug: send
{:id "167e1659-9cd2-4782-8b2e-518f31c9101a"
 :ns "snitch.core-test"
 :op "info"
 :session "16937673-286d-4ffa-a360-d9a77ec5bece"
 :symbol "first"}
; debug: receive
{:added "1.0"
 :arglists-str "[coll]"
 :column 1
 :doc "Returns the first item in the collection. Calls seq on its
    argument. If coll is nil, returns nil."
 :file "jar:file:/C:/Users/abhin/.m2/repository/org/clojure/clojure/1.10.3/clojure-1.10.3.jar!/clojure/core.clj"
 :id "167e1659-9cd2-4782-8b2e-518f31c9101a"
 :line 49
 :name "first"
 :ns "clojure.core"
 :resource "clojure/core.clj"
 :see-also ["clojure.core/rest"
            "clojure.core/next"
            "clojure.core/nth"
            "clojure.core/second"
            "clojure.core/take"
            "clojure.core/ffirst"
            "clojure.core/butlast"]
 :session "16937673-286d-4ffa-a360-d9a77ec5bece"
 :static "true"
 :status ["done"]}
; --------------------------------------------------------------------------------
; localhost:50264 (...gged\conjure/lua/conjure/client/clojure/nrepl/action.lua:337: Cursor position outside buffer): .nrepl-port
Olical commented 1 year ago

This looks like the issue as I suspected: :file "jar:file:/C:/Users/abhin/.m2/repository/org/clojure/clojure/1.10.3/clojure-1.10.3.jar!/clojure/core.clj"

The path may need a different prefix and I'm not sure if we need different slashes for Windows in this case too. This works for me (different Clojure version but still):

nvim zipfile:///home/olical/.m2/repository/org/clojure/clojure/1.11.1/clojure-1.11.1.jar::/clojure/core.clj

Which of these work for you, if any? (also notice how it should be clojure/core.clj, not /clojure/core.clj)

# Correct path with no prefix slash.
nvim zipfile://C:/Users/abhin/.m2/repository/org/clojure/clojure/1.10.3/clojure-1.10.3.jar::clojure/core.clj

# Not sure if windows requires double backslashes like this or just one?
nvim zipfile://C:\\Users\\abhin\\.m2\\repository\\org\\clojure\\clojure\\1.10.3\\clojure-1.10.3.jar::clojure\\core.clj
nvim zipfile://C:\Users\abhin\.m2\repository\org\clojure\clojure\1.10.3\clojure-1.10.3.jar::clojure\core.clj

Also if you're using AstroNvim I just realised that it disables the zip plugin required to read .jar files by default, I overrode this and shorted the disabled plugins list with this:

 :lazy {:defaults {:lazy false}
        :dev {:path "~/repos/Olical"}
        :performance {:rtp {:disabled_plugins ["tohtml" "netrwPlugin"]}}}
Olical commented 1 year ago

Also you should get some output when running :let zipPlugin_ext if you have the required zip plugin loaded. If not, maybe something is disabling it because it's a builtin feature.

AbhinavOmprakash commented 1 year ago

hey, sorry for the late reply. I tried the following

nvim zipfile://C:\\Users\\abhin\\.m2\\repository\\org\\clojure\\clojure\\1.10.3\\clojure-1.10.3.jar::clojure\\core.clj
nvim zipfile://C:\Users\abhin\.m2\repository\org\clojure\clojure\1.10.3\clojure-1.10.3.jar::clojure\core.clj
nvim zipfile:\\C:\Users\abhin\.m2\repository\org\clojure\clojure\1.11.0\clojure-1.11.0.jar::\clojure\core.clj
nvim zipfile://C:\Users\abhin\.m2\repository\org\clojure\clojure\1.11.0\clojure-1.11.0.jar::\clojure\core.clj   

and they didn't work for me.

go to definition doesn't work within the same repository as well. AFAIK windows paths either require \ backslashes or double forward slashes //

I don't use astroNvim so I don't think the zip plugin is disabled

Olical commented 1 year ago

If someone can give me a zipfile path that works on their windows machine I can make sure Conjure uses that, I don't have access to Windows right now though and don't know how to run nvim on it anyway. Like aren't there two very different ways Windows users could be using Neovim on windows?

As I understand it there's:

I'm not sure how the paths should look on each or if the protocol slashes should be :// on EVERY platform no matter what 🤔

If someone can give me a good path I can integrate that, I just don't know what it should be right now.