|
|
|
@ -1,3 +1,5 @@
|
|
|
|
|
set nocompatible
|
|
|
|
|
|
|
|
|
|
" initial plugin manager installation
|
|
|
|
|
if has('nvim')
|
|
|
|
|
if empty(glob('~/.config/nvim/autoload/plug.vim'))
|
|
|
|
@ -11,8 +13,37 @@ else
|
|
|
|
|
endif
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
let $vimdir = $HOME.'/.vim'
|
|
|
|
|
if has('nvim')
|
|
|
|
|
let $vimdir = $HOME.'/.config/nvim'
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
" OS detection functions
|
|
|
|
|
silent function! OSX()
|
|
|
|
|
return has('macunix')
|
|
|
|
|
endfunction
|
|
|
|
|
silent function! LINUX()
|
|
|
|
|
return has('unix') && !has('macunix') && !has('win32unix')
|
|
|
|
|
endfunction
|
|
|
|
|
silent function! WINDOWS()
|
|
|
|
|
return (has('win32') || has('win64'))
|
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
|
|
" tell vim to reload the init.vim file when it saves it
|
|
|
|
|
autocmd! BufWritePost init.vim source %
|
|
|
|
|
" if has('nvim')
|
|
|
|
|
" autocmd! BufWritePost init.vim source %
|
|
|
|
|
" else
|
|
|
|
|
" autocmd! BufWritePost .vimrc source %
|
|
|
|
|
" end
|
|
|
|
|
|
|
|
|
|
" load a per-environment file if one exists
|
|
|
|
|
if filereadable(expand("$HOME/.env_init.vim"))
|
|
|
|
|
source "$HOME/.env_init.vim"
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
if has('vim_starting')
|
|
|
|
|
set encoding=utf8
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
" plugin build functions
|
|
|
|
|
function! BuildComposer(info)
|
|
|
|
@ -26,18 +57,16 @@ function! DoRemote(arg)
|
|
|
|
|
UpdateRemotePlugins
|
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
|
|
" Initialize plugin manager
|
|
|
|
|
" initialize plugin manager
|
|
|
|
|
if has('nvim')
|
|
|
|
|
call plug#begin('~/.config/nvim/bundle')
|
|
|
|
|
else
|
|
|
|
|
call plug#begin('~/.vim/bundle')
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
" let plugin manager manage itself
|
|
|
|
|
Plug 'junegunn/vim-plug'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
" plugins
|
|
|
|
|
|
|
|
|
|
" if vim is being launched to view man pages, don't do our magical session
|
|
|
|
@ -49,6 +78,7 @@ else
|
|
|
|
|
Plug 'dhruvasagar/vim-prosession' " more session ease-of-use
|
|
|
|
|
let g:prosession_dir = '~/.config/nvim/session/'
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
Plug 'vim-airline/vim-airline' " statusline
|
|
|
|
|
" let g:airline_powerline_fonts = 0
|
|
|
|
|
let g:airline#extensions#tabline#enabled = 1 " automatically displays all buffers when there's only one tab open
|
|
|
|
@ -61,6 +91,7 @@ let g:airline_right_alt_sep = ''
|
|
|
|
|
let g:airline_right_sep = ''
|
|
|
|
|
let g:airline_left_alt_sep= ''
|
|
|
|
|
let g:airline_left_sep = ''
|
|
|
|
|
let g:airline#extensions#tabline#buffers_label = ''
|
|
|
|
|
Plug 'vim-airline/vim-airline-themes'
|
|
|
|
|
|
|
|
|
|
Plug 'scrooloose/nerdtree', {'on': ['NERDTreeToggle', 'NERDTree']} " nice sidebar for files
|
|
|
|
@ -76,7 +107,6 @@ Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' } " autocomplete
|
|
|
|
|
let g:deoplete#enable_at_startup = 1
|
|
|
|
|
|
|
|
|
|
Plug 'scrooloose/syntastic' " syntax checker
|
|
|
|
|
Plug 'freitass/todo.txt-vim' " syntax checker
|
|
|
|
|
Plug 'bkad/CamelCaseMotion' " camel case and underscore word movements
|
|
|
|
|
Plug 'LargeFile' " gracefully handle very large files
|
|
|
|
|
Plug 'tpope/vim-commentary' " toggle comments in code easily
|
|
|
|
@ -90,8 +120,8 @@ Plug 'tpope/vim-surround' " quickly modify text surrounding objects
|
|
|
|
|
Plug 'tpope/vim-speeddating' " vim knows about date-like text objects
|
|
|
|
|
Plug 'michaeljsmith/vim-indent-object' " adds an indentation level text object
|
|
|
|
|
Plug 'wellle/targets.vim' " adds some more handy text objects
|
|
|
|
|
Plug 'ternjs/tern_for_vim', { 'do': 'npm install' }
|
|
|
|
|
Plug 'mikewest/vimroom'
|
|
|
|
|
Plug 'ternjs/tern_for_vim', { 'do': 'npm install' } " javascript helpful things
|
|
|
|
|
Plug 'mikewest/vimroom' " distraction-free editing
|
|
|
|
|
Plug 'editorconfig/editorconfig-vim' " loads project-specific editor settings
|
|
|
|
|
let g:vimroom_sidebar_height = 0
|
|
|
|
|
|
|
|
|
@ -100,6 +130,7 @@ Plug 'junegunn/fzf.vim' " helpers for using fzf in vim
|
|
|
|
|
let g:fzf_layout = { 'window': 'enew' }
|
|
|
|
|
|
|
|
|
|
" plugins for specific file types
|
|
|
|
|
|
|
|
|
|
Plug 'kchmck/vim-coffee-script', {'for': ['coffee', 'coffeescript', 'vue']}
|
|
|
|
|
Plug 'posva/vim-vue', {'for': ['vue']}
|
|
|
|
|
Plug 'elixir-lang/vim-elixir', {'for': ['elixir']}
|
|
|
|
@ -109,7 +140,6 @@ Plug 'rust-lang/rust.vim', {'for': ['rs', 'rust']}
|
|
|
|
|
" Plug 'plasticboy/vim-markdown', {'for': ['md', 'markdown']}
|
|
|
|
|
" Plug 'euclio/vim-markdown-composer', { 'do': function('BuildComposer'), 'for': ['md', 'markdown'] }
|
|
|
|
|
Plug 'digitaltoad/vim-jade', {'for': ['pug', 'jade', 'vue']}
|
|
|
|
|
Plug 'freitass/todo.txt-vim', {'for': ['todo']}
|
|
|
|
|
Plug 'leafo/moonscript-vim', {'for': ['moon', 'moonscript']}
|
|
|
|
|
Plug 'evidens/vim-twig'
|
|
|
|
|
Plug 'leafgarland/typescript-vim', {'for': ['ts', 'typescript']}
|
|
|
|
@ -141,18 +171,24 @@ autocmd BufNewFile,BufReadPost *.md setl filetype=markdown spell
|
|
|
|
|
autocmd BufNewFile,BufReadPost *.txt setl spell textwidth=0 wrapmargin=0
|
|
|
|
|
|
|
|
|
|
" whitespace
|
|
|
|
|
" use tabs at a two-space width
|
|
|
|
|
set tabstop=2
|
|
|
|
|
set shiftwidth=2
|
|
|
|
|
set softtabstop=2
|
|
|
|
|
set noexpandtab
|
|
|
|
|
|
|
|
|
|
" auto/smart indent
|
|
|
|
|
set autoindent smartindent
|
|
|
|
|
|
|
|
|
|
" show certain whitespace characters
|
|
|
|
|
set list
|
|
|
|
|
set nostartofline
|
|
|
|
|
set listchars=trail:·,tab:\ \ ,trail:~
|
|
|
|
|
" set listchars=eol:\ ,tab:>-,trail:~,extends:>,precedes:<,space:·
|
|
|
|
|
|
|
|
|
|
" look and feel
|
|
|
|
|
|
|
|
|
|
"
|
|
|
|
|
" try and keep text (and code) to a width of 80 characters
|
|
|
|
|
set wrap
|
|
|
|
|
set linebreak
|
|
|
|
|
set breakindent
|
|
|
|
@ -166,17 +202,27 @@ set formatoptions=crql1j
|
|
|
|
|
" 1 don't break a line after a one-letter word - break it before
|
|
|
|
|
" j where it makes sense, remove a comment leader when joining lines
|
|
|
|
|
|
|
|
|
|
set title " handle window title
|
|
|
|
|
" handle window title
|
|
|
|
|
set title
|
|
|
|
|
|
|
|
|
|
" don't do syntax highlighting on lines longer than 2048 characters
|
|
|
|
|
set synmaxcol=2048
|
|
|
|
|
|
|
|
|
|
if exists('asmanviewer')
|
|
|
|
|
set nonumber " no line numbers when viewing a man page
|
|
|
|
|
else
|
|
|
|
|
set number " line numbers
|
|
|
|
|
endif
|
|
|
|
|
" set relativenumber
|
|
|
|
|
set cursorline " highlight the current line
|
|
|
|
|
|
|
|
|
|
" relative line numbers
|
|
|
|
|
set relativenumber
|
|
|
|
|
|
|
|
|
|
" highlight the current line
|
|
|
|
|
set cursorline
|
|
|
|
|
|
|
|
|
|
" set cursorcolumn " highlight the current column
|
|
|
|
|
" let &colorcolumn=join(range(81,400),",") " colors columns past 80
|
|
|
|
|
|
|
|
|
|
set showcmd
|
|
|
|
|
set nowildmenu
|
|
|
|
|
set wildmode=longest,list,full
|
|
|
|
@ -209,12 +255,17 @@ let base16colorspace=256
|
|
|
|
|
set background=dark
|
|
|
|
|
colorscheme base16-donokai
|
|
|
|
|
|
|
|
|
|
" TODO: need a way to toggle this and maybe make it on by default except in
|
|
|
|
|
" files where space indentation is expected
|
|
|
|
|
fun! ShowSpaceIndentation()
|
|
|
|
|
hi WhiteSpaces ctermfg=black ctermbg=8
|
|
|
|
|
match WhiteSpaces /^ \+/
|
|
|
|
|
hi LeadingWhiteSpaces ctermfg=black ctermbg=8
|
|
|
|
|
endfunction
|
|
|
|
|
fun! HideSpaceIndentation()
|
|
|
|
|
hi LeadingWhiteSpaces ctermfg=black ctermbg=black
|
|
|
|
|
endfunction
|
|
|
|
|
hi LeadingWhiteSpaces ctermfg=black ctermbg=black
|
|
|
|
|
|
|
|
|
|
" a toggle-able minimalistic "distraction-free" text editing mode
|
|
|
|
|
" a toggle-able minimalistic distraction-free text editing mode
|
|
|
|
|
let s:distractionFreeMode = 0
|
|
|
|
|
fun! DistractionFreeModeFunc()
|
|
|
|
|
AirlineToggle
|
|
|
|
@ -248,7 +299,7 @@ fun! CheckCloseDistractionFreeMode()
|
|
|
|
|
endif
|
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
|
|
" run the check function every time we leave a window
|
|
|
|
|
" run the previous checking function every time we leave a window
|
|
|
|
|
if has('autocmd')
|
|
|
|
|
autocmd WinLeave * call CheckCloseDistractionFreeMode()
|
|
|
|
|
endif
|
|
|
|
@ -257,25 +308,27 @@ nnoremap <silent> <Leader>mz :DistractionFreeMode<CR>
|
|
|
|
|
|
|
|
|
|
:command! SpaceIndents call ShowSpaceIndentation()
|
|
|
|
|
:command! ShowSpaceIndents call ShowSpaceIndentation()
|
|
|
|
|
:command! HideSpaceIndents call HideSpaceIndentation()
|
|
|
|
|
:command! DistractionFreeMode call DistractionFreeModeFunc()
|
|
|
|
|
|
|
|
|
|
let $vimdir = $HOME.'/.vim'
|
|
|
|
|
if has('nvim')
|
|
|
|
|
let $vimdir = $HOME.'/.config/nvim'
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
set hidden " allows buffer switching without saving
|
|
|
|
|
set shortmess=I
|
|
|
|
|
set history=1000
|
|
|
|
|
|
|
|
|
|
" undo files
|
|
|
|
|
set undofile
|
|
|
|
|
set undodir=$vimdir/undo
|
|
|
|
|
set undolevels=1000
|
|
|
|
|
set undoreload=10000
|
|
|
|
|
|
|
|
|
|
" backup files
|
|
|
|
|
set backupdir=$vimdir/backup
|
|
|
|
|
set directory=$vimdir/backup
|
|
|
|
|
|
|
|
|
|
" spell file
|
|
|
|
|
set spellfile=$vimdir/spell/en.utf-8.add
|
|
|
|
|
|
|
|
|
|
" smart case insensitivity by default
|
|
|
|
|
set ignorecase
|
|
|
|
|
set smartcase
|
|
|
|
|
set incsearch
|
|
|
|
@ -286,11 +339,8 @@ set foldmethod=syntax
|
|
|
|
|
set foldlevel=99
|
|
|
|
|
set foldnestmax=10
|
|
|
|
|
set nofoldenable
|
|
|
|
|
set foldlevelstart=1
|
|
|
|
|
set foldlevelstart=0
|
|
|
|
|
|
|
|
|
|
if has('vim_starting')
|
|
|
|
|
set encoding=utf8
|
|
|
|
|
endif
|
|
|
|
|
set autowrite
|
|
|
|
|
set autochdir
|
|
|
|
|
set autoread
|
|
|
|
@ -313,6 +363,7 @@ endif
|
|
|
|
|
" no empty buffer on startup
|
|
|
|
|
autocmd VimEnter * nested if bufname('')=='' && line('$') == 1 && col('$')==1 && !&modified | bd % | endif
|
|
|
|
|
|
|
|
|
|
" terminal split in neovim
|
|
|
|
|
if has('nvim')
|
|
|
|
|
function! TerminalSplit()
|
|
|
|
|
let current_file = @%
|
|
|
|
@ -360,8 +411,8 @@ endif
|
|
|
|
|
autocmd BufWinEnter,WinEnter term://* startinsert
|
|
|
|
|
|
|
|
|
|
" change buffers with leader,tab
|
|
|
|
|
nnoremap <leader><Tab> :bnext<CR>
|
|
|
|
|
nnoremap <leader><S-Tab> :bprevious<CR>
|
|
|
|
|
nnoremap <leader><Tab> :bnext<CR>
|
|
|
|
|
nnoremap <leader><S-Tab> :bprevious<CR>
|
|
|
|
|
|
|
|
|
|
" don't kill vim
|
|
|
|
|
nnoremap <leader>K <Nop>
|
|
|
|
@ -390,6 +441,9 @@ nnoremap <C-o> :Files<CR>
|
|
|
|
|
" launch fzf for files modified or not in git
|
|
|
|
|
nnoremap <C-u> :GFiles?<CR>
|
|
|
|
|
|
|
|
|
|
" launch fzf for open buffers (files)
|
|
|
|
|
nnoremap <C-b> :Buffers<CR>
|
|
|
|
|
|
|
|
|
|
" launch fzf for open buffers (files)
|
|
|
|
|
nnoremap <leader>l :Buffers<CR>
|
|
|
|
|
|
|
|
|
@ -413,7 +467,7 @@ inoremap <A-BS> <C-w>
|
|
|
|
|
" clear search higlight
|
|
|
|
|
nnoremap <leader>/ :let @/ = ""<CR>
|
|
|
|
|
|
|
|
|
|
" remap jk and kj to escape in insert mode
|
|
|
|
|
" remap jk/jj and its variants to escape
|
|
|
|
|
inoremap jj <Esc>
|
|
|
|
|
inoremap Jj <Esc>
|
|
|
|
|
inoremap Jj <Esc>
|
|
|
|
@ -442,17 +496,17 @@ omap <silent> ie <Plug>CamelCaseMotion_ie
|
|
|
|
|
xmap <silent> ie <Plug>CamelCaseMotion_ie
|
|
|
|
|
|
|
|
|
|
" a _ objects
|
|
|
|
|
omap <silent> aw <Plug>CamelCaseMotion_aw
|
|
|
|
|
xmap <silent> aw <Plug>CamelCaseMotion_aw
|
|
|
|
|
" omap <silent> aw <Plug>CamelCaseMotion_aw
|
|
|
|
|
" xmap <silent> aw <Plug>CamelCaseMotion_aw
|
|
|
|
|
omap <silent> ab <Plug>CamelCaseMotion_ab
|
|
|
|
|
xmap <silent> ab <Plug>CamelCaseMotion_ab
|
|
|
|
|
omap <silent> ae <Plug>CamelCaseMotion_ae
|
|
|
|
|
xmap <silent> ae <Plug>CamelCaseMotion_ae
|
|
|
|
|
|
|
|
|
|
" remove trailing whitespace:
|
|
|
|
|
" remove trailing whitespace
|
|
|
|
|
map <F3> mw:%s/\s\+$//<CR>:let @/ = ""<CR>'w
|
|
|
|
|
|
|
|
|
|
" close buffer:
|
|
|
|
|
" close buffer with leader-w
|
|
|
|
|
nnoremap <silent> <leader>w :bd<CR>
|
|
|
|
|
|
|
|
|
|
" toggle spell checking:
|
|
|
|
@ -461,7 +515,7 @@ map <F5> :setlocal spell!<CR>
|
|
|
|
|
" open urls, files, etc. example: http://google.com:
|
|
|
|
|
noremap <leader>o :!xdg-open <cfile><CR><CR>
|
|
|
|
|
|
|
|
|
|
" keep that dumb window from popping up
|
|
|
|
|
" keep that dumb window from popping up (wild something or another)
|
|
|
|
|
map q: :q
|
|
|
|
|
noremap qqq: q:
|
|
|
|
|
|
|
|
|
@ -479,3 +533,5 @@ xnoremap > >gv
|
|
|
|
|
|
|
|
|
|
" modify higlight colors
|
|
|
|
|
hi Search cterm=NONE ctermbg=blue ctermfg=black
|
|
|
|
|
highlight LineNr ctermbg=none ctermfg=8
|
|
|
|
|
highlight CursorLineNr ctermbg=18 ctermfg=gray
|
|
|
|
|