Fork me on GitHub
#cursive
<
2019-05-10
>
roklenarcic11:05:53

I am looking at Code Style -> Clojure settings and Form Parameters tab

roklenarcic11:05:17

there I have a dropdown for each form, I can pick Indent or a number

roklenarcic11:05:21

what does that do?

roklenarcic11:05:04

If I break (form x) into having x in new line, then I always get 2 character indentation

thumbnail11:05:10

i think it uses your global ident-setting or a fixed indentation amount

roklenarcic11:05:40

No I mean why when I set this to 0, I still get same indentation than when I set this to 8

roklenarcic11:05:15

Like I set assoc value to 8 and when I linebreak I get this:

(assoc
  :a
  1
  2)

ikitommi11:05:03

@cfleming about the error when after switching project, nothing gets resolved. Got it again and in the logs:

2019-05-10 14:29:42,175 [26173294]   INFO - pl.projectlevelman.NewMappings - VCS Root: [] - [<Project>] 
2019-05-10 14:29:42,175 [26173294]   INFO - pl.projectlevelman.NewMappings - VCS Root: [Git] - [/Users/tommi/projects/metosin/spec-tools] 
2019-05-10 14:29:42,213 [26173332]   INFO - ellij.project.impl.ProjectImpl - 209 project components initialized in 70 ms 
2019-05-10 14:29:42,235 [26173354]   INFO - le.impl.ModuleManagerComponent - 1 module(s) loaded in 21 ms 
2019-05-10 14:29:42,265 [26173384]   INFO - rojectCodeStyleSettingsManager - Initialized from default code style settings. 
2019-05-10 14:29:42,329 [26173448]   INFO -              PerformancePlugin - Performance Plugin is in silent mode 
2019-05-10 14:29:42,387 [26173506]   INFO - .diagnostic.PerformanceWatcher - Pushing properties took 18ms; general responsiveness: ok; EDT responsiveness: ok 
2019-05-10 14:29:42,511 [26173630]   INFO - il.indexing.FileBasedIndexImpl - Rebuild requested for index ClojureSymbolMeta 
java.lang.Throwable
	at com.intellij.util.indexing.FileBasedIndex.requestRebuild(FileBasedIndex.java:70)
	at cursive.intentions.resolve$rebuild_all_indexes_BANG_.invoke(resolve.clj:142)
	at clojure.lang.Var.invoke(Var.java:383)
	at cursive.api.DelayedFn.invoke(DelayedFn.java:36)
	at cursive.settings.ClojureProjectResolveSettings$loadState$1.run(ClojureResolveSettings.kt:95)
	at com.intellij.openapi.application.impl.ApplicationImpl$1.run(ApplicationImpl.java:311)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)

ikitommi11:05:05

2019.1.2, cursive v1.8.2-eap2-2019.1

Ben Hammond13:05:26

Code Formatting seems to have changed. I'd like to align parameters thus

(defn bar
  [a b c]
  (* a 
     b 
     c))

Ben Hammond13:05:35

hmmm; the new tool looks alot more powerfull

Ben Hammond13:05:11

if only I knew how to use it. whata is the differeence between 'Indent' and 'Function'?

sashton14:05:30

;; function
(some-var
 1
 2)
(some-var 1
          2)

;; indent
(some-var
  1
  2)
(some-var 1
  2)

sashton15:05:37

I understand indent to be used for def-like things. Where you’d like the second line to always be indented, regardless how many arguments are on the first line. Whereas function is typical for regular function-type vars, and will line up arguments vertically if you leave any on the first line.

Ben Hammond13:05:05

https://cursive-ide.com/userguide/formatting.html just says Coming Soon: A much better way to do this.

mbjarland14:05:01

I have a question, I quite often find myself in a situation where I need to write an ad-hoc clojure snippet to be run from the command line to do someting like analyze a large xml file, search through a directory structure for patterns, analyze an apache log etc. In this situation I do want the intellij repl experience, the intellisense, goto declaration etc, but I do not want to spend five minutes setting up a project...and also, it seems that projects like their source to be in a separate directory from the project root which is not great in this scenario either. So open question, do other people do these kinds of ad-hoc scripts and if so, do you use intellij/cursive for it and in that case how? Sometimes the scripts need a deps.edn as well, so supporting that would be a bonus. Right now I'm thinking I will create one project called lets say ad-hoc and use it for all scenerios like this, but perhaps there is a better way?

Alex Miller (Clojure team)15:05:39

I spend 5 minutes and make a project

Alex Miller (Clojure team)15:05:07

Half the time I end up enabling git or doing more later on, so just seems easier to bite the bullet

Alex Miller (Clojure team)15:05:34

With a deps.edn project, there’s almost nothing to set up

mbjarland15:05:46

ok. Thanks for the input @alexmiller...and thanks for all the great articles and your general contribution to the community. Much appreciated. I end up doing a lot of small scripts like this in my day job, often driven by a hate for bash for anything more complex. So say I just create an empty dir with a deps.edn and my script, I know I've previously caved in and ended up creating a src dir just to have cursive understand my source. Is this necessary or can you leave the script in the root and still make cursive grok it? I ask also because I would like to have the deps.edn and the script in the same dir as it makes it more trivial to run them directly via clj. I can hear myself being nit picky here but it has been bothering me for a while.

cfleming22:05:27

To those above asking about indentation (@ben.hammond, @saskia, @roklenarcic and others), my apologies for not having this better documented. Here’s how this works:

cfleming22:05:43

Macro forms will often have some number of parameters, followed by any number of body forms. Consider condp:

(condp pred expr
  test result
  ...)
condp can be considered to have two arguments, and then its body. This means that its indent value is 2 - it has two parameters that should be indented differently to the rest.

cfleming22:05:27

Generally, the parameters are aligned, which means that you’ll get e.g. this:

(condp pred
       expr
  test result
  ...)

cfleming22:05:23

So if there’s a line break between the parameters, they will be aligned. All the “body” elements (i.e. elements after the parameter count) are just indented two spaces.

cfleming22:05:10

The default indent is two spaces, so if you have a line break before the first parameter, you’ll get this:

(condp
  pred
  expr
  test result
  ...)

cfleming22:05:16

“Only Indent” is for people who don’t want to think about any of this, and just always want two-space indent after a line break. This is also often useful for forms like proxy, defrecord, extend-protocol and the like. There’s also a setting Preferences | Editor | Code Style | Clojure | General | Default to Only Indent which sets that for all forms which don’t have an explicit setting. See Nikita’s great article on why you might want that: https://tonsky.me/blog/clojurefmt/

cfleming22:05:29

“Function” is usually the default, and treats all form elements after the head as parameters and aligns them, i.e. functions have no body. This is why you’ll get:

(my-fn a
       b
       c)

cfleming22:05:04

Again, with a line break before the first param, params will be indented 2:

(my-fn
  a
  b
  c)

cfleming22:05:40

Cursive’s “Only Indent” setting also implements the improvement for parinfer compatibility that tonsky discusses in recent Cursive versions.

nwjsmith22:05:09

Oooooh cool. I’ve been meaning to give Nikita’s suggestion a try, this will make it really easy. Is there a way to do this per-project?

nwjsmith22:05:37

My coworkers will have choice words for me if I use this, but on my personal projects I’m freeee