-
-
Notifications
You must be signed in to change notification settings - Fork 628
feat(#2349): add "right_align" option for renderer.icons.*_placement #2846
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
Changes from 5 commits
d27bcb8
6d336de
6b7b4f2
a8873b8
cb56c0d
bb666a5
121949d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,7 @@ M.ICON_PLACEMENT = { | |
signcolumn = 1, | ||
before = 2, | ||
after = 3, | ||
right_align = 4, | ||
} | ||
|
||
return M |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,12 +13,13 @@ local M = {} | |
local SIGN_GROUP = "NvimTreeRendererSigns" | ||
|
||
local namespace_id = vim.api.nvim_create_namespace "NvimTreeHighlights" | ||
local namespace_extmarks_id = vim.api.nvim_create_namespace "NvimTreeExtmarks" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice find. Could we play this a bit safer and have a separate namespace for full-name as well? It's using There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would be nice to rename it too, indeed, doesn't have to happen here though. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I looked at the the namespace usage in local extmarks = vim.api.nvim_buf_get_extmarks(0, ns_id, { line_nr - 1, 0 }, { line_nr - 1, -1 }, { details = true }) Because of that I don't think I can introduce a separate namespace for full_name rn, also There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fair enough; there may all sorts of assumptions there. |
||
|
||
---@param bufnr number | ||
---@param lines string[] | ||
---@param hl_args AddHighlightArgs[] | ||
---@param signs string[] | ||
local function _draw(bufnr, lines, hl_args, signs) | ||
local function _draw(bufnr, lines, hl_args, signs, extmarks) | ||
if vim.fn.has "nvim-0.10" == 1 then | ||
vim.api.nvim_set_option_value("modifiable", true, { buf = bufnr }) | ||
else | ||
|
@@ -38,6 +39,17 @@ local function _draw(bufnr, lines, hl_args, signs) | |
for i, sign_name in pairs(signs) do | ||
vim.fn.sign_place(0, SIGN_GROUP, sign_name, bufnr, { lnum = i + 1 }) | ||
end | ||
|
||
vim.api.nvim_buf_clear_namespace(bufnr, namespace_extmarks_id, 0, -1) | ||
for i, extname in pairs(extmarks) do | ||
for _, mark in ipairs(extname) do | ||
vim.api.nvim_buf_set_extmark(bufnr, namespace_extmarks_id, i, -1, { | ||
virt_text = { { mark.str, mark.hl } }, | ||
virt_text_pos = "right_align", | ||
hl_mode = "combine", | ||
}) | ||
end | ||
end | ||
end | ||
|
||
function M.render_hl(bufnr, hl) | ||
|
@@ -67,7 +79,7 @@ function M.draw() | |
|
||
local builder = Builder:new():build() | ||
|
||
_draw(bufnr, builder.lines, builder.hl_args, builder.signs) | ||
_draw(bufnr, builder.lines, builder.hl_args, builder.signs, builder.extmarks) | ||
|
||
if cursor and #builder.lines >= cursor[1] then | ||
vim.api.nvim_win_set_cursor(view.get_winnr() or 0, cursor) | ||
|
Uh oh!
There was an error while loading. Please reload this page.