" VIM Configuration - DarKou

" Cancel VI compatibility
set nocompatible

" -- Vim-plug
if empty(glob('~/.vim/autoload/plug.vim'))
  silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs
    \ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
  autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
endif

call plug#begin('~/.vim/plugged')
	Plug 'arcticicestudio/nord-vim'
	Plug 'sjbach/lusty'
	Plug 'kshenoy/vim-signature'
	Plug 'w0rp/ale'
	Plug 'ap/vim-css-color'
	Plug 'mileszs/ack.vim'
	Plug 'ctrlpvim/ctrlp.vim'
  Plug 'moll/vim-node'
  Plug 'heavenshell/vim-jsdoc',  {
    \ 'for': ['javascript', 'javascript.jsx','typescript'],
    \ 'do': 'make install'
    \}
" Initialize plugin system
call plug#end()

" -- Display
colorscheme nord
set title
set number
set ruler
set wrap
set scrolloff=5
syntax enable

filetype on
filetype plugin on
filetype indent on

:highlight ExtraWhitespace ctermbg=red guibg=red
:match ExtraWhitespace /\s\+$/

" -- Search
set ignorecase
set smartcase
set incsearch
set hlsearch

" -- Ack search
let g:ackprg="ack -H --nocolor --nogroup --column"
nmap <leader>j mA:Ack<space>
nmap <leader>ja mA:Ack "<C-r>=expand("<cword>")<cr>"
nmap <leader>jA mA:Ack "<C-r>=expand("<cWORD>")<cr>"

" -- Ctrlp
let g:ctrlp_map='<leader>c'

" -- Beep
set visualbell
set noerrorbells

"
set backspace=indent,eol,start

" Hide file when open other file
set hidden

" Disable arrow keys
"map <left> <nop>
"map <down> <nop>
"map <up> <nop>
"map <right> <nop>
"imap <left> <nop>
"imap <down> <nop>
"imap <up> <nop>
"imap <right> <nop>

" Remap esc key
:imap <C-x> <Esc>
:map <C-x> <Esc>

" Code formating
set expandtab
set tabstop=2
set shiftwidth=2

let b:ale_linters = ['eslint']
let g:ale_fixers = {
 \ 'javascript': ['eslint']
 \ }
let g:ale_sign_error = '❌'
let g:ale_sign_warning = '⚠️'
let g:ale_fix_on_save = 1
augroup myTodo
  autocmd!
  autocmd Syntax * syntax match myTodo /\v\_.<(TODO|FIXME|INFO).*/hs=s+1 containedin=.*Comment
augroup END
highlight link myTodo Todo