-
-
Notifications
You must be signed in to change notification settings - Fork 625
Add dynamic sizing padding options #1941
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add dynamic sizing padding options #1941
Conversation
with neovim/neovim#20621 merged in it is now possible to fully customize the status-column in nvim (the column on the left containing line-numbers, fold info, signs and borders). A fair few cool implementations have popped up like: - https://github.com/CKolkey/config/blob/master/nvim/after/plugin/statuscolumn.lua - https://github.com/luukvbaal/statuscol.nvim - and my own personal one (based on CKolkey's fantastic work) https://git.hendrikpeter.net/hendrikpeter/pico-vim/-/blob/main/lua/peva/status_column.lua The problem with nvim-tree however is that dynamic sizing doesn't take the custom size of a status column into account and the end of file names get clipped off. This little patch should fix that (and give some examples to help other status_column modders get started). Thanks for looking at this and thanks for making this amazing plugin, I've been using it for a while and I really like it!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Notes from self
@@ -74,7 +74,14 @@ require("nvim-tree").setup() | |||
require("nvim-tree").setup({ | |||
sort_by = "case_sensitive", | |||
view = { | |||
adaptive_size = true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I noticed that this is now deprecated, so I updated the example code in the README with the new way of working with dynamic sizes and then tacked my padding options on
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you. It seems I forgot to update the README... please update to match help
nvim-tree.lua/doc/nvim-tree-lua.txt
Line 82 in 9e87ee2
sort_by = "case_sensitive", |
it's only there to provide an example of a simple option to pass to setup.
doc/nvim-tree-lua.txt
Outdated
*nvim-tree.view.width.padding* | ||
dynamic padding when resizing. Useful for custom status-column | ||
styles. | ||
Type: `number`, Default: `3` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be the right docs, padding only really supports a number
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It can be a function, even if just for the sake of consistency.
You might wish to increase padding as you increase max, to "balance things out".
lua/nvim-tree/view.lua
Outdated
@@ -250,7 +251,7 @@ local function grow() | |||
local starts_at = M.is_root_folder_visible(require("nvim-tree.core").get_cwd()) and 1 or 0 | |||
local lines = vim.api.nvim_buf_get_lines(M.get_bufnr(), starts_at, -1, false) | |||
-- 1 column of right-padding to indicate end of path | |||
local padding = 3 | |||
local padding = M.View.padding |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The big change happens here.
#1930 might be better than my change here, I'll leave the decision to you. (having both the ability to do a bit of padding and read it dynamically could also be an option, i personally like 2 or 3 columns of space to the right) |
We can do both. Padding at the end is quite nice and there's no reason not to make it customisable. I'd be most grateful if you merged the above branch and we release them as one. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please:
- allow a padding function
- update readme
- merge
fix-variable-width-sign-number-columns
doc/nvim-tree-lua.txt
Outdated
*nvim-tree.view.width.padding* | ||
dynamic padding when resizing. Useful for custom status-column | ||
styles. | ||
Type: `number`, Default: `3` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It can be a function, even if just for the sake of consistency.
You might wish to increase padding as you increase max, to "balance things out".
@@ -74,7 +74,14 @@ require("nvim-tree").setup() | |||
require("nvim-tree").setup({ | |||
sort_by = "case_sensitive", | |||
view = { | |||
adaptive_size = true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you. It seems I forgot to update the README... please update to match help
nvim-tree.lua/doc/nvim-tree-lua.txt
Line 82 in 9e87ee2
sort_by = "case_sensitive", |
it's only there to provide an example of a simple option to pass to setup.
Thanks, I'll give this a look and make the corrections after my workday is done! |
c04db63
to
5fa504a
Compare
…-padding-to-dynamic-size # Conflicts: # lua/nvim-tree/view.lua
That should be it @alex-courtis & @ramezgerges I think i went through all the todo-items and cleaned things up a bit. I tested the code myself just now and did some experiments with functions and the likes. you can see the first changes here: and then in the merge commit after that I get rid of the little print() that i had inserted earlier. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested OK
width:
20
min/max 20/25
min/max 20/20
sign:
"no"
"yes:4"
number:
true
false
padding:
0
1
2
function
Many thanks @HendrikPetertje |
if type(wininfo) == "table" and type(wininfo[1]) == "table" then | ||
padding = padding + wininfo[1].textoff | ||
end | ||
print(padding) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove this stray debug print
statement.
This gives me an extra "Press ENTER or type command to continue" prompt with the padding printed, whenever I toggle Nvim tree window.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah sorry that was my mistake, the problem was fixed a few days ago in master ^_^
That has been fixed on master. Please update. |
with neovim/neovim#20621 merged in it is now possible to fully customize the status-column in nvim (the column on the left containing line-numbers, fold info, signs and borders).
A fair few cool implementations have popped up like:
The problem with nvim-tree however is that dynamic sizing doesn't take the custom size of a status column into account and the end of file names get clipped off. This little patch should fix that (and give some examples to help other status_column modders get started).
Thanks for looking at this and thanks for making this amazing plugin, I've been using it for a while and I really like it!
Some screenshots:
Before:

After:
