Fork me on GitHub
#cursive
<
2018-09-28
>
claudiu07:09:53

silly question, but thinking I'm missing something. Is there any way to send the current form to the repl ? I have send top-form and form before caret what I want sometimes is to just send the current form that I'm in. ex:

(comment (let [x (mount-app app)]
   (prn (:a1 x))) ) 

claudiu07:09:15

I run send top form but, after that I just want to send the prn to the repl (I do form before caret, but it's a bit annoying)

cfleming08:09:38

@claudiu If you select the form both Send to… forms will send the selection instead of what they would normally do.

misha09:09:53

yeah, but to do that you need to either: - format code the way which allows you to just triple-click the form (line) to send it to repl - or precise-click specifically after the form to send form-before-caret - or precise-select form - or multiple steps of shift+alt+left/right all of which break the flow harold

misha09:09:42

what really would be cool, is sending to repl all forms, current selection is touching. the same way formatting works now: select nothing – file is formatted, select few lines of a hash map - only that hash map will be formatted

misha09:09:37

otherwise it is tricky to "send current form": you are in the nested form, how many layers to send? 1? what if caret is in the middle of symbol? send just symbol? or always send form around it? unless it is top-form-symbol with nothing around it? ugh...

claudiu09:09:02

(prn (:a1 x)) was just thinking the current form I'm in depending on the cursor. Basically the one that has the first ( to the left. If my cursor is on n send the prn, if my cursor is on 1 send (:a1 x).

claudiu09:09:24

selecting it works nicely 🙂 thank you

cfleming09:09:52

Right, it’s tricky - a few people have asked about a “send current form” which would be the immediately surrounding form as @claudiu describes. Or something that allows you to select the scope you want, something like the introduce refactoring does.

cfleming09:09:24

@misha Generally I find the best option is to be somewhere in the form (or at the end of it) and use Expand Selection

manutter5110:09:22

I have a project with a directory structure like this:

project
  > src
    > clj
    > cljs
      > foo
        > bar
          thing.cljs
  > test
    > cljs
      > foo
        > bar
          thing-test.cljs
The test directory gets marked as Test Sources Root, but then none of my tests will run because they’re all in foo.bar.thing-test, not cljs.foo.bar.thing-test. So I click on test and do “Unmark as Test Sources Root,” click on cljs underneath it, and select “Mark Test Sources Root” and everything works, except I come back to my project later, and discover that test is back to being marked as the Test Sources Root. How can I convince it that I want the Test Sources Root to be cljs and not test?

manutter5110:09:29

(This behavior is happening across multiple iterations of Invalidate Caches / Restart, btw — IDEA 2018.2.4, Cursive 1.8.0-eap7-2018.2)

manutter5110:09:32

Aha, caught it in the act! If I make changes to project.clj, and import changes, it jumps back to selecting the test dir as the Test Sources Root.

manutter5111:09:11

Interesting: if I rename test to tst, then when I import lein changes, it unmarks cljs, but does not mark tst. Saves me a step, at least.

joelsanchez11:09:40

have you tried :test-paths, :resource-paths and :source-paths? I find that cursive ignores changes done through Project Structure, but obeys project.clj

manutter5111:09:50

Woot, didn’t know about :test-paths in the project.clj, that fixes it perfectly! Thanks much, one less mystery in my way.

joelsanchez11:09:08

Einstein said there are only two things that are truly infinite: the universe and the number of possible keys in project.clj...and he's not sure about the universe

manutter5111:09:51

Einstein was wise.

stijn13:09:45

what does this error mean? Error running 'REPL': Error creating RunProfileState

stijn13:09:00

(i'm using clojure.main repl with deps.edn)

scarytom13:09:32

@cfleming can you comment on why Cursive marks directories defined in :resource-paths in the project.clj as source roots rather than resource roots? I have a java+clojure project and when I run the junit tests in intellij, none of my resources are available because of this.

cfleming13:09:18

@manutter51 Right, Cursive obeys project.clj - that’s the source of truth. If you want to change how directories are marked it has to be done there for reproducibility.

cfleming13:09:46

That’s also how e.g. the Maven integration works.

cfleming13:09:10

@stijn It means you should send me your log file 🙂

manutter5113:09:16

That’s cool — I didn’t have a :test-paths key at all (didn’t know there was one) and apparently there’s a default value.

cfleming13:09:44

Yeah, that can be tricky actually. Lein has defaults for :source-paths and :test-paths but Cursive will also pick paths up from e.g. cljsbuild config. So if you have src/cljs configured in cljsbuild Cursive will mark both src (from the :source-paths default) and src/cljs (from cljsbuild), and confusion will ensue.

cfleming13:09:16

Especially since if you have no :source-paths at all it’s confusing that the value for it comes from defaults.

stijn14:09:26

I did thorough restructuring of my project with local/root deps and removing/importing of modules, so that might have caused it. when I import the project from scratch it worked

cfleming14:09:19

@t.denley I’ll reply over on your GH issue, but the tl;dr is that it’s by design due to unfortunate differences between IntelliJ’s and Leiningen’s understanding of what a resource folder is.

cfleming14:09:35

The original issue with gory details is here: https://github.com/cursive-ide/cursive/issues/241

cfleming14:09:21

There’s a workaround which is described in that issue and also https://github.com/cursive-ide/cursive/issues/833 which might work for you, which is modifying the compiler resource patterns.

cfleming14:09:28

Depending on what it is that you need copied.

scarytom14:09:42

thanks -- #833 pretty much describes my issue entirely

scarytom14:09:10

I'll try that workaround. Sad that I have to get everybody in my team to apply this though.

cfleming14:09:40

@t.denley Yeah, it’s unfortunate. Let me know if you can’t work around it and I can look at it again, but IIRC there wasn’t really a good fix which wouldn’t significantly break someone’s use case.

scarytom14:09:04

I've already applied the workaround, and it does solve my immediate issue, thanks

cfleming14:09:59

Oh great. If you’re sharing some or all of your .idea config in your VCS, the change should get to your coworkers.