From f36f51f60070298bb19fb92f58acc06e8dc6a0c6 Mon Sep 17 00:00:00 2001 From: Erlend Fagerheim Date: Thu, 23 Apr 2020 19:58:24 +0200 Subject: support XDG_CACHE_HOME --- README.md | 9 +++++---- init.lua | 7 ++++++- 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 -- cgit