diff --git a/README.md b/README.md index 90f5b84..2359072 100644 --- a/README.md +++ b/README.md @@ -259,9 +259,68 @@ require("wf").setup({

(back to top)

-## Wiki +## Document -You can find guides and showcase of the plugin on [the Wiki](https://github.com/cassin/wf.nvim/wiki) +You can find guides the plugin on [the docs](https://github.com/Cassin01/wf.nvim/blob/main/doc/wf.txt) + +

(back to top)

+ +## Tips + +### Holding specific key pattern on which_key + +It may be a bit arrogant to call it tips, but here is my init.lua setup. + +```lua +-- setup table for prefixes +--------------------------------------- +if _G.__key_prefixes == nil then + _G.__key_prefixes = { + n = {}, + i = {}, + } +end + +-- utility function for setting keymaps +--------------------------------------- +local function nmaps(prefix, desc, tbl) + local sign = "["..name.."]" + table.insert(_G.__key_prefixes["n"], prefix, sign) + local set = function(key, cmd, desc, opt) + local _opt = opt or {} + _opt["desc"] = desc..sign + _opt["noremap"] = true + vim.keymap.set("n", prefix .. key, cmd, _opt) + end + for _, v in ipairs(tbl) do + set(unpack tbl) + end +end + + +-- set keymap for each plugins +--------------------------------------- + +-- lambdalisue/fern.vim +nmaps("n", "fern", +{{"p", "Fern . -drawer -toggle", "open fern on a current working directory"}, + {"d", "Fern %:h -drawer -toggle", "open fern on a parent directory of a current buffer"}}) + +-- nvim-telescope/telescope.nvim +nmaps("t", "telescope" +{{"f", "Telescope find_files", "find files"}, + {"g", "Telescope live_grep", "live grep"}, + {"b", "Telescope buffers", "buffers"}, + {"h", "Telescope help_tags", "help tags"}, + {"t", "Telescope", "telescope"}, + {"o", "Telescope oldfiles", "old files"}, + {"r", "Telescope file_browser", "file_browser"}}) + +-- set keymap for calling which-key +vim.set.keymap("n", ", which_key({text_insert_in_advance="", +key_group_dict=_G.__key_prefixes["n"]}), +{noremap = true, silent = tre, desc = "which-key space", nowait = true}) +```

(back to top)

diff --git a/doc/wf.txt b/doc/wf.txt index f2becb1..8d8b5e6 100644 --- a/doc/wf.txt +++ b/doc/wf.txt @@ -79,7 +79,7 @@ Fields~ {border} `(string)` of window border. This can either be a string or an array. nvim_open_win -{borderchars} `(table)` @field top center bottom +{borderchars} `(table)` @field top center bottom array will specifify the eight chars building up the border in a clockwise fashion starting with the top-left corner. nvim_open_win {icons} `(table)` @field separator fuzzy_prompt which_prompt @@ -94,6 +94,8 @@ Fields~ {selector} "which"|"fuzzy" {text_insert_in_advance} `(string)` {key_group_dict} `(table)` +Usage~ +key_group_dict = { "l"="vimtex", "e"="conjure" } {prefix_size} `(number)` {sorter} `(function)` {behavior} WFBehavior @@ -107,6 +109,8 @@ Fields~ `bookmark`({bookmark_dirs}, {opts}) Parameters~ {bookmark_dirs} `(table)` +Usage~ +bookmark({nvim="~/.config/nvim", zsh="~/.zshrc"}) {opts} `(optional)` WFOptions diff --git a/lua/wf/builtin/bookmark.lua b/lua/wf/builtin/bookmark.lua index 68121e2..aec761e 100644 --- a/lua/wf/builtin/bookmark.lua +++ b/lua/wf/builtin/bookmark.lua @@ -9,6 +9,7 @@ local ok, devicon = pcall(require_deviocon) ---@tag builtin.bookmark ---@param bookmark_dirs table +---@usage bookmark({nvim="~/.config/nvim", zsh="~/.zshrc"}) ---@param opts? WFOptions local function bookmark(bookmark_dirs, opts) local function _bookmark() diff --git a/lua/wf/types.lua b/lua/wf/types.lua index 1eebe36..22c9421 100644 --- a/lua/wf/types.lua +++ b/lua/wf/types.lua @@ -46,7 +46,7 @@ ---@field border string ---Style of window border. This can either be a string or an array. ---:h nvim_open_win ----@field borderchars table @field top center bottom +---@field borderchars table @field top center bottom ---The array will specifify the eight chars building up the border in a clockwise fashion starting with the top-left corner. ---:h nvim_open_win ---@field icons table @field separator fuzzy_prompt which_prompt @@ -58,6 +58,7 @@ ---@field selector "which"|"fuzzy" ---@field text_insert_in_advance string ---@field key_group_dict table +---@usage key_group_dict = { "l"="vimtex", "e"="conjure" } ---@field prefix_size number ---@field sorter function ---@field behavior WFBehavior