Skip to content

Commit 2661052

Browse files
committed
implement custom hl groups
1 parent 4c47437 commit 2661052

File tree

3 files changed

+26
-6
lines changed

3 files changed

+26
-6
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@ let g:nnn#layout = 'new' " or vnew, tabnew etc.
7979
" Or pass a dictionary with window size
8080
let g:nnn#layout = { 'left': '~20%' } " or right, up, down
8181
82-
" Floating window.
83-
let g:nnn#layout = { 'window': { 'width': 0.9, 'height': 0.6, 'highlight': 'Debug' } }
82+
" Floating window. This is the default
83+
let g:nnn#layout = { 'window': { 'width': 0.9, 'height': 0.6, 'highlight': 'Comment' } }
8484
```
8585

8686
### Action

autoload/nnn.vim

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,18 @@ else
1212
let s:local_ses .= substitute(tempname(), '/', '_', 'g')
1313
endif
1414

15+
" nnn highlight groups
16+
if !hlexists('NnnBorder')
17+
if hlexists('FloatBorder')
18+
highlight! link NnnBorder FloatBorder
19+
else
20+
highlight! link NnnBorder Comment
21+
endif
22+
endif
23+
if !hlexists('NnnNormal')
24+
highlight! link NnnNormal Normal
25+
endif
26+
1527
function! s:statusline()
1628
setlocal statusline=%#StatusLineTerm#\ nnn\ %#StatusLineTermNC#
1729
endfunction
@@ -115,8 +127,7 @@ function! s:popup(opts, term_opts)
115127
let col += !has('nvim')
116128

117129
let l:border = get(a:opts, 'border', 'rounded')
118-
let l:default_hl = hlexists('FloatBorder') ? 'FloatBorder' : 'Comment'
119-
let l:highlight = get(a:opts, 'highlight', l:default_hl)
130+
let l:highlight = get(a:opts, 'highlight', 'NnnBorder')
120131

121132
if has('nvim')
122133
let l:borderchars = l:border ==# 'none' ? 'none' : map(l:border ==# 'rounded'
@@ -133,8 +144,7 @@ function! s:popup(opts, term_opts)
133144
\ 'relative': 'editor',
134145
\ 'style': 'minimal'
135146
\ })
136-
call setwinvar(l:win, '&winhighlight', 'NormalFloat:Normal')
137-
call setwinvar(l:win, '&colorcolumn', '')
147+
call setwinvar(l:win, '&winhighlight', 'NormalFloat:NnnNormal')
138148
return { 'buf': s:create_term_buf(a:term_opts), 'winhandle': l:win }
139149
else
140150
let l:buf = s:create_term_buf(extend(a:term_opts, #{ curwin: 0, hidden: 1 }))
@@ -146,6 +156,7 @@ function! s:popup(opts, term_opts)
146156
\ col: col,
147157
\ minwidth: width,
148158
\ minheight: height,
159+
\ highlight: 'NnnNormal',
149160
\ border: l:border ==# 'none' ? [0, 0, 0, 0] : [],
150161
\ borderhighlight: [l:highlight],
151162
\ borderchars: l:borderchars,

doc/nnn.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ CONTENTS *nnn-help*
1818
Mappings .............................. |nnn-mappings|
1919
Configurations ........................ |nnn-config|
2020
Functions ............................. |nnn-func|
21+
Highlights ............................ |nnn-hl|
2122
Miscellaneous ......................... |nnn-misc|
2223
Credits ............................... |nnn-credits|
2324

@@ -237,6 +238,14 @@ nnn#pick([{dir}][,{opts}]) *nnn#pick()*
237238
call nnn#pick('~/some-directory', { 'edit': 'vertical split' })
238239
<
239240

241+
-----------------------------------------------------------------------------
242+
Highlights *nnn-hl*
243+
244+
The following are the highlight groups that are used:
245+
246+
NnnNormal: window hl group. Linked to |hl-Normal|.
247+
NnnBorder: floating window border. Linked to |hl-FloatBorder| or |hl-Comment|.
248+
240249
=============================================================================
241250
Miscellaneous *nnn-misc*
242251

0 commit comments

Comments
 (0)