fix: Extra left padding

Please see linked issues

- simrat39/symbols-outline.nvim/165
- simrat39/symbols-outline.nvim/178
- simrat39/symbols-outline.nvim/209
This commit is contained in:
hedy
2023-11-08 08:36:17 +08:00
parent aaf4a33313
commit 6c47ebf0d7
3 changed files with 8 additions and 4 deletions

View File

@@ -118,12 +118,10 @@ function M.get_lines(flattened_outline_items)
end
for index, _ in ipairs(line) do
-- all items start with a space (or two)
if config.options.guides.enabled then
-- makes the guides and add guide markers
local guide_markers = config.options.guides.markers
if index == 1 then
line[index] = ' '
line[index] = ''
-- if index is last, add a bottom marker if current item is last,
-- else add a middle marker
elseif index == #line then
@@ -177,6 +175,7 @@ function M.get_lines(flattened_outline_items)
running_length = running_length + vim.fn.strlen(line[index])
end
line[1] = ''
local final_prefix = line
local string_prefix = t_utils.table_to_str(final_prefix)
@@ -197,7 +196,7 @@ function M.get_lines(flattened_outline_items)
local max_width = #tostring(lineno_max)
-- Padded prefix to the right of lineno for better readability if linenos
-- get more than 2 digits.
local prefix = string.rep(' ', math.max(2, max_width) - 1)
local prefix = string.rep(' ', math.max(2, max_width)+1)
-- Offset to hl_info due to adding lineno on the left of each symbol line
local total_offset = #prefix
for i, node in ipairs(flattened_outline_items) do

View File

@@ -25,6 +25,7 @@ function View:setup_view()
-- window stuff
vim.api.nvim_win_set_option(self.winnr, 'spell', false)
vim.api.nvim_win_set_option(self.winnr, 'signcolumn', 'no')
vim.api.nvim_win_set_option(self.winnr, 'foldcolumn', '0')
vim.api.nvim_win_set_option(self.winnr, 'number', false)
vim.api.nvim_win_set_option(self.winnr, 'relativenumber', false)
vim.api.nvim_win_set_option(self.winnr, 'winfixwidth', true)