aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorErlend Fagerheim <erlendf80@gmail.com>2020-04-23 19:58:24 +0200
committerErlend Fagerheim <erlendf80@gmail.com>2020-04-23 20:00:22 +0200
commitf36f51f60070298bb19fb92f58acc06e8dc6a0c6 (patch)
tree19b72de48a08b8d827893cec48a24926fe298a73
parent4d6a01f3c476fd38b716faabe20e422b0c65bfb8 (diff)
downloadvis-cursors-f36f51f60070298bb19fb92f58acc06e8dc6a0c6.tar.gz
support XDG_CACHE_HOME
-rw-r--r--README.md9
-rw-r--r--init.lua7
2 files changed, 11 insertions, 5 deletions
diff --git a/README.md b/README.md
index 2bbb4b4..86fa91a 100644
--- a/README.md
+++ b/README.md
@@ -1,7 +1,8 @@
# vis-cursors
-Remember cursor positions per file. A plugin for the [vis editor](https://github.com/martanne/vis).
-# Usage
-Require `vis-cursors` in your `visrc.lua` file ( see [Plugins](https://github.com/martanne/vis/wiki/Plugins) ).
+Remember cursor positions per file.
+
+Cursors are stored in `XDG_CACHE_HOME/cursors`, `$HOME/.cursors` or set via `M.path`.
+
+A [plugin](https://github.com/martanne/vis/wiki/Plugins) for the [vis](https://github.com/martanne/vis) text editor.
-Cursor positions are stored in `$HOME/.cursors`, or set another path using `M.path`.
diff --git a/init.lua b/init.lua
index 888ff8e..69e29bf 100644
--- a/init.lua
+++ b/init.lua
@@ -1,6 +1,11 @@
local M = {}
local cursors = {}
-M.path = os.getenv('HOME') .. '/.cursors'
+local XDG_CACHE_HOME = os.getenv('XDG_CACHE_HOME')
+if XDG_CACHE_HOME then
+ M.path = XDG_CACHE_HOME .. '/cursors'
+else
+ M.path = os.getenv('HOME') .. '/.cursors'
+end
function apply_cursor_pos(win)
if win.file == nil or win.file.path == nil then return end