This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-01-18
Channels
- # announcements (6)
- # aws (1)
- # babashka (47)
- # beginners (50)
- # calva (65)
- # cider (4)
- # clj-commons (1)
- # clj-kondo (44)
- # clojure (150)
- # clojure-europe (41)
- # clojure-nl (4)
- # clojure-spec (1)
- # clojure-sweden (4)
- # clojure-uk (6)
- # clojurescript (15)
- # clr (1)
- # conjure (1)
- # core-async (7)
- # cursive (5)
- # datomic (12)
- # events (2)
- # fulcro (17)
- # graphql (12)
- # introduce-yourself (1)
- # jackdaw (5)
- # jobs (2)
- # lsp (52)
- # malli (5)
- # meander (3)
- # minecraft (2)
- # missionary (2)
- # off-topic (10)
- # other-languages (9)
- # reitit (9)
- # remote-jobs (1)
- # ring (8)
- # rum (7)
- # shadow-cljs (9)
- # sql (2)
- # tools-deps (20)
- # xtdb (12)
It’s possble to use `f` as ‘form’ for selecting in visual mode in spacemacs (by default) and vim (with https://github.com/guns/vim-sexp). For example, typing `daf` in visual mode will delete a form (“text”, (…), […}, {…}) under the cursor. Is it possible to achieve something like this in idea with cursive?
managed to solve it with Idea LivePlugin
import com.intellij.openapi.actionSystem.CommonDataKeys
import liveplugin.registerAction
import liveplugin.show
show("Current project: ${project?.name}")
registerAction("SelectForm", "ctrl alt shift W", function = { event ->
val project = event.project
val editor = CommonDataKeys.EDITOR.getData(event.dataContext)
if (project == null || editor == null) [email protected]
val actionManager = com.intellij.openapi.actionSystem.ActionManager.getInstance()
val actionEditorMatchBrace = actionManager.getAction("EditorMatchBrace")
actionEditorMatchBrace.actionPerformed(event)
val formStart = editor.caretModel.offset
actionEditorMatchBrace.actionPerformed(event)
val formEnd = editor.caretModel.offset
editor.selectionModel.setSelection(formStart, formEnd)
})
if (!isIdeStartup) show("Loaded 'insertClojureComment' action<br/>Use 'Ctrl+Alt+Shift+W' to run it")
does anyone use some shortcut to insert a #_ comment on any form under a cursor with `idea/cursive`? originally asked https://clojurians.slack.com/archives/C053AK3F9/p1642494215468300
managed to solve it with idea LivePlugin + ideavim ideavimrc part:
nnoremap <Leader>c :action insertClojureCommentAtTheFormStart<cr>
live plugin part
import com.intellij.openapi.actionSystem.CommonDataKeys
import com.intellij.openapi.editor.Document
import liveplugin.executeCommand
import liveplugin.registerAction
import liveplugin.show
import kotlin.math.max
show("Current project: ${project?.name}")
registerAction("insertClojureCommentAtTheFormStart", function = { event ->
val project = event.project
val editor = CommonDataKeys.EDITOR.getData(event.dataContext)
if (project == null || editor == null) [email protected]
val actionManager = com.intellij.openapi.actionSystem.ActionManager.getInstance()
val document = editor.document
val caretIndex = editor.caretModel.offset
val currentChar = document.text[caretIndex]
val startFormChars = charArrayOf('"', '(', '{', '[')
if (currentChar.isLetterOrDigit() && isPreviousEmpty(document, caretIndex)) { //beginning of a word
/* just insert here */
} else if (startFormChars.contains(currentChar)) {
/* just insert here */
} else {
val actionEditorMatchBrace = actionManager.getAction(":cursive.actions.paredit/backward-up")
actionEditorMatchBrace.actionPerformed(event)
}
document.executeCommand(project, "insertClojureCommentAtTheFormStart") {
document.insertString(editor.caretModel.offset, "#_")
}
})
fun isPreviousEmpty(document: Document, caretIndex: Int) =
document.text[max(caretIndex - 1, 0)] == ' '
hey all! would anyone be able to recommend the best way to debug a lein middleware issue? for context: i'm unable to sync a project in cursive with the error log saying it's unable to resolve the middleware function. the middleware works fine when calling lein from the CLI or if i create a lein run configuration.