diff options
| -rw-r--r-- | .run/Run IDE with Plugin.run.xml | 24 | ||||
| -rw-r--r-- | README.md | 85 | ||||
| -rw-r--r-- | settings.gradle.kts | 2 | ||||
| -rw-r--r-- | src/main/kotlin/me/kyren223/harpoonforjb/HarpoonQuickMenuSelectAction.kt | 14 | ||||
| -rw-r--r-- | src/main/kotlin/me/kyren223/harpoonforjb/SettingsData.kt | 58 | ||||
| -rw-r--r-- | src/main/kotlin/me/kyren223/trident/AppSettingsConfigurable.kt (renamed from src/main/kotlin/me/kyren223/harpoonforjb/AppSettingsConfigurable.kt) | 28 | ||||
| -rw-r--r-- | src/main/kotlin/me/kyren223/trident/AppSettingsState.kt (renamed from src/main/kotlin/me/kyren223/harpoonforjb/AppSettingsState.kt) | 12 | ||||
| -rw-r--r-- | src/main/kotlin/me/kyren223/trident/SettingsData.kt | 58 | ||||
| -rw-r--r-- | src/main/kotlin/me/kyren223/trident/TridentAppendAction.kt (renamed from src/main/kotlin/me/kyren223/harpoonforjb/HarpoonAppendAction.kt) | 6 | ||||
| -rw-r--r-- | src/main/kotlin/me/kyren223/trident/TridentQuickMenu.kt (renamed from src/main/kotlin/me/kyren223/harpoonforjb/HarpoonQuickMenu.kt) | 16 | ||||
| -rw-r--r-- | src/main/kotlin/me/kyren223/trident/TridentQuickMenuSelectAction.kt | 11 | ||||
| -rw-r--r-- | src/main/kotlin/me/kyren223/trident/TridentSelectAction.kt (renamed from src/main/kotlin/me/kyren223/harpoonforjb/HarpoonSelectAction.kt) | 21 | ||||
| -rw-r--r-- | src/main/kotlin/me/kyren223/trident/TridentState.kt (renamed from src/main/kotlin/me/kyren223/harpoonforjb/HarpoonState.kt) | 22 | ||||
| -rw-r--r-- | src/main/kotlin/me/kyren223/trident/TridentToggleQuickMenuAction.kt (renamed from src/main/kotlin/me/kyren223/harpoonforjb/HarpoonToggleQuickMenuAction.kt) | 12 | ||||
| -rw-r--r-- | src/main/resources/META-INF/Trident-IdeaVim.xml (renamed from src/main/resources/META-INF/HarpoonForJB-IdeaVim.xml) | 0 | ||||
| -rw-r--r-- | src/main/resources/META-INF/plugin.xml | 92 |
16 files changed, 217 insertions, 244 deletions
diff --git a/.run/Run IDE with Plugin.run.xml b/.run/Run IDE with Plugin.run.xml deleted file mode 100644 index 7747a29..0000000 --- a/.run/Run IDE with Plugin.run.xml +++ /dev/null @@ -1,24 +0,0 @@ -<component name="ProjectRunConfigurationManager"> - <configuration default="false" name="Run Plugin" type="GradleRunConfiguration" factoryName="Gradle"> - <log_file alias="idea.log" path="$PROJECT_DIR$/build/idea-sandbox/system/log/idea.log"/> - <ExternalSystemSettings> - <option name="executionName"/> - <option name="externalProjectPath" value="$PROJECT_DIR$"/> - <option name="externalSystemIdString" value="GRADLE"/> - <option name="scriptParameters" value=""/> - <option name="taskDescriptions"> - <list/> - </option> - <option name="taskNames"> - <list> - <option value="runIde"/> - </list> - </option> - <option name="vmOptions" value=""/> - </ExternalSystemSettings> - <ExternalSystemDebugServerProcess>true</ExternalSystemDebugServerProcess> - <ExternalSystemReattachDebugProcess>true</ExternalSystemReattachDebugProcess> - <DebugAllEnabled>false</DebugAllEnabled> - <method v="2"/> - </configuration> -</component>
\ No newline at end of file @@ -1,7 +1,9 @@ <div align="center"> -# Harpoon for JetBrains -##### Getting you where you want with the fewest keystrokes. +# Trident +##### Effortless file traversal to minimize keystrokes and maximize productivity + +[](https://github.com/Kyren223/Trident/releases/tag/1.0) </div> ## Table of Contents @@ -14,80 +16,83 @@ * [Contact](#contact) ## Description -This plugin is inspired by the original [Harpoon](https://github.com/ThePrimeagen/harpoon) NeoVim plugin by ThePrimeagen -but aims to provide the same functionality for JetBrains IDEs. +Trident is a plugin for JetBrains IDEs that allows you to quickly navigate to your most used files with as few keystrokes as possible. + +The plugin is inspired by the [Harpoon](https://github.com/ThePrimeagen/harpoon) NeoVim plugin by ThePrimeagen but aims to add additional features and proper integration with the IDE. ## Features * Navigate to your most used files with a single keystroke. -* Easily append files to your Harpoon list. +* Easily append files to a per-project list for fast access. * Quick Menu - * Select a file from your Harpoon list and open it. - * Delete a file from your Harpoon list. - * Reorder / Move files in your Harpoon list. - * Add / Insert files to your Harpoon list. + * Select a file from the list and open it. + * Delete a file from the list. + * Reorder / Move files in the list. + * Add / Insert files to the list. * Project-relative file paths using `...` syntax. -* Per-project Harpoon lists. -* Configurable Vim & IDE keymaps for all actions. +* Per-project lists. +* Configurable IdeaVim and IDE keymaps for all actions. ## Installation * Version 2023.1 or later of any IntelliJ-based IDE is required. -* Install the plugin from the [JetBrains Marketplace](https://plugins.jetbrains.com/plugin/23771-harpoonforjb). +* Install the plugin from the [JetBrains Marketplace](https://plugins.jetbrains.com/plugin/23771-trident). ## Getting Started +* All actions can be mapped to IDE keymaps like usual, the examples below are for IdeaVim only. +* Make sure to download IdeaVim if you want to configure the keymaps via .ideavimrc ### Example .ideavimrc Configuration ```vimrc -" Append the current file to the Harpoon list -map <leader>a :action HarpoonAppend<CR> +" Append the current file to the list +map <leader>a :action TridentAppend<CR> -" Open the Harpoon quick menu -map <C-h> :action HarpoonToggleQuickMenu<CR> +" Open the quick menu +map <C-h> :action TridentToggleQuickMenu<CR> " Select the given file (from the Quick Menu) and open it -map <leader>o :action HarpoonQuickMenuSelect<CR> +map <leader>o :action TridentQuickMenuSelect<CR> -" Hotkeys to open the first 4 items in the Harpoon list -map <C-h> :action HarpoonSelect1<CR> -map <C-t> :action HarpoonSelect2<CR> -map <C-n> :action HarpoonSelect3<CR> -map <C-s> :action HarpoonSelect4<CR> +" Hotkeys to open the first 4 items in the list +map <C-h> :action TridentSelect1<CR> +map <C-t> :action TridentSelect2<CR> +map <C-n> :action TridentSelect3<CR> +map <C-s> :action TridentSelect4<CR> -" Toggle previous & next buffers stored within Harpoon list -map <C-S-P> :action HarpoonSelectPrev<CR> -map <C-S-N> :action HarpoonSelectNext<CR> +" Toggle previous & next buffers stored within the list +map <C-S-P> :action TridentSelectPrev<CR> +map <C-S-N> :action TridentSelectNext<CR> ``` ### My .ideavimrc Configuration ```vimrc -map <leader>a :action HarpoonAppend<CR> -map <C-e> :action HarpoonToggleQuickMenu<CR> +map <leader>a :action TridentAppend<CR> +map <C-e> :action TridentToggleQuickMenu<CR> " I am Using "Enter" from settings so no need to map it here -map <C-1> :action HarpoonSelect1<CR> -map <C-2> :action HarpoonSelect2<CR> -map <C-3> :action HarpoonSelect3<CR> -map <C-4> :action HarpoonSelect4<CR> +map <C-1> :action TridentSelect1<CR> +map <C-2> :action TridentSelect2<CR> +map <C-3> :action TridentSelect3<CR> +map <C-4> :action TridentSelect4<CR> ``` ### Settings **Descriptions** -* Harpoon Width - Describes how wide the Harpoon Quick Menu should be. -* Harpoon Height - Describes how tall the Harpoon Quick Menu -* Harpoon Font Size - Describes the font size of the Harpoon Quick Menu -* Enter - When checked the Harpoon Quick Menu will open the file when you press enter, otherwise it will look for your .ideavimrc file for the keybinding. +* Width - Describes how wide the Quick Menu should be. +* Height - Describes how tall the Quick Menu +* Font Size - Describes the font size of the Quick Menu +* Enter to select - When checked the Quick Menu will open the file when you press enter, otherwise it will look for your .ideavimrc file for the keybinding. **Defaults** -* Harpoon Width - 800 -* Harpoon Height - 400 -* Harpoon Font Size - 20 -* Enter - true +* Width - 800 +* Height - 400 +* Font Size - 20 +* Enter to select - true ## Contribution This plugin is open-source and contributions are welcome. -Note to beginners or first-time contributors: I recommend starting by going to the issues tab and looking for issues to work on. +I recommend looking at the issues tab or the [TODO.md](TODO.md) file for ideas on what to work on. ### Steps to contribute 1. Fork the repository. diff --git a/settings.gradle.kts b/settings.gradle.kts index d2d2145..dc1ca73 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -5,5 +5,5 @@ pluginManagement { } } -rootProject.name = "HarpoonForJB" +rootProject.name = "Trident (Harpoon)" include("IdeaVIM")
\ No newline at end of file diff --git a/src/main/kotlin/me/kyren223/harpoonforjb/HarpoonQuickMenuSelectAction.kt b/src/main/kotlin/me/kyren223/harpoonforjb/HarpoonQuickMenuSelectAction.kt deleted file mode 100644 index 8ba8c6c..0000000 --- a/src/main/kotlin/me/kyren223/harpoonforjb/HarpoonQuickMenuSelectAction.kt +++ /dev/null @@ -1,14 +0,0 @@ -package me.kyren223.harpoonforjb - -import com.intellij.openapi.actionSystem.AnAction -import com.intellij.openapi.actionSystem.AnActionEvent -import com.maddyhome.idea.vim.api.injector -import com.maddyhome.idea.vim.command.MappingMode -import com.maddyhome.idea.vim.key.MappingOwner.Plugin.Companion.get - -class HarpoonQuickMenuSelectAction : AnAction() { - override fun actionPerformed(e: AnActionEvent) { - HarpoonState.quickMenuSelect() - } - -} diff --git a/src/main/kotlin/me/kyren223/harpoonforjb/SettingsData.kt b/src/main/kotlin/me/kyren223/harpoonforjb/SettingsData.kt deleted file mode 100644 index 3e0c60f..0000000 --- a/src/main/kotlin/me/kyren223/harpoonforjb/SettingsData.kt +++ /dev/null @@ -1,58 +0,0 @@ -package me.kyren223.harpoonforjb - -import com.intellij.ui.JBIntSpinner -import com.intellij.ui.components.JBCheckBox -import com.intellij.ui.components.JBLabel -import com.intellij.util.ui.FormBuilder -import javax.swing.JPanel - -class SettingsData { - - val panel: JPanel - private val harpoonWidth: JBIntSpinner = JBIntSpinner(800, 1, 5000, 10) - private val harpoonHeight: JBIntSpinner = JBIntSpinner(400, 1, 5000, 10) - private val harpoonFontSize: JBIntSpinner = JBIntSpinner(20, 1, 100) - private val harpoonEnter: JBCheckBox = JBCheckBox() - - init { - panel = FormBuilder.createFormBuilder() - .addLabeledComponent(JBLabel("Harpoon width"), harpoonWidth, 1, false) - .addLabeledComponent(JBLabel("Harpoon height"), harpoonHeight, 1, false) - .addLabeledComponent(JBLabel("Harpoon font size"), harpoonFontSize, 1, false) - .addLabeledComponent(JBLabel("Press enter to select item in the QuickMenu"), harpoonEnter, 1, false) - .addComponentFillVertically(JPanel(), 0) - .panel - } - - fun getHarpoonWidth(): Int { - return harpoonWidth.number - } - - fun getHarpoonHeight(): Int { - return harpoonHeight.number - } - - fun getHarpoonFontSize(): Int { - return harpoonFontSize.number - } - - fun getHarpoonEnterToSelect(): Boolean { - return harpoonEnter.isSelected - } - - fun setHarpoonWidth(width: Int) { - harpoonWidth.number = width - } - - fun setHarpoonHeight(height: Int) { - harpoonHeight.number = height - } - - fun setHarpoonFontSize(fontSize: Int) { - harpoonFontSize.number = fontSize - } - - fun setHarpoonEnterToSelect(enter: Boolean) { - harpoonEnter.isSelected = enter - } -} diff --git a/src/main/kotlin/me/kyren223/harpoonforjb/AppSettingsConfigurable.kt b/src/main/kotlin/me/kyren223/trident/AppSettingsConfigurable.kt index 4ece20e..e04b3b8 100644 --- a/src/main/kotlin/me/kyren223/harpoonforjb/AppSettingsConfigurable.kt +++ b/src/main/kotlin/me/kyren223/trident/AppSettingsConfigurable.kt @@ -1,5 +1,5 @@ // Copyright 2000-2022 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. -package me.kyren223.harpoonforjb +package me.kyren223.trident import com.intellij.openapi.options.Configurable import com.intellij.openapi.util.NlsContexts.ConfigurableName @@ -8,7 +8,7 @@ import javax.swing.JComponent class AppSettingsConfigurable : Configurable { private var settings: SettingsData? = null override fun getDisplayName(): @ConfigurableName String { - return "HarpoonForJB Settings" + return "Trident Settings" } override fun createComponent(): JComponent { @@ -18,19 +18,19 @@ class AppSettingsConfigurable : Configurable { override fun isModified(): Boolean { val settings = AppSettingsState.instance - if (settings.harpoonWidth != this.settings!!.getHarpoonWidth()) return true - if (settings.harpoonHeight != this.settings!!.getHarpoonHeight()) return true - if (settings.harpoonFontSize != this.settings!!.getHarpoonFontSize()) return true - if (settings.harpoonEnterToSelect != this.settings!!.getHarpoonEnterToSelect()) return true + if (settings.width != this.settings!!.getWidth()) return true + if (settings.height != this.settings!!.getHeight()) return true + if (settings.fontSize != this.settings!!.getFontSize()) return true + if (settings.enterToSelect != this.settings!!.getEnterToSelect()) return true return false } override fun apply() { val settings = AppSettingsState.instance - settings.harpoonWidth = this.settings!!.getHarpoonWidth() - settings.harpoonHeight = this.settings!!.getHarpoonHeight() - settings.harpoonFontSize = this.settings!!.getHarpoonFontSize() - settings.harpoonEnterToSelect = this.settings!!.getHarpoonEnterToSelect() + settings.width = this.settings!!.getWidth() + settings.height = this.settings!!.getHeight() + settings.fontSize = this.settings!!.getFontSize() + settings.enterToSelect = this.settings!!.getEnterToSelect() } override fun reset() { @@ -38,10 +38,10 @@ class AppSettingsConfigurable : Configurable { if (this.settings == null) { this.settings = SettingsData() } - this.settings!!.setHarpoonWidth(settings.harpoonWidth) - this.settings!!.setHarpoonHeight(settings.harpoonHeight) - this.settings!!.setHarpoonFontSize(settings.harpoonFontSize) - this.settings!!.setHarpoonEnterToSelect(settings.harpoonEnterToSelect) + this.settings!!.setWidth(settings.width) + this.settings!!.setHeight(settings.height) + this.settings!!.setFontSize(settings.fontSize) + this.settings!!.setEnterToSelect(settings.enterToSelect) } override fun disposeUIResources() { diff --git a/src/main/kotlin/me/kyren223/harpoonforjb/AppSettingsState.kt b/src/main/kotlin/me/kyren223/trident/AppSettingsState.kt index ea3eabd..6d61ea0 100644 --- a/src/main/kotlin/me/kyren223/harpoonforjb/AppSettingsState.kt +++ b/src/main/kotlin/me/kyren223/trident/AppSettingsState.kt @@ -1,4 +1,4 @@ -package me.kyren223.harpoonforjb +package me.kyren223.trident import com.intellij.openapi.application.ApplicationManager import com.intellij.openapi.components.PersistentStateComponent @@ -7,13 +7,13 @@ import com.intellij.openapi.components.Storage import com.intellij.util.xmlb.XmlSerializerUtil // Copyright 2000-2022 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. -@State(name = "me.kyren223.harpoonforjb.AppSettingsState", storages = [Storage("SdkSettingsPlugin.xml")]) +@State(name = "me.kyren223.trident.AppSettingsState", storages = [Storage("SdkSettingsPlugin.xml")]) class AppSettingsState : PersistentStateComponent<AppSettingsState?> { - var harpoonEnterToSelect = true - var harpoonWidth = 800 - var harpoonHeight = 400 - var harpoonFontSize = 20 + var enterToSelect = true + var width = 800 + var height = 400 + var fontSize = 20 override fun getState(): AppSettingsState { return this diff --git a/src/main/kotlin/me/kyren223/trident/SettingsData.kt b/src/main/kotlin/me/kyren223/trident/SettingsData.kt new file mode 100644 index 0000000..89ca91a --- /dev/null +++ b/src/main/kotlin/me/kyren223/trident/SettingsData.kt @@ -0,0 +1,58 @@ +package me.kyren223.trident + +import com.intellij.ui.JBIntSpinner +import com.intellij.ui.components.JBCheckBox +import com.intellij.ui.components.JBLabel +import com.intellij.util.ui.FormBuilder +import javax.swing.JPanel + +class SettingsData { + + val panel: JPanel + private val width: JBIntSpinner = JBIntSpinner(800, 1, 5000, 10) + private val height: JBIntSpinner = JBIntSpinner(400, 1, 5000, 10) + private val fontSize: JBIntSpinner = JBIntSpinner(20, 1, 100) + private val enterToSelect: JBCheckBox = JBCheckBox() + + init { + panel = FormBuilder.createFormBuilder() + .addLabeledComponent(JBLabel("QuickMenu width"), width, 1, false) + .addLabeledComponent(JBLabel("QuickMenu height"), height, 1, false) + .addLabeledComponent(JBLabel("QuickMenu font size"), fontSize, 1, false) + .addLabeledComponent(JBLabel("Enter to select item in the QuickMenu"), enterToSelect, 1, false) + .addComponentFillVertically(JPanel(), 0) + .panel + } + + fun getWidth(): Int { + return width.number + } + + fun getHeight(): Int { + return height.number + } + + fun getFontSize(): Int { + return fontSize.number + } + + fun getEnterToSelect(): Boolean { + return enterToSelect.isSelected + } + + fun setWidth(width: Int) { + this.width.number = width + } + + fun setHeight(height: Int) { + this.height.number = height + } + + fun setFontSize(fontSize: Int) { + this.fontSize.number = fontSize + } + + fun setEnterToSelect(enter: Boolean) { + this.enterToSelect.isSelected = enter + } +} diff --git a/src/main/kotlin/me/kyren223/harpoonforjb/HarpoonAppendAction.kt b/src/main/kotlin/me/kyren223/trident/TridentAppendAction.kt index 724f6c8..621b9cd 100644 --- a/src/main/kotlin/me/kyren223/harpoonforjb/HarpoonAppendAction.kt +++ b/src/main/kotlin/me/kyren223/trident/TridentAppendAction.kt @@ -1,4 +1,4 @@ -package me.kyren223.harpoonforjb +package me.kyren223.trident import com.intellij.openapi.actionSystem.AnAction import com.intellij.openapi.actionSystem.AnActionEvent @@ -6,10 +6,10 @@ import com.intellij.openapi.actionSystem.PlatformDataKeys import com.intellij.openapi.project.Project import com.intellij.openapi.vfs.VirtualFile -class HarpoonAppendAction : AnAction() { +class TridentAppendAction : AnAction() { override fun actionPerformed(e: AnActionEvent) { val project: Project = e.project ?: return val file: VirtualFile = e.getData(PlatformDataKeys.VIRTUAL_FILE) ?: return - HarpoonState.appendFile(project, file) + TridentState.appendFile(project, file) } } diff --git a/src/main/kotlin/me/kyren223/harpoonforjb/HarpoonQuickMenu.kt b/src/main/kotlin/me/kyren223/trident/TridentQuickMenu.kt index 3417d7c..e7903e0 100644 --- a/src/main/kotlin/me/kyren223/harpoonforjb/HarpoonQuickMenu.kt +++ b/src/main/kotlin/me/kyren223/trident/TridentQuickMenu.kt @@ -1,6 +1,6 @@ @file:Suppress("SameParameterValue") -package me.kyren223.harpoonforjb +package me.kyren223.trident import com.intellij.openapi.editor.LogicalPosition import com.intellij.openapi.ui.DialogWrapper @@ -14,13 +14,13 @@ import java.awt.event.FocusEvent import java.awt.event.FocusListener import javax.swing.JComponent -class HarpoonQuickMenu(private val content: String) : DialogWrapper(true) { +class TridentQuickMenu(private val content: String) : DialogWrapper(true) { private lateinit var editorTextField: EditorTextField init { val settings = AppSettingsState.instance - this.title = "Harpoon Quick Menu" - setSize(settings.harpoonWidth, settings.harpoonHeight) + this.title = "Trident Quick Menu" + setSize(settings.width, settings.height) super.init() } @@ -29,7 +29,7 @@ class HarpoonQuickMenu(private val content: String) : DialogWrapper(true) { editorTextField = EditorTextField(this.content) editorTextField.setOneLineMode(false) editorTextField.addSettingsProvider { - it.setFontSize(settings.harpoonFontSize) + it.setFontSize(settings.fontSize) it.isInsertMode = true it.caretModel.moveToLogicalPosition(LogicalPosition(0, 0)) it.settings.isLineNumbersShown = true @@ -58,17 +58,17 @@ class HarpoonQuickMenu(private val content: String) : DialogWrapper(true) { fun select() { if (this.editorTextField.editor == null) return - HarpoonState.quickMenuSelectedIndex = this.editorTextField.editor!!.caretModel.logicalPosition.line + TridentState.quickMenuSelectedIndex = this.editorTextField.editor!!.caretModel.logicalPosition.line doOKAction() } override fun doOKAction() { - HarpoonState.quickMenuContent = editorTextField.text + TridentState.quickMenuContent = editorTextField.text super.doOKAction() } override fun doCancelAction() { - HarpoonState.quickMenuContent = editorTextField.text + TridentState.quickMenuContent = editorTextField.text super.doCancelAction() } diff --git a/src/main/kotlin/me/kyren223/trident/TridentQuickMenuSelectAction.kt b/src/main/kotlin/me/kyren223/trident/TridentQuickMenuSelectAction.kt new file mode 100644 index 0000000..f9db35a --- /dev/null +++ b/src/main/kotlin/me/kyren223/trident/TridentQuickMenuSelectAction.kt @@ -0,0 +1,11 @@ +package me.kyren223.trident + +import com.intellij.openapi.actionSystem.AnAction +import com.intellij.openapi.actionSystem.AnActionEvent + +class TridentQuickMenuSelectAction : AnAction() { + override fun actionPerformed(e: AnActionEvent) { + TridentState.quickMenuSelect() + } + +} diff --git a/src/main/kotlin/me/kyren223/harpoonforjb/HarpoonSelectAction.kt b/src/main/kotlin/me/kyren223/trident/TridentSelectAction.kt index 3c196b8..3122650 100644 --- a/src/main/kotlin/me/kyren223/harpoonforjb/HarpoonSelectAction.kt +++ b/src/main/kotlin/me/kyren223/trident/TridentSelectAction.kt @@ -1,22 +1,21 @@ -package me.kyren223.harpoonforjb +package me.kyren223.trident import com.intellij.openapi.actionSystem.AnAction import com.intellij.openapi.actionSystem.AnActionEvent import com.intellij.openapi.actionSystem.PlatformDataKeys import com.intellij.openapi.fileEditor.FileEditorManager -class HarpoonSelectAction : AnAction() { +class TridentSelectAction : AnAction() { override fun actionPerformed(e: AnActionEvent) { val project = e.project ?: return - val actionId = e.actionManager.getId(this) - var index = when (actionId) { + var index = when (val actionId = e.actionManager.getId(this)) { NEXT -> { - val current = HarpoonState.getIndexOfFile(project, e.getData(PlatformDataKeys.VIRTUAL_FILE)) + val current = TridentState.getIndexOfFile(project, e.getData(PlatformDataKeys.VIRTUAL_FILE)) if (current == -1) return current + 1 } PREV -> { - val current = HarpoonState.getIndexOfFile(project, e.getData(PlatformDataKeys.VIRTUAL_FILE)) + val current = TridentState.getIndexOfFile(project, e.getData(PlatformDataKeys.VIRTUAL_FILE)) if (current == -1) return current - 1 } @@ -25,9 +24,9 @@ class HarpoonSelectAction : AnAction() { } } - val count = HarpoonState.getFileCount(project) + val count = TridentState.getFileCount(project) index = ((index % count) + count) % count - val file = HarpoonState.selectFile(project, index) ?: return + val file = TridentState.selectFile(project, index) ?: return FileEditorManager.getInstance(project).openFile(file, true) } @@ -36,9 +35,9 @@ class HarpoonSelectAction : AnAction() { } companion object { - const val NEXT = "HarpoonSelectNext" - const val PREV = "HarpoonSelectPrev" - const val SELECT = "HarpoonSelect" + const val NEXT = "TridentSelectNext" + const val PREV = "TridentSelectPrev" + const val SELECT = "TridentSelect" } } diff --git a/src/main/kotlin/me/kyren223/harpoonforjb/HarpoonState.kt b/src/main/kotlin/me/kyren223/trident/TridentState.kt index 3b476c2..7c60d4b 100644 --- a/src/main/kotlin/me/kyren223/harpoonforjb/HarpoonState.kt +++ b/src/main/kotlin/me/kyren223/trident/TridentState.kt @@ -1,4 +1,4 @@ -package me.kyren223.harpoonforjb +package me.kyren223.trident import com.intellij.ide.util.PropertiesComponent import com.intellij.openapi.fileEditor.FileEditorManager @@ -6,14 +6,13 @@ import com.intellij.openapi.project.Project import com.intellij.openapi.vfs.LocalFileSystem import com.intellij.openapi.vfs.VirtualFile -object HarpoonState { +object TridentState { private var projectFiles: MutableMap<String, MutableList<VirtualFile>> = mutableMapOf() - private const val HARPOON_LIST_KEY = "HarpoonList" - private var quickMenu: HarpoonQuickMenu? = null + private const val TRIDENT_LIST_KEY = "TridentList" + private var quickMenu: TridentQuickMenu? = null var quickMenuSelectedIndex: Int? = null var quickMenuContent: String? = "" - fun appendFile(project: Project, file: VirtualFile) { if (!file.isValid) return loadProject(project) @@ -33,7 +32,7 @@ object HarpoonState { private fun loadProject(project: Project) { if (project.name in projectFiles) return val properties = PropertiesComponent.getInstance(project) - val list = properties.getList(HARPOON_LIST_KEY) + val list = properties.getList(TRIDENT_LIST_KEY) if (list == null) { projectFiles[project.name] = mutableListOf() return @@ -56,7 +55,7 @@ object HarpoonState { .filter { it.isValid } .map { it.path } .toList() - properties.setList(HARPOON_LIST_KEY, stringList) + properties.setList(TRIDENT_LIST_KEY, stringList) } fun getIndexOfFile(project: Project, data: VirtualFile?): Int { @@ -73,24 +72,17 @@ object HarpoonState { fun toggleQuickMenu(project: Project) { if (quickMenu != null && quickMenu!!.isShowing) { - println("Canceling quick menu") quickMenu!!.doCancelAction() return } loadProject(project) val content = getProjectContent(project) - quickMenu = HarpoonQuickMenu(content) + quickMenu = TridentQuickMenu(content) val result = quickMenu!!.showAndGet() if (quickMenuContent != null && content != quickMenuContent) { - // Update the content -// println("Content Before:\n${quickMenuContent}") retrieveProjectFiles(project, quickMenuContent!!) -// val contentAfter = projectFiles[project.name]!! -// .joinToString("\n") { it.path } -// .trim() -// println("Content After:\n${contentAfter}") saveProject(project) } diff --git a/src/main/kotlin/me/kyren223/harpoonforjb/HarpoonToggleQuickMenuAction.kt b/src/main/kotlin/me/kyren223/trident/TridentToggleQuickMenuAction.kt index 66e58b0..a3f8cc7 100644 --- a/src/main/kotlin/me/kyren223/harpoonforjb/HarpoonToggleQuickMenuAction.kt +++ b/src/main/kotlin/me/kyren223/trident/TridentToggleQuickMenuAction.kt @@ -1,4 +1,4 @@ -package me.kyren223.harpoonforjb +package me.kyren223.trident import com.intellij.openapi.actionSystem.AnAction import com.intellij.openapi.actionSystem.AnActionEvent @@ -6,21 +6,21 @@ import com.maddyhome.idea.vim.api.injector import com.maddyhome.idea.vim.command.MappingMode import com.maddyhome.idea.vim.key.MappingOwner -class HarpoonToggleQuickMenuAction : AnAction() { +class TridentToggleQuickMenuAction : AnAction() { override fun actionPerformed(e: AnActionEvent) { if (!remapped) remap() if (e.project != null) { - HarpoonState.toggleQuickMenu(e.project!!) + TridentState.toggleQuickMenu(e.project!!) } } private fun remap() { - if (!AppSettingsState.instance.harpoonEnterToSelect) return - val keys = injector.parser.parseKeys(":action HarpoonQuickMenuSelect<cr>") + if (!AppSettingsState.instance.enterToSelect) return + val keys = injector.parser.parseKeys(":action TridentQuickMenuSelect<cr>") val keyGroup = injector.keyGroup keyGroup.putKeyMapping(MappingMode.NVO, injector.parser.parseKeys("<cr>"), - MappingOwner.Plugin.get("HarpoonForJB"), keys, false + MappingOwner.Plugin.get("Trident"), keys, false ) remapped = true } diff --git a/src/main/resources/META-INF/HarpoonForJB-IdeaVim.xml b/src/main/resources/META-INF/Trident-IdeaVim.xml index 164f46c..164f46c 100644 --- a/src/main/resources/META-INF/HarpoonForJB-IdeaVim.xml +++ b/src/main/resources/META-INF/Trident-IdeaVim.xml diff --git a/src/main/resources/META-INF/plugin.xml b/src/main/resources/META-INF/plugin.xml index 063b1d8..73b0d9b 100644 --- a/src/main/resources/META-INF/plugin.xml +++ b/src/main/resources/META-INF/plugin.xml @@ -1,11 +1,11 @@ <!-- Plugin Configuration File. Read more: https://plugins.jetbrains.com/docs/intellij/plugin-configuration-file.html --> <idea-plugin> <!-- Unique identifier of the plugin. It should be FQN. It cannot be changed between the plugin versions. --> - <id>me.kyren223.harpoonforjb</id> + <id>me.kyren223.trident</id> <!-- Public plugin name should be written in Title Case. Guidelines: https://plugins.jetbrains.com/docs/marketplace/plugin-overview-page.html#plugin-name --> - <name>HarpoonForJB</name> + <name>Trident</name> <!-- A displayed Vendor name or Organization ID displayed on the Plugins Page. --> <vendor email="ulmliad223@gmail.com" url="https://discord.gg/7vpTv7m3QR">Kyren223</vendor> @@ -14,89 +14,93 @@ Simple HTML elements (text formatting, paragraphs, and lists) can be added inside of <![CDATA[ ]]> tag. Guidelines: https://plugins.jetbrains.com/docs/marketplace/plugin-overview-page.html#plugin-description --> <description><![CDATA[ - <h3>HarpoonForJB</h3> - Originally created by ThePrimeagen as a Neovim plugin, "Harpoon"<br> - revolutionized code navigation with its intuitive targeting and<br> - seamless traversal capabilities.<br> - HarpoonForJB aims to bring the same experience to JetBrains IDEs.<br> + <h3>Trident</h3> + Trident is a plugin for JetBrains IDEs that provides a fast and intuitive<br> + way to navigate between files effortlessly.<br> <br> - For fans of the original "Harpoon" plugin, "HarpoonForJB"<br> - offers a familiar yet enhanced experience tailored for JetBrains IDEs.<br> + The plugin is inspired by the "Harpoon" plugin made<br> + by ThePrimeagen for Neovim.<br> + <br> + Trident aims to bring the same experience to JetBrains IDEs.<br> + but with additional features and proper integration with the IDE.<br> + + Want to help contribute to the project? + Source code: <a href="https://github.com/Kyren223/Trident">GitHub Repo</a><br> ]]></description> <!-- Product and plugin compatibility requirements. Read more: https://plugins.jetbrains.com/docs/intellij/plugin-compatibility.html --> <depends>com.intellij.modules.platform</depends> - <depends optional="true" config-file="HarpoonForJB-IdeaVim.xml">IdeaVIM</depends> + <depends optional="true" config-file="Trident-IdeaVim.xml">IdeaVIM</depends> <!-- Extension points defined by the plugin. Read more: https://plugins.jetbrains.com/docs/intellij/plugin-extension-points.html --> <extensions defaultExtensionNs="com.intellij"> <applicationConfigurable parentId="tools" - instance="me.kyren223.harpoonforjb.AppSettingsConfigurable" - id="me.kyren223.harpoonforjb.AppSettingsConfigurable" - displayName="HarpoonForJB Settings"/> - <applicationService serviceImplementation="me.kyren223.harpoonforjb.AppSettingsState"/> + instance="me.kyren223.trident.AppSettingsConfigurable" + id="me.kyren223.trident.AppSettingsConfigurable" + displayName="Trident Settings"/> + <applicationService serviceImplementation="me.kyren223.trident.AppSettingsState"/> </extensions> <actions> - <group id="me.kyren223.harpoonforjb.mainGroup" - text="Harpoon" description="Harpoon" + <group id="me.kyren223.trident.mainGroup" + text="Trident" description="Trident" popup="true"> </group> - <!-- Harpoon Select Buffer --> - <action id="HarpoonSelect1" - class="me.kyren223.harpoonforjb.HarpoonSelectAction" + <!-- Trident Select Buffer --> + <action id="TridentSelect1" + class="me.kyren223.trident.TridentSelectAction" text="Select Buffer 1"> - <add-to-group group-id="me.kyren223.harpoonforjb.mainGroup"/> + <add-to-group group-id="me.kyren223.trident.mainGroup"/> </action> - <action id="HarpoonSelect2" - class="me.kyren223.harpoonforjb.HarpoonSelectAction" + <action id="TridentSelect2" + class="me.kyren223.trident.TridentSelectAction" text="Select Buffer 2"> - <add-to-group group-id="me.kyren223.harpoonforjb.mainGroup"/> + <add-to-group group-id="me.kyren223.trident.mainGroup"/> </action> - <action id="HarpoonSelect3" - class="me.kyren223.harpoonforjb.HarpoonSelectAction" + <action id="TridentSelect3" + class="me.kyren223.trident.TridentSelectAction" text="Select Buffer 3"> - <add-to-group group-id="me.kyren223.harpoonforjb.mainGroup"/> + <add-to-group group-id="me.kyren223.trident.mainGroup"/> </action> - <action id="HarpoonSelect4" - class="me.kyren223.harpoonforjb.HarpoonSelectAction" + <action id="TridentSelect4" + class="me.kyren223.trident.TridentSelectAction" text="Select Buffer 4"> - <add-to-group group-id="me.kyren223.harpoonforjb.mainGroup"/> + <add-to-group group-id="me.kyren223.trident.mainGroup"/> </action> <!-- Select Previous & Next Buffer --> - <action id="HarpoonSelectPrev" - class="me.kyren223.harpoonforjb.HarpoonSelectAction" + <action id="TridentSelectPrev" + class="me.kyren223.trident.TridentSelectAction" text="Select Previous Buffer"> - <add-to-group group-id="me.kyren223.harpoonforjb.mainGroup"/> + <add-to-group group-id="me.kyren223.trident.mainGroup"/> </action> - <action id="HarpoonSelectNext" - class="me.kyren223.harpoonforjb.HarpoonSelectAction" + <action id="TridentSelectNext" + class="me.kyren223.trident.TridentSelectAction" text="Select Next Buffer"> - <add-to-group group-id="me.kyren223.harpoonforjb.mainGroup"/> + <add-to-group group-id="me.kyren223.trident.mainGroup"/> </action> <!-- Append --> - <action id="HarpoonAppend" - class="me.kyren223.harpoonforjb.HarpoonAppendAction" + <action id="TridentAppend" + class="me.kyren223.trident.TridentAppendAction" text="Append File"> - <add-to-group group-id="me.kyren223.harpoonforjb.mainGroup"/> + <add-to-group group-id="me.kyren223.trident.mainGroup"/> </action> <!-- UI Actions --> - <action id="HarpoonToggleQuickMenu" - class="me.kyren223.harpoonforjb.HarpoonToggleQuickMenuAction" + <action id="TridentToggleQuickMenu" + class="me.kyren223.trident.TridentToggleQuickMenuAction" text="Toggle Quick Menu"> - <add-to-group group-id="me.kyren223.harpoonforjb.mainGroup"/> + <add-to-group group-id="me.kyren223.trident.mainGroup"/> </action> - <action id="HarpoonQuickMenuSelect" - class="me.kyren223.harpoonforjb.HarpoonQuickMenuSelectAction" + <action id="TridentQuickMenuSelect" + class="me.kyren223.trident.TridentQuickMenuSelectAction" text="Quick Menu Select"> - <add-to-group group-id="me.kyren223.harpoonforjb.mainGroup"/> + <add-to-group group-id="me.kyren223.trident.mainGroup"/> </action> </actions> |
