" going with vim-plug; has parallel downloading and probably more mature

" install vim plug:
" curl -fLo ~/.vim/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim

" The default plugin directory will be as follows:
" "   - Vim (Linux/macOS): '~/.vim/plugged'
" "   - Vim (Windows): '~/vimfiles/plugged'
" "   - Neovim (Linux/macOS/Windows): stdpath('data') . '/plugged'
" " You can specify a custom plugin directory by passing it as the argument
" "   - e.g. `call plug#begin('~/.vim/plugged')`
" "   - Avoid using standard Vim directory names like 'plugin'
"
" " Make sure you use single quotes
"
" " Shorthand notation; fetches https://github.com/junegunn/vim-easy-align
"

" only use copilot on Mac
let s:usecopilot = 0
let s:usejedi = 0
if has('mac')
    " only enable when not on vpn
    let s:route = system("netstat -nr | grep 'default.*tun' | head -1")
        if s:route != ""
            let s:usecopilot = 1
	endif
    let s:usejedi = 1
endif


" use ssh for cloning
" let g:plug_url_format = 'git@github.com:%s.git'

call plug#begin() 

Plug 'tpope/vim-sensible'
Plug 'tpope/vim-commentary'
Plug 'tpope/vim-surround' " https://github.com/tpope/vim-surround
Plug 'pedrohdz/vim-yaml-folds'
Plug 'vim-syntastic/syntastic'
Plug 'vim-scripts/vcscommand.vim'
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
Plug 'bling/vim-bufferline'
Plug 'tpope/vim-characterize'
Plug 'tpope/vim-endwise'
Plug 'doums/darcula' " pycharm scheme reproduction
Plug 'hashivim/vim-terraform'

if s:usecopilot == 1
    Plug 'github/copilot.vim', { 'on': 'Copilot' }
endif

if s:usejedi == 1
    Plug 'davidhalter/jedi-vim'
endif

Plug 'frankier/neovim-colors-solarized-truecolor-only'

call plug#end()

" let g:airline_solarized_bg='dark'
" let g:airline_theme='solarized'

" let g:syntastic_<filetype>_checkers = ['<checker-name>']
let g:syntastic_yaml_checkers = ['yamllint']

" " syntastic settings
" set statusline+=%#warningmsg#
" set statusline+=%{SyntasticStatuslineFlag()}
" set statusline+=%*

" let g:syntastic_always_populate_loc_list = 1
" let g:syntastic_auto_loc_list = 1
" let g:syntastic_check_on_open = 1
" let g:syntastic_check_on_wq = 0
" let g:pymode_options_max_line_length=120
" " https://vi.stackexchange.com/questions/10007/how-to-make-syntastic-include-sourced-files-for-bash-syntax-as-shellcheck-x
" let g:syntastic_sh_shellcheck_args = "-x"

let g:syntastic_mode_map = {
    \ "mode": "passive",
    \ "active_filetypes": [ "bash" ],
    \ "passive_filetypes": ["sh, yaml"] }

set modeline
set modelines=5

set statusline+=%#warningmsg#
set statusline+=%{SyntasticStatuslineFlag()}
set statusline+=%*

let g:syntastic_always_populate_loc_list = 1
let g:syntastic_auto_loc_list = 1
let g:syntastic_check_on_open = 1
let g:syntastic_check_on_wq = 0
" " https://vi.stackexchange.com/questions/10007/how-to-make-syntastic-include-sourced-files-for-bash-syntax-as-shellcheck-x
let g:syntastic_sh_shellcheck_args = "-x"

" 24bits color fix for tmux
" inspiration from https://github.com/vim/vim/issues/3608
if !has('gui_running') && &term =~ '^\%(screen\|tmux\)'
    let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum"
    let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum"
endif

" solarized config
set termguicolors
set background=dark " or light

" colorscheme solarized
colorscheme darcula

" Check if the color scheme file is available before applying it
if exists("g:plugs['darcula']") && filereadable(expand("~/.vim/plugged/darcula/colors/darcula.vim"))
    colorscheme darcula
endif

hi Visual term=reverse cterm=reverse guibg=Grey

" open unfolded
set foldlevel=99


" copilot config
imap <silent> <C-j> <Plug>(copilot-next)
imap <silent> <C-k> <Plug>(copilot-previous)
imap <silent> <C-l> <Plug>(copilot-dismiss)

" vim: set ft=vim:
" vim: set sw=4 ts=4 sts=4 et:
