Fork me on GitHub
#lsp
<
2021-09-04
>
ericdallo02:09:57

These are some topics which I should focus next weeks/months, keep in mind that are guides, things can and probably will change priority: • Auto-reload configuration changes without the need of restart the server • Improve API support adding missing features that are available on clojure-lsp as editor (Diagnostics, Find definition, Find references etc) • Add more code actions (Move to let, introduce-let) • Improve support on Java classes, find definition and find references (needs clj-kondo improvements) • Keep up-to-date with next LSP 3.17 release • Support for adding dependencies to project.clj or deps.edn, searching on clojars/maven-central the artifacts and its versions • POC Fix the support for static image, a great addition for clojure-lsp. the lib sqlite-jdbc that is used by clojure-lsp doesn't support it, so we can use datalevin instead or something else • POC (probably a separated new branched project) Add support for DAP (Debugger Adapter Protocol) which would be a way to provide a server for debugging Clojure in any editor following DAP (similar to LSP idea), probably using cider-nrepl under the hood. • Fix not critical old issues but that should make clojure-lsp more mature • Keep helping community in Clojurians #lsp • Clojure London talk about Clojure development with clojure-lsp

catjam 10
aw_yeah 2
borkdude10:09:23

What is the minimal analysis you need for Java classes?

ericdallo12:09:42

Probably we could start with a new bucker for java with it's locations, or even add to var-definition with a class flag or something, this way we could have find-definition and if we have the var-usages the references as well

borkdude13:09:26

ok. I'm looking at the javaparser project now. it's lgpl, but I think it's safe to include such a project?

ericdallo13:09:41

I always thought since it's LGPL it's safe, but not sure if it works fine for all kind of licenses like MIT / EPL

borkdude13:09:35

The other option is to use jdk.javadoc.doclet.Doclet which requires java 9+

borkdude13:09:52

we could make that functionality optional, when the class is there, use it, else don't provide java analysis

borkdude13:09:38

and for graalvm it shouldn't matter, as there 11 is already used

ericdallo13:09:00

I see no problems with that approach

borkdude13:09:49

I've already been using that class for java methods (which are stored as functions to get arity errors, which was something from the initial versions of clj-kondo)

borkdude13:09:59

for built-in classes

borkdude13:09:26

the funny thing is, I've never really encountered an example where clj-kondo helped me with this

😂 2
2
borkdude13:09:12

Hmm, this only seems to work for "documented" classes

borkdude13:09:20

not sure if that is a reasonable restriction

borkdude13:09:42

so classes that actually have javadoc stuff in it

ericdallo13:09:07

I think that's not ideal unfortunately 😔

borkdude13:09:37

then I think we should go with javaparser

borkdude13:09:49

but the lgpl is something that could be tricky

ericdallo13:09:57

besides license, is it hard to use javaparser?

borkdude13:09:21

yeah, I tried to write some "proxy" code which didn't work

borkdude13:09:33

so I think it might be better to write an API in Java

borkdude13:09:36

and then use that from Clojure

borkdude13:09:56

let me push what I got so far

ericdallo13:09:10

maybe a separate project as a anti corruption layer/API in clojure

borkdude13:09:41

hmm yeah perhaps. we could make a project in the clj-kondo org for this

borkdude13:09:54

but how would this help us?

ericdallo13:09:18

oh, I misread, you meant an API in java

borkdude13:09:45

yeah, write the javaparser interop in Java

ericdallo13:09:47

well, it could be a clojure API, it'd just be more convenient, but both should work

borkdude13:09:51

and then expose a few functions for Clojure

borkdude13:09:06

basically to hide the messy interop

borkdude13:09:53

I just want the AST as data, not as some classes

ericdallo13:09:29

yeah, makes sense

ericdallo13:09:01

that's why maybe an clojrue API makes more sense as we do care more about data not classes

borkdude13:09:37

ok, let's backup

borkdude13:09:47

what I mean is: you have to write a ton of interop to deal with this library

