Fork me on GitHub
#calva
<
2021-09-23
>
Hukka10:09:21

Quite often after I have deffed a new var, the autocomplete won't kick in until I have written several characters of the new symbol. Is there something I'm doing wrong?

pez11:09:23

So, you def it and then later want to reference it?

Hukka11:09:04

In general autocomplete after first char gives only builtins, two chards gives nothing (if it doesn't match builtins) and only third char ever starts autocompleting to local vars. But sometimes just deffed new var needs so much input that nothing older would match, and I think usually one more (so there's always one point where nothing older matches, so no results are given)

pez12:09:05

Interesting. I’ll test this myself a bit and see if we have a general glitch or if there is something with your config.

Hukka12:09:08

I think the problem is larger than just defs. For example if I destructure a new key in function props, the autocomplete won't pick it up at all if it's a subword of already existing autocomplete/suggest target

Hukka12:09:46

This is a far cry from a smallest possible replication, but just as an example I just now am working with this kind of fulcro component

(defsc Leg [_ {:keys [type origin destination]}]
  {:query [:type :origin :destination]}
  (ui-card
   {:sx {:margin "2rem" :maxWidth 575}}
   (case type
     ; TODO Looks different for comparison. Needs to be refactored into a helper component.
     :flight (ui-cardheader {:avatar ((interop/react-factory Flight)) :title "Flight" :subheader "Helsinki–Stockholm"})
     :train (ui-cardheader {:avatar ((interop/react-factory Train)) :title "Helsinki–Turku" :subheader "Train"})
     :ferry (ui-cardheader {:title "Turku–Stockholm" :subheader "Ferry"})
     nil)
   (ui-cardcontent
    {}
    (ui-cityselector {:label "Origin" :value origin})
    (ui-cityselector {:label "Destination" :value destination})
    )
   (ui-cardactions
    {}
    (ui-iconbutton {:aria-label "delete" :color :warning} ((interop/react-factory Delete))))))
I just added the destination param. I already have a function named destinations-from , and the suggestion flat out refuses to complete the shorter destination

Hukka12:09:13

origin will show in suggestions after inputting orig but not before

Hukka12:09:47

(so or will suggest the builtin, and ori will give empty list of suggestions)

pez12:09:28

I think this is a question for #lsp. It is what provides completions for local vars.

Hukka12:09:55

Ok, thanks

Hukka17:09:02

I tried to run the lsp with tracing on, but I have to say that I don't really see any of the suggestions going over the wire. It seems that it does get all the time all the symbols in global scope, but none of the buildins or function parameters.

Hukka17:09:36

What do the symbols before the suggestions mean? Seems like the global symbols are always something like a box in brackets, and parameters have "abc"

Hukka17:09:32

builtins have kind of two sheets. Do they all come from lsp or are there several suggestion mechanisms in play?

Hukka17:09:48

I found the relevant page for vscode itself, but the intellisense types don't seem to match how calva uses them

bringe15:09:51

To be honest I don’t know what the symbols indicate, but if you do find info on that please point us there. I haven’t looked it up. If the repl is not connected, all suggestions come from either vs code itself or clojure-lsp, otherwise, some come from the repl, depending on what it is.

bringe15:09:08

Actually, to correct what I just said, if the repl is connected, none of the suggestions come from clojure-lsp: https://github.com/BetterThanTomorrow/calva/blob/021efe8925adc49585184c5bc0d381394d416a55/src/lsp/main.ts#L74

bringe15:09:39

What I said previously applies to hovers, I believe.

pez15:09:26

That means there’s a chance we can fix this by doing something similar that we do with hovers and definition jumps, right? If clojure-lsp helps with it, of course, but I think it does.

👍 1
pez15:09:44

In any case, the dynamic lookups never work with locals, never had.

Hukka16:09:16

Something is suggesting those too, though. Some vscode generic thing? The "abc" symbol kinda feels like just arbitary completion to any words in the open file. Just haven't figured out why it needs so much input to trigger.

bringe16:09:13

Yeah, it seems that is correct, @U8ZQ1J1RR.

oly15:09:25

