kis9a / vimsidian

Vim plugin for PKM like obsidian.md
Do What The F*ck You Want To Public License
55 stars 0 forks source link

Enhances interactive search and open commands #16

Open kis9a opened 3 months ago

kis9a commented 3 months ago

The current Interactive commands (VimsidianRgLinesWithMatchesInteractive/VimsidianRgNotesWithMatchesInteractive) search for the search term when you enter it in the prompt and press Enter. The search results are updated and displayed each time the user enters a string of note names.

$ rg example

function! CustomFzf()
  call fzf#run(fzf#wrap({
        \ 'source': 'ls',
        \ 'sink': 'echo', 
        \ 'options': '--preview ''echo {}'' --bind ''change:execute-silent[call s:handle_input({q})]''' 
        \ }))
endfunction

command! CustomFzfCall :call CustomFzf()

function! RgFzf(query)
  let l:command = 'rg --column --line-number --no-heading --color=always --smart-case ' . shellescape(a:query)
  let l:options = '--ansi --preview ''bat --style=numbers --color=always --line-range=:{}'' --bind ''change:reload:rg --column --line-number --no-heading --color=always --smart-case {q} || true'''
  call fzf#vim#grep(l:command, 1, fzf#vim#with_preview({'options': l:options}), 0)
endfunction

command! -nargs=1 RgFzf call RgFzf(<q-args>)
kis9a commented 3 months ago

related sub task: The functions provided by external commands such as rg are abstracted and the files are separated.