mirror of
https://github.com/joshdick/onedark.vim.git
synced 2025-11-15 22:43:49 -05:00
Add style override mechanism. (#70)
Reworked from #67; thanks @webdesus!
This commit is contained in:
24
README.md
24
README.md
@@ -114,6 +114,30 @@ Place `onedark.vim/autoload/airline/themes/onedark.vim` in your `~/.vim/autoload
|
||||
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:
|
||||
|
||||
@@ -98,6 +98,14 @@ function! s:h(group, style)
|
||||
\ "cterm=" (has_key(a:style, "cterm") ? a:style.cterm : "NONE")
|
||||
endfunction
|
||||
|
||||
"public {{
|
||||
|
||||
function! onedark#set_highlight(group, style)
|
||||
call s:h(a:group, a:style)
|
||||
endfunction
|
||||
|
||||
"public end }}
|
||||
|
||||
" +-----------------+
|
||||
" | Color Variables |
|
||||
" +-----------------+
|
||||
|
||||
Reference in New Issue
Block a user