diff --git a/vimrc b/vimrc index a5b48fa..ac14535 100644 --- a/vimrc +++ b/vimrc @@ -59,20 +59,40 @@ if has("unix") || has("mac") map :UndotreeToggle Plugin 'vim-scripts/LaTeX-Box' map ll :Latexmk - 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]" 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 Plugin 'AutoComplPop' endif - Plugin 'vim-airline/vim-airline-themes' - Plugin 'vim-airline/vim-airline' + Plugin 'w0rp/ale' + 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 'tikhomirov/vim-glsl' Plugin 'mzlogin/vim-smali' Plugin 'jamessan/vim-gnupg' Plugin 'petRUShka/vim-opencl' - Plugin 'Raimondi/delimitMate' Plugin 'tpope/vim-surround' Plugin 'captbaritone/better-indent-support-for-php-with-html' "[Autodetect indent style of a file]" @@ -167,16 +187,8 @@ if has("unix") || has("mac") endif "[Always show StatusLine]" set laststatus=2 -"[Define StatusLine]" -set statusline="" -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()}] +"[Do not show mode in command line]" +set noshowmode "[Splitting rules]" set splitbelow set splitright @@ -199,11 +211,10 @@ set mousehide "[Visualisation settings]" set background=dark set ttyfast -set showmode set tabline="" " set cmdheight=1 : default set showtabline=0 -set colorcolumn="" +set colorcolumn=80 set nocursorcolumn set cmdwinheight=10 set virtualedit=all @@ -227,7 +238,7 @@ if has("gui_running") elseif has("unix") try colorscheme solarized - set guifont=Liberation\ Mono\ 12 + set guifont=Liberation\ Mono\ 10 catch endtry elseif has("mac") @@ -265,6 +276,7 @@ set history=1000 set nowritebackup set undolevels=5000 "[Indent & Tab/mode-line settings]" +set breakindent set nopaste set modeline set smarttab @@ -410,7 +422,7 @@ endif "[Python/Perl scripts templates]" function! InitScriptFile(type) if (a:type == "python") - execute setline(1, "#!/usr/bin/env python") + execute setline(1, "#!/usr/bin/env python3") execute setline(2, "# -*- coding: utf-8 -*-") elseif (a:type == "perl") execute setline(1, "#!/usr/bin/env perl") @@ -438,21 +450,6 @@ if has("autocmd") autocmd BufWritePre *.py,*.pyw retab autocmd BufWritePre * call DeleteTrailingTWS() 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]" "[Credit: https://jeffkreeftmeijer.com/vim-number/#relative-line-numbers ]" if has("autocmd") @@ -462,3 +459,33 @@ if has("autocmd") autocmd BufLeave,FocusLost,InsertEnter * set norelativenumber augroup END 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