mirror of
https://github.com/joshdick/onedark.vim.git
synced 2025-11-08 11:03:49 -05:00
Enhance the implementation of onedark#extend_highlight and improve the README
This commit is contained in:
33
README.md
33
README.md
@@ -158,21 +158,29 @@ onedark.vim exposes `onedark#extend_highlight` and `onedark#set_highlight` funct
|
||||
|
||||
`onedark#extend_highlight` allows you to customize individual aspects of onedark.vim's existing highlight groups, overriding only the keys you provide. (To completely redefine/override an existing highlight group, see `onedark#set_highlight` below.)
|
||||
|
||||
`onedark#extend_highlight`'s first argunment should be the name of a highlight group, and its second argument should be style data.
|
||||
`onedark#extend_highlight`'s first argunment should be the name of a highlight group, and its second argument should be **partial** style data.
|
||||
|
||||
For example, if you want functions to be bold only in GUI mode, place the following lines **before** the `colorscheme onedark` line in your `~/.vimrc`:
|
||||
Place the following lines **before** the `colorscheme onedark` line in your `~/.vimrc`, then change the example overrides to suit your needs:
|
||||
|
||||
```vim
|
||||
if (has("autocmd") && has("gui_running"))
|
||||
autocmd ColorScheme * call onedark#extend_highlight("Function", { "gui": "bold" })
|
||||
end
|
||||
if (has("autocmd"))
|
||||
augroup colorextend
|
||||
autocmd!
|
||||
" Make `Function`s bold in GUI mode
|
||||
autocmd ColorScheme * call onedark#extend_highlight("Function", { "gui": "bold" })
|
||||
" Override the `Statement` foreground color in 256-color mode
|
||||
autocmd ColorScheme * call onedark#extend_highlight("Statement", { "fg": { "cterm": 128 } })
|
||||
" Override the `Identifier` background color in GUI mode
|
||||
autocmd ColorScheme * call onedark#extend_highlight("Identifier", { "bg": { "gui": "#333333" } })
|
||||
augroup END
|
||||
endif
|
||||
```
|
||||
|
||||
#### `onedark#set_highlight`
|
||||
|
||||
`onedark#set_highlight` allows you to completely redefine/override highlight groups of your choosing.
|
||||
|
||||
`onedark#set_highlight`'s first argument should be the name of a highlight group, and its second argument should be style data.
|
||||
`onedark#set_highlight`'s first argument should be the name of a highlight group, and its second argument should be **complete** style data.
|
||||
|
||||
For example, to remove the background color only when running in terminals (outside GUI mode and for use in transparent terminals,) place the following lines **before** the `colorscheme onedark` line in your `~/.vimrc`:
|
||||
|
||||
@@ -183,12 +191,17 @@ For example, to remove the background color only when running in terminals (outs
|
||||
" `cterm` is the color code used in 256-color mode
|
||||
" `cterm16` is the color code used in 16-color mode
|
||||
if (has("autocmd") && !has("gui_running"))
|
||||
let s:white = { "gui": "#ABB2BF", "cterm": "145", "cterm16" : "7" }
|
||||
autocmd ColorScheme * call onedark#set_highlight("Normal", { "fg": s:white }) " No `bg` setting
|
||||
end
|
||||
augroup colorset
|
||||
autocmd!
|
||||
let s:white = { "gui": "#ABB2BF", "cterm": "145", "cterm16" : "7" }
|
||||
autocmd ColorScheme * call onedark#set_highlight("Normal", { "fg": s:white }) " `bg` will not be styled since there is no `bg` setting
|
||||
augroup END
|
||||
endif
|
||||
```
|
||||
|
||||
Finally, you can also override a color across all highlights by adding color definitions to the `g:onedark_color_overrides` dictionary in your `~/.vimrc` like so:
|
||||
#### Global color overrides
|
||||
|
||||
You can override colors across all highlights by adding color definitions to the `g:onedark_color_overrides` dictionary in your `~/.vimrc` like so:
|
||||
|
||||
```vim
|
||||
let g:onedark_color_overrides = {
|
||||
|
||||
Reference in New Issue
Block a user