1

I'm trying to customize the colorscheme One for Markdown under Vimwiki.

I'd like to change the color of the Description in [Description](URL).

In my .vimrc I have the following relevant lines:

call plug#begin('~/.vim/plugged')
  Plug 'vimwiki/vimwiki', { 'branch': 'dev' }
  Plug 'rakr/vim-one'
call plug#end()

autocmd BufWritePre *.md :%s/\s\+$//e
set termguicolors
set background=light

set nocompatible
syntax on
filetype plugin on

function! MyHighlights() abort
    call one#highlight('VimwikiLink', '3333ff', '', '')
endfunction

augroup MyColors
    autocmd!
    autocmd ColorScheme * call MyHighlights()
augroup END

colorscheme one

let g:vimwiki_global_ext = 0  "Dont treat every md file as wiki
let g:vimwiki_ext2syntax = {}

augroup vimwiki
  autocmd!
  autocmd BufReadPre,FileReadPre *.md set ft=vimwiki
  let g:vimwiki_list = [{'path' : '/home/USER/Wiki/',
                       \ 'syntax' : 'markdown',
                       \ 'auto_generate_links': 1,
                       \ 'auto_generate_tags' : 1,
                       \ 'ext' : '.md'}]
  autocmd FileType vimwiki setlocal foldcolumn=0
  let g:vimwiki_folding = 'custom'
augroup END

However, it changes all (Description & URL) to one single color:

enter image description here

How can I change, when concealed, the Description color (to bold or something that stands out)?

enter image description here

Other possibility is to gray out all but the Description.

enter image description here

9
  • The answer is going to depend (probably) on the syntax script for vimwiki markdown.
    – D. Ben Knoble
    Feb 25 at 14:53
  • 1
    I try to reproduce the behavior but I fail :-| Maybe could you share your vimwiki configuration and tell us what is the filetype of the document you are editing (:set filetype?) Feb 25 at 15:21
  • Sorry, @VivianDeSmedt I forgot to share the code to call the function. I edited the question to add this. ;)
    – Ludenticus
    Feb 25 at 16:31
  • 1
    Thanks for the additions. But I'm still wondering what is the filetype of your document (what is the result of the :set filetype? command) and it would be good if you could share with us the vimwiki section of your vimrc file (I would like first to be able to reproduce the behavior you have :-) ). Feb 25 at 17:10
  • 1
    @VivianDeSmedt: Document type is vimwiki (not Markdown). I've added all relevant info of the vimrc file.
    – Ludenticus
    Feb 28 at 15:48

1 Answer 1

1

With these additions to the Vimwiki syntax:

~/.vim/after/syntax/vimwiki.vim

syn match VimwikiLinkDelimiter /\[\([^\\\]]*\]\)\@=/ conceal
syn match VimwikiLinkDelimiter /\(\[[^\\\]]*\)\@<=\]/ conceal
syn match VimwikiLinkDescription /\(\[\)\@<=[^\\\]]*\(\]\)\@=/

With these addition to the syntax you can configure the following two highlighting group to control the appearance:

  • VimwikiLinkDelimiter
  • VimwikiLinkeDescription

Remark: I have followed the Markdown syntax [description](link)

Or:

syn match VimwikiLinkDelimiter /\[\[[^|]*|\([^\\\]]*\]\]\)\@=/ conceal
syn match VimwikiLinkDelimiter /\(\[\[[^|]*|[^\\\]]*\)\@<=\]\]/ conceal
syn match VimwikiLinkDescription /\(\[\[[^|]*|\)\@<=[^\\\]]*\(\]\]\)\@=/

For the VimWiki syntax [[link|description]]

3
  • 1
    Vimwiki default syntax is [[Link]] or [[Link|Description]]. Markdown alternative is [Description](Link).
    – Ludenticus
    Mar 12 at 17:51
  • 1
    Well, the answer for the VimWiki default syntax [[Link]] or [[Link|Description]] works. Thanks for that! However, it doesn't work with Markdown notation in vimwiki_markdown_custom.vim: you wrote the regex for [[Description]](Link), but it should be [Description](Link) instead. No double brackets!
    – Ludenticus
    Mar 18 at 5:05
  • 1
    Thanks for the feedback. I have updated the solution accordingly :-) Mar 18 at 6:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.