Open nhat-vo opened 1 year ago
Can we also throw support for lspkind.nvim into this? I attempted to do this myself in document_symbol.kinds
but lspkind
doesn't return Highlight Groups (as far as I can tell) for the items so I don't have a great way to do this. It would be nice if we could simply pass something from lspkind
to update just the icons, while letting the document_symbol
source manage the Highlight Group
Edit: After reading #593, is my request the same as that?
Can we also throw support for lspkind.nvim into this? I attempted to do this myself in
document_symbol.kinds
butlspkind
doesn't return Highlight Groups (as far as I can tell) for the items so I don't have a great way to do this. It would be nice if we could simply pass something fromlspkind
to update just the icons, while letting thedocument_symbol
source manage the Highlight Group
At first, I did try to use Lspkind's icons, but this plugin provides the icon for a different set of kinds (Completion kinds vs. Symbol kinds). So it's not very straightforward to add this. Instead, it is quite straightforward to just copy their symbols, modify them accordingly, and paste into your config.
Edit: After reading #593, is my request the same as that?
I don't think so, #593's request is an integration between the filesystem
and documents_symbols
sources, rather than a icon config like this.
It should be, but I don't know the appropriate highlight groups being used in the background (IE, it doesn't appear they are exposed). Which means that I have to set the icons and make my own highlight group for each icon.
Hi all, very glad to have this feature implemented, I just want to report that I get an error when selecting a document_symbol when the tree is shown in position current (in the same window as the file being edited):
E5108: Error executing lua: ....nvim/lua/neo-tree/sources/document_symbols/commands.lua:25: Cursor position outside buffer
stack traceback:
[C]: in function 'nvim_win_set_cursor'
....nvim/lua/neo-tree/sources/document_symbols/commands.lua:25: in function 'func'
...are/nvim/lazy/neo-tree.nvim/lua/neo-tree/ui/renderer.lua:782: in function <...are/nvim/lazy/neo-tree.nvim/lua/neo-tree/ui/renderer.lua:780>
Thank you very much for this plugin, the best I found that can also work in split mode like netrw.
It should be, but I don't know the appropriate highlight groups being used in the background (IE, it doesn't appear they are exposed). Which means that I have to set the icons and make my own highlight group for each icon.
@miversen33 Just to confirm, do you mean that the default highlight groups should be used when only the names are specified? If so, I think it should be quite an easy tweak - changing tbl_extend
to tbl_deep_extend
. I'll add it this weekend.
Yes exactly! If a highlight group isn't provided, the default should be used.
Hi all, very glad to have this feature implemented, I just want to report that I get an error when selecting a document_symbol when the tree is shown in position current (in the same window as the file being edited):
E5108: Error executing lua: ....nvim/lua/neo-tree/sources/document_symbols/commands.lua:25: Cursor position outside buffer stack traceback: [C]: in function 'nvim_win_set_cursor' ....nvim/lua/neo-tree/sources/document_symbols/commands.lua:25: in function 'func' ...are/nvim/lazy/neo-tree.nvim/lua/neo-tree/ui/renderer.lua:782: in function <...are/nvim/lazy/neo-tree.nvim/lua/neo-tree/ui/renderer.lua:780>
Thank you very much for this plugin, the best I found that can also work in split mode like netrw.
@tenllado Thanks for reporting the bug! Indeed I forgot the case when the buffer is changed in the window like when using position=current
😅. I'll push a fix this weekend for this.
Hi, sorry if I'm not properly documenting this. Please let me know if there's any more info I can provider.
When enabling in sources and running :Neotree document_symbols
I get the follwoing warning/error [Neo-tree WARN] Error rendering component name: ...vim/lua/neo-tree/sources/document_symbols/components.lua:37: attempt to index field 'extra' (a nil value)
Also can be see in the image here
And this is my config
require("neo-tree").setup({
popup_border_style = "rounded",
add_blank_line_at_top = true,
hide_root_node = true,
retain_hidden_root_indent = true,
enable_git_status = true,
enable_diagnostics = true,
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
source_selector = {
-- statusline = true,
winbar = true,
sources = {
{
source = "filesystem",
display_name = "𐎾 𐏃 𐏁 𐎠 𐎲 ",
},
},
content_layout = "center",
highlight_tab = "NeoTreeTabInactive", -- string
highlight_tab_active = "NeoTreeTabActive", -- string
highlight_background = "NeoTreeTabInactive", -- string
highlight_separator = "ActiveWindow", -- string
highlight_separator_active = "NeoTreeTabSeparatorActive", -- string
},
sources = {
"filesystem",
"buffers",
"document_symbols",
},
default_component_configs = {
container = {
enable_character_fade = false,
},
indent = {
indent_size = 2,
padding = 1, -- extra padding on left hand side
-- indent guides
with_markers = true,
indent_marker = "│",
last_indent_marker = "└",
highlight = "NeoTreeIndentMarker",
-- expander config, needed for nesting files
with_expanders = nil, -- if nil and file nesting is enabled, will enable expanders
expander_collapsed = "",
expander_expanded = "",
expander_highlight = "NeoTreeExpander",
},
icon = {
folder_closed = "",
folder_open = "",
folder_empty = "",
folder_empty_open = "",
-- The next two settings are only a fallback, if you use nvim-web-devicons and configure default icons there
-- then these will never be used.
default = "*",
highlight = "NeoTreeFileIcon",
},
modified = {
symbol = "[+]",
highlight = "NeoTreeModified",
},
name = {
trailing_slash = false,
use_git_status_colors = true,
highlight = "NeoTreeFileName",
},
git_status = {
symbols = {
-- Change type
added = "", -- or "✚", but this is redundant info if you use git_status_colors on the name
modified = "", -- or "", but this is redundant info if you use git_status_colors on the name
deleted = "✖", -- this can only be used in the git_status source
renamed = "", -- this can only be used in the git_status source
-- Status type
untracked = "",
ignored = "",
unstaged = "",
staged = "",
conflict = "",
},
},
},
-- A list of functions, each representing a global custom command
-- that will be available in all sources (if not overridden in `opts[source_name].commands`)
-- see `:h neo-tree-global-custom-commands`
commands = {},
window = {
position = "float",
width = 30,
popup = {
size = { height = "30", width = "35" },
position = "50%"
},
mapping_options = {
noremap = true,
nowait = true,
},
mappings = {
["<space>"] = {
"toggle_node",
nowait = false, -- disable `nowait` if you have existing combos starting with this char that you want to use
},
["<2-LeftMouse>"] = "open",
["l"] = "open",
["<esc>"] = "revert_preview",
["P"] = { "toggle_preview", config = { use_float = true } },
-- ["l"] = "focus_preview",
-- ["S"] = "open_split",
["v"] = "open_vsplit",
-- ["S"] = "split_with_window_picker",
-- ["s"] = "vsplit_with_window_picker",
["t"] = "open_tabnew",
-- ["<cr>"] = "open_drop",
-- ["t"] = "open_tab_drop",
["<cr>"] = "open_with_window_picker",
--["P"] = "toggle_preview", -- enter preview mode, which shows the current node without focusing
["h"] = "close_node",
-- ['S'] = 'close_all_subnodes',
["C"] = "close_all_nodes",
["D"] = "expand_all_nodes",
["a"] = {
"add",
-- this command supports BASH style brace expansion ("x{a,b,c}" -> xa,xb,xc). see `:h neo-tree-file-actions` for details
-- some commands may take optional config options, see `:h neo-tree-mappings` for details
config = {
show_path = "none", -- "none", "relative", "absolute"
},
},
["A"] = "add_directory", -- also accepts the optional config.show_path option like "add". this also supports BASH style brace expansion.
["d"] = "delete",
["r"] = "rename",
["y"] = "copy_to_clipboard",
["x"] = "cut_to_clipboard",
["p"] = "paste_from_clipboard",
["c"] = "copy", -- takes text input for destination, also accepts the optional config.show_path option like "add":
-- ["c"] = {
-- "copy",
-- config = {
-- show_path = "none" -- "none", "relative", "absolute"
-- }
--}
["m"] = "move", -- takes text input for destination, also accepts the optional config.show_path option like "add".
["z"] = "close_window",
["R"] = "refresh",
["?"] = "show_help",
["<"] = "prev_source",
[">"] = "next_source",
},
},
nesting_rules = {},
filesystem = {
filtered_items = {
visible = true, -- when true, they will just be displayed differently than normal items
hide_dotfiles = true,
hide_gitignored = true,
hide_hidden = true, -- only works on Windows for hidden files/directories
hide_by_name = {
--"node_modules"
},
hide_by_pattern = { -- uses glob style patterns
--"*.meta",
--"*/src/*/tsconfig.json",
},
always_show = { -- remains visible even if other settings would normally hide it
--".gitignored",
},
never_show = { -- remains hidden even if visible is toggled to true, this overrides always_show
--".DS_Store",
--"thumbs.db"
},
never_show_by_pattern = { -- uses glob style patterns
--".null-ls_*",
},
},
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.
group_empty_dirs = false, -- when true, empty folders will be grouped together
hijack_netrw_behavior = "open_default", -- netrw disabled, opening a directory opens neo-tree
-- in whatever position is specified in window.position
-- "open_current", -- 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
use_libuv_file_watcher = false, -- This will use the OS level file watchers to detect changes
-- instead of relying on nvim autocmd events.
window = {
mappings = {
["<bs>"] = "navigate_up",
["."] = "set_root",
["H"] = "toggle_hidden",
["/"] = "fuzzy_finder",
-- ["/"] = "fuzzy_finder_directory",
["#"] = "fuzzy_sorter", -- fuzzy sorting using the fzy algorithm
-- ["D"] = "fuzzy_sorter_directory",
["f"] = function (state)
vim.api.nvim_command("HopWord")
end,
["<c-x>"] = "clear_filter",
["[g"] = "prev_git_modified",
["]g"] = "next_git_modified",
},
fuzzy_finder_mappings = {
-- define keymaps for filter popup window in fuzzy_finder_mode
["<down>"] = "move_cursor_down",
["<C-n>"] = "move_cursor_down",
["<up>"] = "move_cursor_up",
["<C-p>"] = "move_cursor_up",
},
},
commands = {}, -- Add a custom command or override a global one using the same function name
},
buffers = {
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.
group_empty_dirs = true, -- when true, empty folders will be grouped together
show_unloaded = true,
window = {
mappings = {
["bd"] = "buffer_delete",
["<bs>"] = "navigate_up",
["."] = "set_root",
},
},
},
git_status = {
window = {
position = "float",
mappings = {
["A"] = "git_add_all",
["gu"] = "git_unstage_file",
["ga"] = "git_add_file",
["gr"] = "git_revert_file",
["gc"] = "git_commit",
["gp"] = "git_push",
["gg"] = "git_commit_and_push",
},
},
},
})
Thanks again for making my favorite tree by far :pray:
Can we also throw support for lspkind.nvim into this? I attempted to do this myself in
document_symbol.kinds
butlspkind
doesn't return Highlight Groups (as far as I can tell) for the items so I don't have a great way to do this. It would be nice if we could simply pass something fromlspkind
to update just the icons, while letting thedocument_symbol
source manage the Highlight GroupAt first, I did try to use Lspkind's icons, but this plugin provides the icon for a different set of kinds (Completion kinds vs. Symbol kinds). So it's not very straightforward to add this. Instead, it is quite straightforward to just copy their symbols, modify them accordingly, and paste into your config.
I've found a close match to be this:
local completion_kinds = require'lspkind'.symbol_map -- Completion-kinds:Document-kinds not a 1:1 map
...
document_symbols = { kinds = {
File = { icon = completion_kinds.File, hl = "Tag" },
Namespace = { icon = completion_kinds.Module, hl = "Include" },
Package = { icon = "", hl = "Label" },
Class = { icon = completion_kinds.Class, hl = "Include" },
Property = { icon = completion_kinds.Property, hl = "@property" },
Enum = { icon = completion_kinds.Enum, hl = "@number" },
Function = { icon = completion_kinds.Function, hl = "Function" },
String = { icon = completion_kinds.Text, hl = "String" },
Number = { icon = completion_kinds.Value, hl = "Number" },
Array = { icon = "", hl = "Type" },
Object = { icon = "", hl = "Type" },
Key = { icon = completion_kinds.Keyword, hl = "" },
Struct = { icon = completion_kinds.Struct, hl = "Type" },
Operator = { icon = completion_kinds.Operator, hl = "Operator" },
TypeParameter = { icon = completion_kinds.TypeParameter, hl = "Type" },
StaticMethod = { icon = completion_kinds.Method, hl = 'Function' }
} },
And concerning highlight groups, https://github.com/onsails/lspkind.nvim/issues/32
@TLSingh1 @Curs3W4ll I have just pushed a fix in #972. Could you have a look to see if this fixes the issue?
I actually merged it already, so you can just try out main
as well.
@nhat-vo Seems to fix the error message. Thank you!
But there is still a bug with the add_blank_line_at_top
option.
When set to true, nothing is displayed (see screenshots below)
add_blank_line_at_top = true
add_blank_line_at_top = false
@Curs3W4ll Sorry for the late reply. I have just pushed #1066, which fixes this issue. Have a look to see if it's gone!
@Curs3W4ll Sorry for the late reply. I have just pushed #1066, which fixes this issue. Have a look to see if it's gone!
Hey, no problem at all.
Yep, this is now working well.
Thank you!
Not sure if I should create new issues or post them here... I'll start here, LMK if you want new issues instead:
Based on the command: <cmd>Neotree action=show source=document_symbols position=right reveal=true toggle=true<cr>
:
follow_cursor
, but as a one off on initfollow_cursor
This is a really cool feature. I'm able to replace aerial now, and I'm always happy to load one less plugin.
I'd be interested in taking a shot at call hierarchy. I don't have any experience with neovim development, so any pointers would be very appreciated.
Hi, I found this bug when doing show_help
in document_symbols
:
E5108: Error executing lua: ...ou/.local/share/nvim/lazy/nui.nvim/lua/nui/line/init.lua:22: attempt to index local 'block' (a nil value)
stack traceback:
.../.local/share/nvim/lazy/nui.nvim/lua/nui/line/init.lua:22: in function 'append'
.../lazy/neo-tree.nvim/lua/neo-tree/sources/common/help.lua:62: in function 'show'
...y/neo-tree.nvim/lua/neo-tree/sources/common/commands.lua:886: in function <...y/neo-tree.nvim/lua/neo-tree/sources/common/commands.lua:883>
Not sure if something's wrong with my configurations.
As merged in #841, we now have an additional
document_symbol
source. This source is still rather simple, and more features will be added in the future. The original features are listed in the description of #841, and this issue will track additional features to be implemented.If you have any idea on what to add or want to help out, please feel free to add a comment!