vim/vimrc

497 lines
13 KiB
VimL
Raw Normal View History

2018-01-03 22:05:35 +00:00
" set nocompatible " be iMproved, required
2017-09-10 20:22:02 +00:00
filetype off " required
set ttyfast
2017-09-10 20:22:02 +00:00
" set the runtime path to include Vundle and initialize
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()
" alternatively, pass a path where Vundle should install plugins
"call vundle#begin('~/some/path/here')
" let Vundle manage Vundle, required
Plugin 'VundleVim/Vundle.vim'
" plugin on GitHub repo
Plugin 'tpope/vim-fugitive'
" Nerdtree and nerdtree-git
Plugin 'scrooloose/nerdtree.git'
Plugin 'Xuyuanp/nerdtree-git-plugin'
"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'
" gutentag
2017-09-18 20:20:14 +00:00
"Plugin 'ludovicchabant/vim-gutentags'
" vim-project-tags
"dependancy needed:
"https://github.com/still-dreaming-1/vim-project-tags
Plugin 'still-dreaming-1/vim-elhiv'
Plugin 'still-dreaming-1/vim-project-tags'
2017-09-10 20:22:02 +00:00
" 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-syntax
" Plugin 'jelera/vim-javascript-syntax'
" 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-19 11:47:45 +00:00
" vim-slash
" https://github.com/junegunn/vim-slash
Plugin 'junegunn/vim-slash'
2018-01-21 21:09:06 +00:00
" youcompleteme
" https://github.com/Valloric/YouCompleteMe
Plugin 'Valloric/YouCompleteMe'
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
" To ignore plugin indent changes, instead use:
"
" Brief help
" :PluginList - lists configured plugins
" :PluginInstall - installs plugins; append `!` to update or just :PluginUpdate
" :PluginSearch foo - searches for foo; append `!` to refresh local cache
" :PluginClean - confirms removal of unused plugins; append `!` to auto-approve removal
"
" see :h vundle for more details or wiki for FAQ
" Put your non-Plugin stuff after this line
2018-01-03 12:53:01 +00:00
" let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum"
" let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum"
" set termguicolors
colorscheme customred256
2017-09-30 22:09:41 +00:00
set backupdir=~/.vimtmp
set directory=~/.vimtmp
2017-09-18 20:20:14 +00:00
" tags file set tags=tags;/
" ignore case when searching
set ignorecase
" unless search contains uppercase
set smartcase
2017-12-26 22:11:45 +00:00
set wildmenu
set wildmode=longest:full,full
2017-09-18 23:25:41 +00:00
" allow hidden buffers
set hidden
2017-12-26 22:54:44 +00:00
set background=dark
" set number
2017-10-02 10:30:23 +00:00
set number relativenumber
2017-09-20 10:19:29 +00:00
set hlsearch " highlight searches
2017-12-29 16:37:04 +00:00
set foldcolumn=1
2017-09-18 23:25:41 +00:00
" key mappings
let g:mapleader = "\<space>"
2017-12-26 22:54:44 +00:00
" jk acts as escape in insert
inoremap jk <esc>
2017-12-26 22:32:39 +00:00
nnoremap <leader>co :!clear;
" disable arrow keys
2017-09-18 20:20:14 +00:00
"noremap <Up> <nop>
"noremap <Down> <nop>
"noremap <Left> <nop>
"noremap <Right> <nop>
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
" better window resizing
" need to use <Esc>j because urxvt sends the character prefixed with Escape
" instead of setting the eighth bit
" see https://unix.stackexchange.com/a/199705
2017-09-28 09:24:07 +00:00
nnoremap <Esc>j :resize +5<CR>
nnoremap <Esc>k :resize -5<CR>
nnoremap <Esc>l :vertical resize +5<CR>
nnoremap <Esc>h :vertical resize -5<CR>
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
2017-12-16 15:27:57 +00:00
inoremap {{ {}<left>
inoremap {{{ {<CR>}<esc>O
inoremap {{{; {<CR>};<esc>O
2017-10-17 14:58:44 +00:00
inoremap }} {{}}<Left><Left>
2017-09-18 21:08:35 +00:00
inoremap (( ()<Left>
2017-12-16 15:27:57 +00:00
inoremap ((; ();<Left><Left>
2017-09-18 21:08:35 +00:00
inoremap "" ""<Left>
2017-12-16 15:27:57 +00:00
inoremap ""; "";<Left><Left>
2017-09-18 21:08:35 +00:00
inoremap '' ''<Left>
2017-12-16 15:27:57 +00:00
inoremap ''; '';<Left><Left>
2017-09-18 21:08:35 +00:00
inoremap [[ []<Left>
2017-12-16 15:27:57 +00:00
inoremap [[[ [<CR>]<esc>O
2017-09-10 20:22:02 +00:00
2017-10-04 11:16:08 +00:00
inoremap ;; ;<esc>
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
" abbreviations
iabbrev adn and
iabbrev waht what
iabbrev tehn then
2017-09-10 20:22:02 +00:00
2017-12-06 11:41:04 +00:00
set iskeyword+=-
2017-10-02 11:25:17 +00:00
set scrolloff=10 " scroll offset
2017-09-24 18:53:18 +00:00
set showcmd " show command in bottom bar
set incsearch
2017-09-12 19:55:49 +00:00
2017-09-12 11:48:30 +00:00
" statusline format
2018-01-18 12:03:14 +00:00
set statusline=%#LineNr#
set statusline+=\ \ \
set statusline+=%#StatusLineFile#
set statusline+=\ \ %t\ \ " filename
2018-01-18 11:32:42 +00:00
set statusline+=%*
set statusline+=%q " quickfix/location list flag
2017-09-12 11:48:30 +00:00
set statusline+=%h " help file flag
set statusline+=%w " preview window flag
set statusline+=%m " modified flag
set statusline+=%r " read only flag
2018-01-18 11:32:42 +00:00
set statusline+=%#StatusLineNC#
2017-09-12 11:48:30 +00:00
set statusline+=\
2018-01-18 11:32:42 +00:00
set statusline+=%*
set statusline+=\ %{strlen(&ft)?&ft:'none'}, " filetype
2017-09-12 11:48:30 +00:00
set statusline+=%{strlen(&fenc)?&fenc:&enc}, " encoding
2018-01-18 12:03:14 +00:00
set statusline+=%{&fileformat}\
2018-01-18 11:32:42 +00:00
set statusline+=%#StatusLineNC#
set statusline+=\
set statusline+=%*
2018-01-18 12:03:14 +00:00
set statusline+=\ %{&spelllang}\
2018-01-18 11:32:42 +00:00
set statusline+=%#StatusLineNC#
set statusline+=\
set statusline+=%*
2017-09-10 20:22:02 +00:00
2017-09-12 11:48:30 +00:00
set statusline+=%= " left/right separator
2018-01-18 11:32:42 +00:00
set statusline+=%#StatusLineNC#
set statusline+=\
set statusline+=%*
2018-01-18 12:03:14 +00:00
set statusline+=\ %{v:register}\
2018-01-18 11:32:42 +00:00
set statusline+=%#StatusLineNC#
set statusline+=\
set statusline+=%*
set statusline+=\ %{ObsessionStatus(fnamemodify(v:this_session,':t'),'---')}\ " session status
2017-09-16 20:44:08 +00:00
set statusline+=%#InterfaceH2#
set statusline+=\ %{LinterStatus()}
2017-09-16 20:44:08 +00:00
set statusline+=%#InterfaceNormalDark#
2018-01-18 11:32:42 +00:00
set statusline+=\ %P\ " percentage through file
2017-09-16 20:44:08 +00:00
set statusline+=%*
2017-09-10 20:22:02 +00:00
2017-09-12 11:48:30 +00:00
set laststatus=2
2017-09-10 20:22:02 +00:00
set foldmethod=manual
2017-09-20 10:19:29 +00:00
set autoindent
2017-12-29 12:24:31 +00:00
set breakindent
set showbreak=
2017-12-18 13:03:08 +00:00
2017-09-10 20:22:02 +00:00
syntax on
set mouse=a
2017-09-18 22:16:32 +00:00
2017-09-20 10:19:29 +00:00
set listchars=eol,tab:->,trail:~,extends:>,precedes:<,space
2017-09-10 20:22:02 +00:00
2017-09-13 13:25:22 +00:00
" rewrapping set to 80
2017-09-20 10:45:09 +00:00
set textwidth=180
2017-09-13 13:25:22 +00:00
" disable automatic wrapping
2017-09-20 10:45:09 +00:00
set formatoptions=cq
2017-09-13 13:25:22 +00:00
" disable wrapping based on terminal size
2017-09-20 10:45:09 +00:00
set wrapmargin=0
2017-09-13 13:25:22 +00:00
2017-09-20 10:19:29 +00:00
set t_Sf=<Esc>[3%p1%dm " foreground colour
set t_Sb=<Esc>[4%p1%dm " background coloru
2017-09-10 20:22:02 +00:00
nnoremap <F2> :set invpaste paste?<CR>
set pastetoggle=<F2>
set showmode
" set custom syntax highlighting
2017-12-28 21:01:58 +00:00
augroup syntaxhighlighting
autocmd BufNewFile,BufRead *.html set syntax=html_custom
autocmd BufNewFile,BufRead *.php set syntax=php_custom
autocmd BufNewFile,BufRead *.vue set syntax=vue_custom
autocmd BufNewFile,BufRead *.vue syntax sync fromstart
autocmd BufNewFile,BufRead *.js set syntax=pangloss_javascript_custom
augroup END
2017-09-12 19:55:49 +00:00
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-10 20:22:02 +00:00
2017-09-12 19:55:49 +00:00
" autocommands
" 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
2017-09-12 12:09:12 +00:00
" persisitent undo file
set undodir=/home/ray/.vim/undodir
set undofile
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
2017-09-10 20:22:02 +00:00
2017-09-12 19:55:49 +00:00
" Functions
" get name of syntax item
function! SyntaxItem()
2017-12-26 22:54:44 +00:00
return synIDattr(synID(line('.'),col('.'),1),'name') . ' -> ' . synIDattr(synIDtrans(synID(line('.'),col('.'),1)), 'name' )
2017-09-12 19:55:49 +00:00
endfunction
nnoremap <leader>p :echom SyntaxItem()<CR>
" plugin stuff
2017-09-10 20:22:02 +00:00
2017-12-04 13:43:16 +00:00
" emmet
2017-12-28 11:34:19 +00:00
let g:user_emmet_leader_key='<c-m>'
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
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_javascript_eslint_options = '-c ~/.config/eslint/.eslintrc.js'
let g:ale_fixers = {'javascript': ['eslint']}
" function! ale#handlers#eslint#FindConfig(buffer)
" return '/home/ray/.config/eslint/.eslintrc.js'
" endfunction
2017-09-17 17:18:23 +00:00
function! LinterStatus() 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
2017-12-26 22:54:44 +00:00
return l:counts.total == 0 ? 'OK' : printf('%dW %dE', l:all_non_errors, l:all_errors)
2017-09-17 17:18:23 +00:00
endfunction
"nmap <silent> <C-k> <Plug>(ale_previous_wrap)
"nmap <silent> <C-j> <Plug>(ale_next_wrap)
2017-09-16 17:25:59 +00:00
2017-09-16 16:24:09 +00:00
" ultisnips
" Trigger configuration. Do not use <tab> if you use https://github.com/Valloric/YouCompleteMe.
2017-12-26 22:54:44 +00:00
let g:UltiSnipsExpandTrigger='<Esc><space>'
let g:UltiSnipsJumpForwardTrigger='<c-b>'
let g:UltiSnipsJumpBackwardTrigger='<c-z>'
2017-09-16 15:33:22 +00:00
2017-09-10 20:22:02 +00:00
" NERDtree
nnoremap <F3> :NERDTreeFocus<CR>
nnoremap <leader>nt :NERDTreeFocus<CR>
" allow closing if only window open is a NERDTree
2017-12-28 21:01:58 +00:00
augroup nerdtreewindow
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif
augroup END
2017-09-18 22:16:32 +00:00
let NERDTreeQuitOnOpen = 1
2017-09-10 20:22:02 +00:00
" TagBar
nnoremap <leader>tb :TagbarOpen fj<CR>
2017-09-18 22:16:32 +00:00
let g:tagbar_autoclose = 1
2017-09-10 20:22:02 +00:00
" tagbar css/scss thingy
nnoremap <leader>] :tag /[.#@]<c-r>=expand('<cword>')<cr><cr>
" 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
" vim-project-tags
source ~/.vim/bundle/vim-elhiv/elhiv.vim
2017-12-26 22:11:45 +00:00
" override function so we can have custom tag names for built in languages
2017-12-26 22:11:45 +00:00
" function! project_tags#add_built_in_language_support()
" call project_tags#add_language('.jstags', 'js')
" call project_tags#add_language('.vimtags', 'vim')
" call project_tags#add_language('.phptags', 'php')
" endfunction
" above function causes error (maybe autoloading problem when no
" tags are being used or whatever?)
" see if following three lines work instead
call project_tags#add_language('.jstags', 'js')
call project_tags#add_language('.vimtags', 'vim')
call project_tags#add_language('.phptags', 'php')
call project_tags#add_language('.csstags','css')
call project_tags#add_language('.scsstags','scss')
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'
\ ]
\}
2017-12-26 22:54:44 +00:00
if !exists('*RangerExplorer')
2017-09-10 20:22:02 +00:00
function RangerExplorer()
2017-12-26 22:54:44 +00:00
exec 'silent !ranger --choosefile=/tmp/vim_ranger_current_file ' . expand('%:p:h')
2017-09-10 20:22:02 +00:00
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>
endif
" ze end