Skip to content

Commit

Permalink
Only call exec once per group
Browse files Browse the repository at this point in the history
Calls to `exec` are quite expensive, so using
string concatenation and a single exec at the end
instead of a couple of exec yields a nice
startup performance boost.
  • Loading branch information
Julien Voisin committed Apr 12, 2022
1 parent e2555c1 commit b2e253b
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions colors/nord.vim
Original file line number Diff line number Diff line change
Expand Up @@ -136,23 +136,27 @@ if !exists("g:nord_bold_vertical_split_line")
endif

function! s:hi(group, guifg, guibg, ctermfg, ctermbg, attr, guisp)
let cmd = ""
if a:guifg != ""
exec "hi " . a:group . " guifg=" . a:guifg
let cmd = cmd . " guifg=" . a:guifg
endif
if a:guibg != ""
exec "hi " . a:group . " guibg=" . a:guibg
let cmd = cmd . " guibg=" . a:guibg
endif
if a:ctermfg != ""
exec "hi " . a:group . " ctermfg=" . a:ctermfg
let cmd = cmd . " ctermfg=" . a:ctermfg
endif
if a:ctermbg != ""
exec "hi " . a:group . " ctermbg=" . a:ctermbg
let cmd = cmd . " ctermbg=" . a:ctermbg
endif
if a:attr != ""
exec "hi " . a:group . " gui=" . a:attr . " cterm=" . substitute(a:attr, "undercurl", s:underline, "")
let cmd = cmd . " gui=" . a:attr . " cterm=" . substitute(a:attr, "undercurl", s:underline, "")
endif
if a:guisp != ""
exec "hi " . a:group . " guisp=" . a:guisp
let cmd = cmd . " guisp=" . a:guisp
endif
if cmd != ""
exec "hi " . a:group . cmd
endif
endfunction

Expand Down Expand Up @@ -225,12 +229,12 @@ if has('nvim')
call s:hi("DiagnosticUnderlineError" , s:nord11_gui, "", s:nord11_term, "", "undercurl", "")
call s:hi("DiagnosticUnderlineInfo" , s:nord8_gui, "", s:nord8_term, "", "undercurl", "")
call s:hi("DiagnosticUnderlineHint" , s:nord10_gui, "", s:nord10_term, "", "undercurl", "")

"+- Neovim DocumentHighlight -+
call s:hi("LspReferenceText", "", s:nord3_gui, "", s:nord3_term, "", "")
call s:hi("LspReferenceRead", "", s:nord3_gui, "", s:nord3_term, "", "")
call s:hi("LspReferenceWrite", "", s:nord3_gui, "", s:nord3_term, "", "")

"+- Neovim LspSignatureHelp -+
call s:hi("LspSignatureActiveParameter", s:nord8_gui, "", s:nord8_term, "", s:underline, "")
endif
Expand Down Expand Up @@ -669,7 +673,7 @@ if exists('g:loaded_clap')
call s:hi("ClapNoMatchesFound", s:nord13_gui, "", s:nord13_term, "", "", "")
call s:hi("ClapSelected", s:nord7_gui, "", s:nord7_term, "", s:bold, "")
call s:hi("ClapSelectedSign", s:nord9_gui, "", s:nord9_term, "", "", "")

let s:clap_matches = [
\ [s:nord8_gui, s:nord8_term] ,
\ [s:nord9_gui, s:nord9_term] ,
Expand All @@ -681,7 +685,7 @@ if exists('g:loaded_clap')
call s:hi("ClapFuzzyMatches" . s:nord_clap_match_i, clap_match_color[0], "", clap_match_color[1], "", "", "")
endfor
unlet s:nord_clap_match_i

hi! link ClapCurrentSelection PmenuSel
hi! link ClapCurrentSelectionSign ClapSelectedSign
hi! link ClapInput Pmenu
Expand Down Expand Up @@ -769,7 +773,7 @@ if exists('g:vim_pandoc_syntax_exists')
hi! link pandocTableHeaderWord pandocAtxHeader
hi! link pandocUListItemBullet Operator
endif

if has('nvim')
" tree-sitter
" > nvim-treesitter/nvim-treesitter
Expand Down Expand Up @@ -882,13 +886,13 @@ if exists('g:loaded_vimwiki')
call s:hi("VimwikiHeader".s:i, s:vimwiki_hcolor_guifg[s:i-1] , "", s:vimwiki_hcolor_ctermfg[s:i-1], "", s:bold, "")
endfor
endif

call s:hi("VimwikiLink", s:nord8_gui, "", s:nord8_term, "", s:underline, "")
hi! link VimwikiHeaderChar markdownHeadingDelimiter
hi! link VimwikiHR Keyword
hi! link VimwikiList markdownListMarker
endif

" YAML
" > stephpy/vim-yaml
call s:hi("yamlKey", s:nord7_gui, "", s:nord7_term, "", "", "")
Expand Down

0 comments on commit b2e253b

Please sign in to comment.