Fork me on GitHub
#lsp
<
2021-07-28
>
lassemaatta06:07:52

When invoking the clojure-lsp API through a deps.edn alias, is it normal that no output is printed (when verbose is false)?

lassemaatta06:07:37

[lassemaatta@desktop vk]$ clojure -X:clean-ns
[lassemaatta@desktop vk]$

lassemaatta06:07:45

I would expect the value of {:result-code 1 :message (edits->diff-string edits) :edits edits} to show up somewhere, but do I need to do something extra to get it printed?

ericdallo12:07:23

Hum, this is probably following the same behavior of calling as API

ericdallo12:07:32

Would you expect print in the console?

lassemaatta12:07:57

for example. I think typically a "dry run" option implies a) don't actually perform any side-effects, but b) indicate somehow what would occur if the dry run parameter is false

lassemaatta12:07:37

I haven't been using the clojure cli tools for long, perhaps there's an easy way to get the return value out to stdout? Assuming of course that the map returned by the API contains what I think it contains

ericdallo12:07:18

yeah, that happens exactly as you described running manually via cli clojure-lsp clean-ns --dry , but not running via API/deps, we need to improve that so

ericdallo12:07:14

I have a fix in mind, we can just print to stdout, ATM we only do that if we called via the clojure-lsp.main which is called when clojure-lsp is called via CLI

lassemaatta13:07:55

ah, silly me. I had not realized I could just invoke the clojure-lsp binary directly, instead of calling it through deps.edn

lassemaatta13:07:53

the --dry option for the binary does exactly what I expected

lassemaatta13:07:27

but as you said, it might be a good idea to add printing to stdout or something when calling it through deps, unless the clojure cli has some way to see what the :exec-fn returns

ericdallo13:07:45

there is a way, not that pretty, but it's possible, @UMMMKKADU did some hacking to be able to do that I think

rafaeldelboni13:07:29

hahaha, "some hacking" you are being kind Here one alias I did testing this:

:lint-fix {:extra-paths ["test"]
                      :extra-deps {com.github.clojure-lsp/clojure-lsp {:mvn/version "2021.07.12-12.30.59"}}
                      :main-opts ["-e" "(require 'clojure-lsp.api) {:file-formats (count (:edits (clojure-lsp.api/format! {}))) :ns-cleaned (count (:edits (clojure-lsp.api/clean-ns! {})))}"]}

ericdallo13:07:17

haha , yeah, in this case you want the return map of the call, which makes sense

ericdallo13:07:26

printing to stdout could be another flag maybe...

dharrigan14:07:56

@clojurians-slack100 semantic highlighting is go go go again! https://github.com/clojure-lsp/clojure-lsp/issues/495 See last comment.

walterl15:07:36

Wow, thanks a lot for the investigation!

walterl15:07:37

Looks like it's working 🎉

dharrigan15:07:10

Apparently it has been disabled due to some issues with treesitter and colourising and is being reworked atm. I don't use treesitter, so I've re-enabled it 🙂

walterl15:07:24

Is there anything to look out for other than ns highlighting (which is already awesome!)?

walterl18:07:11

Also, thanks for leading me to palenight 😄

ericdallo15:07:22

clojure-lsp Released https://github.com/clojure-lsp/clojure-lsp/releases/tag/2021.07.28-14.24.06 : • General ◦ Minor fix on the analysis queries comparison. ◦ Improve GraalVM configuration to use direct/less configurations. ◦ Bump clj-kondo 2021.06.18 -> 2021.07.28 which adds support for macroexpanding. • Editor ◦ Fix outgoing/incoming call hierarchy when vars are outside project/external jars. ◦ Fix completion of aliases without var names typed yet, for example: `string/` • API/CLI ◦ Fix filename in diffs with dry option. ◦ Add coloring to diffs following git diff. ◦ Add `ns-exclude-regex` for commands that check whole project, allowing to exclude certain namespaces via regex.

🎉 15
Noah Bogart19:07:31

is it possible to look at a clojure.core function that’s defined with def to see if it’s in fact a function?

Noah Bogart19:07:14

for example, showing the documentation of conj doesn’t display the parameter lists cuz it’s technically a def :

(def
 ^{:arglists '([coll x] [coll x & xs])
   :doc "conj[oin]. Returns a new collection with the xs
    'added'. (conj nil item) returns (item).  The 'addition' may
    happen at different 'places' depending on the concrete type."
   :added "1.0"
   :static true}
 conj (fn ^:static conj

ericdallo19:07:34

ATM no, this is a feature suggestion on clj-kondo side I think

ericdallo19:07:46

I think there is already a issue open about this somewhere :thinking_face:

Noah Bogart19:07:59

i should have checked the issues first! thanks so much

Noah Bogart20:07:31

I want to extract-function while hovering over the right side of a let assignment: (when (some-func) (let [x (do-something-here)] ...)) . I call the extract-function action, and it extracts the when block above and everything inside of the let block as well. Is there some way to make it apply to only the innermost sexp?

ericdallo21:07:27

it does work as expected to me if hovering on the ( of the do-something-here or hover on do-something-here

Noah Bogart21:07:15

ah, you know what, i was running :CocAction which seems to have different semantics than calling the <Plug>coc-codeaction-cursor that i have bound to a key combo

Noah Bogart21:07:21

i wonder why that is

Noah Bogart21:07:37

i get the correct result you have in that gif if i do the -cursor version

ericdallo21:07:54

so it's one more weird vim thing 😛

Noah Bogart21:07:00

haha just keep piling them on!

😂 3
Noah Bogart21:07:19

it’s very possible this is something i’ve messed up in my config, i’ll poke around and see what’s up