Skip to content

Commit a73d0d4

Browse files
authored
feat(file-popup): add actions.file_popup.open_win_config
* file-popup: add nvim_open_win configuration * docs: update file-popup configuration
1 parent ff6e796 commit a73d0d4

File tree

4 files changed

+41
-6
lines changed

4 files changed

+41
-6
lines changed

doc/nvim-tree-lua.txt

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,15 @@ Subsequent calls to setup will replace the previous configuration.
313313
max_folder_discovery = 300,
314314
exclude = {},
315315
},
316+
file_popup = {
317+
open_win_config = {
318+
col = 1,
319+
row = 1,
320+
relative = "cursor",
321+
border = "shadow",
322+
style = "minimal",
323+
},
324+
},
316325
open_file = {
317326
quit_on_open = false,
318327
resize_window = true,
@@ -869,6 +878,22 @@ Configuration for various actions.
869878
E.g `{ ".git", "target", "build" }` etc.
870879
Type: `table`, Default: `{}`
871880

881+
*nvim-tree.actions.file_popup*
882+
Configuration for file_popup behaviour.
883+
884+
*nvim-tree.actions.file_popup.open_win_config*
885+
Floating window config for file_popup. See |nvim_open_win| for more details.
886+
You shouldn't define `"width"` and `"height"` values here. They will be
887+
overridden to fit the file_popup content.
888+
Type: `table`, Default:
889+
`{`
890+
`col = 1,`
891+
`row = 1,`
892+
`relative = "cursor",`
893+
`border = "shadow",`
894+
`style = "minimal",`
895+
`}`
896+
872897
*nvim-tree.actions.open_file*
873898
Configuration options for opening a file from nvim-tree.
874899

lua/nvim-tree.lua

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -576,6 +576,15 @@ local DEFAULT_OPTS = { -- BEGIN_DEFAULT_OPTS
576576
max_folder_discovery = 300,
577577
exclude = {},
578578
},
579+
file_popup = {
580+
open_win_config = {
581+
col = 1,
582+
row = 1,
583+
relative = "cursor",
584+
border = "shadow",
585+
style = "minimal",
586+
},
587+
},
579588
open_file = {
580589
quit_on_open = false,
581590
resize_window = true,

lua/nvim-tree/actions/init.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,7 @@ local DEFAULT_MAPPING_CONFIG = {
389389
function M.setup(opts)
390390
require("nvim-tree.actions.fs.trash").setup(opts)
391391
require("nvim-tree.actions.node.system-open").setup(opts)
392+
require("nvim-tree.actions.node.file-popup").setup(opts)
392393
require("nvim-tree.actions.node.open-file").setup(opts)
393394
require("nvim-tree.actions.root.change-dir").setup(opts)
394395
require("nvim-tree.actions.fs.create-file").setup(opts)

lua/nvim-tree/actions/node/file-popup.lua

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,12 @@ local function setup_window(node)
2828
local max_width = vim.fn.max(vim.tbl_map(function(n)
2929
return #n
3030
end, lines))
31-
local winnr = a.nvim_open_win(0, false, {
32-
col = 1,
33-
row = 1,
34-
relative = "cursor",
31+
local open_win_config = vim.tbl_extend("force", M.open_win_config, {
3532
width = max_width + 1,
3633
height = #lines,
37-
border = "shadow",
3834
noautocmd = true,
39-
style = "minimal",
4035
})
36+
local winnr = a.nvim_open_win(0, false, open_win_config)
4137
current_popup = {
4238
winnr = winnr,
4339
file_path = node.absolute_path,
@@ -78,4 +74,8 @@ function M.toggle_file_info(node)
7874
})
7975
end
8076

77+
function M.setup(opts)
78+
M.open_win_config = opts.actions.file_popup.open_win_config
79+
end
80+
8181
return M

0 commit comments

Comments
 (0)