Replace vim-airline by lightline. Add ALE linter. Configure YCM

This commit is contained in:
lhark 2017-10-26 11:57:35 -04:00
parent de3e9adf71
commit ca3e91e7c3

93
vimrc
View file

@ -59,20 +59,40 @@ if has("unix") || has("mac")
map <F5> :UndotreeToggle<CR> map <F5> :UndotreeToggle<CR>
Plugin 'vim-scripts/LaTeX-Box' Plugin 'vim-scripts/LaTeX-Box'
map <LocalLeader>ll :Latexmk<CR> map <LocalLeader>ll :Latexmk<CR>
if isdirectory(expand("/home/lhark/.vim/bundle/YouCompleteMe")) if isdirectory(expand("$HOME/.vim/bundle/YouCompleteMe")) || isdirectory(expand("/usr/share/vim/vimfiles/third_party/ycmd/"))
"[Workaround for YCM non-portability]" "[Workaround for YCM non-portability]"
Plugin 'Valloric/YouCompleteMe' Plugin 'Valloric/YouCompleteMe'
let g:ycm_global_ycm_extra_conf = '/usr/share/vim/vimfiles/third_party/ycmd/cpp/ycm/.ycm_extra_conf.py'
let g:ycm_server_python_interpreter = '/usr/bin/python2'
else else
Plugin 'AutoComplPop' Plugin 'AutoComplPop'
endif endif
Plugin 'vim-airline/vim-airline-themes' Plugin 'w0rp/ale'
Plugin 'vim-airline/vim-airline' let g:ale_sign_error = 'E'
let g:ale_sign_warning = 'W'
Plugin 'itchyny/lightline.vim'
let g:lightline = {
\'colorscheme': 'solarized',
\ 'active': {
\ 'left': [['mode', 'paste'], ['filename', 'modified']],
\ 'right': [['lineinfo'], ['percent'], ['readonly', 'linter_warnings', 'linter_errors', 'linter_ok']]
\ },
\ 'component_expand': {
\ 'linter_warnings': 'LightlineLinterWarnings',
\ 'linter_errors': 'LightlineLinterErrors',
\ 'linter_ok': 'LightlineLinterOK'
\ },
\ 'component_type': {
\ 'readonly': 'error',
\ 'linter_warnings': 'warning',
\ 'linter_errors': 'error'
\ },
\}
Plugin 'godlygeek/tabular' Plugin 'godlygeek/tabular'
Plugin 'tikhomirov/vim-glsl' Plugin 'tikhomirov/vim-glsl'
Plugin 'mzlogin/vim-smali' Plugin 'mzlogin/vim-smali'
Plugin 'jamessan/vim-gnupg' Plugin 'jamessan/vim-gnupg'
Plugin 'petRUShka/vim-opencl' Plugin 'petRUShka/vim-opencl'
Plugin 'Raimondi/delimitMate'
Plugin 'tpope/vim-surround' Plugin 'tpope/vim-surround'
Plugin 'captbaritone/better-indent-support-for-php-with-html' Plugin 'captbaritone/better-indent-support-for-php-with-html'
"[Autodetect indent style of a file]" "[Autodetect indent style of a file]"
@ -167,16 +187,8 @@ if has("unix") || has("mac")
endif endif
"[Always show StatusLine]" "[Always show StatusLine]"
set laststatus=2 set laststatus=2
"[Define StatusLine]" "[Do not show mode in command line]"
set statusline="" set noshowmode
set statusline+=%F%m%r%h%w
set wrapscan
set statusline+=%=%y
set statusline+=\ [%{&ff}]
set statusline+=\ Line:%l/%L
set statusline+=\ Column:[%v]
set statusline+=\ Buffer:[%n]
"set statusline+=\ Mode:[%{ShowModeInStatusLine()}]
"[Splitting rules]" "[Splitting rules]"
set splitbelow set splitbelow
set splitright set splitright
@ -199,11 +211,10 @@ set mousehide
"[Visualisation settings]" "[Visualisation settings]"
set background=dark set background=dark
set ttyfast set ttyfast
set showmode
set tabline="" set tabline=""
" set cmdheight=1 : default " set cmdheight=1 : default
set showtabline=0 set showtabline=0
set colorcolumn="" set colorcolumn=80
set nocursorcolumn set nocursorcolumn
set cmdwinheight=10 set cmdwinheight=10
set virtualedit=all set virtualedit=all
@ -227,7 +238,7 @@ if has("gui_running")
elseif has("unix") elseif has("unix")
try try
colorscheme solarized colorscheme solarized
set guifont=Liberation\ Mono\ 12 set guifont=Liberation\ Mono\ 10
catch catch
endtry endtry
elseif has("mac") elseif has("mac")
@ -265,6 +276,7 @@ set history=1000
set nowritebackup set nowritebackup
set undolevels=5000 set undolevels=5000
"[Indent & Tab/mode-line settings]" "[Indent & Tab/mode-line settings]"
set breakindent
set nopaste set nopaste
set modeline set modeline
set smarttab set smarttab
@ -410,7 +422,7 @@ endif
"[Python/Perl scripts templates]" "[Python/Perl scripts templates]"
function! InitScriptFile(type) function! InitScriptFile(type)
if (a:type == "python") if (a:type == "python")
execute setline(1, "#!/usr/bin/env python") execute setline(1, "#!/usr/bin/env python3")
execute setline(2, "# -*- coding: utf-8 -*-") execute setline(2, "# -*- coding: utf-8 -*-")
elseif (a:type == "perl") elseif (a:type == "perl")
execute setline(1, "#!/usr/bin/env perl") execute setline(1, "#!/usr/bin/env perl")
@ -438,21 +450,6 @@ if has("autocmd")
autocmd BufWritePre *.py,*.pyw retab autocmd BufWritePre *.py,*.pyw retab
autocmd BufWritePre * call DeleteTrailingTWS() autocmd BufWritePre * call DeleteTrailingTWS()
endif endif
"[Show current mode in StatusLine]"
function! ShowModeInStatusLine()
let g:currentMode = mode()
let g:showMode = ""
if (g:currentMode ==# "i")
let g:showMode = "Insert"
elseif (g:currentMode ==# "R")
let g:showMode = "Replace"
elseif (g:currentMode ==# "n")
let g:showMode = "Normal"
else
let g:showMode = "Visual"
endif
return g:showMode
endfunction
"[Toggle relativenumber between normal & insert mode]" "[Toggle relativenumber between normal & insert mode]"
"[Credit: https://jeffkreeftmeijer.com/vim-number/#relative-line-numbers ]" "[Credit: https://jeffkreeftmeijer.com/vim-number/#relative-line-numbers ]"
if has("autocmd") if has("autocmd")
@ -462,3 +459,33 @@ if has("autocmd")
autocmd BufLeave,FocusLost,InsertEnter * set norelativenumber autocmd BufLeave,FocusLost,InsertEnter * set norelativenumber
augroup END augroup END
endif endif
"[ALELint & Lightline compat]"
function! LightlineLinterWarnings() abort
let l:counts = ale#statusline#Count(bufnr(''))
let l:all_errors = l:counts.error + l:counts.style_error
let l:all_non_errors = l:counts.total - l:all_errors
return l:counts.total == 0 ? '' : printf('%d ◆', all_non_errors)
endfunction
function! LightlineLinterErrors() abort
let l:counts = ale#statusline#Count(bufnr(''))
let l:all_errors = l:counts.error + l:counts.style_error
let l:all_non_errors = l:counts.total - l:all_errors
return l:counts.total == 0 ? '' : printf('%d ✗', all_errors)
endfunction
function! LightlineLinterOK() abort
let l:counts = ale#statusline#Count(bufnr(''))
let l:all_errors = l:counts.error + l:counts.style_error
let l:all_non_errors = l:counts.total - l:all_errors
return l:counts.total == 0 ? '✓ ' : ''
endfunction
autocmd User ALELint call s:MaybeUpdateLightline()
" Update and show lightline but only if it's visible (e.g., not in Goyo)
function! s:MaybeUpdateLightline()
if exists('#lightline')
call lightline#update()
end
endfunction