lsp

:clojure-lsp: Clojure implementation of the Language Server Protocol: https://clojure-lsp.io/
ingesol 2021-02-25T11:05:52.238600Z

Hi! I used Calva for about. week now. Worked fine with refactorings, references search and other Clojure features for somedays, but last few days the message “Initializing clojure language features via clojure-lsp” is spinning in the bottom bar, and things like references search don’t work. I’ve tried restarting VS code and my mac. Any ideas?

ingesol 2021-02-25T11:06:29.238700Z

This is also posted in #calva channel, @pez thought it was a good idea to ask for help here as well. I tried different versions of calva from february, no luck so far.

dharrigan 2021-02-25T11:20:50.238900Z

Is there any output on /tmp/clojure-lsp.*.out?

dharrigan 2021-02-25T11:21:04.239100Z

I don't use a mac, but the clojure-lsp process does write out to /tmp

2021-02-25T11:23:26.239300Z

The issue is fixed by latest release, after I delete all the .lsp folder which is generated by old release. Thanks!

ingesol 2021-02-25T11:29:40.239500Z

Found a bunch of statements like this

ingesol 2021-02-25T11:30:18.239700Z

2021-02-25T11:27:54.356Z UnknownHost DEBUG [clojure-lsp.crawler:150] - Cannot find position for: fn* {:name fn*, :filename “/Users/…/util.clj”, :from myns.util, :col nil, :from-var group-and-count, :arity 2, :bucket :var-usages, :row nil, :to clojure.core} nil

dharrigan 2021-02-25T11:30:57.240100Z

Those are okay

dharrigan 2021-02-25T11:31:09.240400Z

It's overly verbose

ingesol 2021-02-25T11:32:11.240700Z

Oh wait, maybe it actually completed this time? I suspect (embarrassingly) that it was a bad hook I wrote for clj-kondo

dharrigan 2021-02-25T11:32:20.240900Z

np 🙂

ericdallo 2021-02-25T12:18:47.241100Z

I'll remove the verbose log for fn* 🙂

ericdallo 2021-02-25T12:20:00.241300Z

Nice!!

ericdallo 2021-02-25T12:20:26.241500Z

I did a refactor or the way lsp find the configs too, the next release should has a smarter way to get the config

ericdallo 2021-02-25T12:27:31.241900Z

it's printing (string/trim (slurp (io/resource "CLJ_KONDO_VERSION"))) => "2021.02.14-SNAPSHOT" not the exactly version on deps.edn: 2021.02.14-20210218.170309-6

borkdude 2021-02-25T12:27:55.242100Z

yeah, that version you cannot know before you to push to clojars

borkdude 2021-02-25T12:28:01.242300Z

this is good enough

ericdallo 2021-02-25T12:28:08.242500Z

Ok 🙂

borkdude 2021-02-25T12:28:43.242700Z

But you can maybe do your own version parsing from your deps.edn at compile time (beware that deps.edn isn't usually in the deployed jar)

borkdude 2021-02-25T12:29:00.242900Z

or some script or something

borkdude 2021-02-25T12:29:07.243100Z

I leave that as an exercise ;)

ericdallo 2021-02-25T12:33:01.243400Z

hahahaha I think I'll just use the resource file version, parsing the deps.edn looks harder/dangerous for a simple thing like that

ericdallo 2021-02-25T12:33:33.243600Z

maybe clj-kondo could has a function via JVM for that

ericdallo 2021-02-25T12:34:04.243800Z

That could be pretty common for libs using the analyzer

borkdude 2021-02-25T12:34:26.244Z

clj-kondo doesn't know this version itself, it's generated by clojars, like I said before. but you know this version, because you are adding it to your deps.edn

ericdallo 2021-02-25T12:35:01.244200Z

Oh, I see

practicalli-john 2021-02-25T15:33:24.246800Z

Is there a config to set a delay on symbol highlighting? I can switch highlighting off with lsp-symbol-highlighting-skip-current nil it seems, however, it would be more useful to me for a delay of a few seconds, so it only highlights when I linger on a symbol. This would be in the same way I can add a delay to the docstring popup with lsp-ui-doc-delay

ericdallo 2021-02-25T15:35:02.246900Z

not sure there is a lsp-mode setting for that, let me check

practicalli-john 2021-02-25T15:38:46.247100Z

I can use the function lsp-toggle-symbol-highlighting as a work around, toggling the highlighting on when I am most interested.

ericdallo 2021-02-25T15:42:09.247300Z

Yeah, could not find nothing, but I asked here: https://discordapp.com/channels/789885435026604033/789891051644911627/814521532809871411

ericdallo 2021-02-25T16:22:32.247800Z

@jr0cket it seems it follows the lsp-idle-delay , but increasing that will cause other lsp features to delay too

1👍
2021-02-25T17:43:41.248500Z

👋

1
2021-02-25T17:58:23.249500Z

trying to figure out how to get this to work for M-. w/o doom emacs

(define-key lsp-ui-mode-map [remap xref-find-definitions] #'lsp-ui-peek-find-definitions)
(define-key lsp-ui-mode-map [remap xref-find-references] #'lsp-ui-peek-find-references)
searching for M-. is hard 😄

ericdallo 2021-02-25T17:59:52.249600Z

What is M-. ? I don't know that BTW I use doom-emacs

2021-02-25T18:01:26.249800Z

M-. is cider-find-var. I'm just wondering the best way to re-bind it

ericdallo 2021-02-25T18:01:52.250Z

oh, got it

ericdallo 2021-02-25T18:02:22.250200Z

I think lsp-find-definition and lsp-find-references or lsp-ui-pee-find-references are enough indeed

2021-02-25T18:06:59.250400Z

yep, got that bit. Just failing on finding the right thing to do the rebinding just in clojure modes (or I suppose cider). Tho as it is a general lsp-ui-* thing it isn't just for clojure so I suppose I could tweak the global-key-map

2021-02-25T18:08:07.250600Z

ah, looks like I should have a lambda in the cider-hook that does a local-set-key (cribbing from other code)

ericdallo 2021-02-25T18:10:18.250800Z

Yes, for your case using a cider-hook should be the best to add keybindings just for that

ericdallo 2021-02-25T19:27:24.252400Z

Hey LSPeople, What do you think about a Create private 'foo' function code action when hovering in a foo symbol that linter warn as unresolved-symbol ?

snoe 2021-02-26T17:30:02.266900Z

we should definitely be naming our actions the same as cljr they put a lot of thought into the namings and it'll be familiar to people making the jump

1👍
ericdallo 2021-02-26T17:31:29.267300Z

I agree, we can use the refactoring name the same, for the command, but maybe improve the name for code action tittle, like create private function looks better to me than create-fn-from-example

ericdallo 2021-02-25T19:27:49.252500Z

Also only if the symbol does not has a namespace, like bar/foo

dharrigan 2021-02-25T19:32:09.252800Z

Sounds good!

borkdude 2021-02-25T21:51:03.253900Z

@ericdallo I sometimes copy functions to a new namespace but then my namespace form naturally is broken. Can LSP fix this?

jumar 2021-02-26T08:12:30.258300Z

cljr-move-form can do this

ericdallo 2021-02-25T21:54:43.254Z

What do you mean namespace form?

borkdude 2021-02-25T21:55:30.254200Z

(ns foo)

borkdude 2021-02-25T21:55:39.254400Z

e.g. I copy:

borkdude 2021-02-25T21:55:56.254600Z

(deftest foo (is (str/starts-with? :foo :bar)))

borkdude 2021-02-25T21:56:16.254800Z

and then I want clojure.test and clojure.string to turn up magically ;)

ericdallo 2021-02-25T21:56:47.255Z

Oh, you mean lap auto import the alias used on the moved function?

borkdude 2021-02-25T21:56:53.255200Z

There was a project like that, but it's deprecated: https://github.com/technomancy/slamhound Maybe this can be done by inferring this from the clj-kondo aliases, etc

ericdallo 2021-02-25T21:59:11.255600Z

Yeah, it could be done I think, I just wonder how user would use it

ericdallo 2021-02-25T21:59:18.255800Z

Like via a code action

borkdude 2021-02-25T22:00:46.256Z

yeah, lsp-clojure-fix-namespace-form or something

ericdallo 2021-02-25T22:09:54.256200Z

A single emacs command to that makes sense, but a code action not sure, since there is already the add-missing-require code action

snoe 2021-02-25T22:29:39.256400Z

I think cider refactor has something like that... that's really a good source of actions before making up our own too

ericdallo 2021-02-25T22:30:10.256600Z

you mean clj-refactor?

snoe 2021-02-25T22:30:19.256800Z

i think cider refactor calls this function from example or similar

snoe 2021-02-25T22:30:47.257Z

aye

ericdallo 2021-02-25T22:31:20.257200Z

I didn't find on examples: https://github.com/clojure-emacs/clj-refactor.el/tree/master/examples

ericdallo 2021-02-25T22:37:25.257600Z

IMO, clojure-lsp makes users don't need cljr anymore 🙂 So having those functions on lsp would make new users agree in migrate from cljr to clojure-lsp

ericdallo 2021-02-25T22:39:48.257800Z

we could improve that later to create functions on other ns if aliased, it's pretty common to me want something like that