Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(precognition): add line wrapping for virtual lines #74

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions lua/precognition/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,17 @@ local function display_marks()

-- TODO: can we add indent lines to the virt line to match indent-blankline or similar (if installed)?

if vim.opt.wrap and #virt_line > 0 then
local width = vim.go.columns - vim.go.numberwidth - 1
local cursorcolpos = vim.api.nvim_win_get_cursor(0)[2] + 1
local section = math.floor(cursorcolpos / width)
local start = section * width
local end_ = start + width
if #virt_line[1][1] > width then
virt_line[1][1] = string.sub(virt_line[1][1], start, end_)
end
end

-- create (or overwrite) the extmark
if config.showBlankVirtLine or (virt_line and #virt_line > 0) then
extmark = vim.api.nvim_buf_set_extmark(0, ns, cursorline - 1, 0, {
Expand Down
Loading