vim/vimrc

430 lines
11 KiB
VimL
Raw Normal View History

2017-09-10 20:22:02 +00:00
set nocompatible " be iMproved, required
filetype off " required
set ttyfast
2017-09-10 20:22:02 +00:00
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
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 15:33:22 +00:00
" vim-mucomplete
" https://github.com/lifepillar/vim-mucomplete
Plugin 'lifepillar/vim-mucomplete'
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-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:
"filetype plugin on
"
" 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
colorscheme customred256
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-09-18 23:25:41 +00:00
" allow hidden buffers
set hidden
set bg=dark
" set number
set nonumber
2017-09-20 10:19:29 +00:00
set hlsearch " highlight searches
" set width of the fold column to create a margin
set foldcolumn=2
2017-09-18 23:25:41 +00:00
" key mappings
let g:mapleader = "\<space>"
" jk acts as escape in insert,visual/select modes
inoremap jk <esc>
2017-09-18 20:20:14 +00:00
"inoremap <esc> <nop>
" 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
nnoremap <Esc>j :resize +1<CR>
nnoremap <Esc>k :resize -1<CR>
nnoremap <Esc>l :vertical resize +1<CR>
nnoremap <Esc>h :vertical resize -1<CR>
nnoremap <leader>ep :lprev<CR>
nnoremap <leader>en :lnext<CR>
2017-09-18 21:08:35 +00:00
" brace/quotes completion
inoremap {{ {<CR><Tab><CR>}<Up><Right>
2017-09-18 21:08:35 +00:00
inoremap (( ()<Left>
inoremap "" ""<Left>
inoremap '' ''<Left>
inoremap [[ []<Left>
2017-09-10 20:22:02 +00:00
" abbreviations
iabbrev adn and
iabbrev waht what
iabbrev tehn then
2017-09-10 20:22:02 +00:00
2017-09-12 19:55:49 +00:00
2017-09-12 11:48:30 +00:00
" statusline format
set statusline=\ %F\ " filename and path
2017-09-12 19:55:49 +00:00
"set statusline+=%{SyntaxItem()}
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
set statusline+=\
set statusline+=[%{strlen(&ft)?&ft:'none'}, " filetype
set statusline+=%{strlen(&fenc)?&fenc:&enc}, " encoding
set statusline+=%{&fileformat}]\ " file format
2017-09-12 11:54:33 +00:00
set statusline+=%{&spelllang}\ \ \ \ \ " Spell language
set statusline+=%{fugitive#statusline()}
2017-09-10 20:22:02 +00:00
2017-09-12 11:48:30 +00:00
set statusline+=%= " left/right separator
set statusline+=[\ %{v:register}\ ]\ " active register
set statusline+=[%{ObsessionStatus(fnamemodify(v:this_session,':t'),'---')}]\ \ " session status
2017-09-16 20:44:08 +00:00
set statusline+=%#InterfaceH2#
2017-09-17 17:18:23 +00:00
"set statusline+=\ %{SyntasticStatuslineFlag()}
set statusline+=\ %{LinterStatus()}
2017-09-16 20:44:08 +00:00
set statusline+=%#InterfaceNormal#
set statusline+=\ %l\
set statusline+=%#InterfaceNormalDark#
set statusline+=(%P)
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
" always show statusline
set laststatus=2
2017-09-10 20:22:02 +00:00
" set a right margin and it's colour
set colorcolumn=100
set foldmethod=manual
2017-09-20 10:19:29 +00:00
" indents and margins
set autoindent
filetype plugin indent on " file type based indentation
2017-09-10 20:22:02 +00:00
syntax on
2017-09-18 22:09:23 +00:00
"set tabstop=2 " leave at default
set expandtab " tab inserts 'softtabstop' number of spaces
" set following with autocommands to override filetype plugin indent
2017-09-20 10:19:29 +00:00
au Filetype * set softtabstop=2 "
au Filetype * set tabstop=2 "
au Filetype * set shiftwidth=2 " affects what happens with >>,<<,== and automatic indentation
set shiftround " round indent to multiples of shiftwidth
set autoindent " copy indent from current line over to new line
2017-09-10 20:22:02 +00:00
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_Co=255 " number of colours
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
autocmd BufNewFile,BufRead *.html set syntax=html_custom
autocmd BufNewFile,BufRead *.php set syntax=php_custom
2017-09-20 17:45:44 +00:00
autocmd BufNewFile,BufRead *.vue set syntax=vue_custom
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
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-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-09-10 20:22:02 +00:00
2017-09-12 19:55:49 +00:00
" Functions
" get name of syntax item
function! SyntaxItem()
2017-09-13 13:25:22 +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>
2017-09-10 20:22:02 +00:00
" plugins stuff
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-16 15:33:22 +00:00
" MUcomplete
set completeopt+=menuone
let g:mucomplete#enable_auto_at_startup = 1
inoremap <expr> <c-e> mucomplete#popup_exit("\<c-e>")
inoremap <expr> <c-y> mucomplete#popup_exit("\<c-y>")
inoremap <expr> <cr> mucomplete#popup_exit("\<cr>")
set completeopt+=noselect
set completeopt+=noinsert
2017-09-16 17:25:59 +00:00
set complete-=i
set complete-=t
let g:mucomplete#chains = { 'default' : ['tags', 'c-p', 'incl', 'file'] }
2017-09-17 17:18:23 +00:00
let g:mucomplete#popup_direction = { 'path' : 1, 'c-p': 1, 'tags': 1, 'incl': 1 }
2017-09-16 15:33:22 +00:00
set shortmess+=c " Shut off completion messages
set belloff+=ctrlg " If Vim beeps during completion
2017-09-16 17:25:59 +00:00
call add(g:mucomplete#chains['default'], 'ulti')
2017-09-17 17:18:23 +00:00
" ALE
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
return l:counts.total == 0 ? 'OK' : printf('%dW %dE', all_non_errors, all_errors)
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.
let g:UltiSnipsExpandTrigger="<Esc><space>"
2017-09-16 16:24:09 +00:00
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
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif
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
" override function so we can have custom tag names for built in languages
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
call project_tags#add_language('.csstags','css')
call project_tags#add_language('.scsstags','scss')
2017-09-18 20:20:14 +00:00
2017-09-18 23:25:41 +00:00
" jsut some example text one two three four five Six "Seven"
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'
\ ]
\}
if !exists("*RangerExplorer")
function RangerExplorer()
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>
endif
" ze end