borkdude13:09:54

and this interop is messy to do in Clojure

borkdude14:09:01

so that part has to be written in Java

borkdude14:09:14

and then expose a couple of methods that you can then use to get a Clojure API

ericdallo14:09:30

makes sense!

borkdude14:09:37

so I'm already running into this problem: https://stackoverflow.com/a/6054258/6264

ericdallo14:09:41

maybe ask if Alex got his answer? 😂

borkdude14:09:36

ok, pushed to the branch.

lein run -m clj_kondo.impl.JavaParser
now prints something

borkdude14:09:54

I didn't get it to work by writing Clojure, I think just making a facade in Java is the way to go for this nasty lib

👍 2
ericdallo14:09:06

javaparser branch?

borkdude14:09:03

we might want to split this into a separate project so we can package the compiled java into a separate artifact

borkdude14:09:51

and then it seems fairly easy to extract whatever from whatever source files

ericdallo14:09:34

just tested, the javaparser seems quite good for java, a abstraction in java seems a good idea indeed to get data

borkdude14:09:48

ok, I'll make javaparser-clj or so in clj-kondo

borkdude14:09:02

perhaps we can use tools.build with this compilation hook

borkdude14:09:10

but then again, maybe not

borkdude14:09:13

lein is easy

ericdallo14:09:35

hahah, there is americano which I use on clojure-lsp

ericdallo14:09:41

is really easy and you can have deps.edn

borkdude14:09:56

yeah, but I also want to deploy

borkdude14:09:02

and everything needed is already in lein

borkdude14:09:35

we could do it both ways

ericdallo14:09:01

I use a github action for clojure-lsp clojars deploy, there is even no alias for deploy locally

borkdude14:09:45

yeah, we could do it the same way as your lein clj-kondo project

👍 2
borkdude14:09:03

so I think the interface we need is: throw Java source file in, get out a map with information

borkdude14:09:17

and clj-kondo can store this somewhere for linting

borkdude14:09:21

and we can expose it in the analysis

ericdallo14:09:26

seems good, the return map should contain localtion, documentation arity etc right?

borkdude14:09:28

yeah maybe :classes [{:name ... :file :...} or so. let's start with the least info possible

ericdallo14:09:55

yes, seems reasonable

borkdude14:09:04

inside :methods [...] with some other maps

👌 2
borkdude15:09:32

> If you use a library that is LGPL, and you statically link with that library, your software must be released with a compatible license.

borkdude15:09:11

We should ask some advice in the broader #clojure community. If you could do some research to get more clarity, that would be nice

👍 2
borkdude15:09:33

I think a native image is similar to an uberjar

borkdude15:09:21

we could also consider antlr4 which is bsd

borkdude15:09:34

and it has a java grammar, possible also a javascript one

ericdallo15:09:01

it seems generic for multiple languagues right? we would need to check if the java parser is good enough

borkdude15:09:02

I think we could borrow some of this stuff from there too: https://github.com/carocad/parcera/blob/master/src/clojure/parcera/antlr/java.clj

👀 2
borkdude15:09:58

I'll also whip up a POC with this

👍 2
borkdude15:09:29

ghaha parcera is also lgpl, what's up with this

facepalm 2
borkdude15:09:03

hmm, the antlr grammar is unoptimized they say and the optimized one only supports 8

borkdude15:09:29

javaparser is probably better

rafaeldelboni13:09:45

Hey I made a document about writing a basic nvim setup for clojure using fennel, aniseed, conjure and clojure-lsp https://github.com/rafaeldelboni/nvim-fennel-lsp-conjure-as-clojure-ide Hope it helps people wanting to move to use fennel in nvim config files.

🎉 10
gratitude 4
nice 4
clojure-lsp 6
partywombat 4
neovim 2
ericdallo13:09:51

Thank you very much! I will share that with vim users when they find issues to configure clojure-lsp :)

rafaeldelboni13:09:38

Can I open a PR?