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 smarttab
set hidden
set showtabline=1
set termguicolors
set ttyfast
set wildmenu
set title
set list
set listchars=tab:→\ ,eol:¬,trail:⋅,extends:❯,precedes:❮
set showbreak=↪


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

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

"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 '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'

"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'],
		\ })
else
	echohl ErrorMsg
	echom 'Sorry, `solargraph` is not installed. Run `gem install solargraph` once ruby is set up to install.'
	echohl NONE
endif

"Rust
if executable('rls')
    au User lsp_setup call lsp#register_server({
       \ 'name': 'rls',
       \ 'cmd': {server_info->['rustup', 'run', 'stable', 'rls']},
       \ 'whitelist': ['rust'],
       \ })
endif
let g:asynccomplete_smart_completion = 1
let g:asynccomplete_auto_popup = 1