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

@@ -37,6 +37,10 @@ I do not merge PRs from the original repo that I don't personally need.
## Fixes ## Fixes
- Extra padding/indent on left on outline window removed. Fixed issues:
- simrat39/symbols-outline.nvim/165
- simrat39/symbols-outline.nvim/178
- simrat39/symbols-outline.nvim/209
- Symbol preview empty (simrat39/symbols-outline.nvim#176) - Symbol preview empty (simrat39/symbols-outline.nvim#176)
- `SymbolsOutlineClose` crashing when already closed: simrat39/symbols-outline.nvim#163 - `SymbolsOutlineClose` crashing when already closed: simrat39/symbols-outline.nvim#163
- Symbols not showing by supporting Nerd fonts v3.0: simrat39/symbols-outline.nvim#225 - Symbols not showing by supporting Nerd fonts v3.0: simrat39/symbols-outline.nvim#225

View File

@@ -118,9 +118,7 @@ function M.get_lines(flattened_outline_items)
end end
for index, _ in ipairs(line) do for index, _ in ipairs(line) do
-- all items start with a space (or two)
if config.options.guides.enabled then if config.options.guides.enabled then
-- makes the guides and add guide markers
local guide_markers = config.options.guides.markers local guide_markers = config.options.guides.markers
if index == 1 then if index == 1 then
line[index] = '' line[index] = ''
@@ -177,6 +175,7 @@ function M.get_lines(flattened_outline_items)
running_length = running_length + vim.fn.strlen(line[index]) running_length = running_length + vim.fn.strlen(line[index])
end end
line[1] = ''
local final_prefix = line local final_prefix = line
local string_prefix = t_utils.table_to_str(final_prefix) 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) local max_width = #tostring(lineno_max)
-- Padded prefix to the right of lineno for better readability if linenos -- Padded prefix to the right of lineno for better readability if linenos
-- get more than 2 digits. -- 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 -- Offset to hl_info due to adding lineno on the left of each symbol line
local total_offset = #prefix local total_offset = #prefix
for i, node in ipairs(flattened_outline_items) do for i, node in ipairs(flattened_outline_items) do

View File

@@ -25,6 +25,7 @@ function View:setup_view()
-- window stuff -- window stuff
vim.api.nvim_win_set_option(self.winnr, 'spell', false) 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, '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, 'number', false)
vim.api.nvim_win_set_option(self.winnr, 'relativenumber', false) vim.api.nvim_win_set_option(self.winnr, 'relativenumber', false)
vim.api.nvim_win_set_option(self.winnr, 'winfixwidth', true) vim.api.nvim_win_set_option(self.winnr, 'winfixwidth', true)