Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/protect_release_branches.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
pull_request:
branches:
- 'v1.x'
- 'v2.x'
# - 'v2.x'

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
Expand Down
22 changes: 16 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Example for packer:
```lua
use {
"nvim-neo-tree/neo-tree.nvim",
branch = "v1.x",
branch = "v2.x",
requires = {
"nvim-lua/plenary.nvim",
"kyazdani42/nvim-web-devicons", -- not strictly required, but recommended
Expand Down Expand Up @@ -86,13 +86,23 @@ use {
},
},
filesystem = {
filters = { --These filters are applied to both browsing and searching
show_hidden = false,
respect_gitignore = true,
filtered_items = {
visible = false, -- when true, they will just be displayed differently than normal items
hide_dotfiles = true,
hide_gitignored = true,
hide_by_name = {
".DS_Store",
"thumbs.db"
--"node_modules"
},
never_show = { -- remains hidden even if visible is toggled to true
--".DS_Store",
--"thumbs.db"
},
},
follow_current_file = false, -- This will find and focus the file in the active buffer every
follow_current_file = true, -- This will find and focus the file in the active buffer every
-- time the current file is changed while the tree is open.
use_libuv_file_watcher = false, -- This will use the OS level file watchers
use_libuv_file_watcher = true, -- This will use the OS level file watchers
-- to detect changes instead of relying on nvim autocmd events.
hijack_netrw_behavior = "open_default", -- netrw disabled, opening a directory opens neo-tree
-- in whatever position is specified in window.position
Expand Down
62 changes: 50 additions & 12 deletions doc/neo-tree.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Mappings .................... |neo-tree-mappings|
Filter .................... |neo-tree-filter|
Configuration ............... |neo-tree-configuration|
Setup ..................... |neo-tree-setup|
Filtered Items ............ |neo-tree-filtered-items|
Hijack Netrw Behavior ..... |neo-tree-netrw-hijack|
Component Configs ......... |neo-tree-component-configs|
Git Status ................ |neo-tree-git-status|
Expand Down Expand Up @@ -176,14 +177,11 @@ p = paste_from_clipboard: Copy/move each marked file in the to the


VIEW CHANGES *neo-tree-view-changes*
H = toggle_hidden: Toggle whether hidden files (.*) are shown or not.
H = toggle_hidden: Toggle whether hidden (filtered items) are shown or not.

I = toggle_gitignore: Toggle whether the gitignore file is
respected.

R = refresh: Rescan the filesystem and redraw the tree. Changes
made within nvim should be detected automatically, but
this is useful for changes made elsewhere.
R = refresh: Rescan the filesystem and redraw the tree. Changes made
within nvim should be detected automatically, but this is
useful for changes made elsewhere.


FILTER *neo-tree-filter*
Expand Down Expand Up @@ -324,7 +322,44 @@ existing global mappings to work.
Run |NeoTreePasteConfig| to dump the fully commented default config in your
current file. Even if you don't want to use that config as your starting point,
you still may want to dump it to a blank .lua file just to read it as
documentation.
documentation. SOME OPTIONS ARE ONLY DOCUMENTED IN THE DEFAULT CONFIG!


FILTERED ITEMS *neo-tree-filtered-items*

The `filesystem` source has a `filtered_items` section in it's config that
allows you to specify what files and folders should be hidden. By default, any
item identified by these filters will not be visible, but that visibility can
be toggled on and off with a command. Each type of filter has a corresponding
highlight group which will be applied when they are visible, see
|neo-tree-highlights| for details. The following options are available:

>
require("neo-tree").setup({
filesystem = {
filtered_items = {
visible = false, -- when true, they will just be displayed differently than normal items
hide_dotfiles = true,
hide_gitignored = true,
hide_by_name = {
".DS_Store",
"thumbs.db"
--"node_modules"
},
never_show = { -- remains hidden even if visible is toggled to true
--".DS_Store",
--"thumbs.db"
},
},
}
})
<
The `visible` option just defines the default value. This value is toggled by
the "toggle_hidden" command, which is mapped to H by default.

The `never_show` option is the same as `hide_by_name`, except that those items
will remain hidden even if you toggle `visible` to true. This section takes
precedence over the others.


NETRW HIJACK BEHAVIOR *neo-tree-netrw-hijack*
Expand Down Expand Up @@ -484,25 +519,28 @@ exist, they will be created.
NeoTreeBufferNumber The buffer number shown in the buffers source.
NeoTreeCursorLine |hi-CursorLine| override in Neo-tree window.
NeoTreeDimText Greyed out text used in various places.
NeoTreeDirectoryName Directory name.
NeoTreeDirectoryIcon Directory icon.
NeoTreeDirectoryName Directory name.
NeoTreeDotfile Used for icons and names when dotfiles are filtered.
NeoTreeFileIcon File icon, when not overriden by devicons.
NeoTreeFileName File name, when not overwritten by another status.
NeoTreeFileNameOpened File name when the file is open. Not used yet.
NeoTreeSymbolicLinkTarget Symbolic link target.
NeoTreeFilterTerm The filter term, as displayed in the root node.
NeoTreeFloatBorder The border for pop-up windows.
NeoTreeGitAdded File name when the git status is added.
NeoTreeGitConflict File name when the git status is conflict.
NeoTreeGitIgnored File name when the git status is ignored.
NeoTreeGitModified File name when the git status is modified.
NeoTreeGitUntracked File name when the git status is untracked.
NeoTreeHiddenByName Used for icons and names when `hide_by_name` is used.
NeoTreeIndentMarker The style of indentation markers (guides). By default,
the "Normal" highlight is used.
NeoTreeNormal |hl-Normal| override in Neo-tree window.
NeoTreeNormalNC |hi-NormalNC| override in Neo-tree window.
NeoTreeRootName The name of the root node.
NeoTreeSymbolicLinkTarget Symbolic link target.
NeoTreeTitleBar Used for the title bar of pop-ups, when the border-style
is set to "NC". This is derived from NeoTreeFloatBorder.
NeoTreeIndentMarker The style of indentation markers (guides). By default,
the "Normal" highlight is used.


EVENTS *neo-tree-events*
Expand Down
21 changes: 21 additions & 0 deletions lua/neo-tree.lua
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,27 @@ end
M.setup = function(config, is_auto_config)
local default_config = vim.deepcopy(defaults)
config = vim.deepcopy(config or {})

local messages = require("neo-tree.deprecations").migrate(config)
if #messages > 0 then
for i, message in ipairs(messages) do
messages[i] = " * " .. message
end
table.insert(messages, 1, "# Neo-tree configuration has been updated. Please review the changes below.")
local buf = vim.api.nvim_create_buf(false, true)
vim.api.nvim_buf_set_lines(buf, 0, -1, false, messages)
vim.api.nvim_buf_set_option(buf, "buftype", "nofile")
vim.api.nvim_buf_set_option(buf, "bufhidden", "wipe")
vim.api.nvim_buf_set_option(buf, "buflisted", false)
vim.api.nvim_buf_set_option(buf, "swapfile", false)
vim.api.nvim_buf_set_option(buf, "modifiable", false)
vim.api.nvim_buf_set_option(buf, "filetype", "markdown")
vim.defer_fn(function ()
vim.cmd("split")
vim.api.nvim_win_set_buf(0, buf)
end, 100)
end

if config.log_level ~= nil then
M.set_log_level(config.log_level)
end
Expand Down
104 changes: 57 additions & 47 deletions lua/neo-tree/defaults.lua
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,67 @@ local config = {
},
},
filesystem = {
bind_to_cwd = true, -- true creates a 2-way binding between vim's cwd and neo-tree's root
-- The renderer section provides the renderers that will be used to render the tree.
-- The first level is the node type.
-- For each node type, you can specify a list of components to render.
-- Components are rendered in the order they are specified.
-- The first field in each component is the name of the function to call.
-- The rest of the fields are passed to the function as the "config" argument.
filtered_items = {
visible = false, -- when true, they will just be displayed differently than normal items
hide_dotfiles = true,
hide_gitignored = true,
hide_by_name = {
".DS_Store",
"thumbs.db"
--"node_modules"
},
never_show = { -- remains hidden even if visible is toggled to true
--".DS_Store",
--"thumbs.db"
},
gitignore_source = "git check-ignored", -- or "git status", which may be faster in some repos
},
find_by_full_path_words = false, -- `false` means it only searches the tail of a path.
-- `true` will change the filter into a full path
-- search with space as an implicit ".*", so
-- `fi init`
-- will match: `./sources/filesystem/init.lua
--find_command = "fd",
--find_args = { -- you can specify extra args to pass to the find command.
-- "--exclude", ".git",
-- "--exclude", "node_modules"
--},
---- or use a function instead of list of strings
--find_args = function(cmd, path, search_term, args)
-- if cmd ~= "fd" then
-- return args
-- end
-- --maybe you want to force the filter to always include hidden files:
-- table.insert(args, "--hidden")
-- -- but no one ever wants to see .git files
-- table.insert(args, "--exclude")
-- table.insert(args, ".git")
-- -- or node_modules
-- table.insert(args, "--exclude")
-- table.insert(args, "node_modules")
-- --here is where it pays to use the function, you can exclude more for
-- --short search terms, or vary based on the directory
-- if string.len(search_term) < 4 and path == "/home/cseickel" then
-- table.insert(args, "--exclude")
-- table.insert(args, "Library")
-- end
-- return args
--end,
search_limit = 50, -- max number of search results when using filters
follow_current_file = false, -- This will find and focus the file in the active buffer every time
-- the current file is changed while the tree is open.
hijack_netrw_behavior = "open_default", -- netrw disabled, opening a directory opens neo-tree
-- in whatever position is specified in window.position
-- "open_split", -- netrw disabled, opening a directory opens within the
-- window like netrw would, regardless of window.position
-- "disabled", -- netrw left alone, neo-tree does not handle opening dirs
follow_current_file = false, -- This will find and focus the file in the active buffer every time
-- the current file is changed while the tree is open.
use_libuv_file_watcher = false, -- This will use the OS level file watchers to detect changes
-- instead of relying on nvim autocmd events.
window = { -- see https://github.com/MunifTanjim/nui.nvim/tree/main/lua/nui/popup for
Expand Down Expand Up @@ -123,50 +177,6 @@ local config = {
["q"] = "close_window",
},
},
find_by_full_path_words = false, -- `false` means it only searches the tail of a path.
-- `true` will change the filter into a full path
-- search with space as an implicit ".*", so
-- `fi init`
-- will match: `./sources/filesystem/init.lua
--find_command = "fd",
--find_args = { -- you can specify extra args to pass to the find command.
-- "--exclude", ".git",
-- "--exclude", "node_modules"
--},
---- or use a function instead of list of strings
--find_args = function(cmd, path, search_term, args)
-- if cmd ~= "fd" then
-- return args
-- end
-- --maybe you want to force the filter to always include hidden files:
-- table.insert(args, "--hidden")
-- -- but no one ever wants to see .git files
-- table.insert(args, "--exclude")
-- table.insert(args, ".git")
-- -- or node_modules
-- table.insert(args, "--exclude")
-- table.insert(args, "node_modules")
-- --here is where it pays to use the function, you can exclude more for
-- --short search terms, or vary based on the directory
-- if string.len(search_term) < 4 and path == "/home/cseickel" then
-- table.insert(args, "--exclude")
-- table.insert(args, "Library")
-- end
-- return args
--end,
search_limit = 50, -- max number of search results when using filters
filters = {
show_hidden = false,
respect_gitignore = true,
gitignore_source = "git status", -- or "git check-ignored", which may be faster in some repos
},
bind_to_cwd = true, -- true creates a 2-way binding between vim's cwd and neo-tree's root
-- The renderer section provides the renderers that will be used to render the tree.
-- The first level is the node type.
-- For each node type, you can specify a list of components to render.
-- Components are rendered in the order they are specified.
-- The first field in each component is the name of the function to call.
-- The rest of the fields are passed to the function as the "config" argument.
renderers = {
directory = {
{ "indent" },
Expand Down Expand Up @@ -199,6 +209,7 @@ local config = {
},
},
buffers = {
bind_to_cwd = true,
window = {
position = "left",
width = 40,
Expand All @@ -219,7 +230,6 @@ local config = {
["bd"] = "buffer_delete",
},
},
bind_to_cwd = true,
renderers = {
directory = {
{ "indent" },
Expand Down
32 changes: 32 additions & 0 deletions lua/neo-tree/deprecations.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
local utils = require "neo-tree.utils"

local migrate = function (config)
local messages = {}

local moved = function (old, new, converter)
local exising = utils.get_value(config, old)
if type(exising) ~= "nil" then
if type(converter) == "function" then
exising = converter(exising)
end
utils.set_value(config, new, exising)
config[old] = nil
messages[#messages + 1] = string.format("The `%s` option has been deprecated, please use `%s` instead.", old, new)
end
end

local opposite = function (value)
return not value
end

moved("filesystem.filters", "filesystem.filtered_items")
moved("filesystem.filters.show_hidden", "filesystem.filtered_items.hide_dotfiles", opposite)
moved("filesystem.filters.respect_gitignore", "filesystem.filtered_items.hide_gitignored")
moved("filesystem.filters.gitignore_source", "filesystem.filtered_items.gitignore_source")

return messages
end

return {
migrate = migrate
}
Empty file added lua/neo-tree/setup/init.lua
Empty file.
Loading