BetterThanTomorrow / joyride

Making VS Code Hackable like Emacs since 2022
https://marketplace.visualstudio.com/items?itemName=betterthantomorrow.joyride
Other
458 stars 17 forks source link

Joyride scripts do not get full clojure-lsp support #170

Closed PEZ closed 10 months ago

PEZ commented 10 months ago

clojure-lsp needs a classpath to provide information about dependencies. The current workaround is to provide a bb.edn, or deps.edn with something like this content:

{:paths ["src" "scripts"]
 :deps {org.clojure/clojurescript {:mvn/version "1.11.54"}}}

The problems with this are (at least):

On the bright side:

tools-deps-native is experimental, but I think that's fine for our use case.

With this we should be able to support a clojure-lsp project spec looking something like so:

{:project-specs [{:project-path "joyride.edn"
                  :classpath-cmd ["tools-deps-native" ,,,]}]}

Command line args to be figured out. tools-deps-native crurrently has this interface

$ tools-deps-native

tools.deps.edn ...

          help  show this help message
          deps  output a claspath map from a deps map
  create-basis  output a basis from a set of deps sources and a set of aliases
     root-deps  output the root deps.edn
    slurp-deps  read, canonicalize and output a deps.edn file
user-deps-path  output the path to the users deps.edn file

Example usage:

$ tools-deps-native deps '{:deps {medley/medley {:mvn/version "1.0.0"}}}'
{:classpath-roots ["/Users/borkdude/.m2/repository/medley/medley/1.0.0/medley-1.0.0.jar" "/Users/borkdude/.m2/repository/org/clojure/clojure/1.7.0/clojure-1.7.0.jar"], :classpath {"/Users/borkdude/.m2/repository/medley/medley/1.0.0/medley-1.0.0.jar" {:lib-name medley/medley}, "/Users/borkdude/.m2/repository/org/clojure/clojure/1.7.0/clojure-1.7.0.jar" {:lib-name org.clojure/clojure}}}
PEZ commented 10 months ago

Currently tools-deps-native only spits out EDN, so we will need a way to convert that to a classpath string. Ideas:

Both these add a dependency on NodeJS, but maybe that's fine for now.

ericdallo commented 10 months ago

@PEZ also keep in mind that adding that default project spec to clojure-lsp means that we would expect all joyride users that create a joyride.edn to have tools-deps-native installed, which may be ok, but if we could manage to make it work without it would be even nicer

PEZ commented 10 months ago

I think we have exhausted the alternatives. Wherever we turn we hit dependencies, and this one we can fulfill by Joyride downloading tools-deps-native.