symbols-outline.nvim icon indicating copy to clipboard operation
symbols-outline.nvim copied to clipboard

How do I get rid of all this wasted padding?

Open devkvlt opened this issue 2 years ago • 7 comments

symbols-outline

devkvlt avatar Oct 01 '22 14:10 devkvlt

I have the same question.

hawkinchina avatar Oct 14 '22 02:10 hawkinchina

Has anyone been able to figure this out?

tonyalaribe avatar Nov 07 '22 12:11 tonyalaribe

@tonyalaribe For starters, set signcolumn=no for Outline filetype, but that only removes one space.

devkvlt avatar Nov 07 '22 14:11 devkvlt

That worked nicely. Thanks @devkvlt

For others, I added this to my config:

autocmd FileType Outline setlocal signcolumn=no 

tonyalaribe avatar Nov 07 '22 14:11 tonyalaribe

to remove all the spaces, you can modify symbols-outline/parser.lua, go to M.get_lines, change line[index] = ' ' at line 119 to line[index] = '' and line[index] = line[index] .. ' ' at 167 to line[index] = line[index] .. ''.

Result: image

I hope this approach could be added into repo in a proper way, maybe we can add an option?

ch3n9w avatar Feb 05 '23 14:02 ch3n9w

I don't see the padding in other similar plugins, e.g., Tagbar, Aerial, or Vista.

It will be great if the signcolumn and hardcoded paddings are both disabled.

xlucn avatar Feb 17 '23 08:02 xlucn

Hi everyone,

Unfortunately, it seems like simrat39 isn't very active in this plugin lately, so a few days ago I've decided to fork the repo to implement a lot of features people have asked for and fixes users reported from this repo.

Thanks @ch3n9w for the suggested fix. Unfortunately, your changes would break the indents from guide markers. I've worked on top of your fix to make the guide markers look the same as they were, whilst removing the left padding.

Show diff
diff --git a/lua/symbols-outline/parser.lua b/lua/symbols-outline/parser.lua
index d1945fb..e0088ed 100644
--- a/lua/symbols-outline/parser.lua
+++ b/lua/symbols-outline/parser.lua
@@ -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)

I've recently pushed this fix to my fork.

You are welcome to try it out but do note that some new features may be experimental (unstable). These along with other fixes are listed in the readme.

image

hedyhli avatar Nov 08 '23 00:11 hedyhli