BREAKING: Unify lua and plug API mappings
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
Made the names of the functions to invoke the plugin the same. This is a BREAKING change if using the lua mappings. On the other hand, it should stay pretty stable for the foreseeable future, with only new ones added and possibly vim commands added.
This commit is contained in:
parent
49f0b10fde
commit
0e77624689
3 changed files with 23 additions and 21 deletions
14
README.md
14
README.md
|
@ -32,13 +32,15 @@ but there's not much here yet.
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
The one mapping you probably want to undertake (replacing the mapping as needed) is:
|
All exposed functionality of the plugin can be reached either through lua bindings or through vim `<Plug>` mappings.
|
||||||
|
|
||||||
|
The one mapping you probably want to undertake (replacing the mapping as needed) is the following link mapping:
|
||||||
|
|
||||||
### Linking
|
### Linking
|
||||||
|
|
||||||
```vim
|
```vim
|
||||||
nnoremap <cr> :lua require 'zettelkasten'.open_or_make_link()<cr>
|
nnoremap <cr> :lua require 'zettelkasten'.link_follow()<cr>
|
||||||
vnoremap <cr> :lua require 'zettelkasten'.open_or_make_link(true)<cr>
|
vnoremap <cr> :lua require 'zettelkasten'.link_follow(true)<cr>
|
||||||
```
|
```
|
||||||
|
|
||||||
This will allow you to create new links when over any text,
|
This will allow you to create new links when over any text,
|
||||||
|
@ -52,8 +54,8 @@ The function is also exposed as vim mapping `<Plug>zettel_link_follow`, so can b
|
||||||
set via `map <cr> <Plug>zettel_link_follow` to get the same result as above.
|
set via `map <cr> <Plug>zettel_link_follow` to get the same result as above.
|
||||||
|
|
||||||
```vim
|
```vim
|
||||||
:lua require 'zettelkasten'.open_link()
|
:lua require 'zettelkasten'.link_open()
|
||||||
:lua require 'zettelkasten'.make_link(visualmode)
|
:lua require 'zettelkasten'.link_make(visualmode)
|
||||||
```
|
```
|
||||||
|
|
||||||
allows you to separate the link following and creation set by one function above.
|
allows you to separate the link following and creation set by one function above.
|
||||||
|
@ -66,7 +68,7 @@ The functions are again exposed as `<Plug>zettel_link_open` and
|
||||||
### Index
|
### Index
|
||||||
|
|
||||||
```vim
|
```vim
|
||||||
nnoremap <leader>w :lua require 'zettelkasten'.open_index()<cr>
|
nnoremap <leader>w :lua require 'zettelkasten'.index_open()<cr>
|
||||||
```
|
```
|
||||||
|
|
||||||
allows you to map going to your defined zettel index file.
|
allows you to map going to your defined zettel index file.
|
||||||
|
|
|
@ -17,26 +17,26 @@ end
|
||||||
function ZK.get_anchor() return anchor.create() end
|
function ZK.get_anchor() return anchor.create() end
|
||||||
|
|
||||||
-- Open link under cursor, or next on line
|
-- Open link under cursor, or next on line
|
||||||
function ZK.open_link() return action.open_selected() end
|
function ZK.link_open() return action.open_selected() end
|
||||||
|
|
||||||
-- Create a new link under cursor
|
-- Create a new link under cursor
|
||||||
function ZK.make_link(visual) return action.make_link(visual) end
|
function ZK.link_make(visual) return action.make_link(visual) end
|
||||||
|
|
||||||
-- If invoked in reach of a valid link will try to follow said link.
|
-- If invoked in reach of a valid link will try to follow said link.
|
||||||
-- Otherwise will take the current context and make a link out of it.
|
-- Otherwise will take the current context and make a link out of it.
|
||||||
function ZK.open_or_make_link(visual)
|
function ZK.link_follow(visual)
|
||||||
if not ZK.open_link() then ZK.make_link(visual) end
|
if not ZK.link_open() then ZK.link_make(visual) end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Open index file at zettel root directory. If title is passed in opens
|
-- Open index file at zettel root directory. If title is passed in opens
|
||||||
-- `title`.<extension> file, otherwise defaults to `index`.<extension>.
|
-- `title`.<extension> file, otherwise defaults to `index`.<extension>.
|
||||||
function ZK.open_index(title) return action.open_index_file(title) end
|
function ZK.index_open(title) return action.open_index_file(title) end
|
||||||
|
|
||||||
return {
|
return {
|
||||||
get_zettel_list = ZK.get_zettel_list,
|
get_zettel_list = ZK.get_zettel_list,
|
||||||
get_anchor = ZK.get_anchor,
|
get_anchor = ZK.get_anchor,
|
||||||
open_link = ZK.open_link,
|
link_open = ZK.link_open,
|
||||||
make_link = ZK.make_link,
|
link_make = ZK.link_make,
|
||||||
open_or_make_link = ZK.open_or_make_link,
|
link_follow = ZK.link_follow,
|
||||||
open_index = ZK.open_index
|
index_open = ZK.index_open
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,14 +2,14 @@ if exists('g:loaded_zettelkasten')
|
||||||
finish
|
finish
|
||||||
endif
|
endif
|
||||||
|
|
||||||
noremap <Plug>zettel_link_open :lua require 'zettelkasten'.open_link()<cr>
|
noremap <Plug>zettel_link_open :lua require 'zettelkasten'.link_open()<cr>
|
||||||
|
|
||||||
nnoremap <Plug>zettel_link_make :lua require 'zettelkasten'.make_link()<cr>
|
nnoremap <Plug>zettel_link_make :lua require 'zettelkasten'.link_make()<cr>
|
||||||
vnoremap <Plug>zettel_link_make :lua require 'zettelkasten'.make_link(true)<cr>
|
vnoremap <Plug>zettel_link_make :lua require 'zettelkasten'.link_make(true)<cr>
|
||||||
|
|
||||||
nnoremap <Plug>zettel_link_follow :lua require 'zettelkasten'.open_or_make_link()<cr>
|
nnoremap <Plug>zettel_link_follow :lua require 'zettelkasten'.link_follow()<cr>
|
||||||
vnoremap <Plug>zettel_link_follow :lua require 'zettelkasten'.open_or_make_link(true)<cr>
|
vnoremap <Plug>zettel_link_follow :lua require 'zettelkasten'.link_follow(true)<cr>
|
||||||
|
|
||||||
nnoremap <Plug>zettel_index_open :lua require 'zettelkasten'.open_index()<cr>
|
nnoremap <Plug>zettel_index_open :lua require 'zettelkasten'.index_open()<cr>
|
||||||
|
|
||||||
let g:loaded_zettelkasten = 1
|
let g:loaded_zettelkasten = 1
|
||||||
|
|
Loading…
Reference in a new issue