0

For a wiki syntax plugin, i'd like to have two highlighting colors for links. Links already having a destination file should be green and links with no destination yet should be red.

[[This file exist]] (green)
  filereadable("/wiki/dir/this_file_exist.md") -> true

[[File does not exist]] (red) 
  (filereadable("/wiki/dir/file_does_not_exist.md")-> false

Is it possible in vim to run file validation code based on a region match?

  • 1
    Maybe you can write an autocmd to use global to search your link, if it's readable, call matchaddpos to highlight it, but that command works window, i don't know how to restrict it to buffer only. – dedowsdi Apr 2 at 0:37
  • @dedowsdi you helped me get started, I ended up using matchadd inside a function called by autocmd. – mipmip Apr 2 at 23:25
  • Glad you made it. – dedowsdi Apr 2 at 23:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.