Compare commits

...

7 Commits

Author SHA1 Message Date
github-actions[bot]
85c502e907 chore(master): release nvim-tree 1.2.0 (#2713)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2024-03-24 13:25:16 +11:00
gegoune
b1bbd4f7dc ci(workflows): include matrices in concurrency groups (#2715) 2024-03-24 12:44:16 +11:00
Denys Lytviak
f7c09bd72e feat: add api.tree.toggle_enable_filters (#2706)
* feat: toggle filters

* naming refactoring

* change name to enable

* fix default opt

* fix api name

* update doc

* remove default keybinding, toggle live filter

* add API doc

---------

Co-authored-by: Alexander Courtis <alex@courtis.org>
2024-03-16 12:35:13 +11:00
github-actions[bot]
707b24af91 chore(master): release nvim-tree 1.1.1 (#2709)
* chore(master): release nvim-tree 1.1.1

* doc: remove duplicate bug fix entry

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Alexander Courtis <alex@courtis.org>
2024-03-15 12:26:28 +11:00
remvn
76b98109f6 fix: bookmark filter should include parent directory (#2704)
* fix: bookmark filter should include parent directory

* fix: dont match mark's siblings

* fix: match mark from the start

---------

Co-authored-by: Alexander Courtis <alex@courtis.org>
2024-03-15 12:21:04 +11:00
Asman Umbetov
cfea5bd080 fix(#2395): marks.bulk.move defaults to directory at cursor (#2688)
* fix(#2395): marks.bulk.move defaults to directory at cursor

* fix(#2395): adds check if node_at_cursor.parent is nil

---------

Co-authored-by: Alexander Courtis <alex@courtis.org>
2024-03-15 12:03:06 +11:00
Alexander Courtis
1fd9c98960 fix(#2705): change NvimTreeWindowPicker cterm background from Cyan to more visible DarkBlue (#2708)
fix(#2705): change NvimTreeWindowPicker from Cyan to the more visible DarkBlue
2024-03-15 10:58:40 +11:00
11 changed files with 84 additions and 8 deletions

View File

@@ -6,10 +6,6 @@ on:
branches: [master] branches: [master]
workflow_dispatch: workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref_name }}
cancel-in-progress: true
permissions: permissions:
contents: read contents: read
@@ -17,6 +13,10 @@ jobs:
lint: lint:
runs-on: ubuntu-latest runs-on: ubuntu-latest
concurrency:
group: ${{ github.workflow }}-${{ matrix.lua_version }}-${{ github.head_ref || github.ref_name }}
cancel-in-progress: true
strategy: strategy:
matrix: matrix:
lua_version: [ 5.1 ] lua_version: [ 5.1 ]
@@ -37,6 +37,10 @@ jobs:
style: style:
runs-on: ubuntu-latest runs-on: ubuntu-latest
concurrency:
group: ${{ github.workflow }}-${{ matrix.stylua_version }}-${{ github.head_ref || github.ref_name }}
cancel-in-progress: true
strategy: strategy:
matrix: matrix:
stylua_version: [ 0.19.1 ] stylua_version: [ 0.19.1 ]
@@ -56,6 +60,10 @@ jobs:
check: check:
runs-on: ubuntu-latest runs-on: ubuntu-latest
concurrency:
group: ${{ github.workflow }}-${{ matrix.nvim_version }}-${{ matrix.luals_version }}-${{ github.head_ref || github.ref_name }}
cancel-in-progress: true
strategy: strategy:
matrix: matrix:
nvim_version: [ stable, nightly ] nvim_version: [ stable, nightly ]

View File

@@ -1,3 +1,3 @@
{ {
".": "1.1.0" ".": "1.2.0"
} }

View File

@@ -1,5 +1,21 @@
# Changelog # Changelog
## [1.2.0](https://github.com/nvim-tree/nvim-tree.lua/compare/nvim-tree-v1.1.1...nvim-tree-v1.2.0) (2024-03-24)
### Features
* add api.tree.toggle_enable_filters ([#2706](https://github.com/nvim-tree/nvim-tree.lua/issues/2706)) ([f7c09bd](https://github.com/nvim-tree/nvim-tree.lua/commit/f7c09bd72e50e1795bd3afb9e2a2b157b4bfb3c3))
## [1.1.1](https://github.com/nvim-tree/nvim-tree.lua/compare/nvim-tree-v1.1.0...nvim-tree-v1.1.1) (2024-03-15)
### Bug Fixes
* **#2395:** marks.bulk.move defaults to directory at cursor ([#2688](https://github.com/nvim-tree/nvim-tree.lua/issues/2688)) ([cfea5bd](https://github.com/nvim-tree/nvim-tree.lua/commit/cfea5bd0806aab41bef6014c6cf5a510910ddbdb))
* **#2705:** change NvimTreeWindowPicker cterm background from Cyan to more visible DarkBlue ([#2708](https://github.com/nvim-tree/nvim-tree.lua/issues/2708)) ([1fd9c98](https://github.com/nvim-tree/nvim-tree.lua/commit/1fd9c98960463d2d5d400916c0633b2df016941d))
* bookmark filter should include parent directory ([#2704](https://github.com/nvim-tree/nvim-tree.lua/issues/2704)) ([76b9810](https://github.com/nvim-tree/nvim-tree.lua/commit/76b98109f62caa12b2f1dff472060b2233ea2e90))
## [1.1.0](https://github.com/nvim-tree/nvim-tree.lua/compare/nvim-tree-v1.0.0...nvim-tree-v1.1.0) (2024-03-14) ## [1.1.0](https://github.com/nvim-tree/nvim-tree.lua/compare/nvim-tree-v1.0.0...nvim-tree-v1.1.0) (2024-03-14)

View File

@@ -537,6 +537,7 @@ Following is the default configuration. See |nvim-tree-opts| for details.
show_on_open_dirs = true, show_on_open_dirs = true,
}, },
filters = { filters = {
enable = true,
git_ignored = true, git_ignored = true,
dotfiles = false, dotfiles = false,
git_clean = false, git_clean = false,
@@ -1242,6 +1243,11 @@ Only relevant when |modified.show_on_dirs| is `true`.
File / folder filters that may be toggled. File / folder filters that may be toggled.
*nvim-tree.filters.enable*
Enable / disable all filters including live filter.
Toggle via |nvim-tree-api.tree.toggle_enable_filters()|
Type: `boolean`, Default: `true`
*nvim-tree.filters.git_ignored* *nvim-tree.filters.git_ignored*
Ignore files based on `.gitignore`. Requires |git.enable| `= true` Ignore files based on `.gitignore`. Requires |git.enable| `= true`
Toggle via |nvim-tree-api.tree.toggle_gitignore_filter()|, default `I` Toggle via |nvim-tree-api.tree.toggle_gitignore_filter()|, default `I`
@@ -1702,6 +1708,10 @@ tree.expand_all() *nvim-tree-api.tree.expand_all()*
Recursively expand all nodes in the tree. Recursively expand all nodes in the tree.
Folder: only the nodes underneath that folder. Folder: only the nodes underneath that folder.
*nvim-tree-api.tree.toggle_enable_filters()*
tree.toggle_enable_filters()
Toggle |nvim-tree.filters.enable| all filters.
*nvim-tree-api.tree.toggle_gitignore_filter()* *nvim-tree-api.tree.toggle_gitignore_filter()*
tree.toggle_gitignore_filter() tree.toggle_gitignore_filter()
Toggle |nvim-tree.filters.git_ignored| filter. Toggle |nvim-tree.filters.git_ignored| filter.
@@ -2757,6 +2767,7 @@ highlight group is not, hard linking as follows: >
|nvim-tree.filesystem_watchers.ignore_dirs| |nvim-tree.filesystem_watchers.ignore_dirs|
|nvim-tree.filters.custom| |nvim-tree.filters.custom|
|nvim-tree.filters.dotfiles| |nvim-tree.filters.dotfiles|
|nvim-tree.filters.enable|
|nvim-tree.filters.exclude| |nvim-tree.filters.exclude|
|nvim-tree.filters.git_clean| |nvim-tree.filters.git_clean|
|nvim-tree.filters.git_ignored| |nvim-tree.filters.git_ignored|
@@ -2966,6 +2977,7 @@ highlight group is not, hard linking as follows: >
|nvim-tree-api.tree.search_node()| |nvim-tree-api.tree.search_node()|
|nvim-tree-api.tree.toggle()| |nvim-tree-api.tree.toggle()|
|nvim-tree-api.tree.toggle_custom_filter()| |nvim-tree-api.tree.toggle_custom_filter()|
|nvim-tree-api.tree.toggle_enable_filters()|
|nvim-tree-api.tree.toggle_git_clean_filter()| |nvim-tree-api.tree.toggle_git_clean_filter()|
|nvim-tree-api.tree.toggle_gitignore_filter()| |nvim-tree-api.tree.toggle_gitignore_filter()|
|nvim-tree-api.tree.toggle_help()| |nvim-tree-api.tree.toggle_help()|

View File

@@ -499,6 +499,7 @@ local DEFAULT_OPTS = { -- BEGIN_DEFAULT_OPTS
show_on_open_dirs = true, show_on_open_dirs = true,
}, },
filters = { filters = {
enable = true,
git_ignored = true, git_ignored = true,
dotfiles = false, dotfiles = false,
git_clean = false, git_clean = false,

View File

@@ -41,4 +41,9 @@ function M.dotfiles()
reload() reload()
end end
function M.enable()
filters.config.enable = not filters.config.enable
reload()
end
return M return M

View File

@@ -128,6 +128,7 @@ Api.tree.find_file = wrap(actions.tree.find_file.fn)
Api.tree.search_node = wrap(actions.finders.search_node.fn) Api.tree.search_node = wrap(actions.finders.search_node.fn)
Api.tree.collapse_all = wrap(actions.tree.modifiers.collapse_all.fn) Api.tree.collapse_all = wrap(actions.tree.modifiers.collapse_all.fn)
Api.tree.expand_all = wrap_node(actions.tree.modifiers.expand_all.fn) Api.tree.expand_all = wrap_node(actions.tree.modifiers.expand_all.fn)
Api.tree.toggle_enable_filters = wrap(actions.tree.modifiers.toggles.enable)
Api.tree.toggle_gitignore_filter = wrap(actions.tree.modifiers.toggles.git_ignored) Api.tree.toggle_gitignore_filter = wrap(actions.tree.modifiers.toggles.git_ignored)
Api.tree.toggle_git_clean_filter = wrap(actions.tree.modifiers.toggles.git_clean) Api.tree.toggle_git_clean_filter = wrap(actions.tree.modifiers.toggles.git_clean)
Api.tree.toggle_no_buffer_filter = wrap(actions.tree.modifiers.toggles.no_buffer) Api.tree.toggle_no_buffer_filter = wrap(actions.tree.modifiers.toggles.no_buffer)

View File

@@ -51,7 +51,7 @@ M.HIGHLIGHT_GROUPS = {
{ group = "NvimTreeIndentMarker", link = "NvimTreeFolderIcon" }, { group = "NvimTreeIndentMarker", link = "NvimTreeFolderIcon" },
-- Picker -- Picker
{ group = "NvimTreeWindowPicker", def = "guifg=#ededed guibg=#4493c8 gui=bold ctermfg=White ctermbg=Cyan" }, { group = "NvimTreeWindowPicker", def = "guifg=#ededed guibg=#4493c8 gui=bold ctermfg=White ctermbg=DarkBlue" },
-- LiveFilter -- LiveFilter
{ group = "NvimTreeLiveFilterPrefix", link = "PreProc" }, { group = "NvimTreeLiveFilterPrefix", link = "PreProc" },

View File

@@ -73,7 +73,20 @@ end
---@param path string ---@param path string
---@param bookmarks table<string, boolean> absolute paths bookmarked ---@param bookmarks table<string, boolean> absolute paths bookmarked
local function bookmark(path, bookmarks) local function bookmark(path, bookmarks)
return M.config.filter_no_bookmark and not bookmarks[path] if not M.config.filter_no_bookmark then
return false
end
-- add trailing slash to make it match only mark's parent directory
-- not it's siblings
local parent = utils.path_add_trailing(path)
for mark, _ in pairs(bookmarks) do
if path == mark or vim.fn.stridx(mark, parent) == 0 then
return false
end
end
return true
end end
---@param path string ---@param path string
@@ -137,6 +150,10 @@ end
---@param status table from prepare ---@param status table from prepare
---@return boolean ---@return boolean
function M.should_filter(path, status) function M.should_filter(path, status)
if not M.config.enable then
return false
end
-- exclusions override all filters -- exclusions override all filters
if is_excluded(path) then if is_excluded(path) then
return false return false
@@ -147,6 +164,7 @@ end
function M.setup(opts) function M.setup(opts)
M.config = { M.config = {
enable = opts.filters.enable,
filter_custom = true, filter_custom = true,
filter_dotfiles = opts.filters.dotfiles, filter_dotfiles = opts.filters.dotfiles,
filter_git_ignored = opts.filters.git_ignored, filter_git_ignored = opts.filters.git_ignored,

View File

@@ -1,6 +1,7 @@
local view = require "nvim-tree.view" local view = require "nvim-tree.view"
local utils = require "nvim-tree.utils" local utils = require "nvim-tree.utils"
local Iterator = require "nvim-tree.iterators.node-iterator" local Iterator = require "nvim-tree.iterators.node-iterator"
local filters = require "nvim-tree.explorer.filters"
local M = { local M = {
filter = nil, filter = nil,
@@ -56,6 +57,10 @@ end
---@param node Node ---@param node Node
---@return boolean ---@return boolean
local function matches(node) local function matches(node)
if not filters.config.enable then
return true
end
local path = node.absolute_path local path = node.absolute_path
local name = vim.fn.fnamemodify(path, ":t") local name = vim.fn.fnamemodify(path, ":t")
return vim.regex(M.filter):match_str(name) ~= nil return vim.regex(M.filter):match_str(name) ~= nil

View File

@@ -3,6 +3,7 @@ local core = require "nvim-tree.core"
local utils = require "nvim-tree.utils" local utils = require "nvim-tree.utils"
local rename_file = require "nvim-tree.actions.fs.rename-file" local rename_file = require "nvim-tree.actions.fs.rename-file"
local notify = require "nvim-tree.notify" local notify = require "nvim-tree.notify"
local lib = require "nvim-tree.lib"
local M = { local M = {
config = {}, config = {},
@@ -14,9 +15,18 @@ function M.bulk_move()
return return
end end
local node_at_cursor = lib.get_node_at_cursor()
local default_path = core.get_cwd()
if node_at_cursor and node_at_cursor.type == "directory" then
default_path = node_at_cursor.absolute_path
elseif node_at_cursor and node_at_cursor.parent then
default_path = node_at_cursor.parent.absolute_path
end
local input_opts = { local input_opts = {
prompt = "Move to: ", prompt = "Move to: ",
default = core.get_cwd(), default = default_path,
completion = "dir", completion = "dir",
} }