any one seen calva return syntax error when evaling forms, doing the same in cider works I am less familiar with calva and what might cause this

pez15:09:17

Could it be that you haven't loaded the file?

oly15:09:59

I have jacked in to the main file, it could be is that the equivalent of eval buffer in cider

pez16:09:29

To familiarize yourself with Calva you can try the Getting Started REPL: https://calva.io/getting-started/

pez16:09:37

Load current file is similar to eval buffer. There's a command for it. Cmd+Shift+P is your friend. 😀

oly16:09:52

I was searching for eval not load file thanks for that I will give it a try

metehan16:09:53

I am having a problem to connect repl of RN with jack-in; Creating cljs repl session

; Connecting cljs repl: Hello RN Shadow...
;   The Calva Connection Log might have more connection progress information.
; Error while connecting cljs REPL: TypeError: Cannot read property 'search' of undefined
; Jack-in done.
clj꞉shadow.user꞉> (+ 2 2)
Is this "search" of undefined related to my code because I don't have this word anywhere in my repo. It looks like it's connected but I can't evaluate anyting

pez16:09:41

It's probably something with the shadow-cljs file that Calva can't handle. Is this a fresh clone/copy of the project?

metehan18:09:43

no it's not but my friend tried on her mac it worked there but doesn't work on linux

metehan18:09:36

Now I run application wtih this npx shadow-cljs watch app when I run in other terminal shadow-cljs cljs-repl app I was able to connect to the repl and execute (js/console.warn "test") but I can't execute stuff from vs code

metehan07:09:34

is it possible to run shadow-cljs cljs-repl app from calva @U0ETXRFEW

pez07:09:37

Not really, but you can probably run it from the command line in a way that Calva can connect and things work. Try with this command:

npx shadow-cljs -d cider/cider-nrepl:0.26.0 watch app
Then connect from Calva.

metehan07:09:59

it's connected with this way but can't evaluate (+ 2 2)

metehan07:09:24

clj꞉shadow.user꞉>  ; Use `alt+enter` to evaluate
; Creating cljs repl session...
; Connecting cljs repl: shadow-cljs...
;   The Calva Connection Log might have more connection progress information.
; Error while connecting cljs REPL: TypeError: Cannot read property 'search' of undefined
(+  2 2)

pez07:09:26

Ah, so connect also tries to parse the shadow-cljs.edn file of course… And it works on Mac but not on Linux… Hmmm, can you paste the file content here?

metehan07:09:06

{;:deps {:aliases [:dev]} ; In a real app consider using `deps.edn` instead.
 
 ; If you use deps, remove `:source-paths` and `:dependencies` from this file
 :source-paths ["src/main"
                "src/test"]
 
 :dependencies [[reagent "1.0.0-alpha2"]
                [re-frame "1.1.2"]]
 
 :builds       {:app {:target           :react-native
                      :init-fn          
                      :output-dir       "app"
                      :compiler-options {:infer-externs :auto}
                      :devtools         {:autoload true
                                         :preloads [shadow.expo.keep-awake]}}}}

pez07:09:21

That looks totally fine…

metehan07:09:11

I will try with a fresh project

pez07:09:30

I just tried a fresh project on Gitpod (which uses Ubuntu). That worked.

pez07:09:33

But so did your shadow-cljs.edn file, How strange…

pez07:09:14

Which versions of VS Code and Calva are you using?

metehan08:09:57

vscode 1.60.2 and calva v2.0.211

metehan08:09:19

now I am testing with a fresh project

pez08:09:20

OK. I am using 1.60.1 on my mac. Maybe something has happened there…

pez08:09:40

No, still works on 1.60.2. I guess that is good…

metehan08:09:23

now I have another issue I couldn't test on fresh project yet 🙂

pez08:09:38

Which issue? 😃

Jacob Rosenzweig21:09:43

I get an error like Caused by: java.lang.IllegalStateException: Attempting to call unbound fn: #'cider.nrepl.middleware.debug/breakpoint-reader when trying to use the #break feature in calva with vscode. Any ideas?

pez05:09:04

How do you start the repl?