Fork me on GitHub
#cursive
<
2022-01-26
>
robert-stuttaford06:01:53

is it possible to set up cursive to auto-format on save using cljfmt? in emacs, when one uses clojure-lsp, you get lsp-format-buffer, which uses cljfmt under the hood. perhaps cursive uses clojure-lsp and can therefore use cljfmt via lsp?

cfleming06:01:20

Not yet, but it’s something I’m looking into as part of a change I’m just about to release.

cfleming06:01:45

Or rather, I’m about to release the first version of it, it will need more refinement.

robert-stuttaford06:01:51

oh wow you answered quick haha - i just amended my question!

cfleming06:01:25

Haha, yes. I’m planning to support cljfmt in one of two ways, either modifying Cursive to allow its formatting to be configured from the cljfmt file, or by configuring an external formatter which (I think) will allow what you want.

cfleming06:01:06

Are there forms where you can’t get the formatting from Cursive to match cljfmt, or is it just that it’s a pain to maintain the config in two places?

robert-stuttaford06:01:49

so, we have one cursive user and 5 emacs users, and whenever cursive-guy plus anyone else collaborate, the diffs are full of formatting changes

cfleming06:01:17

Has the Cursive user tried to get the formatting to match cljfmt?

robert-stuttaford06:01:50

yes! things like datalog's or-join and tufte/p being indented with two spaces rather than at the end of the function line, and that open issue with map values indenting at the end of the key even though its on a new line

cfleming06:01:05

I’m interested in cases where Cursive can’t support something that cljfmt does. Otherwise it may just be a matter of configuring his Cursive setup.

cfleming06:01:51

Can you give me some examples of the or-join and tufte/p thing? I’ll fix the map value thing in the next EAP (not this one I’m just about to release).

robert-stuttaford06:01:45

sure! we have this cljfmt config:

{:indents {tufte/p [[:inner 0]]
           or-join [[:inner 0]]}}
without the config:
(tufte/p :metric-name
         (measured-code-here))

(d/q '[:find ?x :where
       (or-join [?x]
                [?x :a]
                [?x :b])])
with the config:
(tufte/p :metric-name
  (measured-code-here))

(d/q '[:find ?x :where
       (or-join [?x]
         [?x :a]
         [?x :b])])

robert-stuttaford06:01:47

we have more such indentation rules, all applying the same basic rule to lots of forms - compojure, stuartsierra/component, guardrails, etc

robert-stuttaford06:01:21

ideally we'd maintain one cljfmt config with all of this, and have it in the repo with the code. we've done the same with clj-kondo stuff and it's fantastic

cfleming06:01:32

So in Cursive, he should customise the indentation for that form like this: https://cursive-ide.com/userguide/formatting.html#code-style-settings. As described there, he should set the config to “1”, which is one special parameter and the rest just indented.

robert-stuttaford06:01:23

ok, that's promising! and having that in source control?

cfleming06:01:40

Under Preferences | Editor | Code Style | Clojure, set the scheme to “Project”. That will create file in the .idea folder which contains that config for that project.

robert-stuttaford06:01:08

ok perfect. thanks Colin!

cfleming06:01:42

No worries. There’s a section in that doc about matching emacs too, in case there are other cases missing. If you have any other queries, let me know.

Dumch12:01:41

can I propose some features for the new releases here?

Dumch12:01:13

I already havehttps://github.com/Liverm0r/dotfiles/commit/e514831dfdc115d530444874bc2f37bebae8cbc9#diff-2097776acc409b1c4c6a8ab45fd000f47833f462dae606f010ee7bfaa37b9444 locally, so implementing it won’t be hard. Feature 1. Idea actions for deleting/selecting a form. Feature 2. Idea action to comment out a form. * form is one of "…", (…), {…}, […]

Dumch12:01:20

I need 1 to be able to have something like vim-sexp with idea-vim (an emacs users also can do this). I’ve written here about the problem https://clojurians.slack.com/archives/C0744GXCJ/p1642500532023400

imre16:01:29

Trying to check my code styles today after upgrading and it seems to be hanging:

imre16:01:58

IntelliJ IDEA 2021.3.2 RC (Community Edition)
Build #IC-213.6777.38, built on January 25, 2022
Runtime version: 11.0.13+7-b1751.25 x86_64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
macOS 12.1
GC: G1 Young Generation, G1 Old Generation
Memory: 4096M
Cores: 8
Registry:
    scala.erase.compiler.process.jdk.once=false

