Skip to content

Commit 9ee3783

Browse files
authored
Merge branch 'master' into 2415-highlight-overhaul
2 parents 1151a14 + 5e4475d commit 9ee3783

File tree

8 files changed

+83
-22
lines changed

8 files changed

+83
-22
lines changed

.github/workflows/ci.yml

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,28 +8,35 @@ on:
88
branches:
99
- master
1010

11+
permissions:
12+
contents: read
13+
1114
jobs:
12-
luacheck:
13-
name: luacheck
15+
lint:
1416
runs-on: ubuntu-latest
1517
steps:
1618
- uses: actions/checkout@v4
1719

18-
- name: Prepare
20+
- uses: leafo/gh-actions-lua@v10
21+
with:
22+
luaVersion: "5.1"
23+
24+
- uses: leafo/gh-actions-luarocks@v4
25+
26+
- name: luacheck
1927
run: |
20-
sudo apt-get update
21-
sudo add-apt-repository universe
22-
sudo apt install luarocks -y
23-
sudo luarocks install luacheck
24-
- name: Run luacheck
25-
run: luacheck .
26-
stylua:
27-
name: stylua
28+
luarocks install luacheck 1.1.1
29+
luacheck lua
30+
31+
style:
2832
runs-on: ubuntu-latest
2933
steps:
3034
- uses: actions/checkout@v4
31-
- uses: JohnnyMorganz/stylua-action@v3
35+
36+
- name: stylua
37+
uses: JohnnyMorganz/stylua-action@v3
3238
with:
3339
token: ${{ secrets.GITHUB_TOKEN }}
34-
version: latest
35-
args: --color always --check lua/
40+
version: "0.19"
41+
args: --check lua
42+

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,9 @@ require("nvim-tree").setup()
6161

