* fix(#2004): Change path_relative to use string find and substring to avoid using regex.
- This removed the original gsub with unintentional captures in path_to_matching_str
- The original regex based code captures create a limit where input path cannot
have more than 32 special charactors ( `.` , `_` or `-`)
* style nit
---------
Co-authored-by: Alexander Courtis <alex@courtis.org>
* #1961 diagnostic logging refresh_nodes_for_path
* #1961 add cycle detection to refresh_nodes_for_path
* #1961 escape special characters on when path matching during refresh
* #1961 escape special characters on when path matching during refresh
* fix(#1970): additional log function gating for efficiency when not logging
* fix(#1970): additional log function gating for efficiency when not logging
* fix(#1970): disable git integration after 10 timeouts
* fix(#1970): disable git integration after 10 timeouts
* fix(#1970): disable git integration after 10 timeouts
* fix(#1970): cleanly kill timed out git processes
* fix(#1970): revert git kill, to be completed via #1974 experiment
* fix(#1970): revert git kill, to be completed via #1974 experiment
* fix(#1970): additional log function gating for efficiency when not logging
* fix(#1970): additional log function gating for efficiency when not logging
* 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>
* feat: max_width for adaptive_size
* view grow calculates size correctly based on sign column visibility
* limit width to a minimum of 20
* adaptive_size -> min/max table
* harden view size calculations against bad user input
* style
* add back an extra column of padding to adaptive resizing
* back out: limit width to a minimum of 20
* revert unnecessary change
* backout: view grow calculates size correctly based on sign column visibility
* remove adaptive_size from help
* backout unnecessary change M.View.config
Co-authored-by: Alexander Courtis <alex@courtis.org>
* fix(#1822): test directory capable of watching before presenting it (#1901)
* feat(git): support `DA` state
Co-authored-by: Alexander Courtis <alex@courtis.org>
* fix(#1836):add view.debounce_delay to avoid some unnecessary explorer reloads
* fixed BufReadPost & BufUnload nil pointer
* update_focused_file.debouce_delay to view.debounce_delay
* changed docs to be more accurate
* added debounce on modified update
* Using same event for filter buffer
* removed unused View.debounce_delay
* changed docs to be more accurate
Co-authored-by: doot <gugegby@gmail.com>
Co-authored-by: Alexander Courtis <alex@courtis.org>
* Outlined new options
* highlight_modified is highlight_opened_files
* prototype with autocmd
* moved modified into glyphs
* show_on_dirs and show_on_open_dirs
* icon placement before & after
* _get_filename_offset
* fixed :wq doesn't update modified indicator
* highlight_modified, signcolumn modified_placement
Refactored to make everything use HighlightedString to remove all the complex `insert_highlight` calculation.
Not tested.
* updated doc to match the reality of no multi char for glyphs.modified
* fixed git signcolumn doesn't show
* fixed highlight_modified gets replaced by highlight_opened_files
* fixed renderer.icons.show.modified = false crash
* updated doc to reflect empty icon not breaking rendering
* removed debounce_delay to implement in a later PR
* doc nit: order placement
* change modified dirs default to be consistent with git
* illegal git & modified placement changed to default
* don't assume icon exist
* nit remove comment
* Noted in doc that glyphs can't have more than 2 characters if in signcolumn
* Don't sign_define if placement isn't signcolumn
Co-authored-by: Alexander Courtis <alex@courtis.org>
* feat(#1814): added cursorline config to DEFAULT_OPTS
Extends #1814
Currently, the config cursorline is set to `true` by default.
This behaviour can only be changed by a hacky way of listening to an event, as @alex-courtis mentioned that: "The user can change this default if they want via event".
This PR generalizes the configuration to be easier to config via the function `setup()`.
* doc: add cursorline
Co-authored-by: Alexander Courtis <alex@courtis.org>
* coding style
* outlined git.show_on_open_dirs behavior
* show some icon on opendir even if show_on_open_dir=false
and show all children's status on parent
* fixed renamed icon not showing
* sorted icons
* removed DU from deleted as file will show up in tree
* fixed update_git_status in reloaders not tested
* fixed Api.git.reload()
Tested update_git_status in reloaders.lua
* sort icon only if not git signcolumn
* fixed crashing when root dir isn't git dir
* made git.show_on_dirs doc more concise
* git_statuses -> git_status for consistency
* explorer/common.lua -> explorer/node.lua
* fixed#1784 conflict
* don't order icons
* Revert "don't order icons"
This reverts commit 23f6276ef7.
* Revert "Revert "fix(#1815): don't schedule find_file calls, debounce update_focused_file with 15ms default (#1820)""
This reverts commit a8d26bb088.
* fix(#1723): find_file for externally created new file results in folder unable to be opened
* fix(#1723): find_file for externally created new file results in folder unable to be opened
* feat: allow passing a custom function as a window picker
WIP
* fix: move logic expression to if statement
If `M.window_picker.custom_function()` returns `nil` then `pick_win_id()`
will run (the or part). We don't want that. More verbose, but better.
* feat(open): add window_picker.picker
* feat(open): add window_picker.picker
* style nit
* feat(open): add window_picker.picker
* docs: add window_picker.picker documentation
* docs: add window_picker.picker documentation
Co-authored-by: Alexander Courtis <alex@courtis.org>
* relative rename action
* 🔥 remove debug print statement
* 🐛 better handling of dot files
Also pickout extension in filename with more one dot
* 🔧 keymap e for relative-rename action
* 📝 update help with relative-rename mapping
* ✨ add API for rename_relative
* 🚨 correct lint warnings
* rename_relative -> rename_root
* stylua
* ♻️ use fnamemodify instead of custom logic
* 💥 refactor renaming api using vim filename modifiers
Rename API now supports filename modifiers as arguments, although
only with limited support of options. The function signature however
will allow improvements going forward. The API signature is backward
compatible, although the behviour has changed as per the next comment.
This change changes the default behaviour of the renames, rename_full is
what rename was, rename now just renames the tail (i.e. the filename)
* 🐛 make api rename, without args, functional
* ✨ allow modifier argument to be used in API call
* 📝 update documentation with new command name
* rename-file.fn takes only a modifier as argument
* add Api.fs.rename_basename, specify modifiers for rename, rename_sub
* add Api.fs.rename_node
* rename-file tidy allowed modifiers
* 🐛 fix bugs after last refactoring
rename ":t" and ":t:r" was moving file to root of project and not
maintaining sub-directory
* 🐛 correct absolute rename
which was loosing sub-directory on rename
* 🔥 remove debug print statements
* stylua
Co-authored-by: Alexander Courtis <alex@courtis.org>
* fixed git rename not showing up for the renamed file
* considered " -> " being a part of the filename
Fixed -> pattern to escape -
Fixed "\"" and "\\" in filename
* using string.find(, , true) to match plain ->
* Using -z and removed unnecessary logic
* Filtered dir with git status that are open when show_on_open_dir is false
* refactored for single source of truth of existence of git status on a node
Putting `has_git_status()` in `explorer.common` because that's where node.status is constructed
Or at least I think that's where it's constructed
* 1786 semantic nit
Co-authored-by: Alexander Courtis <alex@courtis.org>
* feat: Add highlight group for opened folder
closes#1674
* docs: Add NvimTreeOpenedFolderIcon default
* feat: Add NvimTreeClosedFolderIcon highlight group
Defaults to NvimTreeFolderIcon
* fix(#1731): watcher refreshes node rather than the first node matching absolute path, profile refresh
* fix(#1731): reload explorer reloads closed folders
* fix(#1731): do not fire folder created event on file create
* fix(#1731): reload profile absolute path, not link to
* fix(#1731): find-file locks/profiles on real path, reloads when watchers disabled
* Revert "fix(#1731): reload explorer reloads closed folders"
This reverts commit 5dfd8bd2fa.
* fix(#1731): tidy watch reload
* fix(#1731): move refresh_node from watch to reload
* fix(#1731): find-file reloads all nodes for the containing directory
* fix(#1731): create-file refreshes synchronously
* fix(#1731): remove unused watch node
* fix(#1731): find-file refreshes root
* fix(#1716): create-file invokes find-file
* fix(#1731): refresh path walks down the tree to the targedt
* Add new renderer setting `add_root_updir` to fix#1743.
* Fix default value in docs.
* Remove proposed “add_root_updir” and rename “root_folder_modifier” to “root_folder_label”. Also, “root_folder_label” can be also a function now.
* chore: warn users about breaking change
* fix(#1743): use silent migration of root_folder_modifier
* fix(#1743): add example, document previous renderer.root_folder_modifier
* Add check to validate return type of “root_folder_label” is string.
* Change “root_folder_label” default value to “:~:s?$?/..?”.
* Add missing keyword “local” to local variable “label”.
Co-authored-by: David Aguilera <david.aguilera@neliosoftware.com>
Co-authored-by: gegoune <dev@clog.rocks>
Co-authored-by: Alexander Courtis <alex@courtis.org>
* Sync closing of nvim-tree across tabs
* chore: remove vim.* "requires"
* Sync closing of nvim-tree across tabs
* Fix api.close calls
* Fix issue from merge
* Implement changes
* Finish todos and add close_all_tabs
* silently refactor options, add doc
* fix vinegar example
* Refactor close to work with tabid
* Close nvim tree if last buffer
* close and abandon all tabs on subsequent setup calls
Co-authored-by: Alexander Courtis <alex@courtis.org>
* fix(#1716): focus file/directory when created in a sub-directory, don't dispatch FolderCreated on file creation
* fix(#1716): focus file/directory when created in a sub-directory
* fix(#1716): focus file/directory when created in a sub-directory
* fix(#1723): find_file for externally created new file results in folder unable to be opened
* fix(#1723): find_file for externally created new file results in folder unable to be opened
* feat: command to clear the clipboard
* feat: command to clear the clipboard: stylua
* feat: command to clear the clipboard: add to :help
Co-authored-by: Alexander Courtis <alex@courtis.org>
* fix: use pcall to prevent live-filter regex errors
Wrap live filter's match function in pcall to prevent errors caused by
invalid regex while typing.
* nit: use ok for pcall rc
* nit: stylua fix
Co-authored-by: Alexander Courtis <alex@courtis.org>
* fix(#1629): nvim start with file named *NvimTree* opens tree instead of buffer
* Revert "fix(#1629): nvim start with file named *NvimTree* opens tree instead of buffer"
This reverts commit e7136078f7.
* fix(#1629): nvim start with file named *NvimTree* treats file as tree
* fix(#1629): nvim start with file named *NvimTree* treats file as tree
* fix(#1639): ensure tree autocommands match filetype as well as name
* fix(#1639): fix bad merge
* fix(#1639): ensure tree autocommands match filetype as well as name
* fix: preview on floating window
* chore: redrawing the tree after setting current win
* chore: ignore winleave autocmd on preview action
* fix: typo in comment
* chore: call correct window id
* chore: revert changes in focus method
* chore: check if float window is enabled before ignoring WinLeave
* fix: prevent quit_on_open from opening in same window
* chore: remove condition for quit_on_open
* fix: prevent opening file in a new window on floting nvim-tree
* stylua
Co-authored-by: Alexander Courtis <alex@courtis.org>
* fix(#1629): nvim start with file named *NvimTree* opens tree instead of buffer
* Revert "fix(#1629): nvim start with file named *NvimTree* opens tree instead of buffer"
This reverts commit e7136078f7.
* fix(#1629): nvim start with file named *NvimTree* treats file as tree
* fix(#1629): nvim start with file named *NvimTree* treats file as tree
* fix(#1615): focus created file when command line prompt requires confirmation
* fix(#1615): focus created file when command line prompt requires confirmation
* the nice fix
* fix(#1547): pass git toplevel cwd unescaped, pass git untracked arguments as per toplevel
Co-authored-by: Maximilian Philipp <philipp@student.tugraz.at>
Co-authored-by: Alexander Courtis <alex@courtis.org>
* feat: Mixin Sorter (#1565) Self Solved
adding `mixin` sort options for `rust` like package systems
```
package.rs
package/
__inside__
lib.rs
lib/
_inside_
a.rs
b.rs
module.rs
```
* feat: sort_by, after_sort options for more convinient using
```
*nvim-tree.sort_by*
Changes how files within the same directory are sorted.
Can be one of 'name', 'case_sensitive', 'modification_time' or 'extension',
'function'.
>
sort_by = function(a, b)
if not (a and b) then
return true
end
if a.nodes and not b.nodes then
return true
elseif not a.nodes and b.nodes then
return false
end
return a.name:lower() <= b.name:lower()
end
end
Type: `string | function(a, b)`, Default: `"name"`
*nvim-tree.after_sort*
Related to nvim-tree.sort_by, this function runs without mergesort.
Can be defined by your own after-sort works.
Type: `function(table)`, Default: `disable`
>
after_sort = function(t)
local i = 1
while i <= #t do
if t[i] and t[i].nodes then
local j = i + 1
while j <= #t do
if t[j] and not t[j].nodes and t[i].name:lower() == t[j].name:lower():match "(.+)%..+$" then
local change_target = t[j]
table.remove(t, j)
table.insert(t, i, change_target)
break
end
j = j + 1
end
end
i = i + 1
end
end
```
* remove: after_sort ( misunderstood feature )
sort_by parameter can be function.
``` lua
sort_by = function(t)
local sorters = require "nvim-tree.explorer.sorters"
local comparator = sorters.retrieve_comparator("name")
sorters.split_merge(t, 1, #t, comparator) -- run default merge_sort
local i = 1
while i <= #t do
if t[i] and t[i].nodes then
local j = i + 1
while j <= #t do
if t[j] and not t[j].nodes and t[i].name:lower() == t[j].name:lower():match "(.+)%..+$" then
local change_target = t[j]
table.remove(t, j)
table.insert(t, i, change_target)
break
end
j = j + 1
end
end
i = i + 1
end
end,
```
* try-fix: change existing merge_sort function, call user's sort_by
hope.. like it...?
* doc: explain function parameter and return, add more complex example
* fix: reorder with user-comparator exceed memory limit
apply merge_sort
check nil & type for senitize
* fix: user_index based sorting ( create index )
for performance, create index once,
using index to re-ordering
* fix: fence problems
* doc & fix: merge_sort problem fix & nil sorting
add complex example
* fix: sort_by detect and use string and nil
* doc: revert sort_by to simple
* fix: sort_by does not return anything
Co-authored-by: Alexander Courtis <alex@courtis.org>
* feat: add config option for a tree indent width
add 'indent_width' option to configure visible indent for tree nesting
levels (default is 2).
* add 'bottom' char for a corner extension
* apply stylua formatting
* provide value constraints in documentation
* limit minimal indent width
* make marker symbols have one utf8 char width
* match stylua formatting
* add the commentary regarding utf-8 first symbol match
* Simple mock-up of floating nvim-tree window
* Passing whole table to nvim_open_win()
* Run update-help.sh
* Use vim.api alias
* Add comment to float options
* Added `anchor` to float options
* Enabling float window enforces `actions.open_file.quit_on_open`
* Added documentation
* add view.float.open_win_config, skipping validation
* Made nvim-tree window closes when float is enabled
* Close nvim-tree window when out of focus
* Update help
Co-authored-by: Krzysztof Cieśla <krzysztof.marcin.ciesla@cern.ch>
Co-authored-by: Alexander Courtis <alex@courtis.org>
Also fixes changing tab by deferring the call on tab enter.
New option `ignore_buf_on_tab_change` to avoid opening for some tabs.
Some example could be neogit, vim fugitive, man pages ...