set nocompatible                        " be iMproved, required
filetype off                            " required

call plug#begin('~/.vim/plugged')
Plug 'embear/vim-localvimrc'          " Read .lvmrc
Plug 'takac/vim-hardtime'             " Do not allow hjkl abuse
Plug 'tpope/vim-surround'             " ys cs ds commands
Plug 'tpope/vim-repeat'               " surround repeat
Plug 'tpope/vim-fugitive'             " git support in airline

Plug 'ervandew/supertab'              " Smart <Tab> => <C-n>
Plug 'neomutt/neomutt.vim'            " Support for neomutt filetypes

Plug 'chriskempson/base16-vim'        " Base16 themes
Plug 'Yggdroot/indentLine'            " Indent guides

Plug 'w0rp/ale'                       " Linting Engine

" Quality of Life
Plug 'benizi/vim-automkdir'           " Create subdirectiries 
Plug 'junegunn/goyo.vim'              " Distraction Free editing
Plug 'vim-scripts/DrawIt'             " Draw boxes/lines
Plug 'rhysd/vim-grammarous'           " Grammer checking
call plug#end()

filetype plugin indent on               " required
filetype plugin on

syntax on                               " Enable syntax hilighting
set showcmd		                " Show (partial) command in status line.

set ignorecase		                " Do case insensitive matching
set smartcase		                " Do smart case matching
set incsearch		                " Incremental search
set hlsearch                            " Hilight matching searched

set relativenumber                      " Show number relative to line
set number                              " Shows current line instead of 0

set isfname+=32                         " Read spaces in path's

set clipboard^=unnamedplus              " sync paste buffer and vims register
set mouse=                              " disable mouse

let $NVIM_TUI_ENABLE_CURSOR_SHAPE = 1   " Change cursor to | when in insert

"Autosave and Autoread
set autoread                            " Reread file on external Commands
set autowriteall
au FocusGained,BufEnter * :silent! !
au FocusLost,WinLeave * :silent! w

set undofile                            " Persisent undo accross saves
set undodir=~/.vim/undodir/             " Don't clobber dir with undo files

set noswapfile                          " Disable silly .swp file
set nobackup                            " No backup file

"Disable the super annoying autocomment
autocmd FileType * setlocal formatoptions-=c formatoptions-=r formatoptions-=o

"Make j and k not jump when wraping
nnoremap j gj
nnoremap k gk

"set leader to comma
let mapleader = ","

"Math with qalc
nnoremap <leader>m :.!~/bin/calc<Enter>

" Ctrl+Backspace should delete words
noremap! <C-BS> <C-w>      
noremap! <C-h> <C-w>

"Set Tab to two spaces
set expandtab
set shiftwidth=2
set softtabstop=2
"Open new file
nnoremap <Leader>o :CtrlP<CR>
nnoremap <Leader>w :w<CR>

" Hard time options
let g:hardtime_default_on = 1
let g:hardtime_maxcount = 2            " Allow to consecutive hjkl
let g:hardtime_showmsg = 0             " Don't even tell us why
let g:hardtime_allow_different_key = 1 " Allows some spamming

" Deoplete enable
let g:deoplete#enable_at_startup = 1

" Supertab
let g:SuperTabDefaultCompletionType    = '<C-n>'
let g:SuperTabCrMapping                = 0

" Ale Linter Config
map <leader>a :ALENext<CR>
map <leader>g :ALEGoToDefinition<CR>
map <leader>r :ALEFindReferences<CR>
map <leader>h :ALEHover<CR>
hi link ALEError Error
hi link ALEWarning Debug
let g:ale_completion_enabled = 1
" Ale Perl
let g:ale_set_loclist             = 0
let g:ale_set_quickfix            = 1
let g:ale_linters                 = {'perl': ['perl', 'perlcritic'], 'python': ['flake8', 'pylint']}
let g:ale_perl_perl_options       = '-cW -Ilib -I./'
let g:ale_perl_perlcritic_options = '--stern'
let g:ale_lint_on_text_changed    = 'normal'
let g:ale_lint_on_insert_leave    = 1

" Ale Rust
let g:ale_rust_rls_toolchain = ''
let g:ale_rust_rls_executable = 'rust-analyzer'
let g:ale_linters = { 'rust': ['rls'] }
let g:ale_fixers = { 'rust': ['rustfmt'] }

" Modify The ColorScheme to show Italic and Bold in Markdown.
" Italicise comments and Type's
" And make Line numbers same as background in Base16 themes
function! s:base16_customize() abort
    call Base16hi("htmlBold",    g:base16_gui0A, "", g:base16_cterm06, "", "bold", "") 
    call Base16hi("markdownBold",    g:base16_gui0A, "", g:base16_cterm06, "", "bold", "") 
    call Base16hi("markdownHeadingDelimiter",    g:base16_gui0A, "", g:base16_cterm08, "", "bold", "") 
    call Base16hi("markdownH1",    g:base16_gui0A, "", g:base16_cterm08, "", "bold", "") 
    call Base16hi("markdownH2",    g:base16_gui0A, "", g:base16_cterm08, "", "bold", "") 
    call Base16hi("htmlItalic",  g:base16_gui0E, "", g:base16_cterm06, "", "italic", "")
    call Base16hi("markdownItalic",  g:base16_gui0E, "", g:base16_cterm06, "", "italic", "")
    call Base16hi("htmlUnderline",  g:base16_gui0E, "", g:base16_cterm06, "", "underline", "")
    call Base16hi("Italic",        "", "", "", "", "italic", "")
    call Base16hi("Comment",      g:base16_gui04, "", g:base16_cterm04, "", "italic", "")

    call Base16hi("Type",         g:base16_gui0A, "", g:base16_cterm0A, "", "italic", "")
    call Base16hi("htmlArg",         "", "", "", "", "italic", "")
    call Base16hi("LineNr",        g:base16_gui03, g:base16_cterm00, g:base16_cterm03, g:base16_cterm00, "", "")
    call Base16hi("CursorLineNr",  g:base16_gui04, g:base16_gui00, g:base16_cterm04, g:base16_cterm00, "", "")
endfunction
"augroup on_change_colorschema
"    autocmd!
"    autocmd ColorScheme * call s:base16_customize()
"augroup END

" Load base16_theme from ~/.vimrc_background
if filereadable(expand("~/.vimrc_background"))
  let base16colorspace=256
  source ~/.vimrc_background
endif



let g:localvimrc_whitelist='/home/vsz/convolutional-screenshot-classifier'