6262
-- OR setup with some options
6363
require("nvim-tree").setup({
64-
sort_by = "case_sensitive",
64+
sort = {
65+
sorter = "case_sensitive",
66+
},
6567
view = {
6668
width = 30,
6769
},

doc/nvim-tree-lua.txt

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ via |nvim-tree.on_attach| e.g. >
233233

234234
Opens the tree. See |nvim-tree-api.tree.open()|
235235

236-
Calls: `api.tree.open({ path = "<arg>" })`
236+
Calls: `api.tree.open({ path = "<args>" })`
237237

238238
*:NvimTreeClose*
239239

@@ -245,13 +245,13 @@ via |nvim-tree.on_attach| e.g. >
245245

246246
Open or close the tree. See |nvim-tree-api.tree.toggle()|
247247

248-
Calls: `api.tree.toggle({ path = "<arg>" })`
248+
Calls: `api.tree.toggle({ path = "<args>", find_file = false, update_root = false, focus = true, })`
249249

250250
*:NvimTreeFocus*
251251

252252
Open the tree if it is closed, and then focus on the tree.
253253

254-
See |nvim-tree-api.tree.toggle()|
254+
See |nvim-tree-api.tree.focus()|
255255

256256
Calls: `api.tree.focus()`
257257

@@ -273,7 +273,7 @@ via |nvim-tree.on_attach| e.g. >
273273

274274
See |nvim-tree-api.tree.find_file()|
275275

276-
Calls: `api.tree.find_file { open = true, update_root = <bang> }`
276+
Calls: `api.tree.find_file({ update_root = <bang>, open = true, focus = true, })`
277277

278278
*:NvimTreeFindFileToggle*
279279

@@ -285,7 +285,7 @@ via |nvim-tree.on_attach| e.g. >
285285

286286
See |nvim-tree-api.tree.toggle()|
287287

288-
Calls: `api.tree.toggle { find_file = true, focus = true, path = "<arg>", update_root = <bang> }`
288+
Calls: `api.tree.toggle({ path = "<args>", update_root = <bang>, find_file = true, focus = true, })`
289289

290290
*:NvimTreeClipboard*
291291

@@ -1701,6 +1701,18 @@ tree.is_visible({opts}) *nvim-tree-api.tree.is_visible()*
17011701
Return: ~
17021702
(boolean) nvim-tree is visible
17031703

1704+
tree.winid({opts}) *nvim-tree-api.tree.winid()*
1705+
Retrieve the winid of the open tree.
1706+
1707+
Parameters: ~
1708+
{opts} (table) optional parameters
1709+
1710+
Options: ~
1711+
{tabpage} (number|nil) tabpage, 0 or nil for current, default nil
1712+
1713+
Return: ~
1714+
(number) winid or nil if tree is not visible
1715+
17041716
==============================================================================
17051717
6.2 API FILE SYSTEM *nvim-tree-api.fs*
17061718

lua/nvim-tree/actions/reloaders/reloaders.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ local M = {}
1111
local function refresh_nodes(node, projects)
1212
Iterator.builder({ node })
1313
:applier(function(n)
14-
if n.open and n.nodes then
14+
if n.nodes then
1515
local toplevel = git.get_toplevel(n.cwd or n.link_to or n.absolute_path)
1616
explorer_module.reload(n, projects[toplevel] or {})
1717
end

lua/nvim-tree/api.lua

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,11 @@ Api.tree.is_tree_buf = wrap(require("nvim-tree.utils").is_nvim_tree_buf)
145145

146146
Api.tree.is_visible = wrap(require("nvim-tree.view").is_visible)
147147

148+
---@class ApiTreeWinIdOpts
149+
---@field tabpage number|nil default nil
150+
151+
Api.tree.winid = wrap(require("nvim-tree.view").winid)
152+
148153
Api.fs.create = wrap_node_or_nil(require("nvim-tree.actions.fs.create-file").fn)
149154
Api.fs.remove = wrap_node(require("nvim-tree.actions.fs.remove-file").fn)
150155
Api.fs.trash = wrap_node(require("nvim-tree.actions.fs.trash").fn)

lua/nvim-tree/core.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ function M.get_explorer()
2828
end
2929

3030
function M.get_cwd()
31-
return TreeExplorer.absolute_path
31+
return TreeExplorer and TreeExplorer.absolute_path
3232
end
3333

3434
function M.get_nodes_starting_line()

lua/nvim-tree/log.lua

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,26 @@ function M.line(typ, fmt, ...)
6161
end
6262
end
6363

64+
local inspect_opts = {}
65+
66+
--- @param opts table
67+
function M.set_inspect_opts(opts)
68+
inspect_opts = opts
69+
end
70+
71+
--- Write to log file the inspection of a node
72+
--- defaults to the node under cursor if none is provided
73+
--- @param typ string as per log.types config
74+
--- @param node table|nil node to be inspected
75+
--- @param fmt string for string.format
76+
--- @vararg any arguments for string.format
77+
function M.node(typ, node, fmt, ...)
78+
if M.enabled(typ) then
79+
node = node or require("nvim-tree.lib").get_node_at_cursor()
80+
M.raw(typ, string.format("[%s] [%s] %s\n%s\n", os.date "%Y-%m-%d %H:%M:%S", typ, (fmt or "???"), vim.inspect(node, inspect_opts)), ...)
81+
end
82+
end
83+
6484
--- Logging is enabled for typ or all
6585
--- @param typ string as per log.types config
6686
--- @return boolean

lua/nvim-tree/view.lua

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,21 @@ function M.focus(winnr, open_if_closed)
427427
vim.api.nvim_set_current_win(wnr)
428428
end
429429

430+
--- Retrieve the winid of the open tree.
431+
--- @param opts ApiTreeWinIdOpts|nil
432+
--- @return number|nil winid unlike get_winnr(), this returns nil if the nvim-tree window is not visible
433+
function M.winid(opts)
434+
local tabpage = opts and opts.tabpage
435+
if tabpage == 0 then
436+
tabpage = vim.api.nvim_get_current_tabpage()
437+
end
438+
if M.is_visible { tabpage = tabpage } then
439+
return M.get_winnr(tabpage)
440+
else
441+
return nil
442+
end
443+
end
444+
430445
--- Restores the state of a NvimTree window if it was initialized before.
431446
function M.restore_tab_state()
432447
local tabpage = vim.api.nvim_get_current_tabpage()

0 commit comments

Comments
 (0)