dotfiles/.config/nvim/init.vim

219 lines
4.0 KiB
VimL
Raw Normal View History

2017-02-22 21:49:21 -07:00
" vim-plug---START
call plug#begin('~/.config/nvim/plugged')
" Plugins
2017-05-05 09:53:15 -07:00
Plug 'altercation/vim-colors-solarized'
2017-02-22 21:49:21 -07:00
Plug 'airblade/vim-gitgutter'
2018-03-11 00:22:12 -07:00
Plug 'fatih/vim-go'
Plug 'gabesoft/vim-ags'
Plug 'junegunn/fzf'
2017-06-22 13:24:12 -07:00
Plug 'kchmck/vim-coffee-script'
2017-02-22 21:49:21 -07:00
Plug 'majutsushi/tagbar'
2017-08-23 08:13:13 -07:00
Plug 'posva/vim-vue'
2017-02-27 10:16:29 -07:00
Plug 'scrooloose/nerdcommenter'
2017-02-22 21:49:21 -07:00
Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' }
Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
Plug 'tpope/vim-fugitive'
Plug 'tpope/vim-rails'
Plug 'tpope/vim-surround'
2018-03-11 00:22:20 -07:00
Plug 'vim-scripts/nginx.vim'
2017-02-22 21:49:21 -07:00
call plug#end()
" vim-plug---END
2018-11-27 09:17:01 -07:00
2017-05-05 09:53:15 -07:00
" Solarized
2017-02-22 21:49:21 -07:00
syntax enable
set background=dark
colorscheme solarized
2017-09-08 08:47:42 -07:00
set cursorline
set colorcolumn=80,100
2017-05-05 09:53:15 -07:00
call togglebg#map("")
2017-05-05 09:55:57 -07:00
function SetWhitespace()
if &background == 'dark'
hi Whitespace ctermfg=0
else
hi Whitespace ctermfg=7
end
endfunction
call SetWhitespace()
map <F5> :ToggleBG<CR> :call SetWhitespace()<CR>
2018-07-26 22:04:05 -07:00
set spell
2017-05-05 09:53:15 -07:00
set number
2017-02-22 21:49:21 -07:00
set nowrap
filetype plugin indent on
2017-07-27 08:38:36 -07:00
set mouse=a
2017-02-22 21:49:21 -07:00
set list
2017-05-17 08:23:56 -07:00
set listchars=tab:――,space,trail
2017-02-22 21:49:21 -07:00
2018-11-27 09:17:01 -07:00
autocmd BufRead,BufNewFile
\ *.cs,
\*.java
\ set tabstop=4 shiftwidth=4 expandtab
autocmd BufRead,BufNewFile
\ *.rb,
\*.css,
\*.js,
\*.jsx,
\*.coffee,
\*.erb,
\*.html,
\*.json,
2018-11-27 09:19:01 -07:00
\*.vue,
\*.yml,
\*.yaml
2018-11-27 09:17:01 -07:00
\ set tabstop=2 shiftwidth=2 expandtab
2017-05-17 08:23:12 -07:00
autocmd FileType crontab set backupcopy=yes
2017-02-22 21:49:21 -07:00
function TrimTrailingInvisibles()
let view = winsaveview()
%s/\s\+$//e
call winrestview(view)
endfunction
function TrimTrailingLines()
let view = winsaveview()
%s/\n\+\%$//e
call winrestview(view)
endfunction
augroup maximus
autocmd BufWrite * call TrimTrailingInvisibles() | call TrimTrailingLines()
2018-11-27 09:17:01 -07:00
autocmd BufLeave * if &buftype == ''
\ && !&readonly
\ && &modifiable
\ && &modified
\ && expand("%:t") != ""
\ | call TrimTrailingInvisibles()
\ | call TrimTrailingLines()
\ | w
\ | GitGutter
\ | endif
2017-02-22 21:49:21 -07:00
augroup END
set statusline=%f
set statusline+=\ %y
set statusline+=[%{&ff}]
set statusline+=%r
set statusline+=%h
set statusline+=%{ModifiedSym()}
set statusline+=%=
set statusline+=%{AddGitGutterToStatusline()}
set statusline+=\ [%c:%l/%L:%p%%]
function ModifiedSym()
if &modified
return "[\u270f]"
else
return ""
end
endfunction
function AddGitGutterToStatusline()
if &buftype == '' && exists("b:gitgutter_summary")
return join(["[Git:", join(b:gitgutter_summary, ","), "]"], "")
else
return ""
endif
endfunction
" Shortcuts
2017-05-22 14:18:38 -07:00
" Plugins
2017-02-22 21:49:21 -07:00
nmap <C-\> :NERDTreeToggle<CR>
nmap <leader>. :TagbarToggle<CR>
2017-05-22 14:18:38 -07:00
" Tabs
nmap <leader>tt :tabnew<CR>
nmap <leader>tn :tabnext<CR>
nmap <leader>tp :tabprevious<CR>
2017-07-01 11:13:15 -07:00
nmap <leader>tc :tabclose<CR>
nmap <leader>tm :tabmove<CR>
2017-05-22 14:18:38 -07:00
2017-06-22 13:24:26 -07:00
" Misc
nmap <leader>h :noh<CR>
2018-12-12 16:07:51 -07:00
nnoremap <leader><space> :call Fullscreen()<CR>
function Fullscreen()
let view = winsaveview()
let buf = winbufnr(0)
let found = 0
for b in win_findbuf(buf)
let tabwin = win_id2tabwin(b)
if gettabwinvar(tabwin[0], tabwin[1], "fullscreen_buf") == buf
let found = 1
let existing_tab = tabwin[0]
let existing_win = tabwin[1]
endif
endfor
if found == 1
if existing_tab == tabpagenr()
tabclose
else
exec "tabnext".existing_tab
endif
else
exec "tabnew +buffer".buf
let w:fullscreen_buf = buf
end
call winrestview(view)
endfunction
2017-06-22 13:24:26 -07:00
2017-02-22 21:49:21 -07:00
" Plugin configuration
" The Silver Searcher
nmap <leader>s :Ags<space>
" FZF
nmap <C-p> :FZF!<CR>
2017-05-01 14:52:00 -07:00
2017-02-27 10:16:29 -07:00
" NERD Commenter
let g:NERDSpaceDelims = 1
2018-08-07 08:55:36 -07:00
" NERD Tree
let g:NERDTreeShowHidden = 1
2017-02-22 21:49:21 -07:00
" deoplete
let g:deoplete#enable_at_startup = 1
let g:deoplete#enable_ignore_case = 1
2017-12-21 19:16:38 -07:00
" Tagbar
let g:tagbar_type_go = {
\ 'ctagstype' : 'go',
\ 'kinds' : [
\ 'p:package',
\ 'i:imports:1',
\ 'c:constants',
\ 'v:variables',
\ 't:types',
\ 'n:interfaces',
\ 'w:fields',
\ 'e:embedded',
\ 'm:methods',
\ 'r:constructor',
\ 'f:functions'
\ ],
\ 'sro' : '.',
\ 'kind2scope' : {
\ 't' : 'ctype',
\ 'n' : 'ntype'
\ },
\ 'scope2kind' : {
\ 'ctype' : 't',
\ 'ntype' : 'n'
\ },
\ 'ctagsbin' : 'gotags',
\ 'ctagsargs' : '-sort -silent'
\ }