This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-08-19
Channels
- # beginners (59)
- # calva (20)
- # cider (25)
- # clj-kondo (12)
- # cljdoc (3)
- # cljsrn (15)
- # clojure (104)
- # clojure-europe (4)
- # clojure-italy (10)
- # clojure-nl (3)
- # clojure-spec (14)
- # clojure-uk (13)
- # clojurescript (33)
- # code-reviews (26)
- # core-async (1)
- # cursive (5)
- # data-science (3)
- # datomic (8)
- # emacs (3)
- # fulcro (5)
- # graphql (3)
- # hoplon (1)
- # jobs-discuss (4)
- # kaocha (14)
- # nyc (1)
- # off-topic (33)
- # pathom (4)
- # pedestal (2)
- # quil (1)
- # re-frame (5)
- # reagent (10)
- # reitit (6)
- # rewrite-clj (3)
- # shadow-cljs (173)
- # specter (7)
- # sql (4)
- # vim (58)
- # yada (3)
Does anyone know how to put the openjdk sources on their classpath to jump from Clojure -> Java code?
e.g hitting [C-d on (Runtime/getRuntime)
should take me to the java source code.
I've downloaded the source using the Arch openjdk10-src
package and then setting the path in neovim:
au Syntax clojure set path+=/usr/lib/jvm/java-10-openjdk/lib/src.zip
You might want to update your ~/.clojure/deps.edn with something like {:deps {jdk-sources {:local/root "/path/to/src.zip"}}}
No success yet but a few things crossed off:
{:deps
;; {jdk-sources {:local/root "/usr/lib/jvm/java-10-openjdk/lib/src.zip"}}
;; {jdk-sources {:local/root "/usr/lib/jvm/java-10-openjdk/lib"}}
;; {java-sources {:local/root "/usr/lib/jvm/java-10-openjdk/lib"}}
;; {java-sources {:local/root "/usr/lib/jvm/java-10-openjdk/lib/src.zip"}}
}
none of these have worked so far, is there a step required to use ~/.clojure/deps.edn
?hmm I only say this because if I include this alias
{:deps
;; {jdk-sources {:local/root "/usr/lib/jvm/java-10-openjdk/lib/src.zip"}}
;; {jdk-sources {:local/root "/usr/lib/jvm/java-10-openjdk/lib"}}
;; {java-sources {:local/root "/usr/lib/jvm/java-10-openjdk/lib"}}
;; {java-sources {:local/root "/usr/lib/jvm/java-10-openjdk/lib/src.zip"}}
:aliases
{:rebel {:extra-deps {com.bhauman/rebel-readline {:mvn/version "RELEASE"}}
:main-opts ["-m" "rebel-readline.main"]}}}
I can't do clj -Arebel
So, I don't actually have to do anything, because it's picked up automatically for me by cider.
echo fireplace#message({'op': 'info', 'ns': 'user', 'symbol': 'Object'}, type({}))
Gives me a path
/`file` entry.But you're right that fireplace isn't handling it properly, I can't jump to source on it. I would guess that fireplace is trying to intelligently guess it's a java thing? dunno
Yeah, https://github.com/tpope/vim-fireplace/blob/493eff65b95ce348c5f55545a7607e05743610fb/autoload/fireplace.vim#L1797-L1805 there's some attempts I think
Ha 😄 fireplace#info is not sending the 'ns'
and it needs to for 'symbol' to work. I think fireplace#info
is completely broken right now for using cider.
I don't think my system deps.edn is being picked up:
~(!) $ clj -A:rebel
Error building classpath. Specified aliases are undeclared: [:rebel]
~(!) $ cat ~/.clojure/deps.edn
{:aliases
{:rebel {:extra-deps {com.bhauman/rebel-readline {:mvn/version "RELEASE"}}
:main-opts ["-m" "rebel-readline.main"]}}}
~(!) $
Which doesn't help..diff --git a/autoload/fireplace.vim b/autoload/fireplace.vim
index 4b72f43..b0e9399 100644
--- a/autoload/fireplace.vim
+++ b/autoload/fireplace.vim
@@ -1798,7 +1798,7 @@ endfunction
function! fireplace#info(symbol) abort
if fireplace#op_available('info')
- let response = fireplace#message({'op': 'info', 'symbol': a:symbol}, v:t_dict)
+ let response = fireplace#message({'op': 'info', 'symbol': a:symbol, 'ns': fireplace#ns()}, v:t_dict)
if type(get(response, 'value')) == type({})
return response.value
elseif has_key(response, 'file') || has_key(response, 'doc')
^ basic diff you needokay, in the case you have that set then clojure will read from there instead of ~/.clojure
. It's not exactly correct or properly documented.
Really on Linux it should always look there, but Alex is not interested in that change for some reason.
fair enough.. I've been collecting a lot of these gotchas in a "What I wish I knew when starting Clojure" document haha
I've applied the diff but I'm still not able to lookup Java source code - I'll pick this up during lunch and let you know if I get this working (thanks again :thumbsup:)
That patch fixes fireplace#info(), but I guess it doesn't help if it's never called 🙂
Okay, so fireplace#source()
will look at resource
for some reason even if there's already a path. I'm not sure why.
and fireplace#findresource() is not returning the file. When I call fireplace#path()
I get nothing back so I think that's why it's broken for me. I think it should really be checking the existing path anyway.
elseif get(info, 'file', '') =~# '^jar:file:'
let zip = matchstr(info.file, '^jar:file:\zs.*\ze!')
let file = 'zipfile:' . zip . '::' . info.resource
^ this is the general code, but the if statements need some reordering too. That'sHi @dominicm, trying to get this PR together - I am getting a blank array back as file at the point you're checking for '^jar:file'
with extra-deps openjdk:
{'status': ['done'], 'file': [], 'throws': [], 'javadoc': '', 'modifiers': '#{:publi
c :static}', 'id': 'e5392260-d43e-4b8e-f6af-4c69c86240d2', 'session': ['4c3e7750-88b8-45ea-a2c9-6de4af55aa4b'], 'returns': 'java.lang.Runtime', 'class': 'java.l
ang.Runtime', 'argtypes': [], 'member': 'getRuntime', 'arglists-str': '[]'}
(I got this back when running FireplaceJumpD against (Runtime/getRuntime)
inside clojure/java/shell.clj
from stdlib)I'm starting the repl with clj -A:nrepl
using this deps.edn
{:deps
{org.clojure/clojure {:mvn/version "1.10.1"}}
:paths ["src"]
:aliases
{:nrepl {:extra-deps {nrepl {:mvn/version "RELEASE"}
cider/cider-nrepl {:mvn/version "0.21.1"}
jdk-sources {:local/root "/usr/lib/jvm/java-10-openjdk/lib/src.zip"}}
:main-opts ["-m" "nrepl.cmdline"
"--middleware" "[cider.nrepl/cider-middleware]"]}
:build {:extra-deps {pack/pack.alpha
{:git/url ""
:sha "dccf2134bcf03726a9465d2b9997c42e5cd91bff"
:exclusions [org.slf4j/slf4j-nop]}}
:main-opts ["-m" "mach.pack.alpha.capsule citadel.jar"
"-m" "citadel.core"]}}}
which I *think* should give me access to the openjdk source code
The diff for vim-fireplace I have so far is:
diff --git a/autoload/fireplace.vim b/autoload/fireplace.vim
index 4b72f43..4a7ad3a 100644
--- a/autoload/fireplace.vim
+++ b/autoload/fireplace.vim
@@ -1798,7 +1798,7 @@ endfunction
function! fireplace#info(symbol) abort
if fireplace#op_available('info')
- let response = fireplace#message({'op': 'info', 'symbol': a:symbol}, v:t_dict)
+ let response = fireplace#message({'op': 'info', 'symbol': a:symbol, 'ns': fireplace#ns()}, v:t_dict)
if type(get(response, 'value')) == type({})
return response.value
elseif has_key(response, 'file') || has_key(response, 'doc')
@@ -1846,6 +1846,9 @@ function! fireplace#source(symbol) abort
let file = fireplace#findresource(info.resource)
elseif get(info, 'file', '') =~# '^file:'
let file = substitute(strpart(info.file, 5), '/', s:slash(), 'g')
+ elseif get(info, 'file', '') =~# '^jar:file:'
+ let zip = matchstr(info.file, '^jar:file:\zs.*\ze!')
+ let file = 'zipfile:' . zip . '::' . info.resource
else
let file = get(info, 'file', '')
endif
in fireplace#source you need to move the if !empty(get(info, 'resource'))
down to a later elseif
, because most things have a resource
I starting executing some of the clojure code in fireplace#info and discovered that for me, calling special-doc
on Object doesn't return a file:
user=> (#'clojure.repl/special-doc 'Object)
{:name Object, :special-form true}
user=> (#'clojure.repl/special-doc 'defn)
{:added "1.0", :ns #object[clojure.lang.Namespace 0x70331432 "clojure.core"], :name defn, :special-form true, :file "clojure/core.clj", :column 1, :line 283, :m
acro true, :arglists ([name doc-string? attr-map? [params*] prepost-map? body] [name doc-string? attr-map? ([params*] prepost-map? body) + attr-map?]), :doc "Sa
me as (def name (fn [params* ] exprs*)) or (def\n name (fn ([params* ] exprs*)+)) with any doc-string or attrs added\n to the var metadata. prepost-map de
fines a map with optional keys\n :pre and :post that contain collections of pre or post conditions."