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

set number
set relativenumber
set tabstop=4
set shiftwidth=4
set hidden
set showtabline=1
set termguicolors

if has('nvim')
	set inccommand=split
endif

call plug#begin('~/.config/nvim/plugged')

"Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
"LSP Stuff
Plug 'prabirshrestha/async.vim'
Plug 'prabirshrestha/vim-lsp'
Plug 'ryanolsonx/vim-lsp-python'
Plug 'ryanolsonx/vim-lsp-typescript'
Plug 'prabirshrestha/asyncomplete.vim'
Plug 'prabirshrestha/asyncomplete-lsp.vim'

Plug 'machakann/vim-highlightedyank'
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
"Plug 'ctrlpvim/ctrlp.vim'
Plug 'morhetz/gruvbox'
Plug 'tpope/vim-fugitive'
Plug 'mhinz/vim-signify'
Plug 'tpope/vim-commentary'

call plug#end()

"Gruvbox config
colorscheme gruvbox
set background=dark
let g:gruvbox_contrast_dark = 'soft'

"Airline settings
let g:airline#extensions#tabline#enabled = 1
let g:airline_powerline_fonts = 1
let g:airline#extensions#tabline#formatter = 'unique_tail_improved'

"CtrlP settings
let g:ctrlp_open_new_file = 'v'
let g:ctrlp_open_multiple_files = '2v'
let g:ctrlp_arg_map = 1
if executable('rg')
	let g:ctrlp_user_command = 'rg --files %s'
	let g:ctrlp_use_caching = 1
	let g:ctrlp_working_path_mode = 'ra'
	let g:ctrlp_switch_buffer = 'et'
endif

"Deoplete
"let g:deoplete#enable_at_startup = 1
"let g:python3_host_prog = '/Users/acicchetti/.pyenv/versions/3.7.0/bin/python'

"LSP stuff
"Ruby
if executable('solargraph')
	" gem install solargraph
	au User lsp_setup call lsp#register_server({
	    \ 'name': 'solargraph',
        \ 'cmd': {server_info->[&shell, &shellcmdflag, 'solargraph stdio']},
		\ 'initialization_options': {"diagnostics": "true"},
		\ 'whitelist': ['ruby'],
		\ })
endif
"Rust
if executable('rls')
    au User lsp_setup call lsp#register_server({
       \ 'name': 'rls',
       \ 'cmd': {server_info->['rustup', 'run', 'nightly', 'rls']},
       \ 'whitelist': ['rust'],
       \ })
endif
let g:asynccomplete_smart_completion = 1
let g:asynccomplete_auto_popup = 1