Fork me on GitHub
#lsp
<
2022-11-24
>
dharrigan19:11:34

Sorta related to the thread in clojure

dharrigan19:11:37

When I ask clojure-lsp to create a new function (that doesn't exist) in a namespace, it puts the arguments beside the funtion name

dharrigan19:11:49

can that be configured so as to pop it on the next line?

dharrigan19:11:17

i.e., from (defn foo [x y] ...) to:

ericdallo19:11:28

IIRC if the function is preivar it should create in the next line, so maybe we are not follow the same standard

dharrigan19:11:30

(defn foo
  [x y]

ericdallo19:11:01

Yeah, I like the always on next line choice and only create a option for same line if requested that much

ericdallo19:11:02

Me and @brcosta are considering creating a IntelliJ plugin that fully uses clojure-lsp and only that, with that we'd have all/most used editors option to use clojure-lsp :) More on 🧵

❤️ 3
ericdallo19:11:10

I know there is a new IDEA's editor on the horizon, but it seems it will take some time for most clojure Intellij users migrate to that (if that will happen) About the clojure-lsp plugin, for that to happen, there is a issue: Intellij plugins can only be created in kotlin/java or scala AFAIK, and I'd really like to do it in Clojure. I thought about creating a generic intellij plugin that allows you to create plugins in Clojure, just like exists for Scala (maybe simpler) I tried to first create ahttps://github.com/ericdallo/clojure-idea-plugin-example and build a jar which I could import on Intellij which would be the first step, and couldn't make that work, it seems intellij recognize the plugin properly (plugin.xml on META-INF), but crashes when try to read clojure stack:

com.intellij.diagnostic.PluginException:  [Plugin: com.github.ericdallo.clojure_idea_plugin_example]
	at com.intellij.openapi.actionSystem.impl.ActionManagerImpl.instantiate(ActionManagerImpl.java:251)
	at com.intellij.openapi.actionSystem.impl.ActionManagerImpl.convertStub(ActionManagerImpl.java:221)
	at com.intellij.openapi.actionSystem.impl.ActionManagerImpl.getActionImpl(ActionManagerImpl.java:570)
	at com.intellij.openapi.actionSystem.impl.ActionManagerImpl.getAction(ActionManagerImpl.java:558)
	at com.intellij.openapi.actionSystem.DefaultActionGroup.unStub(DefaultActionGroup.java:393)
	at com.intellij.openapi.actionSystem.DefaultActionGroup.getChildren(DefaultActionGroup.java:352)
	at com.intellij.openapi.actionSystem.ActionGroupStub.initGroup(ActionGroupStub.kt:34)
	at com.intellij.openapi.actionSystem.impl.ActionManagerImpl.convertGroupStub(ActionManagerImpl.java:278)
	at com.intellij.openapi.actionSystem.impl.ActionManagerImpl.getActionImpl(ActionManagerImpl.java:570)
	at com.intellij.openapi.actionSystem.impl.ActionManagerImpl.getAction(ActionManagerImpl.java:558)
	at com.intellij.openapi.actionSystem.DefaultActionGroup.unStub(DefaultActionGroup.java:393)
	at com.intellij.openapi.actionSystem.DefaultActionGroup.getChildren(DefaultActionGroup.java:352)
	at com.intellij.openapi.actionSystem.DefaultActionGroup.getChildren(DefaultActionGroup.java:331)
	at com.intellij.ide.ui.customization.CustomizationUtil.getReordableChildren(CustomizationUtil.java:67)
	at com.intellij.ide.ui.customization.CustomisedActionGroup.getChildren(CustomisedActionGroup.java:43)
	at com.intellij.openapi.wm.impl.IdeMenuBar.expandActionGroup(IdeMenuBar.java:466)
	at com.intellij.openapi.wm.impl.IdeMenuBar.doUpdateMenuActions(IdeMenuBar.java:371)
	at com.intellij.openapi.wm.impl.IdeMenuBar.lambda$addNotify$2(IdeMenuBar.java:275)
	at com.intellij.openapi.wm.impl.IdeMenuBar.lambda$doWithLazyActionManager$3(IdeMenuBar.java:288)
	at com.intellij.openapi.application.TransactionGuardImpl$2.run(TransactionGuardImpl.java:201)
	at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:822)
	at com.intellij.openapi.application.impl.ApplicationImpl.lambda$invokeLater$4(ApplicationImpl.java:324)
	at com.intellij.openapi.application.impl.FlushQueue.doRun(FlushQueue.java:85)
	at com.intellij.openapi.application.impl.FlushQueue.runNextEvent(FlushQueue.java:134)
	at com.intellij.openapi.application.impl.FlushQueue.flushNow(FlushQueue.java:47)
	at com.intellij.openapi.application.impl.FlushQueue$FlushNow.run(FlushQueue.java:190)
	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:976)
	at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:843)
	at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$8(IdeEventQueue.java:454)
	at com.intellij.openapi.progress.impl.CoreProgressManager.computePrioritized(CoreProgressManager.java:773)
	at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$9(IdeEventQueue.java:453)
	at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:822)
	at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:501)
	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)
Caused by: java.lang.ExceptionInInitializerError
	at clojure.lang.Namespace.<init>(Namespace.java:34)
	at clojure.lang.Namespace.findOrCreate(Namespace.java:176)
	at clojure.lang.Var.internPrivate(Var.java:156)
	at com.github.ericdallo.clojure_idea_plugin_example.actions.MyAction.<clinit>(Unknown Source)
	at java.base/java.lang.Class.forName0(Native Method)
	at java.base/java.lang.Class.forName(Class.java:398)
	at com.intellij.openapi.actionSystem.impl.ActionManagerImpl.instantiate(ActionManagerImpl.java:234)
	... 45 more
Caused by: java.io.FileNotFoundException: Could not locate clojure/core__init.class, clojure/core.clj or clojure/core.cljc on classpath.
	at clojure.lang.RT.load(RT.java:462)
	at clojure.lang.RT.load(RT.java:424)
	at clojure.lang.RT.<clinit>(RT.java:338)
	... 52 more
which is weird because I built a uberjar with clojure code inside, am I missing anything? I feel like is this close to work

Noah Bogart20:11:07

Alternative to Cursive?

ericdallo20:11:11

I was thinking about focusing on static analysis using LSP, so one maybe could use Cursive only for REPL, similar to Cider and lsp-mode for Emacs. Would need to discuss with @U0567Q30W probably if that would work

👍 2
R.A. Porter20:11:47

The IJ plugin for Portal is written mostly in Clojure, so it's certainly possible. https://github.com/djblue/portal/tree/master/extension-intellij

salam20:11:36

Not exactly the same thing as you’re building, but I figured I’d mention https://github.com/gregsh/Clojure-Kit just in case it comes in handy in building your plug-in. 🙂

ericdallo20:11:33

@U01GXCWSRMW that's really interesting, it seems it load clojure on the java file, seems like a alternative approach indeed if mine doesn't work in the end, thank you! @UDCGPTV9R thanks, I will surely check that from time to time to check how use IJ apis :)