Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
Giumo X. Clanjor (哆啦比猫/兰威举) committed Sep 2, 2015
2 parents b011249 + 70d0ce3 commit 2245dcc
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
12 changes: 11 additions & 1 deletion vim/lib/vimlight.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ local make_vimlight = function(root)
local vl = {}
local file
local option
local nline = 1

vl.fetch = function()
if done then return end
Expand Down Expand Up @@ -42,6 +43,15 @@ local make_vimlight = function(root)

vl.modify = function()
modified = true

-- detect line insertion/deletion, then shift the highlight down/up
local n = vim.eval[[line('$')]]
if n ~= nline then
local y = vim.eval[[line('.')]]
local d = math.abs(n - nline) ; -- semicolon required here to avoid parsing ambiguity
(n > nline and env.insert_line or env.delete_line)(y, d)
nline = n
end
end

vl.rename = function()
Expand All @@ -68,7 +78,7 @@ local make_vimlight = function(root)
end

vl.view = function()
local y = vim.eval[[getcurpos()]][1]
local y = vim.eval[[line('.')]]
local h = vim.eval[[&lines]]
env.view(y, h)
end
Expand Down
18 changes: 18 additions & 0 deletions vim/lib/vimlight_environment.lua
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,24 @@ local make_vimlight_environment = function()
vim.command(cmd:format(win_id))
end

env.insert_line = function(y, n)
for _,hl in ipairs(hls()) do
if hl.y >= y then
hl.y = hl.y + n
match_del(hl)
end
end
end

env.delete_line = function(y, n)
for _,hl in ipairs(hls()) do
if hl.y >= y+n then
hl.y = hl.y - n
match_del(hl)
end
end
end

return env
end

Expand Down

0 comments on commit 2245dcc

Please sign in to comment.