* 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>
* feat: Add highlight group for opened folder
closes#1674
* docs: Add NvimTreeOpenedFolderIcon default
* feat: Add NvimTreeClosedFolderIcon highlight group
Defaults to NvimTreeFolderIcon
* 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>
* 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(#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
* 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 ...
* docs: lighten up readme and rework docs
* docs: clean up mappings from readme + some other small changes
* docs: move sections around
* ci: remove readme parts of docs' autogen
* docs: discuss nvim-web-devicons and provide an example
* docs: add an example setup
* docs: fix opts scraping; try and make more macos compatible
* docs: add *nvim-tree* tag at start of help
* docs: add an example setup
* docs: update quick start to match readme
* docs: add basic commands
* docs: add g? hint
* docs: add :help links to readme
* docs: restore help wanted
* docs: add example screenshot
* docs: add features
* docs: add example screenshot
* docs: add features to help
* docs: clarify option functions
Co-authored-by: Alexander Courtis <alex@courtis.org>
* feat(explorer): add experimental watchers
This commit introduces watchers to update the tree.
This behavior is introduced behind an "filesystem_watchers" option
which should prevent instabilities.
It will become the default at some point.
Co-authored-by: Alexander Courtis <alex@courtis.org>
(non breaking, old assignments link to new assignments)
- move lib.collapse-all into actions/collapse-all
- move lib.dir-up into actions/dir-up
- move lib.change-dir into actions/change-dir
- use setup option for change-dir global (and use the old option for
setup)
* feat/chore: rewrite git with job and some other fixes
* fix: fs clear window, rename echo_warning -> warn
also fix renaming and add an event blocker to avoid running many events
at the same time
Colors groups and icons are now in diagnostics.lua. They are defined on
setup which allows an easier configuration and better documentation.
`lsp_diagnostics` boolean value has been moved into a table `diagnostics`
with `enable` and `icons` as properties.
* chore: refacto setup part 1
refacto setup for code entrypoint
following options switched boolean values as options to the setup function:
- `nvim_tree_disable_netrw` -> `disable_netrw`
- `nvim_tree_hijack_netrw` -> `hijack_netrw`
- `nvim_tree_auto_open` -> `open_on_setup`
- `nvim_tree_auto_close` -> `auto_close`
- `nvim_tree_tab_open` -> `tab_open`
- `nvim-tree-update-cwd` -> `update_cwd`
- `nvim_tree_hijack_cursor` -> `hijack_cursor`
- `nvim_tree_system_open_command` -> `system_open.cmd`
- `nvim_tree_system_open_command_args` -> `system_open.args`
- `nvim_tree_follow` -> `update_focused_file.enable`
- `nvim_tree_follow_update_path` -> `update_focused_file.update_cwd`
Also added new option `update_focused_file.ignore_list` which will
ignore filepath or filetypes that matches one entry of the list when
updating the path if update_cwd is true.
* add deprecation warning
* update readme
* schedule on enter to avoid running before vim first buffer has loaded
* update docs
* correct typo
* rename tab open -> open on tab