set relativenumber
syntax on
set tabstop=4
set autoindent
set expandtab
set cursorline
set lazyredraw
set showmatch
set incsearch
set hlsearch
filetype plugin on


let mapleader=" "
let localleader=" "

" PLUGINS

call plug#begin()
Plug 'scrooloose/syntastic'
Plug 'scrooloose/nerdtree'
Plug 'scrooloose/nerdcommenter'
Plug 'tpope/vim-fugitive'
Plug 'vim-airline/vim-airline'
Plug 'lervag/vimtex'
Plug 'sbdchd/neoformat'
Plug 'sirver/ultisnips'
Plug 'terryma/vim-multiple-cursors'
Plug 'roxma/nvim-yarp'
Plug 'roxma/vim-hug-neovim-rpc'
Plug 'Shougo/neosnippet.vim'
Plug 'Shougo/neosnippet-snippets'
Plug 'neoclide/coc.nvim', {'branch': 'release'}
Plug 'neoclide/coc-vimtex'
Plug 'python-rope/ropevim'
Plug 'sainnhe/everforest'
call plug#end()


" MAPPINGS

" SYNTASTIC
" Aborting

" NERDTREE
" Keybidings for NerdTree
nnoremap <leader>n :NERDTreeToggle<CR>

" NERDCOMMENTER
" Keybidings for NerdCommenter

" FUGITIVE
nnoremap <space>ga :Git add % <CR>
nnoremap <space>gs :Git status <CR>
nnoremap <space>gc :Git commit <CR>
nnoremap <space>gp :Git push <CR>

" VIMTEX
let g:vimtex_view_method = 'zathura'
nnoremap <leader>ll :VimtexCompile<CR>
nnoremap <leader>lv :VimtexView<CR>


" NEOSNIPPET
let g:deoplete#enable_at_startup = 1
" Plugin key-mappings.
" Note: It must be "imap" and "smap".  It uses <Plug> mappings.
imap <C-k>     <Plug>(neosnippet_expand_or_jump)
smap <C-k>     <Plug>(neosnippet_expand_or_jump)
xmap <C-k>     <Plug>(neosnippet_expand_target)

" SuperTab like snippets behavior.
" Note: It must be "imap" and "smap".  It uses <Plug> mappings.
"imap <expr><TAB>
" \ pumvisible() ? "\<C-n>" :
" \ neosnippet#expandable_or_jumpable() ?
" \    "\<Plug>(neosnippet_expand_or_jump)" : "\<TAB>"
smap <expr><TAB> neosnippet#expandable_or_jumpable() ?
                        \ "\<Plug>(neosnippet_expand_or_jump)" : "\<TAB>"

" For conceal markers.
if has('conceal')
        set conceallevel=0 concealcursor=niv
endif

" NEOFORMAT
let g:neoformat_enabled_python = ['black', 'isort']
let g:neoformat_run_all_formatters = 1
let g:neoformat_verbose = 0
let g:neoformat_only_msg_on_error = 1
let g:neoformat_basic_format_align = 1
let g:neoformat_basic_format_retab = 1
let g:neoformat_basic_format_trim = 1
" Format on save
augroup fmt
        autocmd!
        autocmd BufWritePre * undojoin | Neoformat
augroup END

inoremap <expr> <CR> coc#pum#visible() ? coc#pum#confirm() : "\<CR>"

" Run python3 Keybidings
autocmd FileType python map <buffer> <F9> :w<CR>:exec '!python3' shellescape(@%, 1)<CR>


" THEME Important!!
if has('termguicolors')
        set termguicolors
endif

" For dark version.
set background=dark

" For light version.
"set background=light

" Set contrast.
" This configuration option should be placed before `colorscheme everforest`.
" Available values: 'hard', 'medium'(default), 'soft'
let g:everforest_background = 'medium'

" For better performance
let g:everforest_better_performance = 1

colorscheme everforest
