-
Notifications
You must be signed in to change notification settings - Fork 66
Adding support for neovim vim.ui.select
#281
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
1473573
feat: adding support for neovim vim.ui.select
saccarosium 38fb4b8
feat!: unifying search commands with Wiki{Pages,Tags,Toc}
saccarosium 8a05bd4
chore: polishing naming and spacing
saccarosium e5fc41b
fix: path relative to g:wiki_path
saccarosium 087d60f
feat: add configuration option g:wiki_selet_method
saccarosium File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -158,7 +158,7 @@ FEATURES *wiki-intro-features* | |
| * Utility functionality | ||
| * |WikiExport| command for exporting to e.g. `pdf` with `pandoc` | ||
| * Third-party support | ||
| * |fzf|: |WikiFzfPages|, |WikiFzfToc|, and |WikiFzfTags| commands | ||
| * |fzf|: |WikiPages|, |WikiToc|, and |WikiTags| commands | ||
| (https://github.com/junegunn/fzf.vim) | ||
|
|
||
| ------------------------------------------------------------------------------ | ||
|
|
@@ -184,7 +184,7 @@ Executive summary ~ | |
| * Speed is key - make sure you have a fast workflow: | ||
| * Use a keyboard shortcut in your desktop/window manager to open Vim/neovim | ||
| with the wiki index (e.g. <alt-n>). | ||
| * Use something like |:WikiFzfPages| and `ripgrep` (with e.g. | ||
| * Use something like |:WikiPages| and `ripgrep` (with e.g. | ||
| `ctrlsf.vim` [2]) for searching. | ||
| * Write short pages and use links between related pages. | ||
| * Don't obsess about the wiki structure. | ||
|
|
@@ -211,7 +211,7 @@ previously also used Dropbox. | |
|
|
||
| Needless to say, it is important to be able to find relevant notes fast. | ||
| I have a global Vim mapping `<leader>ow` to open a page search interface. | ||
| I previously used |:WikiFzfPages|, which works very well! Today, though, I use | ||
| I previously used |:WikiPages|, which works very well! Today, though, I use | ||
| Telescope [4] with a personal function to list wiki files [5]. It usually | ||
| takes no more than a couple of seconds from the moment I think of something | ||
| until I have opened the relevant note. A key here is to use simple names for | ||
|
|
@@ -523,15 +523,15 @@ OPTIONS *wiki-config-options* | |
| endfunction | ||
|
|
||
| *g:wiki_fzf_pages_force_create_key* | ||
| Key combination that, when pressed while searching with |WikiFzfPages|, will | ||
| Key combination that, when pressed while searching with |WikiPages|, will | ||
| create a new page with the name of the query. The value must be a string | ||
| recognized by fzf's `--expect` argument; see fzf's manual page for a list of | ||
| available keys. | ||
|
|
||
| Default: `'alt-enter'` | ||
|
|
||
| *g:wiki_fzf_pages_opts* | ||
| A string with additional user options for |WikiFzfPages|. This can be used | ||
| A string with additional user options for |WikiPages|. This can be used | ||
| e.g. to add a previewer. Users should be aware that the page candidates are | ||
| "prettified" with the `--with-nth=1` and `-d` options for fzf, so to obtain | ||
| the page path in a previewer option one must use the field index expression `1`. | ||
|
|
@@ -542,7 +542,7 @@ OPTIONS *wiki-config-options* | |
| Default: `''` | ||
|
|
||
| *g:wiki_fzf_tags_opts* | ||
| A string with additional user options for |WikiFzfTags|. This can be used | ||
| A string with additional user options for |WikiTags|. This can be used | ||
| e.g. to add a previewer. Users should be aware that the page candidates are | ||
| "prettified" with the `-d` option for fzf, so to obtain the page path in a | ||
| previewer option one must use the field index expression `2..`. | ||
|
|
@@ -1318,12 +1318,12 @@ the commands are also available as mappings of the form `<plug>(wiki-[name])`. | |
| *WikiPageRename* | ||
| Rename wiki page (will update all links to the page). | ||
|
|
||
| *<plug>(wiki-page-toc)* | ||
| *WikiPageToc* | ||
| *<plug>(wiki-toc-generate)* | ||
| *WikiTocGenerate* | ||
| Create/Update table of contents. | ||
|
|
||
| *<plug>(wiki-page-toc-local)* | ||
| *WikiPageTocLocal* | ||
| *<plug>(wiki-toc-generate-local)* | ||
| *WikiTocGenerateLocal* | ||
| Create/Update table of contents (section local variant). | ||
|
|
||
| *<plug>(wiki-journal-index)* | ||
|
|
@@ -1419,7 +1419,7 @@ the commands are also available as mappings of the form `<plug>(wiki-[name])`. | |
| *WikiTagSearch* [options] [tag] | ||
| List wiki pages that contain the desired `tag`. If the argument `tag` is not | ||
| supplied, the command asks for input. See also |wiki-tags| for more | ||
| information on the tags feature and |WikiFzfTags| for an alternative search | ||
| information on the tags feature and |WikiTags| for an alternative search | ||
| mechanism. | ||
|
|
||
| Available options are (use |g:wiki_tag_search| to set default values): | ||
|
|
@@ -1438,8 +1438,8 @@ the commands are also available as mappings of the form `<plug>(wiki-[name])`. | |
| supplied, the command asks for input. This command uses the `make` function | ||
| of |g:wiki_tag_parsers|. | ||
|
|
||
| *<plug>(wiki-fzf-pages)* | ||
| *WikiFzfPages* | ||
| *<plug>(wiki-pages)* | ||
| *WikiPages* | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here we need some updated docs. |
||
| Open |fzf| in find file mode for wiki files in current wiki or in the main | ||
| wiki defined by |g:wiki_root|. | ||
|
|
||
|
|
@@ -1465,16 +1465,16 @@ the commands are also available as mappings of the form `<plug>(wiki-[name])`. | |
| Page", and this term does not exist, then it will instead open a new page | ||
| "My Fzf Page.wiki" (or similar, depending on the value of other options). | ||
|
|
||
| *<plug>(wiki-fzf-tags)* | ||
| *WikiFzfTags* | ||
| *<plug>(wiki-tags)* | ||
| *WikiTags* | ||
| Open |fzf| and search for tags. | ||
|
|
||
| One may pass additional options to fzf with the |g:wiki_fzf_tags_opts| | ||
| option. This allows more fine grained control of fzf, e.g. to add | ||
| a previewer. | ||
|
|
||
| *<plug>(wiki-fzf-toc)* | ||
| *WikiFzfToc* | ||
| *<plug>(wiki-toc)* | ||
| *WikiToc* | ||
| Open |fzf| and list table of contents entries for the current wiki page. | ||
|
|
||
| ============================================================================== | ||
|
|
@@ -1847,7 +1847,7 @@ Related commands: | |
| - |WikiTagReload| | ||
| - |WikiTagSearch| | ||
| - |WikiTagRename| | ||
| - |WikiFzfTags| | ||
| - |WikiTags| | ||
|
|
||
| Related settings: | ||
| - |g:wiki_tag_list| | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| local M = {} | ||
lervag marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| -- Returns shorten path | ||
| local function filter(path) | ||
| local root = vim.g.wiki_root .. "/" | ||
| return path:gsub(root, "") | ||
| end | ||
|
|
||
| -- Returns full path | ||
| local function unfilter(path) | ||
| local root = vim.g.wiki_root .. "/" | ||
| return root .. path | ||
| end | ||
|
|
||
| function M.get_pages() | ||
| local res = {} | ||
| local pages = vim.fn["wiki#page#get_all"]() | ||
lervag marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| for _, p in pairs(pages) do | ||
| local page = filter(p[1]) | ||
| table.insert(res, page) | ||
| end | ||
| vim.ui.select(res, | ||
saccarosium marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| { prompt = "WikiPages> " }, | ||
| function(f) | ||
| f = unfilter(f) | ||
| vim.cmd("edit " .. f) | ||
| end) | ||
| end | ||
|
|
||
| function M.get_tags() | ||
| local res = {} | ||
| local tags = vim.fn["wiki#tags#get_all"]() | ||
| for key, val in pairs(tags) do | ||
| for _, file in pairs(val) do | ||
| local str = string.format("%s:%s:%s", key, file[2], filter(file[1])) | ||
| table.insert(res, str) | ||
| end | ||
| end | ||
| vim.ui.select(res, | ||
| { prompt = "WikiTags> " }, | ||
| function(t) | ||
| t = unfilter(vim.split(t, ':')[3]) | ||
| vim.cmd("edit " .. t) | ||
| end) | ||
| return res | ||
| end | ||
|
|
||
| function M.toc() | ||
| local res = {} | ||
| local toc = vim.fn["wiki#toc#gather_entries"]() | ||
| for _, hd in pairs(toc) do | ||
| local indent = vim.fn["repeat"]('.', hd.level - 1) | ||
| local line = hd.lnum .. '|' .. indent .. hd.header | ||
| table.insert(res, line) | ||
| end | ||
| vim.ui.select(res, | ||
| { prompt = "WikiToc> ", }, | ||
| function(t) | ||
| t = vim.split(t, '|')[1] | ||
| vim.cmd("execute " .. t) | ||
| end) | ||
| end | ||
|
|
||
| return M | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.