diff options
author | Matěj Cepl <mcepl@cepl.eu> | 2020-03-11 13:48:39 +0100 |
---|---|---|
committer | Matěj Cepl <mcepl@cepl.eu> | 2020-03-11 13:48:39 +0100 |
commit | 4385b7eb94b953d90a533fd54e00e89417679846 (patch) | |
tree | 75cdfb6f8b0d38457a2fcadc0db13a50ccc0bcab /init.lua | |
parent | 188a52f7341b8099610f5c00061e89c1963a4218 (diff) | |
download | vis-jump-4385b7eb94b953d90a533fd54e00e89417679846.tar.gz |
Some progress, but not good <cword> implementation yet.
Diffstat (limited to 'init.lua')
-rw-r--r-- | init.lua | 24 |
1 files changed, 20 insertions, 4 deletions
@@ -1,5 +1,21 @@ -vis:map(vis.modes.NORMAL, "gx", function(keys) - local handle = io.popen("xdg-open https://reddit.com") - local data = handle:read() - local success, msg, status = handle:close() +local function get_query() + local line = vis.win.selection.line + local pos = vis.win.selection.col + local str = vis.win.file.lines[line] + + local from, to = 0, 0 + while pos > to do + from, to = str:find('[%a_]+[%a%d_]*', to + 1) + if from == nil or from > pos then + return nil + end + end + + return string.sub(str, from, to) +end + +vis:map(vis.modes.NORMAL, "gx", function() + local cur_word = get_query() + print(cur_word) + os.execute("xdg-open " .. cur_word) end, "Jump to URL") |