This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-11-11
Channels
- # asami (19)
- # babashka (41)
- # beginners (115)
- # biff (7)
- # calva (78)
- # clj-kondo (29)
- # cljs-dev (9)
- # clojure (39)
- # clojure-europe (17)
- # clojure-gamedev (29)
- # clojure-nl (1)
- # clojure-norway (9)
- # clojure-spec (2)
- # clojure-uk (3)
- # clojurescript (7)
- # core-async (26)
- # cursive (16)
- # datomic (13)
- # emacs (1)
- # events (5)
- # fulcro (2)
- # funcool (4)
- # gratitude (1)
- # helix (1)
- # holy-lambda (1)
- # humbleui (1)
- # introduce-yourself (4)
- # java (1)
- # jobs (2)
- # jobs-discuss (9)
- # lsp (28)
- # matcher-combinators (2)
- # mathematics (1)
- # membrane (1)
- # nbb (12)
- # off-topic (10)
- # pathom (52)
- # polylith (38)
- # portal (32)
- # re-frame (4)
- # reagent (16)
- # reitit (2)
- # remote-jobs (1)
- # reveal (1)
- # rewrite-clj (10)
- # sci (67)
- # shadow-cljs (45)
- # squint (1)
- # tools-build (13)
- # tools-deps (16)
@ericdallo @mkvlr I and I were discussing the following:
(require '[clojure.test])
(def foo 'clojure.test/is)
Technically, the symbol clojure.test/is
is just an arbitary thing, it doesn't need (load or refer) the clojure.test/is
var or clojure.test
namespace and as such clj-kondo doesn't emit a var usage for that.
But as a user of lsp, it would still be nice to be able to navigate to clojure.test/is
when you're on that symbol. 🧵I think it would be possible to infer the var just by looking at the namespace / alias and name of the symbol, just for navigation, perhaps.
yes, as a final user that sounds good.
Not that easy I think to support that, as we don't have any analysis of symbols 'clojure.test/is
for example, so we would need to do hacky things like if no analysis is present try to infer that with the logic you mentioned
@U04V15CAJ thanks for starting this conversation! @ericdallo some context if you’re interested: in Clerk a render-fn is a quoted form defined in Clojure that’s then transmitted to the browser. In cursive you can use jump to definition for a symbol like https://github.com/nextjournal/clerk/blob/edd0c2fc22bd0207cc8d3762f00f239ce63ee87f/src/nextjournal/clerk/viewer.cljc#L733 and I’d love it if lsp users could also do that
one level up would be to resolve ns-aliases for a quoted form so when you see a quoted symbol like v/html
to first try to resolve it as-is, and if there’s an ns-alias defined for this, also try with that resolved
I agreed that for user this makes sense, I'm just saying that it'd be something hacky to support on clojure-lsp as ATM we completely rely on analysis and we are saying we would for cases where we don't find a analysis we would introduce a new logic to find a definition
https://github.com/nextjournal/clerk/pull/276 is even more context if you’re interested
Yeah, that makes sense, we would need to have some kind of resolver for symbols with fallbacking to use rewrite-clj on that code and parse because ATM we receive on server: URI line col
so we would need to parse the code on that uri line and col with rewrite-clj, check that is a symbol and try to find analysis for that ns or alias
yes, ATM we find any element from kondo analysis that are inside the range checking name locations
https://github.com/clojure-lsp/clojure-lsp/blob/master/lib/src/clojure_lsp/queries.clj#L501-L505
alright, I have to run now but happy to take a look and see if I can implement this next week if you agree having this makes sense in general
Sure, feel free to create a issue where we can discuss the implementation better, the feature support makes sense, but is not clear to me if we can support it without lots of hacky code
This would be a really nice feature 👍 I remember thinking about opening a ticket about this when I was playing around with lazy loading functions with requiring-resolve
I think just looking at the aliases / used namespaces and using the full namespace name as fallback should be sufficient to navigate to the var (or to do completions)
The dev jar is a one time only mostly, you build and the connect to the running nrepl port, there is even a lsp-clojure-nrepl-connect
command that does automatically for you :)
Then you can change how clojure-lsp works and build your feature without restarting or re-building anything
@ericdallo That works, but why even go through the jar? You can just start a -main function in the script directly?
Yeah, works too, there is run deps alias which runs the main, it's just that was never a issue, as bb debug-cli
takes a few seconds and usually you don't need to re-build that anymore
Merged the first @U04V15CAJ's PR 🎉 it should be available a nightly build soon on #C032YH7P0R2 @mkvlr in case you want to give it a try
It's not the first though ;) https://github.com/clojure-lsp/clojure-lsp/commits?author=borkdude