From 5c6e37c287d6751d8a013a65e72cbfdf83b2f89d Mon Sep 17 00:00:00 2001 From: Yuan Chiu Date: Mon, 5 May 2025 20:49:35 +0800 Subject: [PATCH] feat nvim: document_symbols on NeoTree --- dot_config/nvim/Readme.md | 4 +- .../exact_components/neo-tree.lua | 138 +++++++++--------- 2 files changed, 74 insertions(+), 68 deletions(-) diff --git a/dot_config/nvim/Readme.md b/dot_config/nvim/Readme.md index ea736ad..bf132ec 100644 --- a/dot_config/nvim/Readme.md +++ b/dot_config/nvim/Readme.md @@ -17,15 +17,13 @@ Yuan Neovim 備忘 ### 擴充自行設定的快速鍵 * `` 可以回朔到開啟檔案以來的任何歷史,還會標出修改的地方 +* `` 看看你設定了哪些變數、函數,也可以快速跳轉 * ``: NeoTree: 查看已經開啟的檔案 * ``: NeoTree * ``: git status * `fT`: 浮動NeoTree * `fB`: 已開啟的檔案 -#### 預計設定 -* 看看你設定了哪些變數、函數,也可以快速跳轉 - ### 編輯習慣(已經覆寫) * shift+方向鍵(傳統): 選取文字(傳統習慣) * PS. 不能用jk是因為 shift+j shift+k有被其他功能綁定,不覆寫是想順便習慣vim用法 diff --git a/dot_config/nvim/exact_lua/exact_plugins/exact_components/neo-tree.lua b/dot_config/nvim/exact_lua/exact_plugins/exact_components/neo-tree.lua index b4f296d..f432621 100644 --- a/dot_config/nvim/exact_lua/exact_plugins/exact_components/neo-tree.lua +++ b/dot_config/nvim/exact_lua/exact_plugins/exact_components/neo-tree.lua @@ -55,6 +55,7 @@ return { desc = "NeoTree" }, { "", "Neotree toggle buffers", desc = "NeoTree Buffers" }, + { "", "Neotree document_symbols right toggle", desc = "NeoTree document_symbols" }, { "e", "Neotree reveal" }, { "ft", "Neotree toggle", desc = "NeoTree" }, @@ -63,12 +64,19 @@ return { { "fG", "Neotree git_status float", desc = "NeoTree Git Status Float" }, { "", "Neotree git_status float", desc = "NeoTree Git Status Float" }, --警告!在標準終端無法使用 { "fB", "Neotree buffers float", desc = "NeoTree Buffers Float" }, + { "fD", "Neotree document_symbols float", 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 = { - [""] = { - "toggle_node", - nowait = false, -- disable `nowait` if you have existing combos starting with this char that you want to use - }, - ["<2-LeftMouse>"] = "open", - [""] = "open", - [""] = "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", - -- [""] = "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 = { + -- [""] = { + -- "toggle_node", + -- nowait = false, -- disable `nowait` if you have existing combos starting with this char that you want to use + -- }, + -- ["<2-LeftMouse>"] = "open", + -- [""] = "open", + -- [""] = "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", + -- -- [""] = "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 = {