-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add s/S/x/X actions, various synonyms, mode hooks, userspace docs; optionally differentiate w & e motions; fix process hooks & redo on Mac; automate updating firmware size table in readme #1
Merged
Merged
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
6853fc8
Add user hooks for normal/insert/visual/visual line modes
t33chong 0afed33
Change Mac redo from command-Y to command-shift-Z
t33chong dd1e015
Add s actions and update readme
t33chong f596942
Document mode hooks
t33chong e67ce51
Clean up treatment of VIM_REDO OS bifurcation
t33chong d2e9ebe
Add x actions to visual modes
t33chong 25658c3
Fix process normal and visual mode user hooks
t33chong 0543125
Make w jump to beginning of next word
t33chong 4a8a5d1
Tap VIM_W VIM_B sequence on w release so that holding w skips forward
t33chong 7619be5
Add capital B, E, W motion synonyms
t33chong de28397
Add ^ synonym for 0; document W, E, B, ^ in readme
t33chong 94aa56f
Add visual_line_mode_user hook
t33chong 5e0b30f
Move VIM_REDO definition into ifdef VIM_FOR_MAC block
t33chong 74e7bba
Add X to send backspace without exiting normal mode
t33chong 21a367e
Call action_func on text object key release
t33chong 371d2ac
Revert w functionality to equivalence with e
t33chong fcf4219
Put new w motions behind feature macro, document it + X, fix minor typos
t33chong 1aca124
Link VIM_W_BEGINNING_OF_WORD context directly to relevant comment
t33chong 206ffb3
Update firmware size table in readme
t33chong File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
FROM qmkfm/qmk_firmware:latest | ||
|
||
ENV MY_KEYMAP_PATH=/qmk_firmware/keyboards/uno/keymaps/qmk-vim-update-readme | ||
|
||
WORKDIR /qmk_firmware | ||
|
||
COPY keymap $MY_KEYMAP_PATH | ||
COPY run.py /qmk_firmware/qmk_vim_update_readme.py | ||
|
||
CMD python3 qmk_vim_update_readme.py |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#include QMK_KEYBOARD_H | ||
#include "qmk-vim/src/vim.h" | ||
|
||
enum keycodes { | ||
QMK_VIM = SAFE_RANGE | ||
}; | ||
|
||
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { | ||
[0] = LAYOUT(QMK_VIM) | ||
}; | ||
|
||
bool process_record_user(uint16_t keycode, keyrecord_t *record) { | ||
if (!process_vim_mode(keycode, record)) { | ||
return false; | ||
} | ||
if (keycode == QMK_VIM && record->event.pressed) { | ||
toggle_vim_mode(); | ||
return false; | ||
} | ||
return true; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
include keyboards/uno/keymaps/qmk-vim-update-readme/qmk-vim/rules.mk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import os | ||
import re | ||
import subprocess | ||
|
||
# Path to QMK keymap used for firmware size calculations | ||
MY_KEYMAP_PATH = os.getenv('MY_KEYMAP_PATH') | ||
README_PATH = os.path.join(MY_KEYMAP_PATH, 'qmk-vim/README.org') | ||
|
||
# Split readme into sections: before feature macros table, table itself, and after table | ||
BEFORE, MACROS, AFTER = 0, 1, 2 | ||
lines = [[], [], []] | ||
position = BEFORE | ||
with open(README_PATH) as f: | ||
for line in f: | ||
if ((position == BEFORE and line.startswith('| =')) | ||
or (position == MACROS and not line.startswith('|'))): | ||
position += 1 | ||
lines[position].append(line) | ||
|
||
# Compile and parse output for firmware size | ||
def get_firmware_size(): | ||
process = subprocess.run( | ||
['qmk', 'compile', '-kb', 'uno', '-km', 'qmk-vim-update-readme'], capture_output=True) | ||
matches = re.search(r'The firmware size is fine - (\d+)', process.stdout.decode('utf-8')) | ||
return int(matches[1]) | ||
|
||
# Determine firmware size without any macros defined | ||
baseline = get_firmware_size() | ||
|
||
# Iterate over rows in table | ||
for i in range(len(lines[MACROS])): | ||
# Parse macro name | ||
line = lines[MACROS][i] | ||
cells = line.split('|') | ||
macro = cells[1].strip('= ') | ||
# Add macro to config | ||
with open(os.path.join(MY_KEYMAP_PATH, 'config.h'), 'w') as f: | ||
f.write(f'#define {macro}') | ||
# Determine firmware size difference | ||
size = get_firmware_size() | ||
size_diff = baseline - size | ||
if size_diff >= 0: | ||
new_val_str = f' +{size_diff} B' | ||
else: | ||
new_val_str = f' {size_diff} B' | ||
# Update table | ||
cells[3] = new_val_str.ljust(len(cells[3]), ' ') | ||
lines[MACROS][i] = '|'.join(cells) | ||
|
||
# Overwrite readme with new values | ||
with open(README_PATH, 'w') as f: | ||
f.write(''.join(line for section in lines for line in section)) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is generally a good solution to the holding problem, but it makes
viw
act likevaw
. This is because the object action finishes on the press, returning to visual mode, then w is released and the selection moves to the start of the next word.The other issue I noticed is that
cw
,dw
etc. act likece
, since it also finishes it's action on press.There's two simple solutions to these issues, you could make actions finish on release, which should be okay, the delay is probably not terribly noticeable. However, it allows for a strange ability to hold any of the motion keys during an action, ie
dj
down multiple lines and delete on release. But maybe that's a feature not a bug hehe, I don't think anyone would accidentally hold down long enough to delete more than they intended.The other solution is to just make all the motions aside from
hjkl
not hold-able. I personally never hold w, b, or e, but perhaps that's a more important feature for other people. Frankly, I could go either way, but I think I'm leaning towards making them just be tapping keys, as I think it's generally easier to develop with and should break less stuff (you'd probably have to patch dot repeat if you made actions go on release).After thinking some more, I think you should probably go for the no hold approach, unless you really think we should support holding w. If you do think it's greatly important it can be held, just make sure all the other features are happy, you'll need to make dot repeat act on release at the very least.EDIT:
I've given this some more thought, and decided that being able to hold w is somewhat important since we can't do f or t motions. I think for now, simply adding the better w motion as a macro option is the way to go (with a warning that some things break). And down the line we can take a look at making things work on release (or if you have the time you can do it now, but my gut feeling is that I'd prefer it in a different PR since this one would get pretty big.