Browse Source

Split vim and nvim config

Thomas Dy 8 years ago
parent
commit
7279a24250
5 changed files with 351 additions and 132 deletions
  1. 3 0
      .gitignore
  2. 41 0
      .vim/autoload/airline/extensions/denite.vim
  3. 0 1
      .vim/init.vim
  4. 240 0
      .vim/init.vim
  5. 67 131
      .vimrc

+ 3 - 0
.gitignore

@@ -11,6 +11,9 @@
 !.vim/init.vim
 !.vim/autoload
 !.vim/autoload/plug.vim
+!.vim/autoload/airline
+!.vim/autoload/airline/extensions
+!.vim/autoload/airline/extensions/denite.vim
 !.vimrc
 !.zsh
 !.zsh/**

+ 41 - 0
.vim/autoload/airline/extensions/denite.vim

@@ -0,0 +1,41 @@
+" MIT License. Copyright (c) 2017 Thomas Dy
+" vim: et ts=2 sts=2 sw=2
+
+scriptencoding utf-8
+
+if !get(g:, 'loaded_denite', 0)
+  finish
+endif
+
+" Denite does not use vim's built-in modal editing but has a custom prompt
+" that implements its own insert/normal mode so we have to handle changing the
+" highlight
+function! airline#extensions#denite#check_denite_mode(bufnr)
+  let l:mode = split(denite#get_status_mode(), ' ')
+  let l:mode = tolower(l:mode[1])
+  call airline#highlighter#highlight([l:mode], a:bufnr)
+  return ''
+endfunction
+
+function! airline#extensions#denite#apply(...)
+  if &ft == 'denite'
+    call a:1.add_section('airline_a', ' Denite %{airline#extensions#denite#check_denite_mode('.a:2['bufnr'].')}')
+    call a:1.add_section('airline_c', ' %{denite#get_status_sources()}')
+    call a:1.split()
+    call a:1.add_section('airline_y', ' %{denite#get_status_path()} ')
+    call a:1.add_section('airline_z', ' %{denite#get_status_linenr()} ')
+    return 1
+  endif
+endfunction
+
+function! airline#extensions#denite#init(ext)
+  call denite#custom#option('_', 'statusline', 0)
+  call a:ext.add_statusline_func('airline#extensions#denite#apply')
+
+  " The denite window does not have FileType denite when it's created
+  " so we have to manually update statusline when the FileType is set
+  augroup airline_denite
+    autocmd!
+    autocmd FileType denite call airline#update_statusline()
+  augroup END
+endfunction

+ 0 - 1
.vim/init.vim

@@ -1 +0,0 @@
-../.vimrc

+ 240 - 0
.vim/init.vim

@@ -0,0 +1,240 @@
+call plug#begin('~/.vim/plugged')
+
+Plug 'tpope/vim-sensible'
+Plug 'tpope/vim-sleuth'
+Plug 'tpope/vim-fugitive'
+Plug 'tpope/vim-surround'
+Plug 'bling/vim-airline'
+Plug 'mhinz/vim-signify'
+Plug 'sjl/gundo.vim'
+Plug 'Shougo/denite.nvim'
+Plug 'EinfachToll/DidYouMean'
+Plug 'diepm/vim-rest-console'
+Plug 'idanarye/vim-merginal'
+Plug 'vimwiki/vimwiki'
+
+Plug 'vim-scripts/dbext.vim', {'for': 'sql'}
+Plug 'cespare/vim-toml'
+Plug 'chrisbra/csv.vim'
+
+if executable('lein')
+  Plug 'guns/vim-sexp'
+  Plug 'tpope/vim-sexp-mappings-for-regular-people'
+  Plug 'tpope/vim-fireplace', {'for': 'clojure'}
+endif
+
+if executable('sbt')
+  Plug 'derekwyatt/vim-scala'
+endif
+
+if executable('kotlin')
+  Plug 'udalov/kotlin-vim'
+endif
+
+if executable('ansible')
+  Plug 'pearofducks/ansible-vim'
+endif
+
+if executable('rustc')
+  Plug 'rust-lang/rust.vim'
+endif
+
+if executable('npm')
+  Plug 'pangloss/vim-javascript'
+  Plug 'mxw/vim-jsx'
+endif
+
+if executable('qml')
+  Plug 'peterhoeg/vim-qml'
+endif
+
+Plug 'trusktr/seti.vim'
+
+call plug#end()
+
+" ----- plugin settings ------
+let g:signify_vcs_list = [ 'git' ]
+
+let g:jsx_ext_required = 0
+
+let g:airline_left_sep=''
+let g:airline_right_sep=''
+
+let g:vimwiki_list = [{'path': '~/.root/home/wiki'}]
+
+call denite#custom#option('_', 'cursor_wrap', 1)
+call denite#custom#option('_', 'prompt', '>')
+
+call denite#custom#map(
+      \ 'insert',
+      \ 'jj',
+      \ '<denite:quit>',
+      \ 'noremap'
+      \)
+call denite#custom#map(
+      \ 'insert',
+      \ '<C-j>',
+      \ '<denite:move_to_next_line>',
+      \ 'noremap'
+      \)
+call denite#custom#map(
+      \ 'insert',
+      \ '<C-k>',
+      \ '<denite:move_to_previous_line>',
+      \ 'noremap'
+      \)
+call denite#custom#map(
+      \ 'insert',
+      \ '<C-s>',
+      \ '<denite:do_action:split>',
+      \ 'noremap'
+      \)
+call denite#custom#map(
+      \ 'insert',
+      \ '<C-v>',
+      \ '<denite:do_action:vsplit>',
+      \ 'noremap'
+      \)
+
+" use rg or ag if present
+if executable('rg')
+  call denite#custom#var('file_rec', 'command',
+        \ ['rg', '--files', '--glob', '!.git', ''])
+  call denite#custom#var('grep', 'command', ['rg'])
+  call denite#custom#var('grep', 'default_opts',
+        \ ['--vimgrep', '--no-heading'])
+  call denite#custom#var('grep', 'recursive_opts', [])
+  call denite#custom#var('grep', 'pattern_opt', ['--regexp'])
+  call denite#custom#var('grep', 'separator', ['--'])
+  call denite#custom#var('grep', 'final_opts', [])
+elseif executable('ag')
+  call denite#custom#var('file_rec', 'command',
+        \ ['ag', '--follow', '--nocolor', '--nogroup', '-g', ''])
+  call denite#custom#var('grep', 'command', ['ag'])
+  call denite#custom#var('grep', 'default_opts',
+        \ ['-i', '--vimgrep'])
+  call denite#custom#var('grep', 'recursive_opts', [])
+  call denite#custom#var('grep', 'pattern_opt', [])
+  call denite#custom#var('grep', 'separator', ['--'])
+  call denite#custom#var('grep', 'final_opts', [])
+endif
+
+" ------ settings ------
+
+" change terminal title
+set title
+
+" xdg-ish settings
+set undodir=~/.cache/vim/undo,.
+set backupdir=~/.cache/vim/backup,.
+set directory=~/.cache/vim/swap//,.
+
+" default indentation
+set shiftwidth=2
+set tabstop=4
+set expandtab
+
+" permanent undo history
+set undofile
+
+" allow switching buffers
+set hidden
+
+" always scroll
+set scrolloff=99
+
+" show line numbers
+set number
+set relativenumber
+
+" set wordwrap indent
+set nowrap
+set linebreak
+if exists("&breakindent")
+  set breakindent
+  set breakindentopt=shift:2,sbr
+endif
+
+" show whitespace
+set list
+
+" make a new copy of the file for backup
+" setting to no or auto messes with filewatchers
+set backupcopy=yes
+
+" ------ key bindings ------
+
+" ; as :
+nnoremap ; :
+vnoremap ; :
+
+" allow <ESC> via jj in insert mode
+inoremap jj <ESC>
+
+" fix j/k with wraps
+nnoremap j gj
+nnoremap k gk
+vnoremap j gj
+vnoremap k gk
+
+" opening unite
+nnoremap <C-P> :Denite file_rec<cr>
+nnoremap <C-O> :Denite buffer<cr>
+
+imap <C-W> <ESC><C-W>
+nnoremap <C-T>h :tabprev<cr>
+nnoremap <C-T>l :tabnext<cr>
+
+" grepper
+nnoremap <Leader>f :Denite -mode=normal grep:.<CR>
+
+" git
+nnoremap <Leader>gs :Gstatus<CR>
+nnoremap <Leader>gb :Merginal<CR>
+
+" undo tree
+nnoremap <Leader>ut :GundoToggle<CR>
+
+" vimrc
+nnoremap <Leader>ve :vsplit $MYVIMRC<CR>
+nnoremap <Leader>vs :source $MYVIMRC<CR>
+
+" ------ nvim specific ------
+if has('nvim')
+  set inccommand=split
+
+  let g:airline_theme_patch_func = 'AirlineThemePatch'
+  function! AirlineThemePatch(palette)
+    let a:palette.terminal = copy(a:palette.insert)
+  endfunction
+
+  let g:terminal_scrollback_buffer_size = 10000
+
+  tnoremap <C-j><C-j> <C-\><C-N>
+  tmap <C-T> <C-\><C-N><C-T>
+  tmap <C-W> <C-\><C-N><C-W>
+  tmap <C-P> <C-\><C-N><C-P>
+  tmap <C-O> <C-\><C-N><C-O>
+
+  tnoremap <C-V><C-V><C-V> <C-V><C-V>
+  tnoremap <C-V><C-V> <C-V>
+  tnoremap <C-V> <C-\><C-N>"+pi
+
+  autocmd BufWinEnter,WinEnter term://* startinsert
+
+  nnoremap <Leader>tv :vsp term://zsh<CR>
+  nnoremap <Leader>to :term<CR>
+endif
+
+augroup formatting
+  au!
+  " strip trailing whitespace
+  autocmd BufWritePre * :%s/\s\+$//e
+  autocmd FileType markdown :set tw=80
+augroup end
+
+colorscheme seti
+
+if filereadable(expand('~/.vimrc.local'))
+  source ~/.vimrc.local
+endif

+ 67 - 131
.vimrc

@@ -1,105 +1,92 @@
-call plug#begin('~/.vim/plugged')
+" Sensible.vim
 
-Plug 'tpope/vim-sensible'
-Plug 'tpope/vim-sleuth'
-Plug 'tpope/vim-fugitive'
-Plug 'tpope/vim-surround'
-Plug 'bling/vim-airline'
-Plug 'mhinz/vim-signify'
-Plug 'sjl/gundo.vim'
-Plug 'Shougo/unite.vim'
-Plug 'Shougo/vimproc.vim', {'do' : 'make'}
-Plug 'EinfachToll/DidYouMean'
-Plug 'diepm/vim-rest-console'
-Plug 'idanarye/vim-merginal'
-Plug 'vimwiki/vimwiki'
-
-Plug 'vim-scripts/dbext.vim', {'for': 'sql'}
-Plug 'cespare/vim-toml'
-Plug 'chrisbra/csv.vim'
-
-if executable('lein')
-  Plug 'guns/vim-sexp'
-  Plug 'tpope/vim-sexp-mappings-for-regular-people'
-  Plug 'tpope/vim-fireplace', {'for': 'clojure'}
+if exists('g:loaded_sensible') || &compatible
+  finish
+else
+  let g:loaded_sensible = 1
 endif
 
-if executable('sbt')
-  Plug 'derekwyatt/vim-scala'
+if has('autocmd')
+  filetype plugin indent on
 endif
-
-if executable('kotlin')
-  Plug 'udalov/kotlin-vim'
+if has('syntax') && !exists('g:syntax_on')
+  syntax enable
 endif
 
-if executable('ansible')
-  Plug 'pearofducks/ansible-vim'
-endif
+" Use :help 'option' to see the documentation for the given option.
 
-if executable('rustc')
-  Plug 'rust-lang/rust.vim'
-endif
+set autoindent
+set backspace=indent,eol,start
+set complete-=i
+set smarttab
 
-if executable('npm')
-  Plug 'pangloss/vim-javascript'
-  Plug 'mxw/vim-jsx'
-endif
+set nrformats-=octal
+
+set ttimeout
+set ttimeoutlen=100
 
-if executable('qml')
-  Plug 'peterhoeg/vim-qml'
+set incsearch
+" Use <C-L> to clear the highlighting of :set hlsearch.
+if maparg('<C-L>', 'n') ==# ''
+  nnoremap <silent> <C-L> :nohlsearch<C-R>=has('diff')?'<Bar>diffupdate':''<CR><CR><C-L>
 endif
 
-Plug 'trusktr/seti.vim'
+set laststatus=2
+set ruler
+set wildmenu
 
-call plug#end()
+if !&scrolloff
+  set scrolloff=1
+endif
+if !&sidescrolloff
+  set sidescrolloff=5
+endif
+set display+=lastline
 
-" ----- plugin settings ------
-let g:signify_vcs_list = [ 'git' ]
+if &encoding ==# 'latin1' && has('gui_running')
+  set encoding=utf-8
+endif
+
+if &listchars ==# 'eol:$'
+  set listchars=tab:>\ ,trail:-,extends:>,precedes:<,nbsp:+
+endif
 
-let g:jsx_ext_required = 0
+if v:version > 703 || v:version == 703 && has("patch541")
+  set formatoptions+=j " Delete comment character when joining commented lines
+endif
 
-let g:unite_enable_auto_select = 0
+if has('path_extra')
+  setglobal tags-=./tags tags-=./tags; tags^=./tags;
+endif
 
-let g:airline_left_sep=''
-let g:airline_right_sep=''
+if &shell =~# 'fish$' && (v:version < 704 || v:version == 704 && !has('patch276'))
+  set shell=/bin/bash
+endif
 
-let g:vimwiki_list = [{'path': '~/.root/home/wiki'}]
+set autoread
 
-" use rg or ag if present
-if executable('rg')
-  let g:unite_source_rec_async_command =
-        \ ['rg', '--follow', '--hidden', '--files']
-  let g:unite_source_grep_command = 'rg'
-  let g:unite_source_grep_default_opts = '-i --vimgrep --hidden'
-  let g:unite_source_grep_recursive_opt = ''
-elseif executable('ag')
-  let g:unite_source_rec_async_command =
-        \ ['ag', '--follow', '--nocolor', '--nogroup',
-        \  '--hidden', '-g', '']
-  let g:unite_source_grep_command = 'ag'
-  let g:unite_source_grep_default_opts = '-i --vimgrep --hidden'
-  let g:unite_source_grep_recursive_opt = ''
+if &history < 1000
+  set history=1000
+endif
+if &tabpagemax < 50
+  set tabpagemax=50
+endif
+if !empty(&viminfo)
+  set viminfo^=!
 endif
+set sessionoptions-=options
 
-autocmd FileType unite call s:unite_settings()
-function! s:unite_settings()
-  " Enable navigation with control-j and control-k in insert mode
-  imap <buffer> <C-j>   <Plug>(unite_select_next_line)
-  imap <buffer> <C-k>   <Plug>(unite_select_previous_line)
-  inoremap <silent><buffer><expr> <C-s> unite#do_action('split')
-  inoremap <silent><buffer><expr> <C-v> unite#do_action('vsplit')
-  nnoremap <silent><buffer><expr> s unite#do_action('split')
-  nnoremap <silent><buffer><expr> v unite#do_action('vsplit')
-endfunction
+" Allow color schemes to do bright colors without forcing bold.
+if &t_Co == 8 && $TERM !~# '^linux\|^Eterm'
+  set t_Co=16
+endif
 
-call unite#custom#profile('default', 'context', {
-\   'split': 0,
-\   'ignorecase': 1,
-\   'prompt': '> ',
-\   'direction': 'topright',
-\ })
+" Load matchit.vim, but only if the user hasn't installed a newer version.
+if !exists('g:loaded_matchit') && findfile('plugin/matchit.vim', &rtp) ==# ''
+  runtime! macros/matchit.vim
+endif
 
-" ------ settings ------
+inoremap <C-U> <C-G>u<C-U>
 
 " change terminal title
 set title
@@ -157,55 +144,6 @@ nnoremap k gk
 vnoremap j gj
 vnoremap k gk
 
-" opening unite
-nnoremap <C-P> :Unite -buffer-name=files -start-insert file_rec/async<cr>
-nnoremap <C-O> :Unite -buffer-name=buffers -start-insert buffer<cr>
-
-imap <C-W> <ESC><C-W>
-nnoremap <C-T>h :tabprev<cr>
-nnoremap <C-T>l :tabnext<cr>
-
-" grepper
-nnoremap <Leader>f :Unite grep:.<CR>
-
-" git
-nnoremap <Leader>gs :Gstatus<CR>
-nnoremap <Leader>gb :Merginal<CR>
-
-" undo tree
-nnoremap <Leader>ut :GundoToggle<CR>
-
-" vimrc
-nnoremap <Leader>ve :vsplit $MYVIMRC<CR>
-nnoremap <Leader>vs :source $MYVIMRC<CR>
-
-" ------ nvim specific ------
-if has('nvim')
-  set inccommand=split
-
-  let g:airline_theme_patch_func = 'AirlineThemePatch'
-  function! AirlineThemePatch(palette)
-    let a:palette.terminal = copy(a:palette.insert)
-  endfunction
-
-  let g:terminal_scrollback_buffer_size = 10000
-
-  tnoremap <C-j><C-j> <C-\><C-N>
-  tmap <C-T> <C-\><C-N><C-T>
-  tmap <C-W> <C-\><C-N><C-W>
-  tmap <C-P> <C-\><C-N><C-P>
-  tmap <C-O> <C-\><C-N><C-O>
-
-  tnoremap <C-V><C-V><C-V> <C-V><C-V>
-  tnoremap <C-V><C-V> <C-V>
-  tnoremap <C-V> <C-\><C-N>"+pi
-
-  autocmd BufWinEnter,WinEnter term://* startinsert
-
-  nnoremap <Leader>tv :vsp term://zsh<CR>
-  nnoremap <Leader>to :term<CR>
-endif
-
 augroup formatting
   au!
   " strip trailing whitespace
@@ -213,8 +151,6 @@ augroup formatting
   autocmd FileType markdown :set tw=80
 augroup end
 
-colorscheme seti
-
 if filereadable(expand('~/.vimrc.local'))
   source ~/.vimrc.local
 endif