Fork me on GitHub

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


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


what does that do?


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


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


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


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



@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 
	at com.intellij.util.indexing.FileBasedIndex.requestRebuild(
	at cursive.intentions.resolve$rebuild_all_indexes_BANG_.invoke(resolve.clj:142)
	at clojure.lang.Var.invoke(
	at cursive.api.DelayedFn.invoke(
	at cursive.settings.ClojureProjectResolveSettings$loadState$
	at com.intellij.openapi.application.impl.ApplicationImpl$
	at java.util.concurrent.Executors$
	at java.util.concurrent.ThreadPoolExecutor.runWorker(
	at java.util.concurrent.ThreadPoolExecutor$


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 

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'?


;; function
(some-var 1

;; indent
(some-var 1


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 just says Coming Soon: A much better way to do this.


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


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.


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:


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.


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

(condp pred
  test result


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.


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

  test result


“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:


“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


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



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


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?


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