Skip to content

Commit cc31dcc

Browse files
committed
feat: make fs actions async
1 parent 9e4c395 commit cc31dcc

File tree

11 files changed

+747
-61
lines changed

11 files changed

+747
-61
lines changed

doc/nvim-tree-lua.txt

Lines changed: 43 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ Requirements
6363
==============================================================================
6464
2. QUICK START *nvim-tree-quickstart*
6565

66-
Setup should be run in a lua file or in a |lua-heredoc| if using in a vim file.
66+
Setup should be run in a lua file or in a |lua-heredoc| if using in a vim file. >lua
6767

6868
-- examples for your init.lua
6969

@@ -168,7 +168,7 @@ setup() function takes one optional argument: configuration table. If omitted
168168
nvim-tree will be initialised with default configuration.
169169

170170
Subsequent calls to setup will replace the previous configuration.
171-
>
171+
>lua
172172
require("nvim-tree").setup { -- BEGIN_DEFAULT_OPTS
173173
auto_reload_on_write = true,
174174
disable_netrw = false,
@@ -393,6 +393,14 @@ Subsequent calls to setup will replace the previous configuration.
393393
watcher = false,
394394
},
395395
},
396+
experimental = {
397+
async = {
398+
copy_paste = false,
399+
create_file = false,
400+
remove_file = false,
401+
rename_file = false,
402+
}
403+
}
396404
} -- END_DEFAULT_OPTS
397405
<
398406

@@ -404,7 +412,7 @@ Completely disable netrw
404412

405413
It is strongly advised to eagerly disable netrw, due to race conditions at vim
406414
startup.
407-
Set the following at the very beginning of your `init.lua` / `init.vim`: >
415+
Set the following at the very beginning of your `init.lua` / `init.vim`: >lua
408416
vim.g.loaded_netrw = 1
409417
vim.g.loaded_netrwPlugin = 1
410418
<
@@ -451,7 +459,7 @@ function.
451459
- `name`: `string`
452460
- `type`: `"directory"` | `"file"` | `"link"`
453461

