feat(view): add view.width.padding (#1941)

* fix: variable width accounts for sign/number columns

* Add dynamic sizing padding options

with https://github.com/neovim/neovim/pull/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!

* allow padding function, update docs, rollback readme

* typo in example setup

* help formatting

---------

Co-authored-by: Alexander Courtis <alex@courtis.org>
This commit is contained in:
Peter van der Meulen
2023-01-28 04:07:14 +01:00
committed by GitHub
parent 55028e30d7
commit e05ed6a60f
3 changed files with 28 additions and 9 deletions

View File

@@ -81,6 +81,7 @@ Setup should be run in a lua file or in a |lua-heredoc| if using in a vim file.
require("nvim-tree").setup({
sort_by = "case_sensitive",
view = {
width = 30,
mappings = {
list = {
{ key = "u", action = "dir_up" },
@@ -733,13 +734,17 @@ Window / buffer setup.
Type: `string | number | function | table`, Default: `30`
*nvim-tree.view.width.min*
Minimum dynamic width.
Minimum dynamic width.
Type: `string | number | function`, Default: `30`
*nvim-tree.view.width.max*
Maximum dynamic width, -1 for unbounded.
Maximum dynamic width, -1 for unbounded.
Type: `string | number | function`, Default: `-1`
*nvim-tree.view.width.padding*
Extra padding to the right.
Type: `string | number | function`, Default: `1`
*nvim-tree.view.side*
Side of the tree, can be `"left"`, `"right"`.
Type: `string`, Default: `"left"`