Non-Bundled Plugins:
    org.intellij.plugins.hcl (0.7.14)
    net.seesharpsoft.intellij.plugins.csv (2.18.2)
    name.kropp.intellij.makefile (213.5744.224)
    de.thomasrosenau.diffplugin (2.1.8-imrekoszo)
    com.namespace.sort.namespace-sort-plugin (1.7-imrekoszo-2021-3-linebreak)
    com.jetbrains.plugins.ini4idea (213.5744.190)
    org.jetbrains.kotlin (213-1.6.10-release-944-IJ6461.79)
    org.jetbrains.idea.grammar (2021.1.2)
    gherkin (213.6461.19)
    dev.monogon.cuelang (0.8.3)
    StringToolsPlugin (4.0)
    String Manipulation (8.25.203.5981.1)
    Key Promoter X (2021.3)
    mobi.hsz.idea.gitignore (4.3.0)
    com.cursiveclojure.cursive (1.12.2-eap2-2021.3)
    com.github.shinichy.integrant (0.1.1)
    com.github.brcosta.cljstuffplugin (0.5.2)
    EDN-JSON Converter (0.0.5)
    org.intellij.scala (2021.3.18)

Kotlin: 213-1.6.10-release-944-IJ6461.79

imre16:01:09

oh, I'm just seeing this came up as an IDE error, reported as #23507

serioga18:01:27

Hi @U0567Q30W, no plans for “Optimize imports” to remove unused imports?

cfleming21:01:41

@U0HJNJWJH Yes, there’s a (potentially incomplete) to-do list in the release email, I’m hoping to get to it all over this EAP series.

1
imre16:01:45

Hmm interesting error I got at stub generation, perhaps it's to do with me using clojure 1.11.0-alpha4

Alex Miller (Clojure team)16:01:46

definitely, clojure.core/abs is new in alpha4

imre16:01:59

Not sure why it breaks stub gen though

Alex Miller (Clojure team)16:01:02