454-
Example: sort by name length: >
462+
Example: sort by name length: >lua
455463
local sort_by = function(nodes)
456464
table.sort(nodes, function(a, b)
457465
return #a.name < #b.name
@@ -645,7 +653,7 @@ This can be used to attach keybindings to the tree buffer.
645653
When on_attach is "disabled", it will use the older mapping strategy, otherwise it
646654
will use the newer one.
647655
Type: `function(bufnr)`, Default: `"disable"`
648-
e.g. >
656+
e.g. >lua
649657
local api = require("nvim-tree.api")
650658

651659
local function on_attach(bufnr)
@@ -779,7 +787,7 @@ UI rendering setup
779787
Type: `string` or `function(root_cwd)`, Default: `":~:s?$?/..?"`
780788

781789
Function is passed the absolute path of the root folder and should return a string.
782-
e.g. >
790+
e.g. >lua
783791
my_root_folder_label = function(path)
784792
return ".../" .. vim.fn.fnamemodify(path, ":t")
785793
end
@@ -1011,7 +1019,7 @@ Configuration for various actions.
10111019
The function should return the window id that will open the node,
10121020
or `nil` if an invalid window is picked or user cancelled the action.
10131021
Type: `string` | `function`, Default: `"default"`
1014-
e.g. s1n7ax/nvim-window-picker plugin: >
1022+
e.g. s1n7ax/nvim-window-picker plugin: >lua
10151023
window_picker = {
10161024
enable = true,
10171025
picker = require('window-picker').pick_window,
@@ -1133,6 +1141,18 @@ Configuration for diagnostic logging.
11331141
|nvim-tree.filesystem_watchers| processing, verbose.
11341142
Type: `boolean`, Default: `false`
11351143

1144+
*nvim-tree.experimental*
1145+
Configuration for experimental features.
1146+
1147+
*nvim-tree.experimental.async*
1148+
Control experimental async behavior.
1149+
1150+
*nvim-tree.experimental.async.copy_paste*
1151+
Toggle async behavior of copy paste operation.
1152+
Type: `boolean`, Default: `false`
1153+
1154+
TODO here
1155+
11361156
==============================================================================
11371157
4.1 VINEGAR STYLE *nvim-tree-vinegar*
11381158

@@ -1143,8 +1163,8 @@ it in a specific way:
11431163

11441164
- Use `require"nvim-tree".open_replacing_current_buffer()` instead of the
11451165
default open command.
1146-
You can easily implement a toggle using this too:
1147-
>
1166+
You can easily implement a toggle using this too: >lua
1167+
11481168
local function toggle_replace()
11491169
local view = require"nvim-tree.view"
11501170
local api = require"nvim-tree.api"
@@ -1156,8 +1176,8 @@ You can easily implement a toggle using this too:
11561176
end
11571177
<
11581178
- Use the `edit_in_place` action to edit files. It's bound to `<C-e>` by
1159-
default, vinegar uses `<CR>`. You can override this with:
1160-
>
1179+
default, vinegar uses `<CR>`. You can override this with: >lua
1180+
11611181
require"nvim-tree".setup {
11621182
view = {
11631183
mappings = {
@@ -1178,8 +1198,8 @@ A good functionality to enable is |nvim-tree.hijack_directories|.
11781198
5. API *nvim-tree-api*
11791199

11801200
Nvim-tree's public API can be used to access features.
1181-
>
1182-
e.g. >
1201+
1202+
e.g. >lua
11831203
local api = require("nvim-tree.api")
11841204
api.tree.toggle()
11851205
<
@@ -1299,7 +1319,7 @@ Setting your own mapping in the configuration will soon be deprecated, see
12991319
Default `'n'`.
13001320

13011321
Examples:
1302-
>
1322+
>lua
13031323
local function print_node_path(node)
13041324
print(node.absolute_path)
13051325
end
@@ -1381,7 +1401,7 @@ DEFAULT MAPPINGS *nvim-tree-default-mappings
13811401
`m` toggle_mark Toggle node in bookmarks
13821402
`bmv` bulk_move Move all bookmarked nodes into specified location
13831403

1384-
>
1404+
>lua
13851405
view.mappings.list = { -- BEGIN_DEFAULT_MAPPINGS
13861406
{ key = { "<CR>", "o", "<2-LeftMouse>" }, action = "edit" },
13871407
{ key = "<C-e>", action = "edit_in_place" },
@@ -1443,7 +1463,7 @@ All the following highlight groups can be configured by hand. Aside from
14431463
groups.
14441464

14451465
Example (in your `init.vim`):
1446-
>
1466+
>vim
14471467
highlight NvimTreeSymlink guifg=blue gui=bold,underline
14481468
<
14491469
You should have 'termguicolors' enabled, otherwise, colors will not be
@@ -1533,7 +1553,7 @@ to |nvim_tree_registering_handlers| for more information.
15331553
Handlers are registered by calling |nvim-tree-api| `events.subscribe`
15341554
function with an `events.Event` kind.
15351555

1536-
e.g. handler for node renamed: >
1556+
e.g. handler for node renamed: >lua
15371557
local api = require("nvim-tree.api")
15381558
local Event = api.events.Event
15391559

@@ -1594,11 +1614,10 @@ To get the list of marked paths, you can call
15941614
Navigation for marks is not bound by default in nvim-tree because we don't
15951615
want to focus the tree view each time we wish to switch to another mark.
15961616

1597-
This requires binding bookmark navigation yourself.
1598-
1599-
-- in your lua configuration
1600-
vim.keymap.set("n", "<leader>mn", require("nvim-tree.api").marks.navigate.next)
1601-
vim.keymap.set("n", "<leader>mp", require("nvim-tree.api").marks.navigate.prev)
1602-
vim.keymap.set("n", "<leader>ms", require("nvim-tree.api").marks.navigate.select)
1603-
1617+
This requires binding bookmark navigation yourself. >lua
1618+
-- in your lua configuration
1619+
vim.keymap.set("n", "<leader>mn", require("nvim-tree.api").marks.navigate.next)
1620+
vim.keymap.set("n", "<leader>mp", require("nvim-tree.api").marks.navigate.prev)
1621+
vim.keymap.set("n", "<leader>ms", require("nvim-tree.api").marks.navigate.select)
1622+
<
16041623
vim:tw=78:ts=4:sw=4:et:ft=help:norl:

lua/nvim-tree.lua

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -702,6 +702,14 @@ local DEFAULT_OPTS = { -- BEGIN_DEFAULT_OPTS
702702
watcher = false,
703703
},
704704
},
705+
experimental = {
706+
async = {
707+
copy_paste = false,
708+
create_file = false,
709+
remove_file = false,
710+
rename_file = false,
711+
},
712+
},
705713
} -- END_DEFAULT_OPTS
706714

707715
local function merge_options(conf)

0 commit comments

Comments
 (0)