1

I have a theme which is great apart from some minor things. I could already change the LineNr highlight and some others, but can't seem to change the directory highlight in the terminal buffer, which is barely readable. I had to set the termguicolors option to make the theme use the right colors. I might have to mention that I am using Konsole from KDE. I have already tried

hi Directory guifg=#686f9a ctermfg=141
hi Terminal guifg=#686f9a ctermfg=141

and they do nothing. Another solution would be to set a theme just for the terminal buffer. Not sure how this could be accomplished. I have tried

autocmd BufEnter * if getbufvar(bufnr('%'), '&buftype') == "terminal" | colorscheme default | endif

but it also doesn't work. This works for the help buffer, but then it also sets the global theme. I would only want to set it for that buffer. I guess per-buffer theming is not possible at all, is it?

enter image description here

2
  • Is this about Vim or Neovim?
    – Matt
    Oct 8, 2021 at 7:58
  • It is a about Vim
    – neolith
    Oct 8, 2021 at 8:15

1 Answer 1

1

Terminal in vim uses colors defined in the called terminal. For GUI vim (or when termguicolors is set you can define your own 16 colors to be used by built-in terminal:

For vim it is :h g:terminal_ansi_colors (taken from vim-bronzage colorscheme)

  let g:terminal_ansi_colors = ['#303030', '#d7875f', '#87af87', '#d7d787', '#87afd7', '#d7af5f', '#87d7d7', '#808080', '#4e4e4e', '#d75f5f', '#87af5f', '#afaf5f', '#5f8787', '#af875f', '#87afaf', '#e4e4e4']

Neovim uses set of g:terminal_color_0..15:

    let g:terminal_color_0 = '#303030'
    let g:terminal_color_1 = '#d7875f'
    let g:terminal_color_2 = '#87af87'
    let g:terminal_color_3 = '#d7d787'
    let g:terminal_color_4 = '#87afd7'
    let g:terminal_color_5 = '#d7af5f'
    let g:terminal_color_6 = '#87d7d7'
    let g:terminal_color_7 = '#808080'
    let g:terminal_color_8 = '#4e4e4e'
    let g:terminal_color_9 = '#d75f5f'
    let g:terminal_color_10 = '#87af5f'
    let g:terminal_color_11 = '#afaf5f'
    let g:terminal_color_12 = '#5f8787'
    let g:terminal_color_13 = '#af875f'
    let g:terminal_color_14 = '#87afaf'
    let g:terminal_color_15 = '#e4e4e4'

Make sure you have closed and opened a :term after defining those variables.

PS, what color to use for directory (blue, red, whatever) highlighting depends on your ls setup. One can set up it using $LS_COLORS env variable.

enter image description here

2
  • FYI, Neovim also supports syntax-highlighting for terminal window.
    – Matt
    Oct 8, 2021 at 7:59
  • Thanks, the creator of the theme only set these for Neovim and I created an issue to notify him about it.
    – neolith
    Oct 8, 2021 at 8:26

Your Answer

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

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