the warning is correct and fine though (it's ok to overwrite the function)

imre16:01:23

I'm getting used to seeing this warning all over the place now 🙂

imre16:01:25

sent a pr there just in case

cfleming21:01:27

The stub generation currently assumes that anything output to stderr is an error. I could maybe relax that, but I’d have to ensure that I can be sure that the generation actually terminated correctly.

wilkerlucio19:01:36

hello, I was trying to find the setting to auto organize namespaces, but now when I go to the Clojure style part the screen never loads, it just stays in the state demonstrated by the screenshot

1
1
cfleming21:01:48

I’ll look at this today.

1
cfleming21:01:24

@U066U8JQJ Are you seeing the same error? It’s an NPE in FormParameterCodeStylePanel.getPanel.

wilkerlucio21:01:27

I got this error:

java.lang.RuntimeException: Unexpected value null
	at cursive.formatter.codeStyle.FormParameterCodeStylePanel.<init>(CodeStyleConfig.kt:195)
	at cursive.formatter.codeStyle.ClojureCodeStyleMainPanel.initTabs(CodeStyleConfig.kt:93)
	at com.intellij.application.options.TabbedLanguageCodeStylePanel.ensureTabs(TabbedLanguageCodeStylePanel.java:163)
	at com.intellij.application.options.TabbedLanguageCodeStylePanel.getPreviewText(TabbedLanguageCodeStylePanel.java:266)
	at com.intellij.application.options.CodeStyleAbstractPanel.createEditor(CodeStyleAbstractPanel.java:144)
	at com.intellij.application.options.CodeStyleAbstractPanel.<init>(CodeStyleAbstractPanel.java:105)
	at com.intellij.application.options.TabbedLanguageCodeStylePanel.<init>(TabbedLanguageCodeStylePanel.java:68)
	at cursive.formatter.codeStyle.ClojureCodeStyleMainPanel.<init>(CodeStyleConfig.kt:84)
	at cursive.formatter.codeStyle.ClojureCodeStyleConfigurable.createPanel(CodeStyleConfig.kt:446)
	at cursive.formatter.codeStyle.ClojureCodeStyleConfigurable.createPanel(CodeStyleConfig.kt:442)
	at com.intellij.application.options.CodeStyleAbstractConfigurable.createComponent(CodeStyleAbstractConfigurable.java:36)
	at com.intellij.application.options.codeStyle.NewCodeStyleSettingsPanel.<init>(NewCodeStyleSettingsPanel.java:32)
	at com.intellij.ConfigurableFactory$createCodeStyleConfigurable$codeStyleConfigurableWrapper$1.createPanel(ConfigurableFactory.kt:32)
	at com.intellij.application.options.codeStyle.CodeStyleMainPanel.ensurePanel(CodeStyleMainPanel.java:252)
	at com.intellij.application.options.codeStyle.CodeStyleMainPanel.ensureCurrentPanel(CodeStyleMainPanel.java:237)
	at com.intellij.application.options.codeStyle.CodeStyleMainPanel.highlightOptions(CodeStyleMainPanel.java:312)
	at com.intellij.application.options.CodeStyleConfigurableWrapper.lambda$enableSearch$0(CodeStyleConfigurableWrapper.java:167)
	at com.intellij.openapi.options.newEditor.SpotlightPainter.update(SpotlightPainter.java:75)
	at com.intellij.openapi.options.newEditor.SettingsEditor$6.updateNow(SettingsEditor.java:272)
	at com.intellij.openapi.options.newEditor.SettingsEditor.lambda$updateStatus$3(SettingsEditor.java:470)
	at com.intellij.util.concurrency.QueueProcessor.runSafely(QueueProcessor.java:240)
	at com.intellij.util.Alarm$Request.runSafely(Alarm.java:385)
	at com.intellij.util.Alarm$Request.run(Alarm.java:374)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at com.intellij.util.concurrency.SchedulingWrapper$MyScheduledFutureTask.run(SchedulingWrapper.java:220)
	at com.intellij.openapi.application.TransactionGuardImpl.runWithWritingAllowed(TransactionGuardImpl.java:214)
	at com.intellij.openapi.application.TransactionGuardImpl.access$200(TransactionGuardImpl.java:21)
	at com.intellij.openapi.application.TransactionGuardImpl$2.run(TransactionGuardImpl.java:196)
	at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:805)
	at com.intellij.openapi.application.impl.ApplicationImpl.lambda$invokeLater$4(ApplicationImpl.java:348)
	at com.intellij.openapi.application.impl.FlushQueue.doRun(FlushQueue.java:82)
	at com.intellij.openapi.application.impl.FlushQueue.runNextEvent(FlushQueue.java:131)
	at com.intellij.openapi.application.impl.FlushQueue.flushNow(FlushQueue.java:47)
	at com.intellij.openapi.application.impl.FlushQueue$FlushNow.run(FlushQueue.java:187)
	at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:313)
	at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:776)
	at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:727)
	at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:721)
	at java.base/java.security.AccessController.doPrivileged(Native Method)
	at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85)
	at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:746)
	at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:891)
	at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:760)
	at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$6(IdeEventQueue.java:447)
	at com.intellij.openapi.progress.impl.CoreProgressManager.computePrioritized(CoreProgressManager.java:818)
	at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$7(IdeEventQueue.java:446)
	at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:805)
	at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:492)
	at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203)
	at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124)
	at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:117)
	at java.desktop/java.awt.WaitDispatchSupport$2.run(WaitDispatchSupport.java:190)
	at java.desktop/java.awt.WaitDispatchSupport$4.run(WaitDispatchSupport.java:235)
	at java.desktop/java.awt.WaitDispatchSupport$4.run(WaitDispatchSupport.java:233)
	at java.base/java.security.AccessController.doPrivileged(Native Method)
	at java.desktop/java.awt.WaitDispatchSupport.enter(WaitDispatchSupport.java:233)
	at java.desktop/java.awt.Dialog.show(Dialog.java:1070)
	at com.intellij.openapi.ui.impl.DialogWrapperPeerImpl$MyDialog.show(DialogWrapperPeerImpl.java:701)
	at com.intellij.openapi.ui.impl.DialogWrapperPeerImpl.show(DialogWrapperPeerImpl.java:437)
	at com.intellij.openapi.ui.DialogWrapper.doShow(DialogWrapper.java:1671)
	at com.intellij.openapi.ui.DialogWrapper.show(DialogWrapper.java:1629)
	at com.intellij.ide.actions.ShowSettingsUtilImpl.showSettingsDialog(ShowSettingsUtilImpl.java:90)
	at com.intellij.ide.actions.ShowSettingsAction.perform(ShowSettingsAction.java:50)
	at com.intellij.ui.mac.MacOSApplicationProvider$Worker.lambda$initMacApplication$1(MacOSApplicationProvider.java:74)
	at com.intellij.ui.mac.MacOSApplicationProvider$Worker.lambda$submit$8(MacOSApplicationProvider.java:172)
	at com.intellij.openapi.application.TransactionGuardImpl.runWithWritingAllowed(TransactionGuardImpl.java:214)
	at com.intellij.openapi.application.TransactionGuardImpl.access$200(TransactionGuardImpl.java:21)
	at com.intellij.openapi.application.TransactionGuardImpl$2.run(TransactionGuardImpl.java:196)
	at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:805)
	at com.intellij.openapi.application.impl.ApplicationImpl.lambda$invokeLater$4(ApplicationImpl.java:348)
	at com.intellij.openapi.application.impl.FlushQueue.doRun(FlushQueue.java:82)
	at com.intellij.openapi.application.impl.FlushQueue.runNextEvent(FlushQueue.java:131)
	at com.intellij.openapi.application.impl.FlushQueue.flushNow(FlushQueue.java:47)
	at com.intellij.openapi.application.impl.FlushQueue$FlushNow.run(FlushQueue.java:187)
	at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:313)
	at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:776)
	at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:727)
	at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:721)
	at java.base/java.security.AccessController.doPrivileged(Native Method)
	at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85)
	at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:746)
	at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:891)
	at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:760)
	at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$6(IdeEventQueue.java:447)
	at com.intellij.openapi.progress.impl.CoreProgressManager.computePrioritized(CoreProgressManager.java:818)
	at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$7(IdeEventQueue.java:446)
	at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:805)
	at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:492)
	at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203)
	at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124)
	at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113)
	at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109)
	at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
	at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)

cfleming21:01:57

Hmm, that’s slightly different but seems related. Thanks, I’ll look at both.

1
cfleming22:01:17

Does restarting the IDE or just trying again work for either of you? This seems to be some weird constructor initialisation order problem, but I can’t figure it out.

wilkerlucio23:01:08

here its consistently reproducible

cfleming23:01:31

It’s very strange, I can’t reproduce it at all. Can you email me your .idea/codeStyles/Project.xml file?

cfleming23:01:00

Ideally after closing the project - not required to fully shut the IDE down though.

cfleming07:01:34

@U08BJGV6E Could you do that too please? Also if you could include the system info from About IntelliJ IDEA that would be great too, so I can see which plugins you have in common. I’m starting to think this might be related to a plugin conflict.

cfleming08:01:06

Also, I’m interested to know if this happens for you in all projects, or just a specific one?

imre08:01:11

Also consistently reproable here. I don't even need to have a project open for it, same happens from the Idea launch page

cfleming08:01:35

Ah yes, thanks. That is super weird then, if it doesn’t even need a project.

cfleming08:01:44

I’ll keep investigating.

imre08:01:51

thank you!

wilkerlucio14:01:27

@U0567Q30W just the delay, just tried to get my .idea/codeStyles/Project.xml but I can't find this file (looked at the project and at HOME)

imre14:01:12

I also noticed that I don't seem to be able to save changes to my repl run configs

cfleming20:01:40

@U08BJGV6E do you get an error?

imre20:01:16

no, just the Apply button stays grey and if I click on Run my changes don't get picked up

wilkerlucio20:01:44

in case it helpers, this is my system info:

IntelliJ IDEA 2021.3.1 (Ultimate Edition)
Build #IU-213.6461.79, built on December 28, 2021
Licensed to Wilker Lucio
Subscription is active until May 7, 2022.
Runtime version: 11.0.13+7-b1751.21 x86_64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
macOS 12.1
GC: G1 Young Generation, G1 Old Generation
Memory: 16384M
Cores: 16
Non-Bundled Plugins:
    net.sf.opk.avro-schema-support (203.1.2)
    net.seesharpsoft.intellij.plugins.csv (2.18.2)
    me.ihxq.acejump.lite (1.2)
    djblue.portal (0.20.1)
    com.wakatime.intellij.plugin (13.1.8)
    com.jetbrains.plugins.ini4idea (213.5744.190)
    com.intellij.plugins.watcher (213.6461.19)
    org.intellij.plugins.hcl (0.7.14)
    org.jetbrains.plugins.hocon (2021.1.0)
    com.intellij.apacheConfig (213.5744.190)
    org.asciidoctor.intellij.asciidoc (0.36.13)
    String Manipulation (8.25.203.5981.1)
    PlantUML integration (5.10.0)
    mobi.hsz.idea.gitignore (4.3.0)
    com.cursiveclojure.cursive (1.12.2-eap2-2021.3)
    com.github.shinichy.integrant (0.1.1)
    mdx.js (1.0.213)
    intellij.prettierJS (213.6461.6)
    com.intellij.tailwindcss (213.6461.6)
    com.intellij.lang.jsgraphql (3.1.2)
    aws.toolkit (1.37-213)
    com.dmarcotte.handlebars (213.5744.190)

