call plug#begin('~/.config/nvim/plugged')
" Language Tools
Plug 'roxma/nvim-yarp' " For language client
Plug 'ncm2/ncm2' " For language client
Plug 'autozimu/LanguageClient-neovim', {'branch': '0.1.159', 'do': 'bash install.sh' }
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --bin' }
Plug 'junegunn/fzf.vim'
Plug 'SirVer/ultisnips'
Plug 'luochen1990/rainbow'
" Plug 'enomsg/vim-haskellConcealPlus' " This one isn't always good.

" Languages
Plug 'LnL7/vim-nix'
Plug 'whonore/Coqtail'
Plug 'wlangstroth/vim-racket'
Plug 'lervag/vimtex'
Plug 'idris-hackers/idris-vim'
Plug 'rhysd/vim-crystal'
Plug 'elmcast/elm-vim'
Plug 'ap/vim-css-color'
Plug 'vim-scripts/avrasm.vim'
Plug 'idris-hackers/idris-vim'
Plug 'elixir-editors/vim-elixir'
Plug 'guersam/vim-j'
Plug 'wlangstroth/vim-racket'
Plug 'derekelkins/agda-vim'
Plug 'ftorres16/spice.vim'
Plug 'vmware/differential-datalog', {'rtp': 'tools/vim'}
Plug 'FStarLang/VimFStar', {'for': 'fstar'}

" Themes
Plug 'arcticicestudio/nord-vim'

" Editing Tools
Plug 'junegunn/goyo.vim'
Plug 'iamcco/markdown-preview.vim'
Plug 'junegunn/limelight.vim'
Plug 'luochen1990/rainbow'

" Misc
Plug 'airblade/vim-gitgutter'
call plug#end()

set exrc " Execute local vimscripts
set shiftwidth=4 " Make indents 4 chars wide
set expandtab " Expand tabs into spaces
set number " Set line numbers
set mouse=a " Allow mouse
set signcolumn=yes " Always show extra column
set guifont=Iosevka " Use Ioeska in frontends.
set hidden

autocmd BufEnter * call ncm2#enable_for_buffer() " Enable ncm2 for all buffers
autocmd BufRead,BufNewFile *.v set filetype=coq " Coq is not Verilog
autocmd BufNewFile,BufRead *.cir set filetype=spice " LTSpice is Spice
autocmd BufRead,BufNewFile *.dl set filetype=dl " Datalog is Datalog
autocmd FileType crystal setlocal shiftwidth=2 " Crystal likes 2-wide indent

set completeopt=noinsert,menuone

" Settings for Rainbow
let g:rainbow_active = 1

" Settings for Limelight
let g:limelight_conceal_ctermfg = 8

" Settings for Vim's LaTeX plugin
let g:tex_flavor = 'latex'

" Settings for deoplete
let g:deoplete#enable_at_startup = 1

" Settings for UltiSnips
let g:UltiSnipsExpandTrigger="<tab>"
let g:UltiSnipsJumpForwardTrigger="<c-k>"
let g:UltiSnipsJumpBackwardTrigger="<c-j>"

" Settings for FZF
let g:fzf_action = { 'enter': 'tab drop' }

" Settings for Neovide
let g:neovide_cursor_vfx_mode="ripple"

colorscheme nord

" Language Client settings
let g:LanguageClient_selectionUI = "fzf"
let g:LanguageClient_hasSnippetSupport = 0
let g:LanguageClient_serverCommands = {
              \ 'haskell': ['haskell-language-server-wrapper', '--lsp'],
              \ 'rust': ['rls'],
              \ 'c': ['clangd'],
              \ 'crystal': ['/home/vanilla/software/crystalline/crystalline'],
              \ 'cpp': ['clangd'],
              \ 'javascript': ['typescript-language-server', '--stdio'],
              \ 'typescript': ['typescript-language-server', '--stdio'],
              \ 'elm': ['elm-language-server', '--stdio'],
              \ 'python': ['python', '-m', 'pyls'],
              \ 'elixir': ['/home/vanilla/software/elixir-ls/language_server.sh']
              \ }
let g:LanguageClient_diagnosticsDisplay = {
            \ 1: {"name": "Error","texthl": "ALEError","signText": ">>","signTexthl": "ALEErrorSign",},
            \ 2: {"name": "Warning","texthl": "ALEWarning","signText": ">>","signTexthl": "ALEWarningSign",},
            \ 3: {"name": "Information","texthl": "ALEInfo","signText": ">>","signTexthl": "ALEInfoSign",},
            \ 4: {"name": "Hint","texthl": "ALEInfo","signText": ">>","signTexthl": "ALEInfoSign",},}
let g:LanguageClient_rootMarkers = {
            \ 'haskell': ['.git'],
            \ 'crystal': ['.git'],
            \ 'elm': ['elm.json'],
            \ }

nmap <c-e> :Files<CR>
nmap <silent>K <Plug>(lcn-menu)
nmap <silent>M <Plug>(lcn-explain-error)
nmap <silent>? <Plug>(lcn-hover)

" Racket settings
au BufReadPost *.rkt,*.rktl set filetype=racket
au filetype racket set lisp
au filetype racket set autoindent

" Coq Settings
function! g:CoqtailHighlight()
    hi default link CoqtailChecked Visual
    hi default link CoqtailSent PmenuSel
endfunction
