1
0
mirror of https://github.com/chylex/IntelliJ-AceJump.git synced 2024-11-25 17:42:46 +01:00

Compare commits

..

4 Commits

Author SHA1 Message Date
e005983d4c
Set version to chylex-14 2023-11-17 08:56:13 +01:00
8f4d9748ad
Scroll after jumping in vim mode 2023-11-17 08:55:49 +01:00
76c6458ef4
Re-add action to go to declaration after jump 2023-11-17 08:52:46 +01:00
2f53e9da6d
Update for IdeaVIM chylex-20 2023-11-17 08:52:23 +01:00
4 changed files with 53 additions and 3 deletions

View File

@ -8,7 +8,7 @@ plugins {
} }
group = "org.acejump" group = "org.acejump"
version = "chylex-13" version = "chylex-14"
repositories { repositories {
mavenCentral() mavenCentral()
@ -21,7 +21,7 @@ kotlin {
intellij { intellij {
version.set("2023.2") version.set("2023.2")
updateSinceUntilBuild.set(false) updateSinceUntilBuild.set(false)
plugins.add("IdeaVIM:chylex-16") plugins.add("IdeaVIM:chylex-20")
pluginsRepositories { pluginsRepositories {
custom("https://intellij.chylex.com") custom("https://intellij.chylex.com")

View File

@ -1,5 +1,8 @@
package org.acejump.action package org.acejump.action
import com.intellij.openapi.actionSystem.ActionManager
import com.intellij.openapi.actionSystem.IdeActions
import com.intellij.openapi.application.ApplicationManager
import com.intellij.openapi.command.CommandProcessor import com.intellij.openapi.command.CommandProcessor
import com.intellij.openapi.command.UndoConfirmationPolicy import com.intellij.openapi.command.UndoConfirmationPolicy
import com.intellij.openapi.editor.Document import com.intellij.openapi.editor.Document
@ -9,6 +12,7 @@ import com.intellij.openapi.fileEditor.TextEditor
import com.intellij.openapi.fileEditor.ex.FileEditorManagerEx import com.intellij.openapi.fileEditor.ex.FileEditorManagerEx
import com.intellij.openapi.fileEditor.ex.IdeDocumentHistory import com.intellij.openapi.fileEditor.ex.IdeDocumentHistory
import com.intellij.openapi.project.Project import com.intellij.openapi.project.Project
import com.intellij.openapi.ui.playback.commands.ActionCommand
import org.acejump.search.SearchProcessor import org.acejump.search.SearchProcessor
/** /**
@ -49,6 +53,14 @@ sealed class AceTagAction {
caretModel.moveToOffset(offset) caretModel.moveToOffset(offset)
} }
fun performAction(actionName: String) {
val actionManager = ActionManager.getInstance()
val action = actionManager.getAction(actionName)
if (action != null) {
actionManager.tryToExecute(action, ActionCommand.getInputEvent(null), null, null, true)
}
}
fun ensureEditorFocused(editor: Editor) { fun ensureEditorFocused(editor: Editor) {
val project = editor.project ?: return val project = editor.project ?: return
val fem = FileEditorManagerEx.getInstanceEx(project) val fem = FileEditorManagerEx.getInstanceEx(project)
@ -81,4 +93,16 @@ sealed class AceTagAction {
return offset return offset
} }
} }
/**
* On default action, performs the Go To Declaration action, available via `Navigate | Declaration or Usages`.
* On shift action, performs the Go To Type Declaration action, available via `Navigate | Type Declaration`.
* Always places the caret at the start of the word.
*/
object GoToDeclaration : AceTagAction() {
override fun invoke(editor: Editor, searchProcessor: SearchProcessor, offset: Int, shiftMode: Boolean, isFinal: Boolean) {
JumpToSearchStart(editor, searchProcessor, offset, shiftMode = false, isFinal = isFinal)
ApplicationManager.getApplication().invokeLater { performAction(if (shiftMode) IdeActions.ACTION_GOTO_TYPE_DECLARATION else IdeActions.ACTION_GOTO_DECLARATION) }
}
}
} }

View File

@ -18,7 +18,10 @@ import com.maddyhome.idea.vim.helper.vimSelectionStart
import com.maddyhome.idea.vim.helper.vimStateMachine import com.maddyhome.idea.vim.helper.vimStateMachine
import com.maddyhome.idea.vim.newapi.vim import com.maddyhome.idea.vim.newapi.vim
import com.maddyhome.idea.vim.state.mode.SelectionType import com.maddyhome.idea.vim.state.mode.SelectionType
import org.acejump.boundaries.StandardBoundaries.* import org.acejump.boundaries.StandardBoundaries.AFTER_CARET
import org.acejump.boundaries.StandardBoundaries.BEFORE_CARET
import org.acejump.boundaries.StandardBoundaries.CARET_LINE
import org.acejump.boundaries.StandardBoundaries.VISIBLE_ON_SCREEN
import org.acejump.modes.JumpMode import org.acejump.modes.JumpMode
import org.acejump.search.Pattern import org.acejump.search.Pattern
import org.acejump.search.Tag import org.acejump.search.Tag
@ -83,6 +86,7 @@ sealed class AceVimAction : DumbAwareAction() {
} }
} }
injector.scroll.scrollCaretIntoView(editor.vim)
mode.finishSession(editor, session) mode.finishSession(editor, session)
return true return true
} }
@ -159,4 +163,25 @@ sealed class AceVimAction : DumbAwareAction() {
class JumpUWordEndBackward : AceVimAction() { class JumpUWordEndBackward : AceVimAction() {
override val mode = AceVimMode.JumpToPattern(Pattern.VIM_UWORD_END, BEFORE_CARET.intersection(VISIBLE_ON_SCREEN)) override val mode = AceVimMode.JumpToPattern(Pattern.VIM_UWORD_END, BEFORE_CARET.intersection(VISIBLE_ON_SCREEN))
} }
class JumpAllEditorsGoToDeclaration : DumbAwareAction() {
override fun update(action: AnActionEvent) {
action.presentation.isEnabled = action.getData(CommonDataKeys.EDITOR) != null
}
override fun actionPerformed(e: AnActionEvent) {
val editor = e.getData(CommonDataKeys.EDITOR) ?: return
val session = SessionManager.start(editor, AceVimMode.JumpAllEditors.getJumpEditors(editor))
session.defaultBoundary = VISIBLE_ON_SCREEN
session.startJumpMode {
object : JumpMode() {
override fun accept(state: SessionState, acceptedTag: Tag): Boolean {
state.act(AceTagAction.GoToDeclaration, acceptedTag, shiftMode = wasUpperCase, isFinal = true)
return true
}
}
}
}
}
} }

