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
|
|
|
|
|
|
|
|
|
" Color Schemes {{
|
2019-07-03 00:08:17 +00:00
|
|
|
|
|
|
|
|
|
" Function and command to update colors based on light and dark mode
|
|
|
|
|
function! UpdateColors()
|
|
|
|
|
" Get the light color or default to VIM_COLOR
|
|
|
|
|
let light_color = $VIM_COLOR
|
|
|
|
|
if !empty($VIM_COLOR_LIGHT)
|
|
|
|
|
let light_color = $VIM_COLOR_LIGHT
|
|
|
|
|
endif
|
|
|
|
|
" Get the dark color or default to VIM_COLOR
|
|
|
|
|
let dark_color = $VIM_COLOR
|
|
|
|
|
if !empty($VIM_COLOR_DARK)
|
|
|
|
|
let dark_color = $VIM_COLOR_DARK
|
|
|
|
|
endif
|
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()
|
|
|
|
|
let cmd = "osascript
|
|
|
|
|
\ -e 'tell application \"System Events\"'
|
|
|
|
|
\ -e 'tell appearance preferences'
|
|
|
|
|
\ -e 'return dark mode'
|
|
|
|
|
\ -e 'end tell'
|
|
|
|
|
\ -e 'end tell'"
|
|
|
|
|
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-10-24 20:58:45 +00:00
|
|
|
|
if dark_mode ==# 'true'
|
2019-07-03 00:08:17 +00:00
|
|
|
|
execute 'colorscheme ' . dark_color
|
|
|
|
|
set background=dark
|
|
|
|
|
else
|
|
|
|
|
execute 'colorscheme ' . light_color
|
|
|
|
|
set background=light
|
|
|
|
|
endif
|
|
|
|
|
endfunction
|
|
|
|
|
command! UpdateColors call UpdateColors()
|
2019-10-24 21:12:44 +00:00
|
|
|
|
|
|
|
|
|
" Set theme based on $VIM_COLOR variable
|
|
|
|
|
try
|
|
|
|
|
if !empty($VIM_COLOR)
|
|
|
|
|
colorscheme $VIM_COLOR
|
|
|
|
|
else
|
|
|
|
|
" Prefered default colorscheme
|
|
|
|
|
colorscheme wombat256mod
|
|
|
|
|
endif
|
|
|
|
|
call UpdateColors()
|
|
|
|
|
catch /^Vim\%((\a\+)\)\=:E185/
|
|
|
|
|
" Colorschemes not installed yet
|
|
|
|
|
" This happens when first installing bundles
|
|
|
|
|
colorscheme default
|
|
|
|
|
endtry
|
2019-10-21 23:00:11 +00:00
|
|
|
|
" }}
|
|
|
|
|
|
|
|
|
|
" Set gui specific values {{
|
|
|
|
|
if IsGuiApp()
|
|
|
|
|
colorscheme wombat256mod
|
|
|
|
|
if IsWindows()
|
|
|
|
|
set guifont=Consolas:h10:b
|
|
|
|
|
elseif IsMac()
|
|
|
|
|
try
|
|
|
|
|
set guifont=DejaVu\ Sans\ Mono\ for\ Powerline:h11
|
|
|
|
|
catch
|
|
|
|
|
" Failed to set font, ok with default
|
|
|
|
|
endtry
|
|
|
|
|
endif
|
|
|
|
|
endif
|
|
|
|
|
" }}
|
|
|
|
|
|
|
|
|
|
" 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
|
|
|
|
|
|
|
|
|
|
" gotta set these *last*, since `set term` resets everything
|
|
|
|
|
set t_ts=k
|
|
|
|
|
set t_fs=\
|
|
|
|
|
set t_ut=
|
|
|
|
|
endif
|
|
|
|
|
set notitle
|
|
|
|
|
" }}
|