Browse Source

Add style override mechanism. (#70)

Reworked from #67; thanks @webdesus!
pull/71/head
Josh Dick 8 years ago
committed by GitHub
parent
commit
b15870389a
  1. 24
      README.md
  2. 8
      colors/onedark.vim

24
README.md

@ -114,6 +114,30 @@ Place `onedark.vim/autoload/airline/themes/onedark.vim` in your `~/.vim/autoload
let g:airline_theme='onedark' let g:airline_theme='onedark'
``` ```
## FAQ
### How can I customize onedark.vim's look without forking the repository?
onedark.vim exposes a function called `onedark#set_highlight` that you can call from within your `~/.vimrc` in order to customize the look of onedark.vim by overriding its defaults.
The function's first argument should be the name of a highlight group, and its second argument should be 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`:
```vim
" onedark.vim override: Don't set a background color when running in a terminal;
" just use the terminal's background color
" `gui` is the hex color code used in GUI mode/nvim true-color mode
" `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"))
let s:white = { "gui": "#ABB2BF", "cterm": "145", "cterm16" : "7" }
autocmd ColorScheme * call onedark#set_highlight("Normal", { "fg": s:white }) " No `bg` setting
end
```
More examples of highlight group names and style data can be found in onedark.vim's source code (`colors/onedark.vim` inside this repository).
--- ---
Preview images were taken using: Preview images were taken using:

8
colors/onedark.vim

@ -98,6 +98,14 @@ function! s:h(group, style)
\ "cterm=" (has_key(a:style, "cterm") ? a:style.cterm : "NONE") \ "cterm=" (has_key(a:style, "cterm") ? a:style.cterm : "NONE")
endfunction endfunction
"public {{
function! onedark#set_highlight(group, style)
call s:h(a:group, a:style)
endfunction
"public end }}
" +-----------------+ " +-----------------+
" | Color Variables | " | Color Variables |
" +-----------------+ " +-----------------+

Loading…
Cancel
Save