Fork me on GitHub
#calva
<
2022-08-13
>
ale10:08:30

Hello, I’m getting into Clojure via Calva and I’m not sure if this autocompletion (see attached screenshot) is failing because “we’re not there yet”, or some issue with my system. I’m in a .clj file, the lsp is running, the REPL is running and jacked-in using deps.edn profile. I also loaded the namespace in the REPL, but it should not be necessary for autocompletion to work, right?

Lukas Domagala11:08:58

There’s currently no autocomplete for type hints in nrepl or clojure-lsp, so Calva doesn’t have it either. Have you tried to autocomplete on other stuff?

ale14:08:50

Cool, good to know. Autocompletion of functions in a namespace (`http/…`), local variables, and possibly other things works. simple_smile

ericdallo16:08:03

That sounds like a good feature suggestion for clojure-lsp, we could provide at least java most used classes completions which we do have, feel free to create a issue there

ale16:08:39

@UKFSJSM38 Thanks for the prompt, I’ll do. I’d think it is possible to complete according to the (:import …) option of the ns macro, as it’s already providing a list of available classes after entering <space> and a letter after the package name (1st screenshot), or after I enter a dot right after the packagename. (2nd screenshot) 😃 If the Clojure convention is that ^CapitalizedCamelCase is interpreted as ^{:type CapitalizedCamelCase} , then maybe LSP can guess we’re talking about a Java class… :thinking_face: and use the :import statements to behave smartly.

Lukas Domagala17:08:08

I think you can also type hint stuff that you don't import, so it's more complicated

☑️ 1
ericdallo17:08:11

@U03SQC4A7GF yes, we added recently :java-class-usages from kondo analysis, so that is possible I guess

ale18:08:10

@UKFSJSM38 I’ve tried a few things in preparation of the feature-request and I’m thinking there are two (possibly independent) issues here; I’d like to have your feedback as to frame the problem(s) in the most useful way. The first issue is that imported Java classes are not included in the list of suggested symbols. This is testable by triggering suggestions for a value of the metadata map (1st picture). The second issue is that a ^ not followed by a map causes either an invalid syntax or an error which then results in no symbols being suggested (I do get words suggestions in one case). See 2nd and following pictures. Shall I create two separate feature requests? If LSP is supposed to assist in editing partial code, should the broken syntax case be filed as a bug?

ericdallo18:08:52

Yes, 2 different issues, one is fixable on clojure-lsp, the other may need changes on clj-kondo if it's not providing analysis for that broken code which does for other kind of issues like keywords with just :

👍 1