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

#20 - refactor: remove VimsidianFormatLink command #23

Closed kis9a closed 3 months ago

kis9a commented 3 months ago

Issue

The current VimsidianFormatLink function is unique and specialised, so users cannot understand it, and it is difficult to customise.

This command will be removed from this plugin and rebuilt as a link format plugin if necessary.

function! vimsidian#unit#FormatLinkString(s) abort
  let s = substitute(a:s, '\v(\s|\n|^|\!|\(|[\u3001]|[\u3002])@<![[', ' [[', 'g')
  let s = substitute(s, '\v]](\s|\n|$|\.|\,|\)|[\u3001]|[\u3002])@!', ']] ', 'g')
  let s = substitute(s, '\v(\s|\n|^|\!|\(|[\u3001]|[\u3002])@<!\s+[[', ' [[', 'g')
  let s = substitute(s, '\v(\!|\(|[\u3001]|[\u3002])@<=\s+[[', '[[', 'g')
  let s = substitute(s, '\v]]\s+(\s|\n|$|\.|\,|\)|[\u3001]|[\u3002])@!', ']] ', 'g')
  let s = substitute(s, '\v]]\s+(\n|$|\.|\,|\)|[\u3001]|[\u3002])@=', ']]', 'g')
  return s
endfunction