Skip to content

Commit

Permalink
implement custom hl groups
Browse files Browse the repository at this point in the history
  • Loading branch information
mcchrish committed Oct 12, 2021
1 parent 4c47437 commit 2661052
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 6 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ let g:nnn#layout = 'new' " or vnew, tabnew etc.
" Or pass a dictionary with window size
let g:nnn#layout = { 'left': '~20%' } " or right, up, down
" Floating window.
let g:nnn#layout = { 'window': { 'width': 0.9, 'height': 0.6, 'highlight': 'Debug' } }
" Floating window. This is the default
let g:nnn#layout = { 'window': { 'width': 0.9, 'height': 0.6, 'highlight': 'Comment' } }
```

### Action
Expand Down
19 changes: 15 additions & 4 deletions autoload/nnn.vim
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,18 @@ else
let s:local_ses .= substitute(tempname(), '/', '_', 'g')
endif

" nnn highlight groups
if !hlexists('NnnBorder')
if hlexists('FloatBorder')
highlight! link NnnBorder FloatBorder
else
highlight! link NnnBorder Comment
endif
endif
if !hlexists('NnnNormal')
highlight! link NnnNormal Normal
endif

function! s:statusline()
setlocal statusline=%#StatusLineTerm#\ nnn\ %#StatusLineTermNC#
endfunction
Expand Down Expand Up @@ -115,8 +127,7 @@ function! s:popup(opts, term_opts)
let col += !has('nvim')

let l:border = get(a:opts, 'border', 'rounded')
let l:default_hl = hlexists('FloatBorder') ? 'FloatBorder' : 'Comment'
let l:highlight = get(a:opts, 'highlight', l:default_hl)
let l:highlight = get(a:opts, 'highlight', 'NnnBorder')

if has('nvim')
let l:borderchars = l:border ==# 'none' ? 'none' : map(l:border ==# 'rounded'
Expand All @@ -133,8 +144,7 @@ function! s:popup(opts, term_opts)
\ 'relative': 'editor',
\ 'style': 'minimal'
\ })
call setwinvar(l:win, '&winhighlight', 'NormalFloat:Normal')
call setwinvar(l:win, '&colorcolumn', '')
call setwinvar(l:win, '&winhighlight', 'NormalFloat:NnnNormal')
return { 'buf': s:create_term_buf(a:term_opts), 'winhandle': l:win }
else
let l:buf = s:create_term_buf(extend(a:term_opts, #{ curwin: 0, hidden: 1 }))
Expand All @@ -146,6 +156,7 @@ function! s:popup(opts, term_opts)
\ col: col,
\ minwidth: width,
\ minheight: height,
\ highlight: 'NnnNormal',
\ border: l:border ==# 'none' ? [0, 0, 0, 0] : [],
\ borderhighlight: [l:highlight],
\ borderchars: l:borderchars,
Expand Down
9 changes: 9 additions & 0 deletions doc/nnn.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ CONTENTS *nnn-help*
Mappings .............................. |nnn-mappings|
Configurations ........................ |nnn-config|
Functions ............................. |nnn-func|
Highlights ............................ |nnn-hl|
Miscellaneous ......................... |nnn-misc|
Credits ............................... |nnn-credits|

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

-----------------------------------------------------------------------------
Highlights *nnn-hl*

The following are the highlight groups that are used:

NnnNormal: window hl group. Linked to |hl-Normal|.
NnnBorder: floating window border. Linked to |hl-FloatBorder| or |hl-Comment|.

=============================================================================
Miscellaneous *nnn-misc*

Expand Down

0 comments on commit 2661052

Please sign in to comment.