1

Refresh generated neovim config

This commit is contained in:
2024-07-14 21:12:36 +02:00
parent f215ce2ab5
commit 00464e0e65
731 changed files with 6780 additions and 31110 deletions

View File

@ -3,6 +3,7 @@ local cmd = vim.cmd
local fn = vim.fn
local promise = require('promise')
local async = require('async')
local render = require('ufo.render')
local utils = require('ufo.utils')
local floatwin = require('ufo.preview.floatwin')
@ -288,9 +289,47 @@ function Preview:peekFoldedLinesUnderCursor(enter, nextLineIncluded)
floatwin:refreshTopline()
end)
self:toggleCursor()
render.mapHighlightLimitByRange(bufnr, floatwin:getBufnr(),
{lnum - 1, 0}, {endLnum - 1, #text[endLnum - lnum + 1]}, text, self.ns)
render.mapMatchByLnum(winid, floatwin.winid, lnum, endLnum)
local floatBufnr = floatwin:getBufnr()
local function doHighlight(s, e)
render.mapHighlightLimitByRange(bufnr, floatBufnr, lnum - 1,
{s - 1, 0}, {e - 1, #text[e - lnum + 1]}, text, self.ns)
render.mapMatchByLnum(winid, floatwin.winid, s, e)
end
local span = 800
local lower = math.max(lnum, oLnum - span / 2)
local upper = math.min(endLnum, oLnum + span / 2)
doHighlight(lower, upper)
if lower > lnum or upper < endLnum then
-- TODO
-- use an event like `CursorMoved` to fire is better
async(function()
local function renderSpan(s, e)
local i = s + span
while i < endLnum do
if not self.validate() then
return
end
doHighlight(i - span + 1, i)
await(utils.wait(30))
i = i + span
end
if not self.validate() then
return
end
doHighlight(i - span + 1, e)
end
if lower > lnum then
renderSpan(lnum, lower - 1)
end
if upper < endLnum then
renderSpan(upper + 1, endLnum)
end
end)
end
vim.wo[floatwin.winid].listchars = vim.wo[winid].listchars
return floatwin.winid
end

View File

@ -117,8 +117,8 @@ local function mapInlayMarkers(bufnr, startRow, marks, ns)
end
end
function M.mapHighlightLimitByRange(srcBufnr, dstBufnr, startRange, endRange, text, ns)
local startRow, startCol = startRange[1], startRange[1]
function M.mapHighlightLimitByRange(srcBufnr, dstBufnr, baseRow, startRange, endRange, text, ns)
local startRow, startCol = startRange[1], startRange[2]
local endRow, endCol = endRange[1], endRange[2]
local nss = {}
for _, namespace in pairs(api.nvim_get_namespaces()) do
@ -128,9 +128,9 @@ function M.mapHighlightLimitByRange(srcBufnr, dstBufnr, startRange, endRange, te
end
local hlGroups = highlight.hlGroups()
local hlMarks, inlayMarks = extmark.getHighlightsAndInlayByRange(srcBufnr, startRange, endRange, nss)
mapHighlightMarkers(dstBufnr, startRow, hlMarks, hlGroups, ns)
mapHighlightMarkers(dstBufnr, baseRow, hlMarks, hlGroups, ns)
hlMarks = treesitter.getHighlightsByRange(srcBufnr, startRange, endRange, hlGroups)
mapHighlightMarkers(dstBufnr, startRow, hlMarks, hlGroups, ns)
mapHighlightMarkers(dstBufnr, baseRow, hlMarks, hlGroups, ns)
if vim.bo[srcBufnr].syntax ~= '' then
api.nvim_buf_call(srcBufnr, function()
local res = {}
@ -139,17 +139,17 @@ function M.mapHighlightLimitByRange(srcBufnr, dstBufnr, startRange, endRange, te
syntaxToRowHighlightRange(res, lnum, startCol + 1, endCol)
else
for l = lnum, endLnum - 1 do
syntaxToRowHighlightRange(res, l, 1, #text[l - lnum + 1])
syntaxToRowHighlightRange(res, l, 1, #text[l - baseRow])
end
syntaxToRowHighlightRange(res, endLnum, 1, endCol)
end
for _, r in ipairs(res) do
local row = r[1] - lnum
local row = r[1] - baseRow - 1
extmark.setHighlight(dstBufnr, ns, row, r[2] - 1, row, r[3], r[4], 1)
end
end)
end
mapInlayMarkers(dstBufnr, startRow, inlayMarks, ns)
mapInlayMarkers(dstBufnr, baseRow, inlayMarks, ns)
end
function M.mapMatchByLnum(srcWinid, dstWinid, lnum, endLnum)