vis
a vi-like editor based on Plan 9's structural regular expressions
git clone https://9o.is/git/vis.git
commit 85de88cd914f30ffd7f5599f8b7ae4c6bc0351a9 parent 1e8912f6b5f2cbad7eb6f17df12bd5302ab5f207 Author: Marc André Tanner <mat@brain-dump.org> Date: Wed, 28 Feb 2018 19:53:28 +0100 Merge branch 'vis-open-fixes' of https://github.com/kj/vis Diffstat:
| M | lua/plugins/complete-filename.lua | | | 3 | ++- |
| M | vis-lua.c | | | 8 | ++++++++ |
| M | vis-open | | | 13 | +++++++++---- |
3 files changed, 19 insertions(+), 5 deletions(-)
diff --git a/lua/plugins/complete-filename.lua b/lua/plugins/complete-filename.lua @@ -32,7 +32,8 @@ vis:map(vis.modes.INSERT, "<C-x><C-o>", function() local file = win.file local pos = win.selection.pos if not pos then return end - local range = file:text_object_word(pos > 0 and pos-1 or pos); + -- TODO do something clever here + local range = file:text_object_longword(pos > 0 and pos-1 or pos); if not range then return end if range.finish > pos then range.finish = pos end local prefix = file:content(range) diff --git a/vis-lua.c b/vis-lua.c @@ -2234,6 +2234,14 @@ static int file_mark_get(lua_State *L) { * @treturn Range range the range */ +/*** + * WORD text object. + * + * @function text_object_longword + * @tparam int pos the position which must be part of the word + * @treturn Range range the range + */ + static int file_text_object(lua_State *L) { Filerange range = text_range_empty(); File *file = obj_ref_check(L, 1, VIS_LUA_TYPE_FILE); diff --git a/vis-open b/vis-open @@ -49,10 +49,15 @@ if [ $# -eq 1 -a "$ALLOW_AUTO_SELECT" = 1 ]; then exec "$0" -p "$VIS_MENU_PROMPT" -f .. $(ls -1) else # We've found a single item, and it's not a directory, - # so it must be a filename (or file-like thing) to open. - cd "$(dirname "$1")" - echo "$(pwd -P)"/"$(basename "$1")" - exit 0 + # so it must be a filename (or file-like thing) to open, + # unless the parent directory does not exist. + if [ -d "$(dirname "$1")" ]; then + cd "$(dirname "$1")" + echo "$(pwd -P)"/"$(basename "$1" | sed 's/\*$//')" + exit 0 + else + exit 1 + fi fi fi