vim/vimrc

683 lines
18 KiB
VimL
Raw Normal View History

2017-09-10 20:22:02 +00:00
filetype off " required
set ttyfast
2017-09-10 20:22:02 +00:00
2018-03-15 15:26:21 +00:00
" #plugins{{{
2017-12-26 22:54:44 +00:00
set runtimepath+=~/.vim/bundle/Vundle.vim
2017-09-10 20:22:02 +00:00
call vundle#begin()
Plugin 'VundleVim/Vundle.vim'
"css3-syntax
Plugin 'hail2u/vim-css3-syntax.git'
"scss-syntax
Plugin 'cakebaker/scss-syntax.vim'
"bufexplorer
Plugin 'jlanzarotta/bufexplorer'
"tagbar
Plugin 'majutsushi/tagbar'
"vim-surround
Plugin 'tpope/vim-surround'
"undotree
Plugin 'mbbill/undotree'
" Ctrlp
Plugin 'ctrlpvim/ctrlp.vim'
2017-09-12 11:48:30 +00:00
" Obsession
Plugin 'tpope/vim-obsession'
2017-09-13 17:12:03 +00:00
" vim-css-color
Plugin 'ap/vim-css-color'
2017-09-16 15:02:19 +00:00
" vim-javascript
Plugin 'pangloss/vim-javascript'
2017-09-16 16:24:09 +00:00
" ultisnips
" https://github.com/sirver/UltiSnips
Plugin 'SirVer/ultisnips'
" and some snippets
" https://github.com/honza/vim-snippets
Plugin 'honza/vim-snippets'
2017-09-17 17:18:23 +00:00
" ALE
" https://github.com/w0rp/ale
Plugin 'w0rp/ale'
" MatchTag
" https://github.com/gregsexton/MatchTag
Plugin 'gregsexton/MatchTag'
" phpcomplete.vim
" https://github.com/shawncplus/phpcomplete.vim
Plugin 'shawncplus/phpcomplete.vim'
" https://github.com/dsawardekar/wordpress.vim
" For up to date Wordpress Files see:
" https://github.com/joseluis/wordpress.vim-generator
"Plugin 'dsawardekar/wordpress.vim'
" disabled - doesn't support universal ctags?
2017-09-20 17:45:44 +00:00
" vim-vue
" https://github.com/posva/vim-vue
Plugin 'posva/vim-vue'
2017-09-30 19:52:20 +00:00
" vim-commentary
2017-09-30 19:53:28 +00:00
" https://github.com/tpope/vim-commentary
2017-09-30 19:52:20 +00:00
Plugin 'tpope/vim-commentary'
2017-09-30 19:58:23 +00:00
" vim-repeat
" https://github.com/tpope/vim-repeat
Plugin 'tpope/vim-repeat'
" taboo.vim
" https://github.com/gcmt/taboo.vim
Plugin 'gcmt/taboo.vim'
2017-12-04 13:43:16 +00:00
" https://github.com/mattn/emmet-vim
Plugin 'mattn/emmet-vim'
2018-01-03 22:05:35 +00:00
" vimwiki
" https://github.com/vimwiki/vimwiki
Plugin 'vimwiki/vimwiki'
2018-01-21 21:09:06 +00:00
" youcompleteme
" https://github.com/Valloric/YouCompleteMe
Plugin 'Valloric/YouCompleteMe'
2018-02-23 13:12:42 +00:00
" gitgutter
" https://github.com/airblade/vim-gitgutter/blob/master/README.mkd
Plugin 'airblade/vim-gitgutter'
2018-03-05 16:00:54 +00:00
" vim-peekaboo
2018-03-05 16:05:40 +00:00
" https://github.com/junegunn/vim-peekaboo
2018-03-05 16:00:54 +00:00
Plugin 'junegunn/vim-peekaboo'
2018-03-15 13:54:38 +00:00
" vim-gutentags
" https://github.com/ludovicchabant/vim-gutentags
Plugin 'ludovicchabant/vim-gutentags'
2017-09-10 20:22:02 +00:00
" All of your Plugins must be added before the following line
call vundle#end() " required
filetype plugin indent on " required
2018-03-15 15:26:21 +00:00
"}}}
2018-02-22 18:12:33 +00:00
2018-03-15 15:26:21 +00:00
" #settings{{{
2018-02-22 18:12:33 +00:00
" set t_Sf=<Esc>[3%p1%dm " foreground colour
if &term == 'xterm-256color'
2018-02-03 18:54:18 +00:00
set termguicolors
endif
2018-02-22 18:12:33 +00:00
syntax on
colorscheme customred256
2018-02-10 11:41:22 +00:00
set guioptions-=mTrLb
set guioptions+=c
2018-02-22 18:12:33 +00:00
" set t_Sb=<Esc>[4%p1%dm " background coloru
2018-02-23 13:12:42 +00:00
set updatetime=100
2018-02-11 21:01:24 +00:00
2017-09-30 22:09:41 +00:00
set backupdir=~/.vimtmp
set directory=~/.vimtmp
2018-03-15 13:54:38 +00:00
set tags+=./.tags,.tags;/home/ray/
2018-03-15 12:56:42 +00:00
2018-02-22 18:12:33 +00:00
" persisitent undo file
set undodir=/home/ray/.vim/undodir
set undofile
2018-02-03 14:41:01 +00:00
set clipboard=unnamedplus
2017-09-18 20:20:14 +00:00
set ignorecase
set smartcase
2017-12-26 22:11:45 +00:00
set wildmenu
set wildmode=longest:full,full
set hidden
2017-12-26 22:54:44 +00:00
set background=dark
2017-10-02 10:30:23 +00:00
set number relativenumber
2018-02-22 18:12:33 +00:00
set hlsearch
2017-12-29 16:37:04 +00:00
set foldcolumn=1
2018-02-22 18:12:33 +00:00
set iskeyword+=-
set scrolloff=10
set showcmd
set incsearch
set laststatus=2
set foldmethod=manual
set showmode
set autoindent
set breakindent
set showbreak=
set mouse=a
set listchars=eol,tab:->,trail:~,extends:>,precedes:<,space
2017-09-18 23:25:41 +00:00
2018-02-22 18:12:33 +00:00
set textwidth=180
set formatoptions=cq
set wrapmargin=0
2018-03-15 15:26:21 +00:00
"}}}
2018-02-22 18:12:33 +00:00
2018-03-15 15:26:21 +00:00
" key #mappings{{{
let g:mapleader = "\<space>"
2018-03-15 13:54:38 +00:00
nnoremap <leader>rc :so $MYVIMRC<CR>
" Focus on current fold, close the rest
nnoremap <leader>zz zMzvzz
2018-02-10 11:58:33 +00:00
" replace current word with last yanked/deleted text
2018-02-11 15:28:21 +00:00
nnoremap <leader>rr "_diwP
2018-02-10 11:58:33 +00:00
" replace current word with last yanked text
2018-02-11 15:28:21 +00:00
nnoremap <leader>ry diw"0P
2018-02-10 11:58:33 +00:00
inoremap jk <esc>
2017-12-26 22:32:39 +00:00
nnoremap A :call CheckLineEnding()<CR>
2018-02-25 18:14:54 +00:00
nnoremap <leader>co :!clear;
2018-03-01 21:35:28 +00:00
2018-03-05 16:25:30 +00:00
nnoremap <leader>gs :!clear; echo 'git status'; git status<CR>
nnoremap <leader>gd :!clear; echo 'git diff'; git diff<CR>
2018-03-05 14:26:44 +00:00
nnoremap <leader>ga :!clear; git add %; git status<CR>
nnoremap <leader>gA :!clear; git add .; git status<CR>
2018-03-01 21:35:28 +00:00
nnoremap <leader>gc :!clear; git commit -m ''<Left>
2018-03-05 16:08:17 +00:00
nnoremap <leader>gg :!clear; git add %; git commit -m ''<Left>
2018-03-05 16:22:44 +00:00
nnoremap <leader>gp :!clear; echo 'git push'; git push<CR>
2018-03-01 21:35:28 +00:00
nnoremap <leader>gl :!clear; git log<CR>
2018-02-18 12:19:37 +00:00
" netrw
nnoremap <leader>ex :Ex<CR>
2018-02-18 12:34:12 +00:00
nnoremap <leader>ee :e .<CR>
2018-02-18 13:07:37 +00:00
nnoremap <leader>eq :Rex<CR>
2017-09-10 20:22:02 +00:00
" better window navigaton
nnoremap <C-h> <C-w>h
nnoremap <C-l> <C-w>l
nnoremap <C-k> <C-w>k
nnoremap <C-j> <C-w>j
2018-02-17 14:15:42 +00:00
nnoremap <Esc>j :resize -5<CR>
nnoremap <Esc>k :resize +5<CR>
nnoremap <Esc>l :vertical resize +5<CR>
2018-02-23 13:41:21 +00:00
nnoremap <Esc>h :vertical resize -5<CR>
2018-02-17 14:24:00 +00:00
nnoremap <Esc>= <C-w>=
2017-09-10 20:22:02 +00:00
2017-12-27 12:43:01 +00:00
"location list and quickfix mappings
nnoremap <leader>ll :botright lwindow<CR>
nnoremap <leader>lp :lprev<CR>
nnoremap <leader>ln :lnext<CR>
nnoremap <leader>lc :lclose<CR>
nnoremap <leader>llh :lhistory<CR>
nnoremap <leader>llp :lolder<CR>
nnoremap <leader>lln :lnewer<CR>
nnoremap <leader>qf :botright cwindow<CR>
nnoremap <leader>qp :cprev<CR>
nnoremap <leader>qn :cnext<CR>
nnoremap <leader>qc :cclose<CR>
nnoremap <leader>qfh :chistory<CR>
nnoremap <leader>qfp :colder<CR>
nnoremap <leader>qfn :cnewer<CR>
2017-12-29 12:24:31 +00:00
nnoremap <leader>nh :noh<CR>
2017-12-27 13:15:57 +00:00
" quick grep of visual selection
vnoremap <leader>gr y:grep! -R <C-r>" .
2017-12-27 13:28:03 +00:00
" open quickfix window of TODOs
2017-12-27 13:46:18 +00:00
nnoremap <leader>td :grep! -R '// *TODO' .<CR>:botright cwindow<CR>:echo len(getqflist()) 'TODOs'<CR>
2017-12-27 13:28:03 +00:00
2017-09-18 21:08:35 +00:00
" brace/quotes completion
2018-02-11 15:28:21 +00:00
inoremap {{ {}<left>
2018-02-11 21:01:24 +00:00
inoremap {<CR> {<CR>}<esc>O
inoremap {; {<CR>};<esc>O
inoremap }} {{}}<Left><Left>
2018-02-11 15:28:21 +00:00
inoremap (( ()<Left>
2018-02-11 21:01:24 +00:00
inoremap (; ();<Left><Left>
2018-02-11 15:28:21 +00:00
inoremap [[ []<Left>
2018-02-11 21:01:24 +00:00
inoremap [<CR> [<CR>]<esc>O
2018-02-11 15:28:21 +00:00
2018-02-11 21:01:24 +00:00
inoremap "" ""<Left>
inoremap "; "";<Left><Left>
inoremap '' ''<Left>
inoremap '; '';<Left><Left>
2018-02-11 15:28:21 +00:00
inoremap ;; ;<esc>
2017-10-04 11:16:08 +00:00
2017-12-29 12:26:05 +00:00
nnoremap <leader>nn :set invrelativenumber<CR>
2017-12-29 12:30:07 +00:00
nnoremap <leader>hl :nohlsearch<CR>
2017-12-29 12:24:31 +00:00
2018-02-11 15:28:21 +00:00
" devdocs mapping
nnoremap <leader>dd :DD<CR>
2018-03-15 15:26:21 +00:00
"}}}
2018-02-11 15:28:21 +00:00
2018-03-15 15:26:21 +00:00
" #abbreviations{{{
iabbrev adn and
iabbrev waht what
iabbrev tehn then
2018-03-15 15:26:21 +00:00
"}}}
2017-09-10 20:22:02 +00:00
2018-03-16 19:56:24 +00:00
" #statusline format
2018-03-06 13:59:45 +00:00
" isactive = 0 when inactive, 1 otherwise
2018-03-15 16:19:18 +00:00
" get status line{{{
2018-03-06 13:59:45 +00:00
function! GetStatus(isactive)
2018-03-17 00:58:49 +00:00
" let l:linter = ale#statusline#Count(bufnr(''))
let l:divider = '- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - >'
let l:separator = '%#StatusLineSeparator# '
let l:normal = '%#StatusLineNormal#'
let l:active = '%#StatusLineActive#'
let l:bracket_open = '%#CRNoiseDark#('
let l:bracket_close = '%#CRNoiseDark#) '
let l:statusline = ''
" let l:statusline = '%#CRNoise#b%#CRNoiseDark#:%#CRNoiseBright#%n '
2018-03-16 19:56:24 +00:00
" let l:curbuf = bufnr('')
" let l:statusline .= '%#CRNormal#' . l:curbuf . ': ' . &buftype . ' '
2018-03-17 12:46:20 +00:00
" file percentage
let l:statusline.='%#FoldColumn#: %#InterfaceNormal# %P%* '
if a:isactive
2018-03-17 12:46:20 +00:00
let l:statusline.=l:active . ' %q%h%w%#StatusLineActiveNoText#'
else
2018-03-17 12:46:20 +00:00
let l:statusline.=l:normal . ' %q%h%w%#StatusLineNormalNoText#'
endif
let l:statusline .= "%{&buftype == '' ? '' : ' '}%s "
2018-03-16 19:56:24 +00:00
2018-03-15 17:12:20 +00:00
"}}}
2018-03-16 19:56:24 +00:00
2018-03-15 17:12:20 +00:00
" file info{{{
2018-03-06 13:59:45 +00:00
if a:isactive == 1
2018-03-15 17:12:20 +00:00
let l:statusline.=l:active
2018-03-17 12:46:20 +00:00
let l:statusline.="%{strlen(&ft)?&ft:'none'} "
let l:statusline.=l:separator . l:active
let l:statusline.=' %{strlen(&fenc)?&fenc:&enc} '
let l:statusline.=l:separator . l:active
let l:statusline.=' %{&fileformat} '
2018-03-15 17:12:20 +00:00
let l:statusline.=l:separator . l:active
let l:statusline.=' %{&spelllang} '
2018-03-06 13:59:45 +00:00
else
let l:statusline.=l:separator
2018-03-05 21:27:09 +00:00
endif
2018-03-15 17:12:20 +00:00
"}}}
2018-03-16 19:56:24 +00:00
2018-03-15 17:12:20 +00:00
" current register{{{
2018-03-06 13:59:45 +00:00
if a:isactive
2018-03-15 17:12:20 +00:00
let l:statusline.=l:separator . l:active
let l:statusline.=' %#StatusLineActiveQuotes#"' . l:active . '%{v:register}%#StatusLineActiveQuotes#" '
2018-03-06 13:59:45 +00:00
endif
2018-03-15 17:12:20 +00:00
"}}}
2018-03-16 19:56:24 +00:00
2018-03-15 17:12:20 +00:00
" session status{{{
2018-03-06 13:59:45 +00:00
if a:isactive
2018-03-15 17:12:20 +00:00
let l:statusline.=l:separator . l:active
2018-03-06 13:59:45 +00:00
let l:statusline.=" %{ObsessionStatus(fnamemodify(v:this_session,':t'),'---')} %*"
2018-03-15 17:12:20 +00:00
let l:statusline.=l:separator . l:active
2018-03-06 13:59:45 +00:00
endif
2018-03-15 17:12:20 +00:00
"}}}
2018-03-06 13:59:45 +00:00
2018-03-16 19:56:24 +00:00
" right/left divider{{{
2018-03-17 00:58:49 +00:00
2018-03-16 19:56:24 +00:00
" modified version
2018-03-17 00:58:49 +00:00
let l:color = 'StatusLineDivMod' . (a:isactive?'Active':'')
let l:statusline .= GetStatusFrag("&modified && mode() != 'i'", l:color, '%<', l:divider)
2018-03-16 19:56:24 +00:00
" unmodified version
2018-03-17 00:58:49 +00:00
let l:color = 'StatusLineDiv' . (a:isactive?'Active':'')
let l:statusline .= GetStatusFrag("!&modified && mode() != 'i'", l:color, '%<', l:divider)
2018-03-16 19:56:24 +00:00
" input mode version
2018-03-06 13:59:45 +00:00
if a:isactive
2018-03-17 00:58:49 +00:00
let l:statusline .= GetStatusFrag("mode() == 'i'", 'StatusLineDivInput', '%<', l:divider)
2018-03-16 19:56:24 +00:00
endif
2018-03-17 00:58:49 +00:00
let l:statusline.= l:separator . '%*%='
2018-03-15 18:07:58 +00:00
2018-03-16 19:56:24 +00:00
"}}}
2018-03-15 18:07:58 +00:00
2018-03-16 19:56:24 +00:00
" modified flag {{{
" let l:statusline.='%#StatusLineMod#%M' . l:separator . '%*'
"}}}
2018-03-15 18:07:58 +00:00
2018-03-16 19:56:24 +00:00
" path/filename.extension{{{
2018-03-16 19:56:24 +00:00
if a:isactive
let l:statusline.='%#StatusLineDirActive# '
let l:statusline.="%{expand('%:p:h:t')}/"
let l:statusline.='%#StatusLineFileActive#'
let l:statusline.="%{expand('%:t:r')}"
let l:statusline.='%#StatusLineDotActive#'
let l:statusline.="%{strlen(expand('%:e'))?'.':''}"
let l:statusline.='%#StatusLineExtActive#'
let l:statusline.="%{strlen(expand('%:e'))?expand('%:e'):expand('%:e')}"
let l:statusline.=' %*'
else
let l:statusline.='%#StatusLineDir# '
let l:statusline.="%{expand('%:p:h')}/"
let l:statusline.='%#StatusLineFile#'
let l:statusline.="%{expand('%:t:r')}"
let l:statusline.='%#StatusLineDot#'
let l:statusline.="%{strlen(expand('%:e'))?'.':''}"
let l:statusline.='%#StatusLineExt#'
let l:statusline.="%{strlen(expand('%:e'))?expand('%:e'):expand('%:e')}"
let l:statusline.=' %*'
endif
2018-03-17 12:46:20 +00:00
let l:statusline .= '%#CRNormal#%r' " TODO color
2018-03-06 13:59:45 +00:00
"}}}
2018-03-16 19:56:24 +00:00
2018-03-17 00:58:49 +00:00
" linter status "{{{
" let l:statusline.= "%{LinterStatus()} "
if a:isactive
" errors
let l:statusline .= " %#CRNoiseDark#%{(GetLinterStatus('error') == 0?'-':'')}"
let l:statusline .= "%#InterfaceSignError#%{(GetLinterStatus('error') == 0?'':GetLinterStatus('error'))}"
" style errors
let l:statusline .= '%#CRNoiseDarker#|'
let l:statusline .= "%#CRNoiseDark#%{(GetLinterStatus('style_error') == 0?'-':'')}"
let l:statusline .= "%#InterfaceSignErrorDark#%{(GetLinterStatus('style_error') == 0?'':GetLinterStatus('style_error'))} "
" warnings
let l:statusline .= "%#CRNoiseDark#%{(GetLinterStatus('warning') == 0?'-':'')}"
let l:statusline .= "%#InterfaceSignWarning#%{(GetLinterStatus('warning') == 0?'':GetLinterStatus('warning'))}"
" style warnings
let l:statusline .= '%#CRNoiseDarker#|'
let l:statusline .= "%#CRNoiseDark#%{(GetLinterStatus('style_warning') == 0?'-':'')}"
let l:statusline .= "%#InterfaceSignWarningDark#%{(GetLinterStatus('style_warning') == 0?'':GetLinterStatus('style_warning'))} "
" info
let l:statusline .= "%#CRNoiseDark#%{(GetLinterStatus('info') == 0?'-':'')}"
let l:statusline .= "%#CRNoiseRed#%{(GetLinterStatus('info') == 0?'':GetLinterStatus('info'))}"
else
" errors
let l:statusline .= " %#CRNoiseDarker#%{(GetLinterStatus('error') == 0?'-':'')}"
let l:statusline .= "%#CRNoiseBright#%{(GetLinterStatus('error') == 0?'':GetLinterStatus('error'))}"
" style errors
let l:statusline .= '%#CRNoiseDarker#|'
let l:statusline .= "%{(GetLinterStatus('style_error') == 0?'-':'')}"
let l:statusline .= "%#CRNoiseBright#%{(GetLinterStatus('style_error') == 0?'':GetLinterStatus('style_error'))} "
" warnings
let l:statusline .= "%#CRNoiseDarker#%{(GetLinterStatus('warning') == 0?'-':'')}"
let l:statusline .= "%#CRNoise#%{(GetLinterStatus('warning') == 0?'':GetLinterStatus('warning'))}"
" style warnings
let l:statusline .= '%#CRNoiseDarker#|'
let l:statusline .= "%{(GetLinterStatus('style_warning') == 0?'-':'')}"
let l:statusline .= "%#CRNoise#%{(GetLinterStatus('style_warning') == 0?'':GetLinterStatus('style_warning'))} "
" info
let l:statusline .= "%#CRNoiseDarker#%{GetLinterStatus('info') == 0 ? '-' : GetLinterStatus('info')}"
endif
"}}}
2018-03-17 12:46:20 +00:00
2018-03-05 21:27:09 +00:00
return l:statusline
endfunction
2018-03-17 12:46:20 +00:00
2018-03-16 19:56:24 +00:00
2018-03-15 17:12:20 +00:00
" status line autocommands{{{
2018-03-05 21:27:09 +00:00
augroup status
autocmd!
autocmd WinEnter * setlocal statusline=%!GetStatus(1)
autocmd WinLeave * setlocal statusline=%!GetStatus(0)
2018-03-15 17:12:20 +00:00
" autocmd InsertChange * setlocal statusline=%!GetStatus(1)
2018-03-05 21:27:09 +00:00
augroup END
2018-03-15 17:12:20 +00:00
"}}}}}}
2018-03-16 19:56:24 +00:00
2018-03-15 15:26:21 +00:00
" #autocommands{{{
2017-09-10 20:22:02 +00:00
2018-02-01 17:46:16 +00:00
" persistent folds
augroup AutoSaveFolds
autocmd!
autocmd BufWritePost *.* mkview
2018-02-01 17:46:16 +00:00
autocmd BufWinEnter *.* silent loadview
augroup END
2017-09-10 20:22:02 +00:00
" fix higlight problems such as vertical-align etc
augroup VimCSS3Syntax
autocmd!
autocmd FileType css setlocal iskeyword+=-
augroup END
" Show trailing whitepace and spaces before a tab:
augroup whitespaceerrors
autocmd Syntax * syn match ExtraWhitespace /\s\+$\| \+\ze\t/ containedin=ALL
augroup END
2017-09-12 19:55:49 +00:00
" automatically reload if color scheme file written
augroup coloreload
au!
au BufWritePost customred256.vim so $MYVIMRC
augroup end
2017-12-28 21:01:58 +00:00
augroup linenumbering
autocmd InsertEnter * :set norelativenumber
autocmd InsertLeave * :set number relativenumber
autocmd WinEnter * :set number relativenumber
autocmd WinLeave * set norelativenumber
augroup END
2017-09-12 19:55:49 +00:00
2017-12-28 21:01:58 +00:00
augroup colorcolumns
autocmd WinEnter * set colorcolumn=80
autocmd WinLeave * set colorcolumn=0
augroup END
2017-09-10 20:22:02 +00:00
" Automatically reload .vimrc if chanaged
augroup myvimrc
au!
au BufWritePost .vimrc,_vimrc,vimrc,.gvimrc,_gvimrc,gvimrc so $MYVIMRC | if has('gui_running') | so $MYGVIMRC | endif
augroup END
2018-03-15 15:26:21 +00:00
"}}}
2017-09-10 20:22:02 +00:00
2018-03-15 15:26:21 +00:00
" #functions{{{
2018-02-22 18:12:33 +00:00
2018-03-16 19:56:24 +00:00
" TODO better name
2018-03-17 00:58:49 +00:00
function! GetStatusFrag(condition, colorname, conditionprefix, text) abort "{{{
2018-03-16 19:56:24 +00:00
let l:frag='%#' . a:colorname . '#'
let l:frag.=a:conditionprefix
let l:frag.='%{(' . a:condition . ")?'" . a:text . "':''}"
return l:frag
endfunction"}}}
2018-03-17 00:58:49 +00:00
function! CheckLineEnding() abort "{{{
:normal $
if getline('.')[col('.')-1] == ';' || getline('.')[col('.')-1] == ','
:startinsert
else
:startinsert!
endif
2018-03-16 19:56:24 +00:00
endfunction"}}}
2018-02-22 18:12:33 +00:00
" get name of syntax item
2018-03-17 00:58:49 +00:00
function! SyntaxItem() abort "{{{
2018-02-22 18:12:33 +00:00
return synIDattr(synID(line('.'),col('.'),1),'name') . ' -> ' . synIDattr(synIDtrans(synID(line('.'),col('.'),1)), 'name' )
endfunction
2018-03-16 19:56:24 +00:00
nnoremap <leader>p :echom SyntaxItem()<CR>"}}}
2018-02-22 18:12:33 +00:00
" devdocs DD
" https://gist.github.com/romainl/8d3b73428b4366f75a19be2dad2f0987#file-devdocs-vim
2018-03-16 19:56:24 +00:00
function! s:Get_env() abort "{{{
2018-02-22 18:12:33 +00:00
if has('win64') || has('win32') || has('win16')
return 'WINDOWS'
else
return toupper(substitute(system('uname'), '\n', '', ''))
endif
endfunction
" What command to use on what system
2018-03-05 16:03:26 +00:00
let s:cmds = {'DARWIN': 'open', 'LINUX': 'qutebrowser', 'WINDOWS': 'start'}
2018-02-22 18:12:33 +00:00
" Build the URL stub
let s:stub = s:cmds[<SID>Get_env()] . " 'http://devdocs.io/?q="
command! -nargs=* DD silent! call system(len(split(<q-args>, ' ')) == 0 ?
\ s:stub . &ft . ' ' . expand('<cword>') . "'" : len(split(<q-args>, ' ')) == 1 ?
\ s:stub . &ft . ' ' . <q-args> . "'" : s:stub . <q-args> . "'")
2018-03-16 19:56:24 +00:00
"}}}
2018-02-22 18:12:33 +00:00
" use ranger as file manager
2018-03-17 00:58:49 +00:00
if !exists('*RangerExplorer') "{{{
function RangerExplorer() abort
2018-02-22 18:12:33 +00:00
exec 'silent !ranger --choosefile=/tmp/vim_ranger_current_file ' . expand('%:p:h')
if filereadable('/tmp/vim_ranger_current_file')
exec 'edit ' . system('cat /tmp/vim_ranger_current_file')
call system('rm /tmp/vim_ranger_current_file')
endif
redraw!
endfun
map <Leader>ra :call RangerExplorer()<CR>
2018-03-16 19:56:24 +00:00
endif"}}}
function! LinterStatus() abort "{{{
2018-03-17 00:58:49 +00:00
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
2018-03-16 19:56:24 +00:00
2018-03-17 00:58:49 +00:00
return l:counts.total == 0 ? 'OK' : printf('%dW %dE', l:all_non_errors, l:all_errors)
endfunction
"}}}
2018-03-16 19:56:24 +00:00
2018-03-17 00:58:49 +00:00
function! GetLinterStatus(key) abort "{{{
let l:linter = ale#statusline#Count(bufnr(''))
return l:linter[a:key]
2018-03-16 19:56:24 +00:00
endfunction
2018-03-17 00:58:49 +00:00
2018-03-16 19:56:24 +00:00
"}}}
2018-02-22 18:12:33 +00:00
2018-03-15 15:26:21 +00:00
"}}}
2018-02-22 18:12:33 +00:00
2018-03-15 15:26:21 +00:00
" #plugin settings{{{
2017-09-12 12:09:12 +00:00
2018-03-05 16:00:54 +00:00
" vim-peekaboo
let g:peekaboo_window = 'vert to 30new'
2018-02-23 13:31:14 +00:00
" gitgutter
nmap ]h <Plug>GitGutterNextHunk
nmap [h <Plug>GitGutterPrevHunk
2018-02-23 13:38:26 +00:00
omap ih <Plug>GitGutterTextObjectInnerPending
omap ah <Plug>GitGutterTextObjectOuterPending
xmap ih <Plug>GitGutterTextObjectInnerVisual
xmap ah <Plug>GitGutterTextObjectOuterVisual
2018-02-23 13:31:14 +00:00
2017-12-27 13:15:57 +00:00
" Use the silver searcher ag command instead of grep
if executable('ag')
" Use ag over grep
set grepprg=ag\ --nogroup\ --nocolor
" Use ag in CtrlP for listing files. Lightning fast and respects .gitignore
let g:ctrlp_user_command = 'ag %s -l --nocolor -g ""'
" ag is fast enough that CtrlP doesn't need to cache
let g:ctrlp_use_caching = 0
endif
2017-09-12 12:09:12 +00:00
2018-02-22 20:11:43 +00:00
"vim-wiki
let g:vimwiki_list = [{'path': '~/vimwiki/', 'path_html': '~/vimwiki_html/'}]
2018-01-21 22:07:49 +00:00
" youcompleteme
let g:ycm_collect_identifiers_from_tags_files = 1
2017-12-04 13:43:16 +00:00
" emmet
2018-02-11 15:41:34 +00:00
let g:user_emmet_leader_key='<C-y>'
2017-12-04 13:43:16 +00:00
" taboo.vim
set sessionoptions+=tabpages,globals
2017-12-26 22:54:44 +00:00
let g:taboo_tab_format = ' %f%m '
let g:taboo_renamed_tab_format = ' %l%m '
let g:taboo_modified_tab_flag = '+'
2017-09-20 17:45:44 +00:00
" vue-vim
" disable preprocessor checking for vue files - increases speed
let g:vue_disable_pre_processors=1
2018-03-14 13:02:17 +00:00
" set custom syntax highlighting
augroup fixhighlighting
autocmd BufNewFile,BufRead *.vue syntax sync fromstart
augroup END
2017-09-18 20:20:14 +00:00
2017-09-17 17:18:23 +00:00
" ALE
2017-12-26 22:54:44 +00:00
nnoremap <leader>ne :lnext<cr>
nnoremap <leader>pe :lprev<cr>
2017-09-17 17:18:23 +00:00
let g:ale_sign_error = '>>'
let g:ale_sign_warning = '--'
2017-09-17 17:32:04 +00:00
let g:ale_sign_column_always = 1
2017-09-17 17:18:23 +00:00
let g:ale_linters = {'scss': ['stylelint'], 'javascript': ['eslint'], 'php':['php'], 'html':['htmlhint']}
2017-09-17 17:18:23 +00:00
let g:ale_html_htmlhint_options = '-c ~/.htmlhintrc --format=unix'
let g:ale_fixers = {'javascript': ['eslint']}
2017-09-17 17:18:23 +00:00
2017-09-16 16:24:09 +00:00
" ultisnips
2018-02-11 22:27:09 +00:00
let g:UltiSnipsSnippetsDir="~/.vim/UltiSnips"
2017-09-16 16:24:09 +00:00
" Trigger configuration. Do not use <tab> if you use https://github.com/Valloric/YouCompleteMe.
2018-02-11 21:01:24 +00:00
let g:UltiSnipsExpandTrigger='<c-j>'
2017-12-26 22:54:44 +00:00
let g:UltiSnipsJumpForwardTrigger='<c-b>'
let g:UltiSnipsJumpBackwardTrigger='<c-z>'
2018-02-11 21:01:24 +00:00
let g:UltiSnipsEditSplit='horizontal'
2017-09-16 15:33:22 +00:00
2018-02-18 12:19:37 +00:00
" Netrw
let g:netrw_liststyle=3
2018-02-18 13:27:19 +00:00
let g:netrw_list_hide='^\..*'
2018-02-18 12:19:37 +00:00
2017-09-10 20:22:02 +00:00
" bufexploer
2017-09-16 17:25:59 +00:00
nnoremap <leader>o :BufExplorer<CR>
2017-09-10 20:22:02 +00:00
2017-09-16 17:25:59 +00:00
" undotree
2017-09-10 20:22:02 +00:00
nnoremap <leader>ut :UndotreeToggle<cr>
2017-09-18 20:20:14 +00:00
2018-03-15 12:38:53 +00:00
" TagBar
nnoremap <leader>tb :TagbarOpen fj<CR>
nnoremap <leader>] :tag /[.#@]<c-r>=expand('<cword>')<cr><cr>
let g:tagbar_autoclose = 1
" let g:tagbar_autopreview = 1
" let g:tagbar_previewwin_pos = ''
2017-09-18 20:20:14 +00:00
let g:tagbar_type_css = {
\ 'ctagstype' : 'css',
\ 'kinds' : [
\ 'c:classes',
\ 'i:ids',
\ 't:tags',
\ 'm:medias'
\ ]
\}
2017-09-10 20:22:02 +00:00
let g:tagbar_type_scss = {
\ 'ctagstype' : 'scss',
\ 'kinds' : [
\ 'v:variables',
\ 'c:classes',
\ 'i:ids',
\ 't:tags',
\ 'd:medias',
\ 'm:mixins',
\ 'f:functions'
\ ]
\}
2018-01-21 22:07:49 +00:00
let g:tagbar_type_vue = {
\ 'ctagstype' : 'vue',
\ 'kinds' : [
\ 'o:objects',
\ 'f:functions',
\ 'a:array',
\ 's:string',
\ 'b:boolean',
\ 'n:number',
\ 'v:variable'
\ ]
\ }
2018-03-15 13:54:38 +00:00
" gutentags
let g:gutentags_ctags_tagfile = '.tags'
2018-03-15 14:07:53 +00:00
let g:gutentags_ctags_exclude = ['package.json', 'Session.vim' ,'package-lock.json', 'TODO.txt']
2018-01-21 23:19:09 +00:00
2018-03-15 15:26:21 +00:00
"}}}
2017-09-10 20:22:02 +00:00
2018-03-15 15:26:21 +00:00
" vim: foldmethod=marker