Initiate vimrc rewrite

This commit is contained in:
lhark 2019-02-19 14:35:03 -05:00 committed by aearil
parent 53f1070a37
commit b01f419954
2 changed files with 85 additions and 492 deletions

View file

@ -0,0 +1,6 @@
setlocal tw=79
setlocal tabstop=4
setlocal softtabstop=4
setlocal shiftwidth=4
setlocal expandtab
setlocal autoindent

571
vimrc
View file

@ -1,150 +1,29 @@
"on: [1.8.8]"
"""""""""""""""""""""""""""""""""
"Authors: [Karlkorp, Inc. 2014; lhark, Inc. 2015]"
""""""""""""""""""""""""""""""""""""""""""""""""
"Type: [Vim/GVim/MacVim configuration file]"
""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"Name: [.vimrc (unix/mac); _vimrc (MS Windows/DOS)]"
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"Location: [$HOME/.vimrc (unix/mac); $USERNAME\_vimrc (MS Windows)]"
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"[Plug-ins list]""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"+------------------+-------------------------------------------------+"
"| AutoComplPop | https://github.com/vim-scripts/AutoComplPop |"
"| DelimitMate | https://github.com/Raimondi/delimitMate |"
"| DetectIndent | https://github.com/roryokane/detectindent |"
"| Gutentags | https://github.com/ludovicchabant/vim-gutentags |"
"| Multiple-Cursors | https://github.com/terryma/vim-multiple-cursors |"
"| Python-Mode | https://github.com/klen/python-mode |"
"| Surround | https://github.com/tpope/vim-surround |"
"| Undotree | https://github.com/mbbill/undotree |"
"| Vim-Airline | https://github.com/bling/vim-airline |"
"| Vim-GLSL | https://github.com/tikhomirov/vim-glsl |"
"| Vim-Gnupg | https://github.com/jamessan/vim-gnupg |"
"| Vundle | https://github.com/gmarik/Vundle.vim.git |"
"| YouCompleteMe | https://github.com/Valloric/YouCompleteMe |"
"+------------------+-------------------------------------------------+"
"[Colorschemes list]""""""""""""""""""""""""""""""""""""""""""""""""""""
"+------------------+-------------------------------------------------+"
"| Solarized | https://github.com/altercation/vim-colors-solarized |"
"+------------------+-------------------------------------------------+"
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"[To disable compatibility with Vi]"
set autochdir
set nocompatible
"[Use Plug-ins and Plug-in Manager(Vundle) only on UNIX or MAC OS]"
if has("unix") || has("mac")
filetype off
"[Download and install Vundle Plug-in Manager]"
try
if !isdirectory(expand("$HOME/.vim/bundle"))
silent !mkdir -p $HOME/.vim/bundle
silent cd $HOME/.vim/bundle
silent !git clone https://github.com/gmarik/Vundle.vim.git
silent cd $HOME
endif
"[Run Plug-ins]"
set runtimepath+=$HOME/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'gmarik/Vundle.vim'
map <F2> :VundleInstall<CR>
map <F3> :VundleUpdate<CR>
Plugin 'mbbill/undotree'
map <F5> :UndotreeToggle<CR>
Plugin 'vim-scripts/LaTeX-Box'
map <LocalLeader>ll :Latexmk<CR>
if isdirectory(expand("$HOME/.vim/bundle/YouCompleteMe"))
"[Workaround for YCM non-portability]"
Plugin 'Valloric/YouCompleteMe'
let g:ycm_global_ycm_extra_conf = expand("$HOME/.vim/ycm_global_conf.py")
let g:ycm_extra_conf_vim_data =[ "&filetype" ]
"[We're using ale for linting]"
let g:ycm_show_diagnostics_ui = 0
let g:ycm_collect_identifiers_from_tags_files=1
let g:ycm_seed_identifiers_with_syntax=1
let g:ycm_show_diagnostics_ui = 0
let g:ycm_use_ultisnips_completer = 0
else
Plugin 'AutoComplPop'
Plugin 'davidhalter/jedi-vim'
endif
Plugin 'w0rp/ale'
let g:ale_linters = {
\ 'cpp': ['g++'],
\ 'c': ['clang']
\ }
let g:ale_c_gcc_options='-std=c99 -pedantic'
let g:ale_sign_error = '●'
let g:ale_sign_warning = '●'
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'],
\ ['fileformat'],
\ ['fileencoding']
\ ]
\ },
\ 'component_expand': {
\ 'linter_warnings': 'LightlineLinterWarnings',
\ 'linter_errors': 'LightlineLinterErrors',
\ 'linter_ok': 'LightlineLinterOK',
\ 'lineinfo': 'LineInfo'
\ },
\ 'component_type': {
\ 'readonly': 'error',
\ 'linter_warnings': 'warning',
\ 'linter_errors': 'error'
\ },
\}
if executable('ctags')
Plugin 'ludovicchabant/vim-gutentags'
endif
Plugin 'godlygeek/tabular'
Plugin 'beyondmarc/opengl.vim'
Plugin 'tikhomirov/vim-glsl'
Plugin 'beyondmarc/hlsl.vim'
Plugin 'rust-lang/rust.vim'
Plugin 'mzlogin/vim-smali'
Plugin 'jamessan/vim-gnupg'
Plugin 'petRUShka/vim-opencl'
Plugin 'hynek/vim-python-pep8-indent'
Plugin 'tpope/vim-surround'
Plugin 'captbaritone/better-indent-support-for-php-with-html'
"[Autodetect indent style of a file]"
Plugin 'roryokane/detectindent'
let g:detectindent_preferred_indent=4
let g:detectindent_autodetect=1
"[Solarized theme]"
"Plugin 'ericbn/vim-solarized'
Plugin 'https://gitlab.federez.net/lhark/vim-solarized.git'
call vundle#end()
catch
endtry
else
filetype on
endif
"[Recognize the type/syntax of the file]"
filetype plugin on
filetype indent on
set omnifunc=syntaxcomplete#Complete
"[Default to filetype=tex when viewing partial tex files]"
let g:tex_flavor="tex"
"[Enable built-in plug-ins/macros]"
runtime macros/matchit.vim
"[Enable syntax highlighting]"
syntax on
"[Read the changes after the save .vimrc]"
if has("autocmd")
autocmd! BufWritePost $MYVIMRC source $MYVIMRC
endif
" Allow backspacing over everything in insert mode.
set backspace=indent,eol,start
set number
set relativenumber
set history=200 " keep 200 lines of command line history
set ruler " show the cursor position all the time
set showcmd " display incomplete commands
set wildmenu " display completion matches in a status line
set ttimeout " time out for key codes
set ttimeoutlen=100 " wait up to 100ms after Esc for special key
"[Turn backup off and value of history]"
set nobackup
set noswapfile
set history=1000
set nowritebackup
set undolevels=5000
"[Define the leader key]"
let mapleader=","
let maplocalleader=","
"[List of buffers]"
map <F7> :ls!<CR>:buffer<Space>
"[Reselect visual block after indent/outdent]"
vnoremap < <gv
vnoremap > >gv
@ -152,14 +31,6 @@ vnoremap > >gv
"[If preceded by a count, jump actual lines. Also if > 5, save to jumplist]"
nnoremap <expr> j v:count ? (v:count > 5 ? "m'" . v:count : '') . 'j' : 'gj'
nnoremap <expr> k v:count ? (v:count > 5 ? "m'" . v:count : '') . 'k' : 'gk'
" nnoremap <Down> gj
" nnoremap <Up> gk
" vnoremap <Down> gj
" vnoremap <Up> gk
" inoremap <Down> <C-o>gj
" inoremap <Up> <C-o>gk
"[Clear search highlights]"
nnoremap // :nohlsearch<CR>
"[Easy split navigation]"
nnoremap <C-j> <C-W>j
nnoremap <C-k> <C-W>k
@ -177,352 +48,68 @@ nnoremap <silent> # #zz
"[New line under/bellow current line without jump to insert-mode]"
nnoremap <leader>o o<Esc>
nnoremap <leader>O O<Esc>
"[Auto-complete parenthesis, brackets and braces, quotes]"
"inoremap " ""<Left>
"inoremap ' ''<Left>
"inoremap ( ()<Left>
"inoremap [ []<Left>
"inoremap { {}<Left>
"[Easy jump into the normal-mode from the insert-mode]"
inoremap jj <Esc>
"[To move over parenthesis, brackets, quotes in insert-mode]"
inoremap kk <Right>
inoremap hh <Left>
" http://stackoverflow.com/questions/1005/getting-root-permissions-on-a-file-inside-of-vi
cmap w!! w !sudo tee >/dev/null %
"[To disable the arrow keys]"
for prefix in ['i', 'n', 'v']
for key in ['<Up>', '<Down>', '<Left>', '<Right>']
execute prefix . "noremap " . key . " <Nop>"
endfor
endfor
"[Threshold for reporting number of lines changed]"
set report=0
"[Show command in the last line of the screen]"
set showcmd
"[Show both the tag name and a tidied-up form of the search pattern]"
set showfulltag
"[Don't give the intro message when starting Vim]"
set shortmess=""
if has("unix") || has("mac")
set shortmess+=I
"[Clear search highlights]"
nnoremap // :nohlsearch<CR>
" Don't use Ex mode, use Q for formatting.
map Q gq
"[Reflow current paragraph]"
"[http://stevelosh.com/blog/2010/09/coming-home-to-vim/]"
nnoremap <leader>q gqip
" Show @@@ in the last line if it is truncated.
set display=truncate
" Show a few lines of context around the cursor. Note that this makes the
" text scroll if you mouse-click near the start or end of the window.
set scrolloff=5
let base16colorspace=256
colorscheme base16-default-dark
" Do incremental searching when it's possible to timeout.
if has('reltime')
set incsearch
endif
"[Always show StatusLine]"
set laststatus=2
"[Do not show mode in command line]"
set noshowmode
"[Splitting rules]"
set splitbelow
set splitright
set equalalways
"[Lisp coding settings]"
if (&filetype == "lisp")
set lisp
" LaTeX ftdetect
let g:tex_flavor = "latex"
" Switch syntax highlighting on when the terminal has colors or when using the
" GUI (which always has colors).
if &t_Co > 2 || has("gui_running")
" Revert with ":syntax off".
syntax on
" I like highlighting strings inside C comments.
" Revert with ":unlet c_comment_strings".
let c_comment_strings=1
endif
"[Don't use the mouse in terminal]"
set mouse=
set mousemodel=extend
"[Fix mouse past column 222]"
if has("mouse_sgr")
set ttymouse=sgr
else
set ttymouse=xterm2
end
"[Hide mouse while printing the text]"
set mousehide
"[Visualisation settings]"
set background=dark
set ttyfast
set tabline=""
"[Kitty doesn't support background color erase]"
let &t_ut=''
" set cmdheight=1 : default
set showtabline=0
set colorcolumn=80
set nocursorcolumn
set cmdwinheight=10
set virtualedit=all
"[GUI/Color Scheme/Font settings]"
if has("gui_running")
winsize 90 50
silent cd $HOME
set linespace=0
set guioptions=""
set guitablabel=""
if has("autocmd")
autocmd InsertEnter * set cursorline
autocmd InsertLeave * set nocursorline
endif
if has("win32") || has("win64")
try
colorscheme solarized
set guifont=PT_Mono:h12
catch
endtry
elseif has("unix")
try
colorscheme solarized
set guifont=Liberation\ Mono\ 10
catch
endtry
elseif has("mac")
try
set antialias
colorscheme solarized
set guifont=Monaco:h12
catch
endtry
endif
else
if has("unix") || has("mac")
try
set t_Co=16
let g:solarized_termtrans=1
let g:solarized_termcolors=16
colorscheme solarized
catch
endtry
endif
endif
"[Backspace functions]"
set backspace=indent,eol,start
"[Scroll settings]"
set scrolloff=10
set scrolljump=10
set showmatch
set matchpairs=\":\"
set matchpairs+=(:)
set matchpairs+={:}
set matchpairs+=[:]
"set matchpairs+=<:> : too annoying
"[Turn backup off and value of history]"
set nobackup
set noswapfile
set history=1000
set nowritebackup
set undolevels=5000
"[Indent & Tab/mode-line settings]"
set breakindent
set nopaste
set modeline
set smarttab
set tabstop=4
set expandtab
set autoindent
set copyindent
set smartindent
set cinwords=except,finally,def,class,with,do,if,elif,else,for,while,try,switch
set cinoptions+=l1
set modelines=1
set shiftwidth=4
set softtabstop=4
"[TextWidth settings]"
set textwidth=0
"[Settings of line numbers]"
set number
set numberwidth=2
set relativenumber
"[Don't show current position]"
set ruler
"[For regular expressions turn magic on]"
set magic
"[Search settings]"
set hlsearch
set incsearch
set smartcase
set ignorecase
set wrapscan
"[When on, the ":substitute" flag 'g' is default on]"
set nogdefault
"[Language settings]"
set iminsert=0
set imsearch=0
set helplang=en
set langmenu=en
language messages POSIX
"[Show DocName in title]"
set title
"[Hide/show the white-space and more invisible symbols]"
set list
set listchars=nbsp,trail:-
"set listchars+=tab:│\ ,
set listchars+=tab:▸\ ,
set nojoinspaces
"[Folding settings]"
set foldenable
set foldclose=""
set foldcolumn=0
set foldlevel=99
set foldlevelstart=99
set foldmethod=indent
set foldopen=block,hor,mark,percent,quickfix,search,tag,undo
"[Set to auto-read and to auto-write when
" a file is changed from the outside]"
set autoread
set autowrite
"[Vim will change the current working directory whenever you
" open a file, switch buffers, delete a buffer or open/close a window]"
set autochdir
"[Not be redrawn while executing macros,
" registers that have not been typed]"
set lazyredraw
"[Time-out settings]"
set timeout
set timeoutlen=3000
set ttimeoutlen=100
"[When off a buffer is unloaded when it is abandoned]"
set hidden
"[Switch between buffers. Settings]"
set switchbuf=useopen,usetab,newtab
"[Wrap settings]"
set wrap
set whichwrap=<,>,[,]
set nolinebreak
"[Encoding/FileType settings]"
set encoding=utf-8
set termencoding=utf-8
set fileencoding=utf-8
set fileencodings=utf-8,latin1,cp1251,koi8-r,utf-16le
"[Use UNIX, DOS, MAC FileType]"
set fileformat=unix
set fileformats=unix,mac,dos
"[Better consistency between Windows and UNIX]"
set sessionoptions=""
set viewoptions=folds,options,cursor,unix,slash
set sessionoptions+=unix,slash,blank,buffers,curdir
set sessionoptions+=folds,help,options,tabpages,winsize
"[Completion settings]"
" Only do this part when compiled with support for autocommands.
if has("autocmd")
autocmd FileType c set omnifunc=ccomplete#Complete
autocmd FileType css set omnifunc=csscomplete#CompleteCSS
autocmd FileType html set omnifunc=htmlcomplete#CompleteTags
if has("ruby")
autocmd FileType ruby set omnifunc=rubycomplete#Complete
endif
if has("perl")
autocmd FileType perl set omnifunc=perlcomplete#CompletePERL
endif
if has("python")
autocmd FileType python set omnifunc=pythoncomplete#Complete
endif
autocmd FileType javascript set omnifunc=javascriptcomplete#CompleteJS
endif
"[Completion search settings]"
set complete=.,b,d,i,k,s,t,u,U,w
set completeopt=longest,menuone,preview,menu
"[For jump between Java import statement]"
set includeexpr=substitute(v:fname,'\\.','/','g')
"[Determines the maximum number of items
" to show in the popup menu for Insert mode completion]"
set pumheight=7
"[No annoying sound or errors]"
set noerrorbells
set novisualbell
"[Shared with OS clipboard]"
set clipboard=unnamed
"[Abbreviations]"
cnoreabbrev W w
cnoreabbrev Q q
"[Turn on the wild menu and wild-mode settings]"
set wildmenu
set wildmode=list:longest,full
set wildignore=*.o,*.obj,*.pyc,*.pyo,*.swp,*.bak,*.exe,*.class
"[Use a GUI dialog when confirming]"
set confirm
"[Method used for encryption when the buffer is written to a file]"
if (version <= 702)
set cryptmethod=zip
else
set cryptmethod=blowfish
endif
"[Make the scripts executable]"
function! ChangeScriptMode()
if getline(1) =~ "#!"
if getline(1) =~ "bin/"
silent !chmod +x <afile>
endif
endif
endfunction
if has("unix") || has("mac")
if has("autocmd")
autocmd BufWritePost * call ChangeScriptMode()
endif
endif
"[Python/Perl scripts templates]"
function! InitScriptFile(type)
if (a:type == "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")
execute setline(2, "")
execute setline(3, "use warnings;")
execute setline(4, "use strict;")
endif
normal Go
endfunction
if has("autocmd")
autocmd BufNewFile *.pl,*.pm call InitScriptFile("perl")
autocmd BufNewFile *.py,*.pyw call InitScriptFile("python")
endif
"[Remove tabs and spaces at the end of lines]"
function! DeleteTrailingTWS()
if &ft =~ 'diff'
return
end
normal mb
silent %s/[ \t]*$//g
silent %s/\s\+$//ge
normal 'b
endfunction
"[Do not clean up trailing spaces in binary mode]"
if has("autocmd") && !&binary
autocmd BufWritePre *.py,*.pyw retab
autocmd BufWritePre * call DeleteTrailingTWS()
endif
"[Toggle relativenumber between normal & insert mode]"
"[Credit: https://jeffkreeftmeijer.com/vim-number/#relative-line-numbers ]"
if has("autocmd")
augroup numbertoggle
autocmd!
autocmd BufEnter,FocusGained,InsertLeave * set relativenumber
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
" Enable file type detection.
" Use the default filetype settings, so that mail gets 'tw' set to 72,
" 'cindent' is on in C files, etc.
" Also load indent files, to automatically do language-dependent indenting.
" Revert with ":filetype off".
filetype plugin indent on
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
" Put these in an autocmd group, so that you can revert them with:
" ":augroup vimStartup | au! | augroup END"
augroup vimStartup
au!
function! LineInfo()
return !&binary ? '%3l:%-2v' : '%3l:%-2v off:%o,0x%O'
endfunction
" When editing a file, always jump to the last known cursor position.
" Don't do it when the position is invalid, when inside an event handler
" (happens when dropping a file on gvim) and for a commit message (it's
" likely a different one than last time).
autocmd BufReadPost *
\ if line("'\"") >= 1 && line("'\"") <= line("$") && &ft !~# 'commit'
\ | exe "normal! g`\""
\ | endif
if has("autocmd")
autocmd User ALELint call s:MaybeUpdateLightline()
autocmd VimResized * wincmd =
endif
augroup END
" 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
endif " has("autocmd")