aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorErlend Lind Madsen <erlendf80@gmail.com>2020-12-22 14:24:27 +0100
committerErlend Lind Madsen <erlendf80@gmail.com>2020-12-22 14:24:27 +0100
commitdba4bebb314f2cae111ac5dafcd84cf1be9943b9 (patch)
tree20645cf16a57d167b4abec9a52c81bc3e33de7cf
parentc1c0d5b7c907c67bce967ae4193f2185d5b9e9a3 (diff)
downloadvis-cursors-dba4bebb314f2cae111ac5dafcd84cf1be9943b9.tar.gz
use csv format | save to .vis-cursors.csv
-rw-r--r--README.md2
-rw-r--r--init.lua6
2 files changed, 4 insertions, 4 deletions
diff --git a/README.md b/README.md
index 1965d85..36e3161 100644
--- a/README.md
+++ b/README.md
@@ -2,6 +2,6 @@
A [vis](https://github.com/martanne/vis) [plugin](https://github.com/martanne/vis/wiki/Plugins) for saving cursor position per file.
-Default save path is `{XDG_CACHE_HOME|HOME}/.vis-cursors`
+Default save path is `{XDG_CACHE_HOME|HOME}/.vis-cursors.csv`
Set a custom path with `M.path` \ No newline at end of file
diff --git a/init.lua b/init.lua
index caaf879..2651fe7 100644
--- a/init.lua
+++ b/init.lua
@@ -5,7 +5,7 @@ local get_default_cache_path = function()
local HOME = os.getenv('HOME')
local XDG_CACHE_HOME = os.getenv('XDG_CACHE_HOME')
local BASE = XDG_CACHE_HOME or HOME
- return BASE .. '/.vis-cursors'
+ return BASE .. '/.vis-cursors.csv'
end
M.path = get_default_cache_path()
@@ -39,7 +39,7 @@ local read_cursors = function()
end
-- read positions per file path
for line in f:lines() do
- for path, pos in string.gmatch(line, '(.+)%s(%d+)') do
+ for path, pos in string.gmatch(line, '(.+)[,%s](%d+)') do
cursors[path] = pos
end
end
@@ -58,7 +58,7 @@ local write_cursors = function()
-- buffer cursors string
local t = {}
for i, path in ipairs(paths) do
- table.insert(t, string.format('%s %d', path, cursors[path]))
+ table.insert(t, string.format('%s,%d', path, cursors[path]))
end
local s = table.concat(t, '\n')
f:write(s)