Skip to content

Commit

Permalink
Bump version to v1.3
Browse files Browse the repository at this point in the history
- bind H -> start of line or paragraph
- bind ; -> end of line or paragraph
- bind 1 -> select word
- bind 2 -> select line
- bind G -> delete current code block
- bind B -> toggle case
- bind [ -> hippie completion
- bind P -> activate insert mode with space before
  • Loading branch information
amibiz committed Dec 28, 2018
1 parent 7648610 commit 50d8d22
Show file tree
Hide file tree
Showing 7 changed files with 129 additions and 13 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ plugins {
}

group 'com.github.amibiz'
version '1.2'
version '1.3'

sourceCompatibility = 1.8

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.github.amibiz.ergokeys;

import com.intellij.openapi.actionSystem.*;
import com.intellij.openapi.command.WriteCommandAction;
import com.intellij.openapi.editor.Caret;
import com.intellij.openapi.editor.CaretModel;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.project.Project;

public class ActivateInsertModeSpaceBeforeAction extends AnAction {
final private ActionManager actionManager = ActionManager.getInstance();

@Override
public void actionPerformed(AnActionEvent e) {
final Editor editor = e.getRequiredData(CommonDataKeys.EDITOR);
final Project project = e.getProject();
final Document document = editor.getDocument();
final CaretModel caretModel = editor.getCaretModel();
final Caret caret = caretModel.getCurrentCaret();

WriteCommandAction.runWriteCommandAction(project, new Runnable() {
@Override
public void run() {
document.insertString(caret.getOffset(), " ");
}
});
actionManager.getAction(IdeActions.ACTION_EDITOR_MOVE_CARET_RIGHT).actionPerformed(e);
actionManager.getAction("ErgoKeysInsertMode").actionPerformed(e);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.github.amibiz.ergokeys;

import com.intellij.openapi.actionSystem.ActionManager;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.IdeActions;

public class DeleteCurrentCodeBlockAction extends AnAction {
final private ActionManager actionManager = ActionManager.getInstance();

@Override
public void actionPerformed(AnActionEvent e) {
actionManager.getAction("EditorCodeBlockStart").actionPerformed(e);
actionManager.getAction("EditorCodeBlockEndWithSelection").actionPerformed(e);
actionManager.getAction(IdeActions.ACTION_DELETE).actionPerformed(e);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.github.amibiz.ergokeys;

import com.intellij.openapi.actionSystem.*;
import com.intellij.openapi.editor.Caret;
import com.intellij.openapi.editor.CaretModel;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.editor.Editor;
import com.intellij.util.DocumentUtil;

public class EndOfLineOrParagraphAction extends AnAction {
final private ActionManager actionManager = ActionManager.getInstance();

@Override
public void actionPerformed(AnActionEvent e) {
final Editor editor = e.getRequiredData(CommonDataKeys.EDITOR);
final Document document = editor.getDocument();
final CaretModel caretModel = editor.getCaretModel();
final Caret caret = caretModel.getCurrentCaret();

if (DocumentUtil.isAtLineEnd(caret.getOffset(), document)) {
actionManager.getAction(IdeActions.ACTION_EDITOR_FORWARD_PARAGRAPH).actionPerformed(e);
} else {
actionManager.getAction(IdeActions.ACTION_EDITOR_MOVE_LINE_END).actionPerformed(e);
}
}
}
25 changes: 13 additions & 12 deletions src/main/java/com/github/amibiz/ergokeys/ErgoKeysPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,18 +59,25 @@ public class ErgoKeysPlugin implements ApplicationComponent {
new ActionBinding("EditorDown", KeyEvent.VK_K, KeyEvent.VK_T),
new ActionBinding("EditorPreviousWord", KeyEvent.VK_U, KeyEvent.VK_G),
new ActionBinding("EditorNextWord", KeyEvent.VK_O, KeyEvent.VK_R),
new ActionBinding("EditorLineStart", KeyEvent.VK_H, KeyEvent.VK_D),
new ActionBinding("EditorLineEnd", KeyEvent.VK_SEMICOLON, KeyEvent.VK_S),
new ActionBinding("ErgoKeysStartOfLineOrParagraphAction", KeyEvent.VK_H, KeyEvent.VK_D),
new ActionBinding("ErgoKeysEndOfLineOrParagraphAction", KeyEvent.VK_SEMICOLON, KeyEvent.VK_S),
new ActionBinding("NextSplitter", KeyEvent.VK_COMMA, KeyEvent.VK_W),
new ActionBinding("Find", KeyEvent.VK_N, KeyEvent.VK_B),

new ActionBinding("EditorSelectWord", KeyEvent.VK_1, KeyEvent.VK_1),
new ActionBinding("EditorSelectLine", KeyEvent.VK_2, KeyEvent.VK_2),
new ActionBinding("UnsplitAll", KeyEvent.VK_3, KeyEvent.VK_3),
new ActionBinding("SplitVertically", KeyEvent.VK_4, KeyEvent.VK_4),
new ActionBinding("$Delete", KeyEvent.VK_5, KeyEvent.VK_5),
new ActionBinding("EditorSelectLine", KeyEvent.VK_7, KeyEvent.VK_7),
new ActionBinding("EditorSelectWord", KeyEvent.VK_8, KeyEvent.VK_8),
new ActionBinding("ErgoKeysSelectString", KeyEvent.VK_9, KeyEvent.VK_9),

new ActionBinding("ErgoKeysDeleteCurrentCodeBlockAction", KeyEvent.VK_G, KeyEvent.VK_I),
new ActionBinding("EditorToggleCase", KeyEvent.VK_B, KeyEvent.VK_X),
new ActionBinding("HippieCompletion", KeyEvent.VK_OPEN_BRACKET, KeyEvent.VK_SLASH),
new ActionBinding("ErgoKeysActivateInsertModeSpaceBefore", KeyEvent.VK_P, KeyEvent.VK_L),

// Tab shortcuts
new ActionBinding("EditorTab", KeyEvent.VK_TAB, KeyEvent.VK_TAB),
new ActionBinding("NextTemplateVariable", KeyEvent.VK_TAB, KeyEvent.VK_TAB),
Expand All @@ -89,30 +96,24 @@ public class ErgoKeysPlugin implements ApplicationComponent {
new ActionBinding("EditorEscape", KeyEvent.VK_ESCAPE, KeyEvent.VK_ESCAPE),
new ActionBinding("EditorBackSpace", KeyEvent.VK_BACK_SPACE, KeyEvent.VK_BACK_SPACE),

// Navigation
new ActionBinding("GotoDeclaration", KeyEvent.VK_SLASH, KeyEvent.VK_Z),

// Unused keys
new ActionBinding("ErgoKeysNoopAction", KeyEvent.VK_BACK_QUOTE, KeyEvent.VK_BACK_QUOTE),
new ActionBinding("ErgoKeysNoopAction", KeyEvent.VK_1, KeyEvent.VK_1),
new ActionBinding("ErgoKeysNoopAction", KeyEvent.VK_2, KeyEvent.VK_2),
new ActionBinding("ErgoKeysNoopAction", KeyEvent.VK_6, KeyEvent.VK_6),
new ActionBinding("ErgoKeysNoopAction", KeyEvent.VK_0, KeyEvent.VK_0),
new ActionBinding("ErgoKeysNoopAction", KeyEvent.VK_MINUS, KeyEvent.VK_OPEN_BRACKET),
new ActionBinding("ErgoKeysNoopAction", KeyEvent.VK_EQUALS, KeyEvent.VK_CLOSE_BRACKET),

new ActionBinding("ErgoKeysNoopAction", KeyEvent.VK_W, KeyEvent.VK_COMMA),
new ActionBinding("ErgoKeysNoopAction", KeyEvent.VK_P, KeyEvent.VK_L),
new ActionBinding("ErgoKeysNoopAction", KeyEvent.VK_OPEN_BRACKET, KeyEvent.VK_SLASH),

new ActionBinding("ErgoKeysNoopAction", KeyEvent.VK_CLOSE_BRACKET, KeyEvent.VK_EQUALS),
new ActionBinding("ErgoKeysNoopAction", KeyEvent.VK_BACK_SLASH, KeyEvent.VK_BACK_SLASH),

new ActionBinding("ErgoKeysNoopAction", KeyEvent.VK_G, KeyEvent.VK_I),
new ActionBinding("ErgoKeysNoopAction", KeyEvent.VK_QUOTE, KeyEvent.VK_MINUS),

new ActionBinding("ErgoKeysNoopAction", KeyEvent.VK_B, KeyEvent.VK_X),
new ActionBinding("ErgoKeysNoopAction", KeyEvent.VK_M, KeyEvent.VK_M),
new ActionBinding("ErgoKeysNoopAction", KeyEvent.VK_PERIOD, KeyEvent.VK_V),

// Navigation
new ActionBinding("GotoDeclaration", KeyEvent.VK_SLASH, KeyEvent.VK_Z),
};
private Keymap userKeymap;
private Keymap commandModeKeymap;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.github.amibiz.ergokeys;

import com.intellij.openapi.actionSystem.*;
import com.intellij.openapi.editor.Caret;
import com.intellij.openapi.editor.CaretModel;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.editor.Editor;
import com.intellij.util.DocumentUtil;

public class StartOfLineOrParagraphAction extends AnAction {
final private ActionManager actionManager = ActionManager.getInstance();

@Override
public void actionPerformed(AnActionEvent e) {
final Editor editor = e.getRequiredData(CommonDataKeys.EDITOR);
final Document document = editor.getDocument();
final CaretModel caretModel = editor.getCaretModel();
final Caret caret = caretModel.getCurrentCaret();

if (DocumentUtil.isAtLineStart(caret.getOffset(), document)) {
actionManager.getAction(IdeActions.ACTION_EDITOR_BACKWARD_PARAGRAPH).actionPerformed(e);
} else {
actionManager.getAction(IdeActions.ACTION_EDITOR_MOVE_LINE_START).actionPerformed(e);
}
}
}
15 changes: 15 additions & 0 deletions src/main/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,20 @@
description="Activate Insert Mode"/>
<action id="ErgoKeysSelectString" class="com.github.amibiz.ergokeys.SelectStringAction" text="Select String"
description="Select String"/>
<action id="ErgoKeysStartOfLineOrParagraphAction"
class="com.github.amibiz.ergokeys.StartOfLineOrParagraphAction"
text="Move Caret to Line or Block Start"
description="Move Caret to Line or Block Start"/>
<action id="ErgoKeysEndOfLineOrParagraphAction"
class="com.github.amibiz.ergokeys.EndOfLineOrParagraphAction" text="EndOfLineOrParagraphAction"
description="EndOfLineOrParagraphAction"/>
<action id="ErgoKeysDeleteCurrentCodeBlockAction"
class="com.github.amibiz.ergokeys.DeleteCurrentCodeBlockAction"
text="ErgoKeysDeleteCurrentCodeBlockAction"
description="DeleteCurrentCodeBlockAction"/>
<action id="ErgoKeysActivateInsertModeSpaceBefore"
class="com.github.amibiz.ergokeys.ActivateInsertModeSpaceBeforeAction"
text="ActivateInsertModeSpaceBefore"
description="ActivateInsertModeSpaceBefore"/>
</actions>
</idea-plugin>

0 comments on commit 50d8d22

Please sign in to comment.