Skip to content
This repository was archived by the owner on Jan 3, 2024. It is now read-only.
Open
Show file tree
Hide file tree
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
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,13 @@ local opts = {
-- padding from the left if max_len_align is true
max_len_align_padding = 1,

-- whether to show hints at a fixed column or not
left_align = false,

-- column to show the hints at if left_align is true
-- useful to set this to rustfmt.max_width
left_align_column = 100,

-- whether to align to the extreme right or not
right_align = false,

Expand Down
9 changes: 8 additions & 1 deletion doc/rust-tools.txt
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,14 @@ for keys that are not provided.

-- padding from the left if max_len_align is true
max_len_align_padding = 1,


-- whether to show hints at a fixed column or not
left_align = false,

-- column to show the hints at if left_align is true
-- useful to set this to rustfmt.max_width
left_align_column = 100,

-- whether to align to the extreme right or not
right_align = false,

Expand Down
7 changes: 7 additions & 0 deletions lua/rust-tools/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,13 @@ local defaults = {
-- padding from the left if max_len_align is true
max_len_align_padding = 1,

-- whether to show hints at a fixed column or not
left_align = false,

-- column to show the hints at if left_align is true
-- useful to set this to rustfmt.max_width
left_align_column = 100,

-- whether to align to the extreme right or not
right_align = false,

Expand Down
10 changes: 7 additions & 3 deletions lua/rust-tools/inlay_hints.lua
Original file line number Diff line number Diff line change
Expand Up @@ -197,12 +197,16 @@ local function render_line(line, line_hints, bufnr, max_line_len)
return
end

if opts.max_len_align then
if opts.max_len_align or opts.left_align then
local line_len =
string.len(vim.api.nvim_buf_get_lines(bufnr, line, line + 1, true)[1])

virt_text =
string.rep(" ", max_line_len - line_len + opts.max_len_align_padding)
if opts.left_align then
virt_text = string.rep(" ", opts.left_align_column - line_len)
else
virt_text =
string.rep(" ", max_line_len - line_len + opts.max_len_align_padding)
end
end

-- segregate parameter hints and other hints
Expand Down