Skip to content

Commit

Permalink
Merge pull request #49 from Cassin01/update
Browse files Browse the repository at this point in the history
  • Loading branch information
Cassin01 authored Mar 3, 2023
2 parents e8a3f08 + a53db0e commit f01731c
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 4 deletions.
63 changes: 61 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -259,9 +259,68 @@ require("wf").setup({

<p align="right">(<a href="#readme-top">back to top</a>)</p>

## 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)

<p align="right">(<a href="#readme-top">back to top</a>)</p>

## 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("<space>n", "fern",
{{"p", "<cmd>Fern . -drawer -toggle<cr>", "open fern on a current working directory"},
{"d", "<cmd>Fern %:h -drawer -toggle<cr>", "open fern on a parent directory of a current buffer"}})

-- nvim-telescope/telescope.nvim
nmaps("<space>t", "telescope"
{{"f", "<cmd>Telescope find_files<cr>", "find files"},
{"g", "<cmd>Telescope live_grep<cr>", "live grep"},
{"b", "<cmd>Telescope buffers<cr>", "buffers"},
{"h", "<cmd>Telescope help_tags<cr>", "help tags"},
{"t", "<cmd>Telescope<cr>", "telescope"},
{"o", "<cmd>Telescope oldfiles<cr>", "old files"},
{"r", "<cmd>Telescope file_browser<cr>", "file_browser"}})

-- set keymap for calling which-key
vim.set.keymap("n", "<Space>, which_key({text_insert_in_advance="<space>",
key_group_dict=_G.__key_prefixes["n"]}),
{noremap = true, silent = tre, desc = "which-key space", nowait = true})
```


<p align="right">(<a href="#readme-top">back to top</a>)</p>
Expand Down
6 changes: 5 additions & 1 deletion doc/wf.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -94,6 +94,8 @@ Fields~
{selector} "which"|"fuzzy"
{text_insert_in_advance} `(string)`
{key_group_dict} `(table)`
Usage~
key_group_dict = { "<leader>l"="vimtex", "<leader>e"="conjure" }
{prefix_size} `(number)`
{sorter} `(function)`
{behavior} WFBehavior
Expand All @@ -107,6 +109,8 @@ Fields~
`bookmark`({bookmark_dirs}, {opts})
Parameters~
{bookmark_dirs} `(table)`
Usage~
bookmark({nvim="~/.config/nvim", zsh="~/.zshrc"})
{opts} `(optional)` WFOptions


Expand Down
1 change: 1 addition & 0 deletions lua/wf/builtin/bookmark.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
3 changes: 2 additions & 1 deletion lua/wf/types.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -58,6 +58,7 @@
---@field selector "which"|"fuzzy"
---@field text_insert_in_advance string
---@field key_group_dict table
---@usage key_group_dict = { "<leader>l"="vimtex", "<leader>e"="conjure" }
---@field prefix_size number
---@field sorter function
---@field behavior WFBehavior
Expand Down

0 comments on commit f01731c

Please sign in to comment.