Merge branch 'master' into type-annotations

This commit is contained in:
Azad
2023-11-24 12:47:41 +01:00
committed by GitHub
6 changed files with 57 additions and 16 deletions

View File

@@ -8,28 +8,35 @@ on:
branches: branches:
- master - master
permissions:
contents: read
jobs: jobs:
luacheck: lint:
name: luacheck
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- name: Prepare - uses: leafo/gh-actions-lua@v10
with:
luaVersion: "5.1"
- uses: leafo/gh-actions-luarocks@v4
- name: luacheck
run: | run: |
sudo apt-get update luarocks install luacheck 1.1.1
sudo add-apt-repository universe luacheck lua
sudo apt install luarocks -y
sudo luarocks install luacheck style:
- name: Run luacheck
run: luacheck .
stylua:
name: stylua
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- uses: JohnnyMorganz/stylua-action@v3
- name: stylua
uses: JohnnyMorganz/stylua-action@v3
with: with:
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }}
version: latest version: "0.19"
args: --color always --check lua/ args: --check lua

View File

@@ -61,7 +61,9 @@ require("nvim-tree").setup()
-- OR setup with some options -- OR setup with some options
require("nvim-tree").setup({ require("nvim-tree").setup({
sort_by = "case_sensitive", sort = {
sorter = "case_sensitive",
},
view = { view = {
width = 30, width = 30,
}, },

View File

@@ -1698,6 +1698,18 @@ tree.is_visible({opts}) *nvim-tree-api.tree.is_visible()*
Return: ~ Return: ~
(boolean) nvim-tree is visible (boolean) nvim-tree is visible
tree.winid({opts}) *nvim-tree-api.tree.winid()*
Retrieve the winid of the open tree.
Parameters: ~
• {opts} (table) optional parameters
Options: ~
• {tabpage} (number|nil) tabpage, 0 or nil for current, default nil
Return: ~
(number) winid or nil if tree is not visible
============================================================================== ==============================================================================
6.2 API FILE SYSTEM *nvim-tree-api.fs* 6.2 API FILE SYSTEM *nvim-tree-api.fs*

View File

@@ -14,7 +14,7 @@ local M = {}
local function refresh_nodes(node, projects, unloaded_bufnr) local function refresh_nodes(node, projects, unloaded_bufnr)
Iterator.builder({ node }) Iterator.builder({ node })
:applier(function(n) :applier(function(n)
if n.open and n.nodes then if n.nodes then
local toplevel = git.get_toplevel(n.cwd or n.link_to or n.absolute_path) local toplevel = git.get_toplevel(n.cwd or n.link_to or n.absolute_path)
explorer_module.reload(n, projects[toplevel] or {}, unloaded_bufnr) explorer_module.reload(n, projects[toplevel] or {}, unloaded_bufnr)
end end

View File

@@ -146,6 +146,11 @@ Api.tree.is_tree_buf = wrap(require("nvim-tree.utils").is_nvim_tree_buf)
Api.tree.is_visible = wrap(require("nvim-tree.view").is_visible) Api.tree.is_visible = wrap(require("nvim-tree.view").is_visible)
---@class ApiTreeWinIdOpts
---@field tabpage number|nil default nil
Api.tree.winid = wrap(require("nvim-tree.view").winid)
Api.fs.create = wrap_node_or_nil(require("nvim-tree.actions.fs.create-file").fn) Api.fs.create = wrap_node_or_nil(require("nvim-tree.actions.fs.create-file").fn)
Api.fs.remove = wrap_node(require("nvim-tree.actions.fs.remove-file").fn) Api.fs.remove = wrap_node(require("nvim-tree.actions.fs.remove-file").fn)
Api.fs.trash = wrap_node(require("nvim-tree.actions.fs.trash").fn) Api.fs.trash = wrap_node(require("nvim-tree.actions.fs.trash").fn)

View File

@@ -433,6 +433,21 @@ function M.focus(winnr, open_if_closed)
vim.api.nvim_set_current_win(wnr) vim.api.nvim_set_current_win(wnr)
end end
--- Retrieve the winid of the open tree.
--- @param opts ApiTreeWinIdOpts|nil
--- @return number|nil winid unlike get_winnr(), this returns nil if the nvim-tree window is not visible
function M.winid(opts)
local tabpage = opts and opts.tabpage
if tabpage == 0 then
tabpage = vim.api.nvim_get_current_tabpage()
end
if M.is_visible { tabpage = tabpage } then
return M.get_winnr(tabpage)
else
return nil
end
end
--- Restores the state of a NvimTree window if it was initialized before. --- Restores the state of a NvimTree window if it was initialized before.
function M.restore_tab_state() function M.restore_tab_state()
local tabpage = vim.api.nvim_get_current_tabpage() local tabpage = vim.api.nvim_get_current_tabpage()