marks.lua - dotfiles - leot's dotfiles
(HTM) hg clone https://bitbucket.org/iamleot/dotfiles
(DIR) Log
(DIR) Files
(DIR) Refs
---
marks.lua
---
1 --- Mark support.
2 --
3 -- TODO: description
4 --
5 -- @module marks
6 -- @copyright 2018 Leonardo Taccari
7
8 local modes = require("modes")
9
10 local _M = {}
11
12 --
13 -- TODO: previous_y and markers should be per-URI, otherwise they are
14 -- TODO: globally shared.
15 --
16
17 _M.previous_y = nil
18 _M.markers = {}
19
20 modes.add_binds("normal", {
21 { "^m[a-zA-Z0-9]", "TODO", function (w, o)
22 local token = string.match(o.buffer, "^m(.)$")
23 _M.previous_y = w.view.scroll.y
24 _M.markers[token] = w.view.scroll.y
25 end },
26 { "^'[a-zA-Z0-9]", "TODO", function (w, o)
27 local token = string.match(o.buffer, "^'(.)$")
28 if _M.markers[token] then
29 _M.previous_y = w.view.scroll.y
30 w.view.scroll.y = _M.markers[token]
31 end
32 end },
33 { "''", "TODO", function (w, o)
34 _M.previous_y, w.view.scroll.y = w.view.scroll.y, _M.previous_y
35 end },
36 })
37
38 return _M