mirror of
https://github.com/nordtheme/vim.git
synced 2026-09-10 07:36:23 -04:00
Only call execute function once per syntax group (#303)
Before the custom `s:hi` function called Vim's `execute` function [1] for each defined attribute which is quite expensive in terms of performance. To improve this the attributes are now concatenate as string and passed to `exec` at the end of the function instead. Co-authored-by: Julien Voisin <jvoisin@google.com> Co-authored-by: Sven Greb <development@svengreb.de> Co-authored-by: Arctic Ice Sudio <development@arcticicestudio.com> [1]: https://vimhelp.org/builtin.txt.html#builtin.txt#execute%28%29 GH-303
This commit is contained in:
parent
e3eb208437
commit
77fe4b3f0e
|
|
@ -99,23 +99,27 @@ let g:nord_cursor_line_number_background = get(g:, "nord_cursor_line_number_back
|
||||||
let g:nord_uniform_diff_background = get(g:, "nord_uniform_diff_background", 0)
|
let g:nord_uniform_diff_background = get(g:, "nord_uniform_diff_background", 0)
|
||||||
|
|
||||||
function! s:hi(group, guifg, guibg, ctermfg, ctermbg, attr, guisp)
|
function! s:hi(group, guifg, guibg, ctermfg, ctermbg, attr, guisp)
|
||||||
|
let cmd = ""
|
||||||
if a:guifg != ""
|
if a:guifg != ""
|
||||||
exec "hi " . a:group . " guifg=" . a:guifg
|
let cmd = cmd . " guifg=" . a:guifg
|
||||||
endif
|
endif
|
||||||
if a:guibg != ""
|
if a:guibg != ""
|
||||||
exec "hi " . a:group . " guibg=" . a:guibg
|
let cmd = cmd . " guibg=" . a:guibg
|
||||||
endif
|
endif
|
||||||
if a:ctermfg != ""
|
if a:ctermfg != ""
|
||||||
exec "hi " . a:group . " ctermfg=" . a:ctermfg
|
let cmd = cmd . " ctermfg=" . a:ctermfg
|
||||||
endif
|
endif
|
||||||
if a:ctermbg != ""
|
if a:ctermbg != ""
|
||||||
exec "hi " . a:group . " ctermbg=" . a:ctermbg
|
let cmd = cmd . " ctermbg=" . a:ctermbg
|
||||||
endif
|
endif
|
||||||
if a:attr != ""
|
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
|
endif
|
||||||
if a:guisp != ""
|
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
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue