Fork me on GitHub
#lsp
<
2021-09-23
>
filipkon10:09:58

Hello! I have a question about auto-completion with Company in Emacs. I noticed that when trying to complete Java class methods in the Cider REPL after slash (e.g., Integer/) works fine. However, the same approach does not work in the .clj file. It hangs after slash and Company does not show any suggestions after Interger/. I've checked that the company backend is the same for the REPL and the document buffer (i.e. company-capf). Also, I tried using (add-to-list 'company-begin-commands 'cljr-slash), but no luck. Is it supposed to work like this or am I missing something?

borkdude10:09:17

currently that's not yet working

borkdude10:09:12

there is some work going on about analyzing java bytecode but we're not yet sure what's the best approach

☝️ 1
filipkon10:09:12

I see. Thanks for the response!

mynomoto19:09:17

If i do a namespace renaming say from foo.bar to bar.baz should clojure-lsp change explicit keywords from :foo.bar/x to :bar.baz/x?

ericdallo19:09:22

Probably, I'm not sure as well 😅

ericdallo19:09:28

we need to confirm that

mynomoto00:09:01

A follow up question is should it change the keyword if it is inside a .edn file? I used the rename namespace today and found it helpful but it got me thinking if it should try harder to find all possible changes.

ericdallo00:09:59

yeah, ATM it does not and IMO it's safer do not change edn files

ericdallo00:09:07

BTW, answering your question, we don't rename the keyword if using as full like:

:foo.bar/x
but we rename if using it with an alias like:
(:require [foo.bar :as b])

::b/x
->
(:require [bar.baz :as b])

::b/x

mynomoto00:09:19

In this case was an integrant configuration filé so the rename was necessary. I would guess that most of the time this is true, but I agree that it could cause problems.

ericdallo00:09:08

I'm not sure why we decided to not rename full qualified keywords when renaming ns though :thinking_face:

mynomoto00:09:17

Yeah, using an alias makes it impossible to miss the rename. But those doesn't exist on edn files 😉

ericdallo00:09:02

I think they are 2 different issues/features: renaming consider edn renaming ns consider renaming keywords that use that ns

mynomoto01:09:00

I agree, 2 separate issues.

mynomoto01:09:13

And thanks for clojure-lsp, it helps a lot on renaming, enough for me to do many more of them 👏

ericdallo01:09:56

Thanks :) The edn one could work, but ATM clj-kondo doesn't provide analysis on edn files AFAIK, still an issue is welcome. The other one probably needs to be implemented, I'm not remembering why we decided at the time to not allow that, a issue may help discuss that

delaguardo07:09:43

there is one use case where changing keys might cause some unexpected effects: 1. change namespace from foo.bar -> baz.bar 2. add namespace foo.bar 3. move some code from baz.bar to foo.bar In that case automaticaly changed keywords can cause some extra steps of refactoring.

ericdallo12:09:12

@U04V4KLKC could you elaborate your example on the issue please?

delaguardo13:09:52

I’m often begin writing code in single namespace (let’s call it foo.bar) and when it starts to be big enough I extract some functions using following steps: • rename entire namespace foo.bar -> foo.bar.lib • create empty foo.bar • move some functions from foo.bar.lib back to foo.bar After that foo.bar can require foo.bar.lib to have access to the rest of functionality. Normally foo.bar exposes api for the program, sometimes via implementation for integrant keys. If during the step 1 such keys will be changed without notice in some file it might break my program.

ericdallo13:09:33

yes, that could happen indeed, yet not sure how ofter this flow happens for other users, it's something to consider

ericdallo13:09:51

maybe a opt-out flag would work

delaguardo13:09:47

yes, option would be great

👍 1