This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-05-10
Channels
- # announcements (4)
- # beginners (111)
- # boot (34)
- # cider (67)
- # cljdoc (10)
- # clojure (90)
- # clojure-dev (37)
- # clojure-europe (3)
- # clojure-gamedev (3)
- # clojure-italy (18)
- # clojure-losangeles (2)
- # clojure-nl (27)
- # clojure-spec (24)
- # clojure-uk (59)
- # clojurescript (41)
- # cursive (32)
- # datomic (31)
- # emacs (21)
- # figwheel (1)
- # figwheel-main (2)
- # fulcro (43)
- # graalvm (6)
- # graphql (3)
- # jobs-discuss (3)
- # kaocha (1)
- # nyc (1)
- # off-topic (22)
- # pathom (10)
- # pedestal (11)
- # re-frame (9)
- # reitit (17)
- # shadow-cljs (15)
- # spacemacs (13)
- # sql (6)
- # testing (5)
- # tools-deps (3)
- # vim (13)
- # yada (1)
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
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:
(assoc
:a
1
2)
@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)
Code Formatting seems to have changed. I'd like to align parameters thus
(defn bar
[a b c]
(* a
b
c))
in cljs
hmmm; the new tool looks alot more powerfull
if only I knew how to use it. whata is the differeence between 'Indent' and 'Function'?
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.
https://cursive-ide.com/userguide/formatting.html 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?
I spend 5 minutes and make a project
Half the time I end up enabling git or doing more later on, so just seems easier to bite the bullet
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
expr
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:
(condp
pred
expr
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: https://tonsky.me/blog/clojurefmt/
“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)
Again, with a line break before the first param, params will be indented 2:
(my-fn
a
b
c)
Cursive’s “Only Indent” setting also implements the improvement for parinfer compatibility that tonsky discusses in recent Cursive versions.