dotfiles/vim/vimrc

195 lines
5.4 KiB
VimL
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

if empty(glob('~/.config/nvim/autoload/plug.vim'))
silent !curl -fLo ~/.config/nvim/autoload/plug.vim --create-dirs
\ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
endif
let g:pyxversion = 'python3'
set number
set relativenumber
set tabstop=4
set shiftwidth=4
set smarttab
set expandtab
set hidden
set showtabline=1
set termguicolors
set ttyfast
set wildmenu
set title
set list
set listchars=tab:→\ ,eol,trail:•,extends:,precedes:,space:⨪
set showbreak=
set timeoutlen=500
let g:mapleader="\<SPACE>"
let g:maplocallead=','
if has('nvim')
set inccommand=split
endif
if has("persistent_undo")
set undodir=$HOME/.undodir
set undofile
endif
call plug#begin('~/.config/nvim/plugged')
"LSP Stuff
Plug 'neoclide/coc.nvim', {'branch': 'release'}
Plug 'junegunn/rainbow_parentheses.vim'
Plug 'machakann/vim-highlightedyank'
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
Plug 'morhetz/gruvbox'
Plug 'arzg/vim-corvine'
Plug 'tpope/vim-fugitive'
Plug 'mhinz/vim-signify'
Plug 'tpope/vim-commentary'
Plug 'mbbill/undotree'
Plug 'elmcast/elm-vim'
Plug 'liuchengxu/vim-which-key'
"async.vim
Plug 'prabirshrestha/async.vim'
"https://github.com/baverman/vial-http/blob/master/doc/tutorial.rst
"Plug 'baverman/vial'
"Plug 'baverman/vial-http'
call plug#end()
function! s:writebuffer(bufname, text)
let l:bufnum = bufwinnr(a:bufname)
if l:bufnum == -1
execute "vsplit" a:bufname
setlocal buftype=nofile
else
execute l:bufnum . 'wincmd w'
endif
call append(0, a:text)
endfunction
function! s:handlegeneric(cmd, tech, job_id, data, event_type)
if a:event_type == 'exit'
echo a:cmd . ' completed successfully'
elseif a:event_type == 'stdout' && len(a:data) > 1
call s:writebuffer('__STDOUT_' . a:tech . '__', a:data)
elseif a:event_type == 'stderr' && len(a:data) > 1
call s:writebuffer('__STDERR_' . a:tech . '__', a:data)
endif
endfunction
"Setting up coc-tools
function! s:handlepython(job_id, data, event_type)
call s:handlegeneric('pip install python-language-server pynvim', 'PYTHON', a:job_id, a:data, a:event_type)
endfunction
function! s:handleruby(job_id, data, event_type)
call s:handlegeneric('gem install solargraph neovim', 'RUBY', a:job_id, a:data, a:event_type)
endfunction
function! s:handlenode(job_id, data, event_type)
call s:handlegeneric('yarn global add neovim', 'NODE', a:job_id, a:data, a:event_type)
endfunction
function! s:cmdexitcode(cmd)
let l:output = system(a:cmd)
return v:shell_error
endfunction
function! s:asyncFunc(cmd, callbackfunc)
return async#job#start(a:cmd, {
\ 'on_stdout': function(a:callbackfunc),
\ 'on_stderr': function(a:callbackfunc),
\ 'on_exit': function(a:callbackfunc)
\ })
endfunction
function! s:ensurePython()
if (s:cmdexitcode('pyls -h') || s:cmdexitcode('python -c "import neovim"'))
let l:jobid = s:asyncFunc('pip install python-language-server pynvim', 's:handlepython')
au VimEnter * CocInstall coc-python
endif
endfunction
function! s:ensureRuby()
if (s:cmdexitcode('solargraph -v') || s:cmdexitcode('ruby -e "require \"neovim\""'))
let l:jobid = s:asyncFunc('gem install solargraph neovim', 's:handleruby')
au VimEnter * CocInstall coc-solargraph
endif
endfunction
function! s:ensureNode()
if (s:cmdexitcode('neovim-node-host --version'))
let l:jobid = s:asyncFunc('yarn global add neovim', 's:ensureNode')
au VimEnter * CocInstall coc-tsserver
endif
endfunction
call s:ensurePython()
call s:ensureRuby()
call s:ensureNode()
inoremap <silent><expr> <TAB>
\ pumvisible() ? "\<C-n>" :
\ <SID>check_back_space() ? "\<TAB>" :
\ coc#refresh()
inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>"
inoremap <expr> <cr> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>"
function! s:check_back_space() abort
let col = col('.') - 1
return !col || getline('.')[col - 1] =~# '\s'
endfunction
inoremap <silent><expr> <c-space> coc#refresh()
autocmd CursorHold * silent call CocActionAsync('highlight')
command! -nargs=0 Format :call CocAction('format')
set background=dark
colorscheme corvine
"Airline settings
let g:airline#extensions#tabline#enabled = 1
let g:airline_powerline_fonts = 1
let g:airline#extensions#tabline#formatter = 'unique_tail_improved'
let g:airline_theme='base16_tomorrow'
nnoremap <leader>u :UndotreeToggle<cr>
nnoremap <leader>h <C-W><C-H>
nnoremap <leader>j <C-W><C-J>
nnoremap <leader>k <C-W><C-K>
nnoremap <leader>l <C-W><C-L>
nnoremap <leader>n :nohl<cr>
nnoremap <C-k> <C-u>
nnoremap <C-j> <C-d>
"Coc Keymaps and options
nnoremap <silent> <leader><Space>d :call CocAction('jumpDefinition')<cr>
nnoremap <silent> <leader><Space>g :call CocAtion('jumpTypeDefinition')<cr>
"which-key
let g:which_key_map = {}
autocmd! User vim-which-key call which_key#register('<Space>', 'g:which_key_map')
let g:which_key_map[' '] = {
\ 'name' : '+CoC' ,
\ 'd' : 'go-to-definition' ,
\ 'g' : 'go-to-type-definition' ,
\ }
call which_key#register('<Space>', "g:which_key_map")
nnoremap <silent> <leader> :<c-u>WhichKey '<Space>'<CR>
nnoremap <silent> <localleader> :<c-u>WhichKey ','<CR>
"rainbow-parens
autocmd VimEnter * RainbowParentheses
let g:rainbow#blacklist = [248]
let g:rainbow#pairs = [['(', ')'], ['[', ']'], ['{', '}']]