View File

@ -30,6 +30,7 @@
<actions> <actions>
<action id="AceVimAction_JumpAllEditors" class="org.acejump.action.AceVimAction$JumpAllEditors" text="AceJump Vim - Jump All Editors" /> <action id="AceVimAction_JumpAllEditors" class="org.acejump.action.AceVimAction$JumpAllEditors" text="AceJump Vim - Jump All Editors" />
<action id="AceVimAction_JumpAllEditors_GoToDeclaration" class="org.acejump.action.AceVimAction$JumpAllEditorsGoToDeclaration" text="AceJump Vim - Jump All Editors - Go To Declaration" />
<action id="AceVimAction_JumpForward" class="org.acejump.action.AceVimAction$JumpForward" text="AceJump Vim - Jump Forward" /> <action id="AceVimAction_JumpForward" class="org.acejump.action.AceVimAction$JumpForward" text="AceJump Vim - Jump Forward" />
<action id="AceVimAction_JumpBackward" class="org.acejump.action.AceVimAction$JumpBackward" text="AceJump Vim - Jump Backward" /> <action id="AceVimAction_JumpBackward" class="org.acejump.action.AceVimAction$JumpBackward" text="AceJump Vim - Jump Backward" />
<action id="AceVimAction_JumpTillForward" class="org.acejump.action.AceVimAction$JumpTillForward" text="AceJump Vim - Jump Till Forward" /> <action id="AceVimAction_JumpTillForward" class="org.acejump.action.AceVimAction$JumpTillForward" text="AceJump Vim - Jump Till Forward" />