kis9a / vimsidian

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

rg automatically escape flag #2

Closed kis9a closed 2 years ago

kis9a commented 2 years ago

I am escaping the characters manually, like '\[\[" . fname . "\]]'. but, But if fame also contains characters that must be escaped, it's very difficult.

function! s:ObsidianRgNotesWithMatches(word) abort
  let cmd = 'cd ' . g:obsidian_path . "; rg -n %s --files-with-matches" . "| awk '" . '{ print $0 ":1: " }' . "'"
...

function! s:ObsidianRgNotesLinkingThisNote() abort
  let fname = fnamemodify(expand("%:t"), ":r")
  let ext = expand("%:e")
  if ext == "md"
    let a=s:ObsidianRgNotesWithMatches("'\\[\\[" . fname . "\\]]'")
  else
    let a=s:ObsidianRgNotesWithMatches("'\\[\\[" . expand("%t") . "\\]]'")
  endif
endfunction
kis9a commented 2 years ago

Found a issue talking about this. In my case the -F flag seems to work. Option flag to automatically escape regex #299