mirror of
https://github.com/joshdick/onedark.vim.git
synced 2025-11-13 05:23:48 -05:00
Expose function for extending highlight group.
This commit is contained in:
@@ -170,6 +170,11 @@ if (has("autocmd") && !has("gui_running"))
|
|||||||
end
|
end
|
||||||
```
|
```
|
||||||
|
|
||||||
|
If you want to change only some parts of highlight group, you can use `onedark#extend_highlight` that will change only keys you provide. For example, if you want functions to be bold in GUI, you can do something like this:
|
||||||
|
```vim
|
||||||
|
call onedark#extend_highlight("Function", { "gui": "bold" })
|
||||||
|
```
|
||||||
|
|
||||||
You can also override a color across all highlights by adding the color definitions to the `g:onedark_color_overrides` dictionary in your `~/.vimrc` like so:
|
You can also override a color across all highlights by adding the color definitions to the `g:onedark_color_overrides` dictionary in your `~/.vimrc` like so:
|
||||||
|
|
||||||
```vim
|
```vim
|
||||||
|
|||||||
@@ -52,6 +52,7 @@ endif
|
|||||||
set t_Co=256
|
set t_Co=256
|
||||||
|
|
||||||
let g:colors_name="onedark"
|
let g:colors_name="onedark"
|
||||||
|
let s:group_colors = {}
|
||||||
|
|
||||||
" Set to "256" for 256-color terminals, or
|
" Set to "256" for 256-color terminals, or
|
||||||
" set to "16" to use your terminal emulator's native colors
|
" set to "16" to use your terminal emulator's native colors
|
||||||
@@ -69,30 +70,33 @@ endif
|
|||||||
|
|
||||||
" This function is based on one from FlatColor: https://github.com/MaxSt/FlatColor/
|
" This function is based on one from FlatColor: https://github.com/MaxSt/FlatColor/
|
||||||
" Which in turn was based on one found in hemisu: https://github.com/noahfrederick/vim-hemisu/
|
" Which in turn was based on one found in hemisu: https://github.com/noahfrederick/vim-hemisu/
|
||||||
function! s:h(group, style)
|
function! s:h(group, style, ...)
|
||||||
|
let a:highlight = a:0 > 0 ? extend(s:group_colors[a:group], a:style) : a:style
|
||||||
if g:onedark_terminal_italics == 0
|
if g:onedark_terminal_italics == 0
|
||||||
if has_key(a:style, "cterm") && a:style["cterm"] == "italic"
|
if has_key(a:highlight, "cterm") && a:highlight["cterm"] == "italic"
|
||||||
unlet a:style.cterm
|
unlet a:highlight.cterm
|
||||||
endif
|
endif
|
||||||
if has_key(a:style, "gui") && a:style["gui"] == "italic"
|
if has_key(a:highlight, "gui") && a:highlight["gui"] == "italic"
|
||||||
unlet a:style.gui
|
unlet a:highlight.gui
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if g:onedark_termcolors == 16
|
if g:onedark_termcolors == 16
|
||||||
let l:ctermfg = (has_key(a:style, "fg") ? a:style.fg.cterm16 : "NONE")
|
let l:ctermfg = (has_key(a:highlight, "fg") ? a:highlight.fg.cterm16 : "NONE")
|
||||||
let l:ctermbg = (has_key(a:style, "bg") ? a:style.bg.cterm16 : "NONE")
|
let l:ctermbg = (has_key(a:highlight, "bg") ? a:highlight.bg.cterm16 : "NONE")
|
||||||
else
|
else
|
||||||
let l:ctermfg = (has_key(a:style, "fg") ? a:style.fg.cterm : "NONE")
|
let l:ctermfg = (has_key(a:highlight, "fg") ? a:highlight.fg.cterm : "NONE")
|
||||||
let l:ctermbg = (has_key(a:style, "bg") ? a:style.bg.cterm : "NONE")
|
let l:ctermbg = (has_key(a:highlight, "bg") ? a:highlight.bg.cterm : "NONE")
|
||||||
endif
|
endif
|
||||||
execute "highlight" a:group
|
execute "highlight" a:group
|
||||||
\ "guifg=" (has_key(a:style, "fg") ? a:style.fg.gui : "NONE")
|
\ "guifg=" (has_key(a:highlight, "fg") ? a:highlight.fg.gui : "NONE")
|
||||||
\ "guibg=" (has_key(a:style, "bg") ? a:style.bg.gui : "NONE")
|
\ "guibg=" (has_key(a:highlight, "bg") ? a:highlight.bg.gui : "NONE")
|
||||||
\ "guisp=" (has_key(a:style, "sp") ? a:style.sp.gui : "NONE")
|
\ "guisp=" (has_key(a:highlight, "sp") ? a:highlight.sp.gui : "NONE")
|
||||||
\ "gui=" (has_key(a:style, "gui") ? a:style.gui : "NONE")
|
\ "gui=" (has_key(a:highlight, "gui") ? a:highlight.gui : "NONE")
|
||||||
\ "ctermfg=" . l:ctermfg
|
\ "ctermfg=" . l:ctermfg
|
||||||
\ "ctermbg=" . l:ctermbg
|
\ "ctermbg=" . l:ctermbg
|
||||||
\ "cterm=" (has_key(a:style, "cterm") ? a:style.cterm : "NONE")
|
\ "cterm=" (has_key(a:highlight, "cterm") ? a:highlight.cterm : "NONE")
|
||||||
|
let s:group_colors[a:group] = a:highlight
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" public {{{
|
" public {{{
|
||||||
@@ -101,6 +105,10 @@ function! onedark#set_highlight(group, style)
|
|||||||
call s:h(a:group, a:style)
|
call s:h(a:group, a:style)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
function! onedark#extend_highlight(group, style)
|
||||||
|
call s:h(a:group, a:style, 1)
|
||||||
|
endfunction
|
||||||
|
|
||||||
" }}}
|
" }}}
|
||||||
|
|
||||||
" }}}
|
" }}}
|
||||||
|
|||||||
Reference in New Issue
Block a user