Commit Graph

108 Commits

Author SHA1 Message Date
Alexander Courtis
bcb2a5a80d
fix(#1720): .git watch only FETCH_HEAD, HEAD, HEAD.lock, config, index (#1732)
* fix(#1720): .git watch only HEAD, config and index

* fix(#1720): .git watch only FETCH_HEAD, HEAD, HEAD.lock, config, index
2022-11-12 14:38:33 +11:00
Alexander Courtis
8cc369695b
fix: replace vim.* "requires" with explicit calls to vim functions (#1701) 2022-11-06 10:37:33 +11:00
Alexander Courtis
ed9db632a8
feat(watcher): add filesystem_watchers.ignore_dirs (#1705) 2022-11-05 10:24:25 +11:00
kylo252
6ca6f99e76
feat(notify): add notify.threshold (#1693)
* feat: configurable notification level

add `notify.threshold` to setup opts

* feat: configurable notification level: add threshold example doc

* feat: configurable notification level: log always comes last

Co-authored-by: Alexander Courtis <alex@courtis.org>
2022-11-01 10:24:40 +11:00
Alexander Courtis
be2b4f58e6
fix(#1615): focus created file when command line prompt requires confirmation (#1622)
* fix(#1615): focus created file when command line prompt requires confirmation

* fix(#1615): focus created file when command line prompt requires confirmation
2022-10-08 14:26:31 +11:00
KuuWang
3676e0b124
feat(sorters): allow user sort_by
* 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>
2022-09-18 16:00:49 +10:00
Piotr Doan
4a725c0ca5
fix(#1555): incorrect exe highlight in Windows filesystem from WSL (#1557) 2022-08-29 10:53:23 +10:00
Alexander Courtis
259efeee62 fix(#1540): watcher ignore directories with name exactly '.git' 2022-08-23 10:29:45 +10:00
Sebastian Volland
049cdd3073
fix(#1518): sort_by=modification_time not reordering on refresh. (#1519) 2022-08-22 14:19:06 +10:00
Sebastian Volland
c5fba1ec18
fix(#1520): file type changes are not detected. (#1521) 2022-08-22 11:41:11 +10:00
kiyan
665813b9e6 fix(perf): explorer was creating new table for each new entry
augment performance on large folder by a factor of 10.
my /nix/store explorer goes from ~12sec to ~1.5sec.
2022-07-29 09:35:15 +02:00
kiyan
ac90664001 fix(watchers): disable watchers on kernel filesystems
fixes #1465
2022-07-28 11:45:47 +02:00
Kian-Meng Ang
2928f8fe31
fix(docs): typos (#1470) 2022-07-27 13:48:14 +02:00
Alexander Courtis
eff1db341c
chore(watchers): Watcher shares single fs_event from Event, node watchers use unique path prefixed debounce context (#1453) 2022-07-26 10:43:58 +02:00
kiyan
630305c233 fix(executable): prevent nil extensions in executable check
fix on windows
fixes #1444
2022-07-19 14:11:53 +02:00
Klesh Wong
b754eb8359
fix(explorer): reload executable stat (#1427) 2022-07-19 11:25:41 +02:00
Alexander Courtis
ecca8118f8 doc: remove fs_poll interval and update doc 2022-07-19 09:39:03 +10:00
kiyan
18447132fc feat(notify): switch all print/nvim_*write statements to utils.notify 2022-07-18 14:04:48 +02:00
Alexander Courtis
06e48c29c4
chore(watchers): refactor events and make debouncer safe
- fs poll -> fs events
- make debouncer safe and fix diagnostics events
2022-07-17 08:50:24 +02:00
Alexander Courtis
736cc843e1
feat(#1389): add git.show_on_dirs (#1390) 2022-07-03 11:57:12 +02:00
Alexander Courtis
e401a4c957 feat(watcher): debounce FS watchers 2022-06-28 11:18:22 +10:00
Alexander Courtis
7a795d78fa
feat(watcher): partial git refresh (#1373) 2022-06-27 11:12:28 +10:00
Kiyan
e6c1b4cd5b
chore(setup): make setup idempotent (#1340)
Co-authored-by: Alexander Courtis <alex@courtis.org>
2022-06-26 12:14:03 +02:00
Kiyan
b0d27c09b6
feat(explorer): add filesystem watchers (#1304)
* 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>
2022-06-05 12:39:39 +02:00
kiyan
5e900c2f29 refacto: tree explorer root should be absolute_path not cwd 2022-05-29 11:40:06 +02:00
Alexander Courtis
c3b7be8d19
add .luarc.json for lua-language-server and fix a couple of nits (#1296) 2022-05-28 11:16:54 +02:00
Alexander Courtis
3ba383d591
chore/remove globals (#1279)
* remove renderer globals: nvim_tree_add_trailing nvim_tree_highlight_opened_files nvim_tree_root_folder_modifier nvim_tree_special_files

* remove renderer globals: nvim_tree_icon_padding

* remove renderer globals: nvim_tree_symlink_arrow

* remove renderer globals: nvim_tree_show_icons, nvim_tree_show_icons

* remove renderer globals: nvim_tree_git_hl

* remove renderer globals: nvim_tree_group_empty

* remove renderer globals: respect_buf_cwd

* remove renderer globals: nvim_tree_create_in_closed_folder

* remove globals: consistency in legacy checks

* remove renderer globals: nvim_tree_special_files

* renderer.icons.symbols -> glyphs
2022-05-28 11:08:40 +10:00
Kiyan
6343813a35
feat(live-filter): add ability to live filter out nodes in the tree (#1056) 2022-05-17 10:03:49 +02:00
muro3r
aefa66c04d
feat: extension sorter (#1181) (#1264) 2022-05-14 10:54:01 +02:00
Alexander Courtis
f85af83f13
#1217 show git status for link targets, when no status on the link itself (#1263) 2022-05-14 09:34:53 +02:00
Vincent Law
fd2332a33f
feat: case sensitive sorter (#1198) 2022-04-28 10:43:58 +10:00
kiyan
95a5c2d4bc fix: add parent ref to nodes
also refactor movement go to parent
fixes #1148
2022-04-21 20:39:14 +02:00
Alexander Courtis
1bdef08cfa
#1059 protect against duplicates (#1143) 2022-04-09 14:59:38 +02:00
Alexander Courtis
00fd8aefe0
feat: filters.custom can specify regex (#1112) 2022-04-02 13:03:57 +02:00
Alexander Courtis
9eea0ca51d
#504 determine whether symlinked directories are empty when building (#1089) 2022-03-19 12:49:32 +01:00
Alexander Courtis
a50fd77c99
#857 add filter_custom action, filter_ignored->filter_git_ignored (#1077) 2022-03-18 11:30:30 +01:00
kiyan
08c57660a7 fix: switch order of modification time sorter 2022-03-07 22:32:19 +01:00
Kiyan
0816064a8b
chore: add stylua to format the codebase, and run on CI (#1055) 2022-03-06 17:33:30 +01:00
kiyan
76d181d480 refacto: move filters and sorters in their own modules
Also exclude filters is taken into account in git ignore
fixes #892
2022-03-06 14:14:56 +01:00
Andreas Bissinger
ceadf83809
feat: add file size in popup (#1049) 2022-03-06 11:26:35 +01:00
Brandon D
690c7e96ed
feat: add sort_by option to sort files by modification time (#1040)
Co-authored-by: Brandon Dwiel <bdwiel@apple.com>
2022-03-03 23:41:58 +01:00
kiyan
f977e5c05a refacto: make git module interface to wait for job to finish
allows simplify the explore/reload/find/initialization by making the
whole code synchronous. No more callback needed.
2022-02-21 19:12:16 +01:00
kiyan
ec7043c53f refacto: extract functions in explorer 2022-02-20 15:24:23 +01:00
kiyan
527d88d54e refacto: simplify interface of reload and explore
also make common group empty check in explorer utils
2022-02-20 15:08:36 +01:00
kiyan
2e1f82d8c0 fix: reload group_next properly
fixes #948
2022-02-17 20:08:33 +01:00
kiyan
0c43c809b9 fix lint issue 2022-02-15 20:52:26 +01:00
Xavier Young
fdf63e572d
fix: use fs_realpath to normalize path (#978) 2022-02-15 08:33:11 +01:00
Kiyan
3f4ed9b6c2
fix: reload git status of existing nodes (#975) 2022-02-13 13:44:09 +01:00
kiyan
92a64daf27 fix: normalize cwd with '..' 2022-02-08 21:36:46 +01:00
kiyan
ea92e7bf7c refacto: set tree explorer in the global state
also remove the redraw method and use renderer.draw immediately
2022-02-07 22:07:08 +01:00
kiyan
e42a4337d0 fix: do not group empty at root 2022-02-07 21:16:59 +01:00
kiyan
1ab7812c62 fix: properly reload nodes 2022-02-07 20:54:26 +01:00
kiyan
47ccc2913f refacto: move toggle help and filter toggles into actions
also fix explorer to properly remove element on update when filter is
applied
2022-02-07 20:43:24 +01:00
kiyan
e1c3744631 refacto: rewrite reloader
next step needs to merge the reloader and the explorer, the ancient code
was super complicated and long and the new one is very similar to the explorer.
2022-02-06 23:18:12 +01:00
kiyan
7fec0f658b chore: simplify reloader and start fixing group nodes refresh 2022-02-06 22:59:37 +01:00
kiyan
b76602182f refacto: simplify explorer and make it a bit faster
Also fixes #933
2022-02-06 18:51:17 +01:00
kiyan
8a6c7bae3a refacto: move code ton explorer and simplify some internal apis 2022-02-06 17:58:24 +01:00
kiyan
74791bb624 refacto: split explorer module into multiple files 2022-02-06 17:01:18 +01:00