feat nvim: document_symbols on NeoTree

This commit is contained in:
Yuan Chiu 2025-05-05 20:49:35 +08:00
parent 5f615e405a
commit 5c6e37c287
2 changed files with 74 additions and 68 deletions

View File

@ -17,15 +17,13 @@ Yuan Neovim 備忘
### 擴充自行設定的快速鍵
* `<F6>` 可以回朔到開啟檔案以來的任何歷史,還會標出修改的地方
* `<F7>` 看看你設定了哪些變數、函數,也可以快速跳轉
* `<F8>`: NeoTree: 查看已經開啟的檔案
* `<F9>`: NeoTree
* `<F10>`: git status
* `<leader>fT`: 浮動NeoTree
* `<leader>fB`: 已開啟的檔案
#### 預計設定
* <F7> 看看你設定了哪些變數、函數,也可以快速跳轉
### 編輯習慣(已經覆寫)
* shift+方向鍵(傳統): 選取文字(傳統習慣)
* PS. 不能用jk是因為 shift+j shift+k有被其他功能綁定不覆寫是想順便習慣vim用法

View File

@ -55,6 +55,7 @@ return {
desc = "NeoTree"
},
{ "<F8>", "<cmd>Neotree toggle buffers<cr>", desc = "NeoTree Buffers" },
{ "<F7>", "<cmd>Neotree document_symbols right toggle<cr>", desc = "NeoTree document_symbols" },
{ "<leader>e", "<Cmd>Neotree reveal<CR>" },
{ "<leader>ft", "<cmd>Neotree toggle<cr>", desc = "NeoTree" },
@ -63,12 +64,19 @@ return {
{ "<leader>fG", "<cmd>Neotree git_status float<cr>", desc = "NeoTree Git Status Float" },
{ "<S-F9>", "<cmd>Neotree git_status float<cr>", desc = "NeoTree Git Status Float" }, --警告!在標準終端無法使用
{ "<leader>fB", "<cmd>Neotree buffers float<cr>", desc = "NeoTree Buffers Float" },
{ "<leader>fD", "<cmd>Neotree document_symbols float<cr>", desc = "NeoTree Document Symbols Float" },
},
lazy = false,
-----Instead of using `config`, you can use `opts` instead, if you'd like:
-----@module "neo-tree"
-----@type neotree.Config
opts = {
sources = {
"filesystem",
"buffers",
"git_status",
"document_symbols",
},
close_if_last_window = true, -- Close Neo-tree if it is the last window left in the tab
popup_border_style = "NC", -- or "" to use 'winborder' on Neovim v0.11+
enable_git_status = true,
@ -182,71 +190,71 @@ return {
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",
["<cr>"] = "open",
["<esc>"] = "cancel", -- close preview or floating neo-tree window
["P"] = { "toggle_preview", config = { use_float = true, use_image_nvim = false } },
-- Read `# Preview Mode` for more information
["l"] = "focus_preview",
["S"] = "open_split",
["s"] = "open_vsplit",
-- ["S"] = "split_with_window_picker",
-- ["s"] = "vsplit_with_window_picker",
["t"] = "open_tabnew",
-- ["<cr>"] = "open_drop",
-- ["t"] = "open_tab_drop",
["w"] = "open_with_window_picker",
--["P"] = "toggle_preview", -- enter preview mode, which shows the current node without focusing
["C"] = "close_node",
-- ['C'] = 'close_all_subnodes',
["z"] = "close_all_nodes",
--["Z"] = "expand_all_nodes",
--["Z"] = "expand_all_subnodes",
["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",
["b"] = "rename_basename",
["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".
["q"] = "close_window",
["R"] = "refresh",
["?"] = "show_help",
["<"] = "prev_source",
[">"] = "next_source",
["i"] = "show_file_details",
-- ["i"] = {
-- "show_file_details",
-- -- format strings of the timestamps shown for date created and last modified (see `:h os.date()`)
-- -- both options accept a string or a function that takes in the date in seconds and returns a string to display
-- -- config = {
-- -- created_format = "%Y-%m-%d %I:%M %p",
-- -- modified_format = "relative", -- equivalent to the line below
-- -- modified_format = function(seconds) return require('neo-tree.utils').relative_date(seconds) end
-- -- }
-- 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",
-- ["<cr>"] = "open",
-- ["<esc>"] = "cancel", -- close preview or floating neo-tree window
-- ["P"] = { "toggle_preview", config = { use_float = true, use_image_nvim = false } },
-- -- Read `# Preview Mode` for more information
-- ["l"] = "focus_preview",
-- ["S"] = "open_split",
-- ["s"] = "open_vsplit",
-- -- ["S"] = "split_with_window_picker",
-- -- ["s"] = "vsplit_with_window_picker",
-- ["t"] = "open_tabnew",
-- -- ["<cr>"] = "open_drop",
-- -- ["t"] = "open_tab_drop",
-- ["w"] = "open_with_window_picker",
-- --["P"] = "toggle_preview", -- enter preview mode, which shows the current node without focusing
-- ["C"] = "close_node",
-- -- ['C'] = 'close_all_subnodes',
-- ["z"] = "close_all_nodes",
-- --["Z"] = "expand_all_nodes",
-- --["Z"] = "expand_all_subnodes",
-- ["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",
-- ["b"] = "rename_basename",
-- ["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".
-- ["q"] = "close_window",
-- ["R"] = "refresh",
-- ["?"] = "show_help",
-- ["<"] = "prev_source",
-- [">"] = "next_source",
-- ["i"] = "show_file_details",
-- -- ["i"] = {
-- -- "show_file_details",
-- -- -- format strings of the timestamps shown for date created and last modified (see `:h os.date()`)
-- -- -- both options accept a string or a function that takes in the date in seconds and returns a string to display
-- -- -- config = {
-- -- -- created_format = "%Y-%m-%d %I:%M %p",
-- -- -- modified_format = "relative", -- equivalent to the line below
-- -- -- modified_format = function(seconds) return require('neo-tree.utils').relative_date(seconds) end
-- -- -- }
-- -- },
-- },
},
},
nesting_rules = {},
filesystem = {