Skip to content

Commit

Permalink
Merge branch 'nvim-neo-tree:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
tribhuwan-kumar authored May 22, 2024
2 parents 7676d7f + 29f7c21 commit 5896224
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 46 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,6 @@ use {
popup_border_style = "rounded",
enable_git_status = true,
enable_diagnostics = true,
enable_normal_mode_for_inputs = false, -- Enable normal mode for input dialogs.
open_files_do_not_replace_types = { "terminal", "trouble", "qf" }, -- when opening files, do not use windows containing these filetypes or buftypes
sort_case_insensitive = false, -- used when sorting files and directories in the tree
sort_function = nil , -- use a custom function for sorting files and directories in the tree
Expand Down Expand Up @@ -667,7 +666,7 @@ add `"document_symbols"` to `config.sources` and open it with the command
### External Sources

There are more sources available as extensions that are managed outside of this repository. See the
[wiki](https://github.com/nvim-neo-tree/neo-tree.nvim/wiki/External-Sources) for me information.
[wiki](https://github.com/nvim-neo-tree/neo-tree.nvim/wiki/External-Sources) for more information.

### Source Selector

Expand Down
8 changes: 4 additions & 4 deletions doc/neo-tree.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1017,7 +1017,7 @@ for a deeper dive into customizing this aspect. If you wish to configure those
components in a universal way, the best place to do that is in the
`default_component_configs` section of the config.

For example, to add indent markers, you can apply your settings in each renderer
For example, to configure indent markers, you can apply your settings in each renderer
for each source, or just do it once in the default_component_configs section:

>lua
Expand Down Expand Up @@ -1174,8 +1174,8 @@ config when calling the setup function.

INDENT MARKERS *neo-tree-indent-markers*

By default, indent markers (aka indent guides) are disabled. In Neo-tree
indent is a component, so to enable indent markers, you need configure the
By default, indent markers (aka indent guides) are enabled. In Neo-tree
indent is a component, so to edit indent markers, you can configure the
`indent` component:

...at the global level:
Expand Down Expand Up @@ -1555,7 +1555,7 @@ configs for each source, look at the default config by pasting it with
:lua require("neo-tree").paste_default_config()
<
or view it online at:
https://github.com/nvim-neo-tree/neo-tree.nvim/blob/v1.x/lua/neo-tree/defaults.lua
https://github.com/nvim-neo-tree/neo-tree.nvim/blob/v3.x/lua/neo-tree/defaults.lua

A default `renderers` config is specified at the root level and will be used
by each source unless another renderer is defined. If you just want to
Expand Down
85 changes: 45 additions & 40 deletions lua/neo-tree/utils/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -239,34 +239,43 @@ M.get_diagnostic_counts = function()
for ns, _ in pairs(vim.diagnostic.get_namespaces()) do
for _, bufnr in ipairs(vim.api.nvim_list_bufs()) do
local success, file_name = pcall(vim.api.nvim_buf_get_name, bufnr)
-- TODO, remove is_disabled nil check when dropping support for 0.8
if
success and vim.diagnostic.is_disabled == nil or not vim.diagnostic.is_disabled(bufnr, ns)
then
for severity, _ in ipairs(vim.diagnostic.severity) do
local diagnostics = vim.diagnostic.get(bufnr, { namespace = ns, severity = severity })

if #diagnostics > 0 then
local severity_string = diag_severity_to_string(severity)
-- Get or create the entry for this file
local entry = lookup[file_name]
if entry == nil then
entry = {
severity_number = severity,
severity_string = severity_string,
}
lookup[file_name] = entry
end
-- Set the count for this diagnostic type
if severity_string ~= nil then
entry[severity_string] = #diagnostics
end
if success then
-- TODO: remove is_disabled check when dropping support for 0.8
local enabled
if vim.diagnostic.is_enabled then
enabled = vim.diagnostic.is_enabled({ bufnr = bufnr, ns_id = ns })
elseif vim.diagnostic.is_disabled then
enabled = not vim.diagnostic.is_disabled(bufnr, ns)
else
enabled = true
end

-- Set the overall severity to the most severe so far
-- Error = 1, Warn = 2, Info = 3, Hint = 4
if severity < entry.severity_number then
entry.severity_number = severity
entry.severity_string = severity_string
if enabled then
for severity, _ in ipairs(vim.diagnostic.severity) do
local diagnostics = vim.diagnostic.get(bufnr, { namespace = ns, severity = severity })

if #diagnostics > 0 then
local severity_string = diag_severity_to_string(severity)
-- Get or create the entry for this file
local entry = lookup[file_name]
if entry == nil then
entry = {
severity_number = severity,
severity_string = severity_string,
}
lookup[file_name] = entry
end
-- Set the count for this diagnostic type
if severity_string ~= nil then
entry[severity_string] = #diagnostics
end

-- Set the overall severity to the most severe so far
-- Error = 1, Warn = 2, Info = 3, Hint = 4
if severity < entry.severity_number then
entry.severity_number = severity
entry.severity_string = severity_string
end
end
end
end
Expand Down Expand Up @@ -1042,24 +1051,20 @@ end
---be lost.
---
---For more details, see issue #889 when this function was introduced, and further
---discussions in #1264 and #1352.
---discussions in #1264, #1352, and #1448.
---@param path string
---@return string
M.escape_path_for_cmd = function(path)
local escaped_path = vim.fn.fnameescape(path)
if M.is_windows then
-- on windows, some punctuation preceeded by a `\` needs to have a second
-- `\` added to preserve the path separator. this is a naive replacement and
-- definitely not bullet proof. if we start finding issues with opening files
-- or changing directories, look here first. #1382 was the first regression
-- from the implementation that used lua's %p to match punctuation, which
-- did not quite work. the following characters were tested on windows to
-- be known to require an extra escape character.
for _, c in ipairs({ "&", "(", ")", ";", "^", "`" }) do
-- lua doesn't seem to have a problem with an unnecessary `%` escape
-- (e.g., `%;`), so we can use it to ensure we match the punctuation
-- for the ones that do (e.g., `%(` and `%^`)
escaped_path = escaped_path:gsub("\\%" .. c, "\\%1")
-- there is too much history to this logic to capture in a reasonable comment.
-- essentially, the following logic adds a number of `\` depending on the leading
-- character in a path segment. see #1264, #1352, and #1448 for more info.
local need_extra_esc = path:find("[%[%]`%$~]")
local esc = need_extra_esc and "\\\\" or "\\"
escaped_path = escaped_path:gsub("\\[%(%)%^&;]", esc .. "%1")
if need_extra_esc then
escaped_path = escaped_path:gsub("\\\\['` ]", "\\%1")
end
end
return escaped_path
Expand Down

0 comments on commit 5896224

Please sign in to comment.