2019-10-24 20:58:45 +00:00
|
|
|
|
" Add encoding for multibyte chars
|
|
|
|
|
scriptencoding utf-8
|
|
|
|
|
|
2015-03-26 17:09:26 +00:00
|
|
|
|
" Display filename at bottom of window
|
2019-10-24 20:58:45 +00:00
|
|
|
|
set laststatus=2
|
2015-03-26 17:09:26 +00:00
|
|
|
|
"enable line numbers
|
2019-10-24 20:58:45 +00:00
|
|
|
|
set number
|
2015-03-26 17:09:26 +00:00
|
|
|
|
|
|
|
|
|
" Highlights the line the cursor is on
|
|
|
|
|
set cursorline
|
|
|
|
|
:hi CursorLine cterm=NONE ctermbg=darkred guibg=darkred guifg=white
|
|
|
|
|
|
|
|
|
|
" Syntax Hightlighting
|
|
|
|
|
syntax on
|
|
|
|
|
|
|
|
|
|
" Enable search highlighting
|
2019-10-24 20:58:45 +00:00
|
|
|
|
set hlsearch
|
2015-03-26 17:09:26 +00:00
|
|
|
|
|
2019-11-01 22:07:29 +00:00
|
|
|
|
" Set fonts for gui apps {{
|
|
|
|
|
if IsGuiApp()
|
|
|
|
|
if IsWindows()
|
|
|
|
|
set guifont=Consolas:h10:b
|
|
|
|
|
endif
|
|
|
|
|
endif
|
|
|
|
|
" }}
|
|
|
|
|
|
2015-03-26 17:09:26 +00:00
|
|
|
|
" Color Schemes {{
|
2019-07-03 00:08:17 +00:00
|
|
|
|
|
2019-11-01 22:07:29 +00:00
|
|
|
|
" Set a default color scheme to use
|
|
|
|
|
let g:default_color = 'wombat256mod'
|
|
|
|
|
|
|
|
|
|
" Gets the value of an env or returns a default
|
2019-11-02 00:19:22 +00:00
|
|
|
|
function! s:val_default(env, default)
|
2019-11-01 22:07:29 +00:00
|
|
|
|
return !empty(a:env) ? a:env : a:default
|
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
|
|
" Get color schemes from env variables
|
|
|
|
|
let s:env_color = s:val_default($VIM_COLOR, g:default_color)
|
|
|
|
|
let s:env_color_light = s:val_default($VIM_COLOR_LIGHT, s:env_color)
|
|
|
|
|
let s:env_color_dark = s:val_default($VIM_COLOR_DARK, s:env_color)
|
|
|
|
|
|
|
|
|
|
" Override colors for gui apps
|
|
|
|
|
if IsGuiApp()
|
|
|
|
|
let g:default_color = 'solarized'
|
|
|
|
|
let s:env_color = 'solarized'
|
|
|
|
|
let s:env_color_light = 'solarized'
|
|
|
|
|
let s:env_color_dark = 'solarized'
|
|
|
|
|
endif
|
|
|
|
|
|
2019-11-02 00:19:22 +00:00
|
|
|
|
" Set the colorscheme if it's different than the current
|
|
|
|
|
function! s:maybe_set_color(colorscheme_name)
|
|
|
|
|
" On some versions of vim, g:colors_name doesn't seem to exist on start
|
|
|
|
|
if !exists('g:colors_name') || g:colors_name !=# a:colorscheme_name
|
|
|
|
|
execute 'colorscheme ' . a:colorscheme_name
|
|
|
|
|
endif
|
|
|
|
|
endfunction
|
|
|
|
|
|
2019-07-03 00:08:17 +00:00
|
|
|
|
" Function and command to update colors based on light and dark mode
|
|
|
|
|
function! UpdateColors()
|
2019-10-16 16:24:17 +00:00
|
|
|
|
" Detect using an env variable
|
2019-10-24 20:58:45 +00:00
|
|
|
|
let cmd = 'echo $IS_DARKMODE'
|
2019-10-16 16:24:17 +00:00
|
|
|
|
" On macOS we can do something a bit more fancy
|
|
|
|
|
if IsMac()
|
2019-11-01 22:07:29 +00:00
|
|
|
|
let cmd = 'defaults read -g AppleInterfaceStyle'
|
2019-10-16 16:24:17 +00:00
|
|
|
|
endif
|
2019-07-03 00:08:17 +00:00
|
|
|
|
let dark_mode = substitute(system(cmd), '\n', '', 'g')
|
|
|
|
|
" Set colorscheme and background based on mode
|
2019-11-01 22:07:29 +00:00
|
|
|
|
if dark_mode ==# 'Dark'
|
2021-04-30 18:26:06 +00:00
|
|
|
|
if &background !=# 'dark'
|
|
|
|
|
set background=dark
|
|
|
|
|
endif
|
2019-11-02 00:19:22 +00:00
|
|
|
|
call s:maybe_set_color(s:env_color_dark)
|
2019-07-03 00:08:17 +00:00
|
|
|
|
else
|
2021-04-30 18:26:06 +00:00
|
|
|
|
if &background !=# 'light'
|
|
|
|
|
set background=light
|
|
|
|
|
endif
|
2019-11-02 00:19:22 +00:00
|
|
|
|
call s:maybe_set_color(s:env_color_light)
|
2019-07-03 00:08:17 +00:00
|
|
|
|
endif
|
|
|
|
|
endfunction
|
|
|
|
|
command! UpdateColors call UpdateColors()
|
2019-11-01 22:07:29 +00:00
|
|
|
|
nnoremap <leader>cc :UpdateColors<CR>
|
|
|
|
|
|
|
|
|
|
augroup AutoColors
|
|
|
|
|
autocmd FocusGained * call UpdateColors()
|
|
|
|
|
augroup END
|
2019-10-24 21:12:44 +00:00
|
|
|
|
|
|
|
|
|
try
|
2019-11-01 22:07:29 +00:00
|
|
|
|
execute 'colorscheme ' . s:env_color
|
|
|
|
|
" Disabled because this slows startup
|
2019-10-24 21:12:44 +00:00
|
|
|
|
call UpdateColors()
|
|
|
|
|
catch /^Vim\%((\a\+)\)\=:E185/
|
|
|
|
|
" Colorschemes not installed yet
|
|
|
|
|
" This happens when first installing bundles
|
|
|
|
|
endtry
|
2019-10-21 23:00:11 +00:00
|
|
|
|
" }}
|
|
|
|
|
|
|
|
|
|
" Set xterm and screen/tmux's title {{
|
|
|
|
|
set titlestring=vim\ %{expand(\"%t\")}
|
2019-10-24 20:58:45 +00:00
|
|
|
|
if &term =~# '^screen'
|
2019-10-21 23:00:11 +00:00
|
|
|
|
" pretend this is xterm. it probably is anyway, but if term is left as
|
|
|
|
|
" `screen`, vim doesn't understand ctrl-arrow.
|
2019-10-24 20:58:45 +00:00
|
|
|
|
if &term ==# 'screen-256color'
|
2019-10-21 23:00:11 +00:00
|
|
|
|
set term=xterm-256color
|
|
|
|
|
else
|
|
|
|
|
set term=xterm
|
|
|
|
|
endif
|
|
|
|
|
|
2021-12-15 23:24:22 +00:00
|
|
|
|
if exists('+termguicolors')
|
|
|
|
|
let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum"
|
|
|
|
|
let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum"
|
|
|
|
|
set termguicolors
|
|
|
|
|
endif
|
|
|
|
|
|
2019-10-21 23:00:11 +00:00
|
|
|
|
" gotta set these *last*, since `set term` resets everything
|
|
|
|
|
set t_ts=k
|
|
|
|
|
set t_fs=\
|
|
|
|
|
set t_ut=
|
|
|
|
|
endif
|
|
|
|
|
set notitle
|
|
|
|
|
" }}
|