Kotlin: 213-1.5.10-release-949-IJ6461.79

👍 1
cfleming20:01:52

Hmm, that’s weird, I don’t think anything else has changed there. I’ll check.

wilkerlucio20:01:15

@U0567Q30W is it weird that I can't find the xml config file? seems like its not getting generated here

cfleming20:01:19

@U066U8JQJ Maybe, which files do you have in your .idea folder in your project? Also, does this happen in all projects for you? Does it also happen if you don’t have projects open like imre?

wilkerlucio20:01:06

just tested: 1. closed IntelliJ 2. open intellij on the Welcome Screen 3. open settings from there 4. navigate to clojure code style

wilkerlucio20:01:10

this still had the same issue

cfleming20:01:03

Ok, although the exception is slightly different, I think you’re both seeing the same thing somehow.

wilkerlucio20:01:08

my .idea in a project

cfleming20:01:57

Thanks. So you have the Scheme under Code Style settings set to IDE, right?

imre20:01:26

I also have it set to IDE and this is what I see under .idea in a project:

cfleming21:01:57

Interesting, I wonder if that’s the problem, I’ll test that.

cfleming11:01:49

Hi guys, I have published a dev build, 1.12.2-dev1. Could you download it from here: https://plugins.jetbrains.com/plugin/8090-cursive/versions/dev and try it out? I’m pretty sure it will fix Wilker’s problem, and I hope it will fix Imre’s even though I don’t have a good explanation for it.

imre11:01:19

cheers, gonna try now

cfleming11:01:20

There is still another problem I’m working on where the settings aren’t serialised properly, but I will have to try to finish that off tomorrow.

imre11:01:12

nice, I can now load the clojure code style page on the welcome page

imre11:01:24

got an error when I opened a project right after: #23569

cfleming11:01:08

Ah yeah, that’s just because it’s a dev build.

cfleming11:01:37

I don’t think that should affect the other issue.

imre11:01:12

I also checked editing the repl run config

imre11:01:37

It appears I can edit and the apply button works

cfleming11:01:40

Still, that’s great news. I’m still not sure what the problem was, but it’s possibly related to Wilker’s problem (which was something else in the end.

imre11:01:21

My report yesterday probably wasn't complete: then I only tried to change the value of "allow parallel run" - and when that's the only change it still won't get applied

cfleming11:01:29

What is not working at the moment is saving the config when you modify code style settings - I’m working with JetBrains on that. As soon as I get it fixed I’ll get this out.

imre11:01:32

but it does together with say changing display name

cfleming11:01:41

Huh, interesting - I’ll check that out tomorrow too.

imre11:01:09

Thanks for the fix so far

cfleming11:01:09

Probably just that field is missing from the list of things to check to see whether the editor has modified the config.

cfleming11:01:40

No worries, hopefully I can get the full thing out tomorrow.

imre11:01:29

👍:skin-tone-3:

wilkerlucio13:01:42

its back! 😄

💯 1
wilkerlucio21:01:48

@U0567Q30W one thing though, I just tried to see if my imports where getting auto-organized, but they are not, the option is checked, but they still getting always add to the end of the :require (simple require structure, no reader conditions or fancy things)

cfleming22:01:20

@U066U8JQJ You’re talking about new ones being added by auto-require, right? Yes, that’s not there yet, it’s on the to-do list. What is new is that you can use the Optimise Imports action and it will sort out the ones that are there.

wilkerlucio22:01:01

ah, gotcha, thanks for the clarification

cfleming22:01:52

So you can run that right after an auto-require and it should put it in the right place.