Skip to content

Commit

Permalink
Finished implementing all the settings, mapping menu, trident list me…
Browse files Browse the repository at this point in the history
…nu, and fixed all the bugs/issues.

Added more index actions for a total of 10 actions (compared to the original 4).
Updated README.md and TODO.md.
Changed version to 2.0.0.
Versions now follow the semver standard. which means that for each major version there will be backwards incompatible changes. for minor versions there will be new features and bug fixes. and for patch versions there will be bug fixes only.
  • Loading branch information
Kyren223 committed May 9, 2024
1 parent 1e30fa7 commit 9b9c0f0
Show file tree
Hide file tree
Showing 16 changed files with 265 additions and 329 deletions.
105 changes: 75 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
# Trident
##### Effortless file traversal to minimize keystrokes and maximize productivity

[![GitHub release](https://img.shields.io/github/v/release/Kyren223/Trident?style=for-the-badge)](https://github.com/Kyren223/Trident/releases/tag/1.0)
[![GitHub release](https://img.shields.io/github/v/release/Kyren223/Trident?style=for-the-badge)](https://github.com/Kyren223/Trident/releases/tag/2.0.0)
</div>

## Table of Contents
* [Features](#features)
* [Installation](#installation)
* [Getting Started](#getting-started)
* [Settings](#settings)
* [Configuration](#configuration)
* [Contribution](#contribution)
* [License](#license)
* [Contact](#contact)
Expand All @@ -34,24 +34,29 @@ The plugin is inspired by the [Harpoon](https://github.com/ThePrimeagen/harpoon)

## Installation
* Version 2023.1 or later of any IntelliJ-based IDE is required.
* Install the plugin through the IDE's plugin manager by searching for "Trident".
* Install the plugin from the [JetBrains Marketplace](https://plugins.jetbrains.com/plugin/23818-trident).
* Install the plugin from the [GitHub Releases](https://github.com/Kyren223/Trident/releases).

## 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
* The default settings are sensible, but you can customize them if you wish.

* Actions can be mapped to IDE keymaps, search for "Trident" in the IDE's keymap settings.
* If you are using IdeaVim, you can configure the keymaps through .ideavimrc

### Example .ideavimrc Configuration
```vimrc
" Append the current file to the list
map <leader>a :action TridentAppend<CR>
map <leader>a :action TridentAppend<cr>
" Open the quick menu
map <C-h> :action TridentToggleQuickMenu<CR>
" Open the Trident list
map <C-h> :action TridentList<cr>
" Select the given file (from the Quick Menu) and open it
map <leader>o :action TridentQuickMenuSelect<CR>
" Select the given file (from the Trident list) and open it
map <leader>o :action TridentListSelect<cr>
" Hotkeys to open the first 4 items in the list
" You can assign up to 10 hotkeys using TridentSelect[1-10]
" This is an example for 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>
Expand All @@ -62,49 +67,89 @@ map <C-S-P> :action TridentSelectPrev<CR>
map <C-S-N> :action TridentSelectNext<CR>
```

### My .ideavimrc Configuration
## Configuration

### Settings
* Search for "Trident Settings" in the IDE's settings
* You can customize the width, height, font size of the Trident list
* You can also customize other settings, each setting has an explanation under it

* All actions can be mapped to IDE keymaps
* Keymaps can also be configured through .ideavimrc (requires IdeaVim)

### Full .ideavimrc Configuration with all keymaps
* The comments explain the keymaps and their functionality
```vimrc
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
" Append the current file to the list
map <leader>a :action TridentAppend<cr>
" Open the Trident list
map <C-h> :action TridentList<cr>
" Select the given file (from the Trident list) and open it
map <leader>o :action TridentListSelect<cr>
" You can assign up to 10 hotkeys using TridentSelect[1-10]
" These hotkeys are used to quickly navigate to the corresponding Trident list item
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
map <C-5> :action TridentSelect5<CR>
map <C-6> :action TridentSelect6<CR>
map <C-7> :action TridentSelect7<CR>
map <C-8> :action TridentSelect8<CR>
map <C-9> :action TridentSelect9<CR>
map <C-0> :action TridentSelect10<CR>
**Descriptions**
* 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.
" Toggle previous & next buffers stored within the list
map <C-S-P> :action TridentSelectPrev<CR>
map <C-S-N> :action TridentSelectNext<CR>
```

**Defaults**
### My settings values
* Width - 800
* Height - 400
* Font Size - 20
* Enter to select - true
* Font Size - 30

* Enter to select item - true
* Automatic Mappings - true
* Recursive Mappings - true
* Remember last line - false
* Index Cycling - true

### My .ideavimrc Configuration
```vimrc
map <leader>a :action TridentAppend<cr>
map <C-e> :action TridentToggleQuickMenu<cr>
" I am Using "Enter to select" from settings
" so I don't need to map a TridentListSelect keymap here
map <C-1> :action TridentSelect1<cr>
map <C-2> :action TridentSelect2<cr>
map <C-3> :action TridentSelect3<cr>
map <C-4> :action TridentSelect4<cr>
```

## Contribution

This plugin is open-source and contributions are welcome.

I recommend looking at the issues tab or the [TODO.md](TODO.md) file for ideas on what to work on.
If you are looking for what to work on, see the [issues tab](https://github.com/Kyren223/Trident/issues)

It's recommended to first open an issue before starting to work on a feature.

### Steps to contribute
1. Fork the repository.
2. Make your changes.
2. Make your changes and commit them.
3. Push your changes to your fork.
4. Create a pull request.
5. Wait for the pull request to be reviewed.
5. Wait for the pull request to be reviewed and merged.

## License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
This project is licensed under the MIT License, see the [LICENSE](LICENSE) file for details.

The logo was design by me and is copyrighted.
The logo was designed by me and is copyrighted.
You may not use it without my permission.

## Contact
Expand Down
5 changes: 0 additions & 5 deletions TODO.md

This file was deleted.

4 changes: 2 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ plugins {
}

group = "me.kyren223"
version = "1.2.0"
version = "2.0.0"

repositories {
mavenCentral()
Expand All @@ -17,7 +17,7 @@ intellij {
version.set("2024.1")
type.set("IC") // Target IDE Platform
updateSinceUntilBuild.set(false)
plugins.set(listOf("IdeaVim:2.7.5"))
plugins.set(listOf("IdeaVim:2.11.0"))
}

tasks {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import com.intellij.openapi.project.Project
import com.intellij.openapi.vfs.VirtualFile
import me.kyren223.trident.utils.TridentList

class AppendAction : AnAction() {
class TridentAppendAction : AnAction() {
override fun actionPerformed(e: AnActionEvent) {
val project: Project = e.project ?: return
val file: VirtualFile = e.getData(PlatformDataKeys.VIRTUAL_FILE) ?: return
Expand Down
20 changes: 0 additions & 20 deletions src/main/kotlin/me/kyren223/trident/actions/TridentListAction.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,12 @@ package me.kyren223.trident.actions

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
import me.kyren223.trident.data.SettingsState
import me.kyren223.trident.ui.TridentListMenu

class TridentListAction : AnAction() {
override fun actionPerformed(e: AnActionEvent) {
if (!remapped) remap()
val project = e.project ?: return
TridentListMenu.open(project)
}

// TODO move the remap to somewhere else
private fun remap() {
if (!SettingsState.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("Trident"), keys, false
)
remapped = true
}

companion object {
var remapped = false
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,9 @@ package me.kyren223.trident.actions
import com.intellij.openapi.actionSystem.AnAction
import com.intellij.openapi.actionSystem.AnActionEvent
import me.kyren223.trident.ui.TridentListMenu
import me.kyren223.trident.utils.TridentList

class TridentListSelectAction : AnAction() {
override fun actionPerformed(e: AnActionEvent) {
val project = e.project ?: return
TridentList.select(project, TridentListMenu.line)
TridentListMenu.instance?.select()
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import com.intellij.openapi.actionSystem.PlatformDataKeys
import com.intellij.openapi.fileEditor.FileEditorManager
import me.kyren223.trident.utils.TridentList

class SelectAction : AnAction() {
class TridentSelectAction : AnAction() {
override fun actionPerformed(e: AnActionEvent) {
val project = e.project ?: return
var index = when (val actionId = e.actionManager.getId(this)) {
val index = when (val actionId = e.actionManager.getId(this)) {
NEXT -> {
val file = e.getData(PlatformDataKeys.VIRTUAL_FILE) ?: return
val current = TridentList.getIndexOfFile(project, file) ?: return
Expand Down
Original file line number Diff line number Diff line change
@@ -1,33 +1,27 @@
package me.kyren223.trident.data

import com.intellij.openapi.application.ApplicationManager
import com.intellij.openapi.components.PersistentStateComponent
import com.intellij.openapi.components.State
import com.intellij.openapi.components.Storage
import com.intellij.util.xmlb.XmlSerializerUtil
import com.intellij.openapi.components.*

// 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.
@Service
@State(name = "me.kyren223.trident.data.SettingsState", storages = [Storage("SdkSettingsPlugin.xml")])
class SettingsState : PersistentStateComponent<SettingsState?> {
class Settings : SimplePersistentStateComponent<SettingsState>(SettingsState()) {
companion object {
val instance: Settings
get() = ApplicationManager.getApplication().getService(Settings::class.java)
val state: SettingsState
get() = instance.state
}
}

class SettingsState : BaseState() {
var width = 800
var height = 400
var fontSize = 20
var enterToSelect = true
var automaticMapping = false
var recursiveMapping = false
var rememberLine = false

override fun getState(): SettingsState {
return this
}

override fun loadState(state: SettingsState) {
XmlSerializerUtil.copyBean(state, this)
}

companion object {
val instance: SettingsState
get() = ApplicationManager.getApplication().getService(SettingsState::class.java)
}
var indexCycling = false
}
27 changes: 20 additions & 7 deletions src/main/kotlin/me/kyren223/trident/data/SettingsData.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,15 @@ class SettingsData {

val panel: JPanel

private val width = JBIntSpinner(SettingsState.instance.width, minValue, maxValue, step)
private val height = JBIntSpinner(SettingsState.instance.height, minValue, maxValue, step)
private val fontSize = JBIntSpinner(SettingsState.instance.fontSize, minValue, maxValue, step)
private val width = JBIntSpinner(Settings.state.width, minValue, maxValue, step)
private val height = JBIntSpinner(Settings.state.height, minValue, maxValue, step)
private val fontSize = JBIntSpinner(Settings.state.fontSize, minValue, maxValue, step)

private val enterToSelect = JBCheckBox(null, SettingsState.instance.enterToSelect)
private val rememberLine = JBCheckBox(null, SettingsState.instance.rememberLine)
private val automaticMapping = JBCheckBox(null, SettingsState.instance.automaticMapping)
private val recursiveMapping = JBCheckBox(null, SettingsState.instance.recursiveMapping)
private val enterToSelect = JBCheckBox(null, Settings.state.enterToSelect)
private val rememberLine = JBCheckBox(null, Settings.state.rememberLine)
private val automaticMapping = JBCheckBox(null, Settings.state.automaticMapping)
private val recursiveMapping = JBCheckBox(null, Settings.state.recursiveMapping)
private val indexCycling = JBCheckBox(null, Settings.state.indexCycling)

init {
panel = FormBuilder.createFormBuilder()
Expand Down Expand Up @@ -56,6 +57,10 @@ class SettingsData {
"and will be selected when the TridentList is opened."))
.addComponent(desc("Note, this does not persist across restarts, it's run-time only."))

.addLabeledComponent("Index cycling", indexCycling)
.addComponent(desc("If enabled, indexes will be cyclic, " +
"For example if you have 3 files and hotkey to 4, it'll cycle to 1."))

.addComponentFillVertically(JPanel(), 0)
.panel
}
Expand Down Expand Up @@ -121,4 +126,12 @@ class SettingsData {
fun setRecursiveMapping(recursiveMapping: Boolean) {
this.recursiveMapping.isSelected = recursiveMapping
}

fun getIndexCycling(): Boolean {
return indexCycling.isSelected
}

fun setIndexCycling(indexCycling: Boolean) {
this.indexCycling.isSelected = indexCycling
}
}
Loading

0 comments on commit 9b9c0f0

Please sign in to comment.