lua require ('setting')
set number
set relativenumber

set showcmd
set clipboard=unnamed

set mouse=a

set nobackup
set noswapfile
set noexpandtab
set noundofile

set autoindent
set tabstop=4
set softtabstop=4
set shiftwidth=4

set smartindent
set syntax

call plug#begin()
Plug 'morhetz/gruvbox'
Plug 'neoclide/coc.nvim', {'branch': 'release'}
call plug#end()
exec"PlugInstall"
exec"CocRestart"
"font
set guifont=Hack\ Nerd\ Font\ Mono:h9

"colorscheme
	colorscheme gruvbox

"compile


func! Run()
    exec "w"
    exec "!g++ -O2 -std=gnu++14 -Wall -Wextra -Wfatal-errors -o %<.exe %"
endfunc

"auto-pairs
:inoremap " ""<ESC>i
:inoremap ' ''<ESC>i
inoremap { {}<Left>
inoremap {<CR> {<CR>}<Esc>O
inoremap {{ {
inoremap {} {}


:inoremap ( ()<ESC>i
:inoremap ) <c-r>=ClosePair(')')<CR>
:inoremap [ []<ESC>i
:inoremap ] <c-r>=ClosePair(']')<CR>

function! ClosePair(char)
    if getline('.')[col('.') - 1] == a:char
        return "\<Right>"
    else
        return a:char
    endif
endfunction

"Keymaps
map <F2> :NvimTreeToggle<CR>
map <F3> :bp<CR>
map <F4> :w<CR>
map <F6> :CocRestart<CR>
map <F8> :bd<CR>
map <F9> :call Run()<CR>
map <F11> :!%<.exe<CR>

"template
inoremap <F10> #include <algorithm><CR>#include <cstring><CR>#include <cmath><CR>#include <iostream><CR><CR>typedef long long ll;<CR>typedef unsigned long long ull;<CR>typedef long double ld;<CR><CR>using namespace std;<CR><CR><CR>int main()<CR>{<CR>ios::sync_with_stdio(false);<CR>cin.tie(nullptr);<CR><CR><CR><CR><CR><ESC>i<TAB>return 0;<CR>}<ESC>

"Coc
inoremap <silent><expr> <cr> pumvisible() ? coc#_select_confirm()
                              \: "\<C-g>u\<CR>\<c-r>=coc#on_enter()\<CR>"
set hidden
set updatetime=100
