Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VimWiki and Goyo #1380

Open
mbbmbbmm opened this issue Nov 18, 2023 · 1 comment
Open

VimWiki and Goyo #1380

mbbmbbmm opened this issue Nov 18, 2023 · 1 comment

Comments

@mbbmbbmm
Copy link

Hi, I am trying to set up VimWiki in harmony with Goyo. I'm toggling Goyo with a leader key mapping.
The problem is (I think) that Goyo reloads the colorscheme from scratch and I lose the rendering for italic, bold etc. and also the header colors I set with e.g. hi VimwikiHeader1 guifg=#DD7722... Apparently the solution is hinted at in issue #84 of the Goyo repo. But I don't understand it at all (complete vim script idiot).
So how would I force Vim to reload VimWiki's visuals after exiting Goyo?

VimWiki settings from your .vimrc

let wiki_1 = {}
let wiki_1.path = '~/vimwiki/'
let wiki_2 = {}
let wiki_2.path = '~/Documents/sqwiki/'
let wiki_2.syntax = 'markdown'
let wiki_2.ext = '.md'
let g:vimwiki_list = [wiki_1, wiki_2]

hi VimwikiHeader1 guifg=#DD7722
hi VimwikiHeader2 guifg=#33BB88
hi VimwikiHeader3 guifg=#7777CC
hi VimwikiHeader4 guifg=#33BBEE
hi VimwikiHeader5 guifg=#AACCCC
hi VimwikiHeader6 guifg=#777744

Include the syntax you are using (default / Markdown / MediaWiki)
default and Markdown

Provide a detailed description of the problem including steps to reproduce the issue
See above, basically :

  • Open VimWiki
  • Toggle Goyo on - colors/style correct,
  • Toggle Goyo off - colors/style incorrect

Include the output of :VimwikiShowVersion
I am still using VimWiki 2.3 (on GVim 9.0, on Windows 10) - any VimWiki version above gave me errors and wouldn't run.

@Goli4thus
Copy link

Not sure if this helps, but always had the issue of some colors I defined via after/syntax/vimwiki.vim not loading properly when leaving Goyo.

I used this workaround so far:

function! s:goyo_leave()
  syn off | syn on
endfunction

autocmd! User GoyoLeave nested call <SID>goyo_leave()

Based on Goyo's help file: :h goyo-callbacks.

It certainly feels like a hack, cause I'm toggling the entire syntax highlighting with this.
But the end result is that my custom styles are applied as well.

EDIT: better approach

I just played around with the above mentioned linked suggestion using autocmd.
I actually got it working like this:

file 'after/syntax/vimwiki.vim'

Define just your syntax definitions here.
For example:

syntax match my_custom_phrase_Todo     "TODO"

file 'after/ftplugin/vimwiki.vim'

Define a function that sets up the resp. highlight definition.
For example:

func! s:my_custom_vimwiki_styling_addon()
    highlight my_custom_phrase_Todo guifg=#ffab49 guibg=NONE gui=bold ctermfg=green ctermbg=NONE cterm=NONE
endfunc


augroup my_custom_augroup
    " Delete any existing autocmd in this augroup.
    autocmd!

    " INFO: 'BufWinEnter' fires whenever a buffer is viewed in a window.
    "       Only happens upon initial 'load', not upon switching 
    autocmd BufWinEnter *.wiki call s:my_custom_vimwiki_styling_addon()

    " INFO: 'ColorScheme' fires upon a change in colorscheme.
    "       Also happens when leaving 'Goyo'.
    autocmd ColorScheme * call s:my_custom_vimwiki_styling_addon()
augroup END

With this I no longer need the initially described workaround via syn off | syn on.
IMO this feels a lot cleaner, cause really just about re-applying one's custom styles, not the entire syntax highlighting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants