michal-h21 / vim-zettel

VimWiki addon for managing notes according to Zettelkasten method
MIT License
557 stars 73 forks source link

Remaps stopped working on new version #98

Closed rober-m closed 3 years ago

rober-m commented 3 years ago

Hi! My remaps stopped working when updated to the new version. These are my old remaps:

"Open a note by title
nnoremap <leader>ot :ZettelOpen<CR>title:

"Open a note by full text
nnoremap <leader>of :ZettelOpen<CR>

"Search and insert a note by the title
inoremap [[ [[<ESC>:ZettelSearch<CR>title:

"Search and insert a note by full text
inoremap [f [[<ESC>:ZettelSearch<CR>

I read the documentation and changed the remaps to:


let g:zettel_default_mappings = 0

augroup filetype_vimwiki
   autocmd!

   "Search and insert a note by the title
   autocmd FileType vimwiki imap [[ [[<esc><Plug>ZettelSearchMap title:

   "Search and insert a note by full text
   autocmd FileType vimwiki imap [f [[<esc><Plug>ZettelSearchMap

   "Open a note by title
   autocmd FileType vimwiki nmap <silent> <leader>ot <Plug>ZettelOpen title:

   "Open a note by full text
   autocmd FileType vimwiki nmap <silent> <leader>of <Plug>ZettelOpen

   "Default config
   autocmd FileType vimwiki nmap T <Plug>ZettelYankNameMap
   autocmd FileType vimwiki xmap z <Plug>ZettelNewSelectedMap
   autocmd FileType vimwiki nmap gZ <Plug>ZettelReplaceFileWithLink

augroup END

They still don't work. Also, now the [[ command inserts :[[ . 🤔

rober-m commented 3 years ago

To clarify, the Zettel_____ functions keep working on my original remaps. But I get the same result for both <leader>ot and <leader>of, and the same applies for [[ and [f. It seems that the title:is ignored now.

When mapping following the documentation, the mappings are completely ignored. Like I didn't do anything.

Notes:

nathanbraun commented 3 years ago

It might be your g:zettel_fzf_options, which control the arguments passed to fzf behind the scenes.

In particular, fzf has a setting where if you type multiple words, it'll search for each of them individually. If that was on it'd explain your results. I'd run:

:echo g:zettel_fzf_options

Copy what it is, then add then add +x to it to turn this setting off. I also turned off exact mode and added --algo=v2 for fuzzy searching, and like that better than the default.

rober-m commented 3 years ago

@nathanbraun I've read the fzf documentation regarding your comment and tried the arguments. Although it's valuable information (thanks), it isn't related to my issue.

The issue is that the title: keyword isn't automatically written on the fzf search bar. And the behavior of

nnoremap <leader>ot :ZettelOpen<CR>title:

is the same as

nnoremap <leader>ot :ZettelOpen<CR>

once I type title: it works as intended.

nathanbraun commented 3 years ago

@IIPatternII interesting, I actually recently updated vim-zettel and now am running into the same issue

nathanbraun commented 3 years ago

@IIPatternII I looked at the source code a bit. The following in my neovim config fixes it for me:

let g:zettel_default_mappings = 0 

augroup filetype_vimwiki
  autocmd!

  " insert file bindings
  inoremap [[ [[<esc>:ZettelSearch<CR>:title
  inoremap [f [[<ESC>:ZettelSearch<CR>

  " open file bindings
  nnoremap <leader>ot :ZettelOpen<CR>title: 
  nnoremap <leader>of :ZettelOpen<CR>

  " other, normal bindings
  nmap T <Plug>ZettelYankNameMap
  xmap zx <Plug>ZettelNewSelectedMap<CR>
  nmap gZ <Plug>ZettelReplaceFileWithLink

augroup END
rober-m commented 3 years ago

@nathanbraun Sorry for the late answer. I solved the issue a little differently:

function! ZettelTitleSearch()
   let g:zettel_fzf_command = "rg --column --line-number --smart-case --multiline --no-heading --color=always --regexp '^title: (.+)' --replace '$1'"
   ZettelOpen()
 endfunction

 nnoremap <leader>ot :call ZettelTitleSearch()<CR>

 function! ZettelFullSearch()
   let g:zettel_fzf_command = "rg --column --line-number --smart-case --multiline --no-heading --color=always"
   ZettelOpen()
 endfunction

nnoremap <leader>of :call ZettelFullSearch()<CR>

I'm no longer using vim-zettel. I switched to Obsidian with the Vim plugin (lacking functionality but good enough), but I'm leaving this in case someone finds it useful.