-
Notifications
You must be signed in to change notification settings - Fork 264
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
Complete file name and file path swapped in doc #1146
Comments
It is all in the script |
The difference isn't that big. Assuming
Here is my first attempt at cleaning it up, but it could probably be better: local complete_filename = function(expand)
local win = vis.win
local file = win.file
local pos = win.selection.pos
if not pos then return end
-- 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
if not expand and range.start == range.finish then return end
local prefix = file:content(range)
if not prefix then return end
-- Strip leading delimiters for some progamming languages
local _, j = prefix:find("[[(<'\"]+")
if not expand and j then prefix = prefix:sub(j + 1) end
if expand and prefix:match("^%s*$") then
prefix = ""
range.start = pos
range.finish = pos
end
local cmdfmt = "vis-complete --file '%s'"
if expand then cmdfmt = "vis-open -- '%s'*" end
local status, out, err = vis:pipe(cmdfmt:format(prefix:gsub("'", "'\\''")))
if status ~= 0 or not out then
if err then vis:info(err) end
return
end
out = out:gsub("\n$", "")
if expand then
file:delete(range)
file:insert(range.start, out)
win.selection.pos = range.start + #out
else
file:insert(pos, out)
win.selection.pos = pos + #out
end
end
-- complete file path at primary selection location using vis-complete(1)
vis:map(vis.modes.INSERT, "<C-x><C-f>", function()
complete_filename(false);
end, "Complete file name")
-- complete file path at primary selection location using vis-open(1)
vis:map(vis.modes.INSERT, "<C-x><C-o>", function()
complete_filename(true);
end, "Complete file name (expands path)") |
Perhaps PR would be better? Something like https://git.sr.ht/~mcepl/vis/commit/620d37d121f76b0fe98d75040d3337fe5d73f5f4 ? |
There are probably more things to simplify but at least this makes it easier to see what exactly is different between `<C-x><C-f>` and `<C-x><C-o>`. closes martanne#1146
Done: #1148. I didn't use yours because your repo has some commit adding expansion of |
There are probably more things to simplify but at least this makes it easier to see what exactly is different between `<C-x><C-f>` and `<C-x><C-o>`. closes martanne#1146: Complete file name and file path swapped in doc
There are probably more things to simplify but at least this makes it easier to see what exactly is different between `<C-x><C-f>` and `<C-x><C-o>`. closes martanne#1146: Complete file name and file path swapped in doc
There are probably more things to simplify but at least this makes it easier to see what exactly is different between `<C-x><C-f>` and `<C-x><C-o>`. Some differences were removed: * whitespace in range is treated the same for both actions * empty range will expand to files in CWD for both actions closes martanne#1146: Complete file name and file path swapped in doc
There are probably more things to simplify but at least this makes it easier to see what exactly is different between `<C-x><C-f>` and `<C-x><C-o>`. Some differences were removed: * whitespace in range is treated the same for both actions * empty range will expand to files in CWD for both actions closes martanne#1146: Complete file name and file path swapped in doc
There are probably more things to simplify but at least this makes it easier to see what exactly is different between `<C-x><C-f>` and `<C-x><C-o>`. Some differences were removed: * whitespace in range is treated the same for both actions * empty range will expand to files in CWD for both actions closes martanne#1146: Complete file name and file path swapped in doc
There are probably more things to simplify but at least this makes it easier to see what exactly is different between `<C-x><C-f>` and `<C-x><C-o>`. Some differences were removed: * whitespace in range is treated the same for both actions * empty range will expand to files in CWD for both actions closes martanne#1146: Complete file name and file path swapped in doc
There are probably more things to simplify but at least this makes it easier to see what exactly is different between `<C-x><C-f>` and `<C-x><C-o>`. Some differences were removed: * whitespace in range is treated the same for both actions * empty range will expand to files in CWD for both actions closes martanne#1146: Complete file name and file path swapped in doc
There are probably more things to simplify but at least this makes it easier to see what exactly is different between `<C-x><C-f>` and `<C-x><C-o>`. Some differences were removed: * whitespace in range is treated the same for both actions * empty range will expand to files in CWD for both actions closes martanne#1146: Complete file name and file path swapped in doc
There are probably more things to simplify but at least this makes it easier to see what exactly is different between `<C-x><C-f>` and `<C-x><C-o>`. Some differences were removed: * whitespace in range is treated the same for both actions * empty range will expand to files in CWD for both actions closes martanne#1146: Complete file name and file path swapped in doc
There are probably more things to simplify but at least this makes it easier to see what exactly is different between `<C-x><C-f>` and `<C-x><C-o>`. Some differences were removed: * whitespace in range is treated the same for both actions * empty range will expand to files in CWD for both actions closes martanne#1146: Complete file name and file path swapped in doc
Doing
:help
gives me this:Trying myself, it seems it is the opposite in fact:
I don't know if it is the implementation or doc that is wrong.
The text was updated successfully, but these errors were encountered: