add light/dark theme toggle

This commit is contained in:
Nachuan Tang
2022-07-23 01:48:30 -04:00
parent 2beb7791df
commit ef122af8b5
2 changed files with 85 additions and 73 deletions
+6 -50
View File
@@ -1,5 +1,4 @@
" Modeline and Notes {
" vim: set sw=4 ts=4 sts=4 et tw=78 foldmarker={,} nofoldenable foldmethod=marker spell:
" Environment {
" The default leader is '\', but many people prefer ',' as it's in a standard
let mapleader = ','
@@ -11,18 +10,6 @@
set background=dark " Assume a dark background
" Allow to trigger background
function! ToggleBG()
let s:tbg = &background
" Inversion
if s:tbg == "dark"
set background=light
else
set background=dark
endif
endfunction
noremap <leader>bg :call ToggleBG()<CR>
noremap <leader>h :noh<CR> " turn off highlight
filetype plugin indent on " Automatically detect file types.
@@ -41,7 +28,6 @@
set viewoptions=folds,options,cursor,unix,slash " Better Unix / Windows compatibility
set virtualedit=onemore " Allow for cursor beyond last character
set history=1000 " Store a ton of history (default is 20)
set nospell " Spell checking off
set hidden " Allow buffer switching without saving
set iskeyword-=. " '.' is an end of word designator
set iskeyword-=# " '#' is an end of word designator
@@ -132,10 +118,13 @@
set nojoinspaces " Prevents inserting two spaces after punctuation on a join (J)
set splitright " Puts new vsplit windows to the right of the current
set splitbelow " Puts new split windows to the bottom of the current
set nolist " let vim not showing '$' or other sign
set nolist " let vim not showing '$' or other sign
"set list " Display unprintable characters f12 - switches
"set listchars=tab:•\ ,trail:•,extends:»,precedes:« " Unprintable chars mapping
set nospell " Spell checking off
set matchpairs+=<:> " Match, to be used with %
set comments=sl:/*,mb:*,elx:*/ " auto format comment blocks
"set comments=sl:/*,mb:*,elx:*/ " auto format comment blocks
autocmd BufNewFile,BufRead *.html.twig set filetype=html.twig
autocmd FileType haskell,puppet,ruby,yml setlocal expandtab shiftwidth=2 softtabstop=2
@@ -190,17 +179,6 @@
nmap <leader>f8 :set foldlevel=8<CR>
nmap <leader>f9 :set foldlevel=9<CR>
" Most prefer to toggle search highlighting rather than clear the current
" search results. To clear search highlighting rather than toggle it on
" and off, add the following to your .vimrc.before.local file:
" let g:spf13_clear_search_highlight = 1
if exists('g:spf13_clear_search_highlight')
nmap <silent> <leader>/ :nohlsearch<CR>
else
nmap <silent> <leader>/ :set invhlsearch<CR>
endif
" Find merge conflict markers
map <leader>fc /\v^[<\|=>]{7}( .*\|$)<CR>
@@ -291,20 +269,6 @@
call InitializeDirectories()
" }
" Initialize NERDTree as needed {
function! NERDTreeInitAsNeeded()
redir => bufoutput
buffers!
redir END
let idx = stridx(bufoutput, "NERD_tree")
if idx > -1
NERDTreeMirror
NERDTreeFind
wincmd l
endif
endfunction
" }
" Shell command {
function! s:RunShellCommand(cmdline)
botright new
@@ -326,7 +290,6 @@
command! -complete=file -nargs=+ Shell call s:RunShellCommand(<q-args>)
" e.g. Grep current file for <search_term>: Shell grep -Hn <search_term> %
" }
" Fix file type error for typescript
autocmd BufNewFile,BufRead *.ts set filetype=typescript
@@ -369,15 +332,8 @@
" copy to system
set clipboard=unnamed
" space-d jump to definition if coc is installed
"nnoremap <silent><nowait> <space>d :call CocAction('jumpDefinition', v: false)<CR>
"nnoremap <silent><nowait> <space>r :call CocAction('jumpReferences', v: false)<CR>
if filereadable(expand("~/.dotfile/.exp-coc-config"))
source ~/.vim-config/.exp-coc-config
endif
" fix paste mess up when using tmux
if &term =~ "screen"
if &term =~ "screen"
let &t_BE = "\e[?2004h"
let &t_BD = "\e[?2004l"
exec "set t_PS=\e[200~"
+79 -23
View File
@@ -6,15 +6,11 @@
" }
"
" Plugin directory
let config_dir = '~/.dotfiles/'
let plugin_dir = '~/.vim/plugged/'
call plug#begin(plugin_dir)
Plug 'neoclide/coc.nvim', {'branch': 'release'}
" add desired extensions to the following global variable
" coc-tsserver: javascript
" coc-pyright: python
" coc-clangd: c/c++, may need to install clangd seperatly
let g:coc_global_extensions = ['coc-pyright', 'coc-rls']
Plug 'rust-lang/rust.vim'
" syntax highlighting(and more) for typescript
" {
@@ -38,7 +34,7 @@
" for window resize{
Plug 'simeji/winresizer'
let g:winresizer_start_key = '<C-r>'
let g:winresizer_start_key = '<leader-r>'
let g:winresizer_vert_resize = 2
let g:winresizer_horiz_resize = 2
" }
@@ -54,7 +50,7 @@
Plug 'mg979/vim-visual-multi'
" }
Plug 'vim-airline/vim-airline'
"Plug 'vim-airline/vim-airline-themes'
Plug 'vim-airline/vim-airline-themes'
" For nvim-bufferline
" {
@@ -70,8 +66,17 @@
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
endif
" nvim support only theme
" {
Plug 'projekt0n/github-nvim-theme'
" }
" vim theme
" {
Plug 'nanotech/jellybeans.vim'
Plug 'danilo-augusto/vim-afterglow'
Plug 'NLKNguyen/papercolor-theme'
" }
call plug#end()
@@ -105,16 +110,13 @@
" vim-airline {
" Set configuration options for the statusline plugin vim-airline.
" Use the powerline theme and optionally enable powerline symbols.
" To use the symbols , , , , , , and .in the statusline
" segments add the following to your .vimrc.before.local file:
" let g:airline_powerline_fonts=1
" If the previous symbols do not render for you then install a
" powerline enabled font.
" See `:echo g:airline_theme_map` for some more choices
" Default in terminal vim is 'dark'
let g:airline_section_b = ''
let g:airline_section_z = ''
let g:airline_section_y = ''
let g:airline_section_x = ''
let g:airline_section_warning = ''
let g:airline#extensions#tabline#left_sep = ''
let g:airline#extensions#tabline#left_alt_sep = '|'
if isdirectory(expand(plugin_dir . "/vim-airline-themes/"))
"let g:airline_theme = 'solarized'
@@ -124,28 +126,82 @@
" junegunnjunegunn/fzf {
" [Buffers] Jump to the existing window if possible
let g:fzf_buffers_jump = 1
let $FZF_DEFAULT_COMMAND = 'find -L'
"let $FZF_DEFAULT_COMMAND = 'find -L'
let $FZF_DEFAULT_COMMAND='find . \( -name node_modules -o -name .git \) -prune -o -print'
noremap <leader>f :FZF<CR>
" }
" neoclide/coc.nvim {
" add desired extensions to the following global variable
" coc-tsserver: javascript
" coc-pyright: python
" coc-clangd: c/c++, may need to install clangd seperatly
let g:coc_global_extensions = ['coc-pyright', 'coc-rls']
" space-d jump to definition if coc is installed
"nnoremap <silent><nowait> <space>d :call CocAction('jumpDefinition', v: false)<CR>
"nnoremap <silent><nowait> <space>r :call CocAction('jumpReferences', v: false)<CR>
if filereadable(expand(config_dir . "/.exp-coc-config"))
exec "source " . config_dir . "/.exp-coc-config"
endif
" }
" }
" THEME APPEARANCE
" {
" {
"projekt0n/github-nvim-theme
" nvim only theme
" has('nvim') check if it's running on nvim rather than
" having neovim on your machine
if isdirectory(expand(plugin_dir . "/github-nvim-theme")) && has('nvim')
let g:github_function_style = "italic"
let g:github_sidebars = ["qf", "vista_kind", "terminal", "packer"]
set background=dark
"let g:github_sidebars = ["qf", "vista_kind", "terminal", "packer"]
colorscheme github_dark
" Allow to trigger background
function! ToggleBG()
" Inversion
if g:colors_name == "github_light"
colorscheme github_dark
else
colorscheme github_light
endif
endfunction
noremap <leader>bg :call ToggleBG()<CR>
endif
" }
" {
" nanotech/jellybeans.vim
if isdirectory(expand(plugin_dir . "/jellybeans.vim")) && !has('nvim')
colorscheme jellybeans
" vim theme
"if isdirectory(expand(plugin_dir . "/jellybeans.vim")) && !has('nvim')
if isdirectory(expand(plugin_dir . "/vim-afterglow")) && !has('nvim')
colorscheme afterglow
let g:airline_theme='afterglow'
" Allow to trigger background
function! ToggleBG()
" Inversion
if g:colors_name == "afterglow"
set background=light
colorscheme PaperColor
"let g:airline_theme='papercolor'
:AirlineTheme papercolor
else
set background=dark
colorscheme afterglow
"let g:airline_theme='afterglow'
:AirlineTheme afterglow
endif
endfunction
noremap <leader>bg :call ToggleBG()<CR>
endif
" }
" }