Skip to content
This repository was archived by the owner on Jan 3, 2024. It is now read-only.

Commit ae734a1

Browse files
feat(inlay_hints): Add left_align for fixed column
Signed-off-by: Utkarsh Gupta <utkarshgupta137@gmail.com>
1 parent 71d2cf6 commit ae734a1

File tree

4 files changed

+26
-2
lines changed

4 files changed

+26
-2
lines changed

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,13 @@ local opts = {
264264
-- padding from the left if max_len_align is true
265265
max_len_align_padding = 1,
266266

267+
-- whether to show hints at a fixed column or not
268+
left_align = false,
269+
270+
-- column to show the hints at if left_align is true
271+
-- useful to set this to rustfmt.max_width + 1/2
272+
left_align_column = 1,
273+
267274
-- whether to align to the extreme right or not
268275
right_align = false,
269276

doc/rust-tools.txt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,14 @@ for keys that are not provided.
189189

190190
-- padding from the left if max_len_align is true
191191
max_len_align_padding = 1,
192-
192+
193+
-- whether to show hints at a fixed column or not
194+
left_align = false,
195+
196+
-- column to show the hints at if left_align is true
197+
-- useful to set this to rustfmt.max_width + 1/2
198+
left_align_column = 1,
199+
193200
-- whether to align to the extreme right or not
194201
right_align = false,
195202

lua/rust-tools/config.lua

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,13 @@ local defaults = {
4848
-- padding from the left if max_len_align is true
4949
max_len_align_padding = 1,
5050

51+
-- whether to show hints at a fixed column or not
52+
left_align = false,
53+
54+
-- column to show the hints at if left_align is true
55+
-- useful to set this to rustfmt.max_width + 1/2
56+
left_align_column = 1,
57+
5158
-- whether to align to the extreme right or not
5259
right_align = false,
5360

lua/rust-tools/inlay_hints.lua

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,10 +197,13 @@ local function render_line(line, line_hints, bufnr, max_line_len)
197197
return
198198
end
199199

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

204+
if opts.left_align then
205+
max_line_len = opts.left_align_column
206+
end
204207
virt_text =
205208
string.rep(" ", max_line_len - line_len + opts.max_len_align_padding)
206209
end

0 commit comments

Comments
 (0)