nnn.vim icon indicating copy to clipboard operation
nnn.vim copied to clipboard

Colors in nnn.vim don't seem to work always

Open sedimentation-fault opened this issue 9 months ago • 1 comments

How to set colors in nnn.vim

I've had to spend days(!) to find out how to set some colors in nnn.vim. One problem is that documentation about them is so hard to find, so let me put some information here for anyone with the same problem:

Highlights nnn-hl

The following are the highlight groups that are used:

NnnNormal Window. Linked to |hl-Normal|.

NnnNormalNC Non-current window. Linked to |hl-Normal|.

NnnNormalFloat Floating window. Linked to |hl-Normal|.

NnnBorder Floating window border. Linked to |hl-FloatBorder| or |hl-Comment|.

NnnVertSplit (depecated. for < nvim-0.7) Explorer window VertSplit. Linked to |hl-VertSplit|. NnnWinSeparator Explorer window WinSeparator. Linked to |hl-WinSeparator|. (requires nvim-0.7 and above). The above is from https://github.com/mcchrish/nnn.vim/blob/e0104e369508fc12e3651ad4dee20261b5b3e87f/doc/nnn.txt#L276

, so let's try it:

In my /etc/vim/vimrc.local I have:

let g:nnn#layout = { 'window': { 'width': 0.9, 'height': 0.6, 'highlight': 'StatusLineNC' } }
let NNN_COLORS='#b4c77b9b;5384'
let g:nnn#command='nnn -C'
highlight NnnNormalNC guibg=#C8AE95 ctermbg=darkgrey ctermfg=white
highlight NnnNormalFloat guibg=#4992A7 guifg=white ctermbg=cyan ctermfg=white

The above works only partially for me:

  • The floating windows does get its border colored according to the colors of the StatusLineNC group, so that's OK.
  • NNN_COLORS does not have any effect, even though g:nnn#command is nnn -C, which means that at least directories should be colored according to the context colors set in NNN_COLORS. Directories are always blue for me (color 4, the default for all contexts) in the floating window.
  • Changing g:nnn#command to nnn -D has only the effect of painting directories (in the floating window) in white too, according to the guifg color of NnnNormalFloat. Directories should appear in "context color" and it seems that guifg overwrites the context color set in NNN_COLORS - not sure if that's OK or not...
  • Switching to the floating window with, say, <leader>-n, should change the "non-current" window (the background window that has just lost its focus to the floating one) to the color set in NnnNormalNC. This works if I have one or two files open, but not if I have opened a whole session that contains dozens of files. I have taken care to save my sessions without options, i.e. I have taken away options from my sessionoptions variable: set sessionoptions=blank,buffers,curdir,folds,help,tabpages,winsize,terminal.

How to reproduce

Use the above settings and try to set colors.

Expected behavior

Consistent, trouble-free user experience regarding colors.

Environment:

  • OS: Gentoo Linux
  • Terminal: x11-misc/tabbed-0.6-r1 with x11-terms/xterm-367
  • Shell: app-shells/bash-5.1_p16
  • Vim version: app-editors/vim-8.2.3741
  • Gvim version: app-editors/gvim-8.2.3741
  • Plugin manager: None
  • Plugin version: git clone of Aug. 21st, 2023
  • Nnn version: app-misc/nnn-4.8

sedimentation-fault avatar Sep 22 '23 04:09 sedimentation-fault