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?
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.
Is there any output on /tmp/clojure-lsp.*.out
?
I don't use a mac, but the clojure-lsp process does write out to /tmp
The issue is fixed by latest release, after I delete all the .lsp
folder which is generated by old release. Thanks!
Found a bunch of statements like this
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
Those are okay
It's overly verbose
Oh wait, maybe it actually completed this time? I suspect (embarrassingly) that it was a bad hook I wrote for clj-kondo
np 🙂
I'll remove the verbose log for fn* 🙂
Nice!!
I did a refactor or the way lsp find the configs too, the next release should has a smarter way to get the config
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
yeah, that version you cannot know before you to push to clojars
this is good enough
Ok 🙂
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)
or some script or something
I leave that as an exercise ;)
hahahaha I think I'll just use the resource file version, parsing the deps.edn looks harder/dangerous for a simple thing like that
maybe clj-kondo could has a function via JVM for that
That could be pretty common for libs using the analyzer
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
Oh, I see
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
not sure there is a lsp-mode setting for that, let me check
I can use the function lsp-toggle-symbol-highlighting
as a work around, toggling the highlighting on when I am most interested.
Yeah, could not find nothing, but I asked here: https://discordapp.com/channels/789885435026604033/789891051644911627/814521532809871411
@jr0cket it seems it follows the lsp-idle-delay
, but increasing that will cause other lsp features to delay too
👋
1trying 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 😄What is M-.
? I don't know that
BTW I use doom-emacs
M-.
is cider-find-var
. I'm just wondering the best way to re-bind it
oh, got it
I think lsp-find-definition
and lsp-find-references
or lsp-ui-pee-find-references
are enough indeed
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
ah, looks like I should have a lambda in the cider-hook that does a local-set-key (cribbing from other code)
Yes, for your case using a cider-hook should be the best to add keybindings just for that
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
?
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👍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
Also only if the symbol does not has a namespace, like bar/foo
Sounds good!
@ericdallo I sometimes copy functions to a new namespace but then my namespace form naturally is broken. Can LSP fix this?
cljr-move-form
can do this
What do you mean namespace form?
(ns foo)
e.g. I copy:
(deftest foo (is (str/starts-with? :foo :bar)))
and then I want clojure.test
and clojure.string
to turn up magically ;)
Oh, you mean lap auto import the alias used on the moved function?
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
Yeah, it could be done I think, I just wonder how user would use it
Like via a code action
yeah, lsp-clojure-fix-namespace-form
or something
A single emacs command to that makes sense, but a code action not sure, since there is already the add-missing-require code action
I think cider refactor has something like that... that's really a good source of actions before making up our own too
you mean clj-refactor?
i think cider refactor calls this function from example or similar
aye
I didn't find on examples: https://github.com/clojure-emacs/clj-refactor.el/tree/master/examples
yes! https://github.com/clojure-emacs/clj-refactor.el/wiki/cljr-create-fn-from-example
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
we could improve that later to create functions on other ns if aliased, it's pretty common to me want something like that