summaryrefslogtreecommitdiff
path: root/users/xtonhasvim/xtonhasvim.c
diff options
context:
space:
mode:
Diffstat (limited to 'users/xtonhasvim/xtonhasvim.c')
-rw-r--r--users/xtonhasvim/xtonhasvim.c72
1 files changed, 50 insertions, 22 deletions
diff --git a/users/xtonhasvim/xtonhasvim.c b/users/xtonhasvim/xtonhasvim.c
index a2ff2fa31c..5f6701830f 100644
--- a/users/xtonhasvim/xtonhasvim.c
+++ b/users/xtonhasvim/xtonhasvim.c
@@ -15,6 +15,7 @@
*/
#include "xtonhasvim.h"
+#include "fancylighting.h"
/************************************
* helper foo
@@ -53,13 +54,13 @@ static void ALT(uint16_t keycode) {
}
-static uint16_t vstate = VIM_START;
+uint16_t vstate = VIM_START;
static bool yank_was_lines = false;
static bool SHIFTED = false;
static uint32_t mod_override_layer_state = 0;
static uint16_t mod_override_triggering_key = 0;
-static void edit(void) { vstate = VIM_START; layer_on(_EDIT); layer_off(_CMD); }
+static void edit(void) { vstate = VIM_START; layer_clear(); }
#define EDIT edit()
@@ -102,25 +103,54 @@ static void simple_movement(uint16_t keycode) {
}
}
+static void comma_period(uint16_t keycode) {
+ switch (keycode) {
+ case VIM_COMMA:
+ if (SHIFTED) {
+ // indent
+ CMD(KC_LBRACKET);
+ } else {
+ // toggle comment
+ CMD(KC_SLASH);
+ }
+ break;
+ case VIM_PERIOD:
+ if (SHIFTED) {
+ // outdent
+ CMD(KC_RBRACKET);
+ }
+ break;
+ }
+}
+
__attribute__ ((weak))
bool process_record_keymap(uint16_t keycode, keyrecord_t *record) {
return true;
}
-#define PASS_THRU process_record_keymap(keycode, record)
-
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
- if(record->event.pressed && layer_state_is(_CMD) && IS_MOD(keycode)) {
+ /* keymap gets first whack */
+ if(!process_record_keymap(keycode, record)) return false;
+
+ /****** FIREY_RETURN *****/
+ if(record->event.pressed && keycode == FIREY_RETURN) {
+ start_firey_return();
+ TAP(KC_ENT);
+ }
+
+ /****** mod passthru *****/
+ if(record->event.pressed && layer_state_is(vim_cmd_layer()) && (IS_MOD(keycode) || keycode == LSFT(KC_LALT))) {
mod_override_layer_state = layer_state;
mod_override_triggering_key = keycode;
+ // TODO: change this to track key location instead
layer_clear();
- return PASS_THRU; // let the event fall through...
+ return true; // let the event fall through...
}
if(mod_override_layer_state && !record->event.pressed && keycode == mod_override_triggering_key) {
layer_state_set(mod_override_layer_state);
mod_override_layer_state = 0;
mod_override_triggering_key = 0;
- return PASS_THRU;
+ return true;
}
if (VIM_START <= keycode && keycode <= VIM_ESC) {
@@ -132,7 +162,7 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
if (record->event.pressed) {
if(keycode == VIM_START) {
// entry from anywhere
- layer_on(_CMD);
+ layer_on(vim_cmd_layer());
vstate = VIM_START;
// reset state
@@ -176,7 +206,7 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
break;
case VIM_D:
if(SHIFTED) {
- TAP(KC_K);
+ CTRL(KC_K);
} else {
vstate = VIM_D;
}
@@ -300,19 +330,8 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
}
break;
case VIM_COMMA:
- if(SHIFTED) {
- // indent
- CMD(KC_LBRACKET);
- } else {
- // toggle comment
- CMD(KC_SLASH);
- }
- break;
case VIM_PERIOD:
- if(SHIFTED) {
- // outdent
- CMD(KC_RBRACKET);
- }
+ comma_period(keycode);
break;
}
break;
@@ -483,6 +502,10 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
TAP(KC_RIGHT);
vstate = VIM_START;
break;
+ case VIM_COMMA:
+ case VIM_PERIOD:
+ comma_period(keycode);
+ break;
default:
// do nothing
break;
@@ -539,6 +562,10 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
TAP(KC_RIGHT);
vstate = VIM_START;
break;
+ case VIM_COMMA:
+ case VIM_PERIOD:
+ comma_period(keycode);
+ break;
default:
// do nothing
break;
@@ -610,6 +637,7 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
}
return false;
} else {
- return PASS_THRU;
+ return true;
}
}
+