" CONFIGS --------------------------------------- {{{
syntax on
set title
set ruler
set number
set bg=dark
set incsearch
set showcmd
set wildmenu
set wildmode=list:longest
" set wildignore=*.docx,*.jpg,*.png,*.gif,*.pdf,*.pyc,*.exe,*.flv,*.img,*.xlsx
filetype on
" filetype plugin indent on
set cursorline
set cursorcolumn
set shiftwidth=4
set tabstop=4
set expandtab
set autoindent
set ignorecase
set smartcase
set showmode
set showmatch
set foldenable
set foldmethod=marker
set foldcolumn=2
colorscheme desert
autocmd FileType yaml setlocal ai sw=2 ts=2 et cuc cul " configuração para arquivos YAML (yaml/yml): 
" setlocal: configurações apenas para o buffer, não globais
" ai: autoindentação (noautoindent) 
" sw=2: shiftwidth=2, tamanho da indentação de 2 espaços (para avanços e recuos)
" ts=2: tabstop=2, largura da indentação com tab
" et (expandtab): converte tabs em espaços, não usa o tab real
" cuc: cursor column
" cul: cursor line
"
" set cmdheight=1
" set t_Co=256
" }}}

" MAPPINGS ------------------------------------- {{{

inoremap jj <esc>

" }}}

" PLUGINS ---------------------------------------- {{{

"call plug#begin('~/.vim/plugged')
"    Plug 'dense-analysis/ale'
"  Plug 'bling/vim-airline'
"  Plug 'vim-airline/vim-airline-themes'
"  Plug 'preservim/nerdtree'
"  Plug 'Xuyuanp/nerdtree-git-plugin'
"  Plug 'tpope/vim-commentary'
"  Plug 'tmsvg/pear-tree'
"call plug#end()

"  NERDTree CUSTOMIZATION: 
"map <C-n> :NERDTreeToggle<CR>
"let g:NERDTreeGitStatusUseNerdFonts = 1 " you should install nerdfonts by yourself. default: 0

" VIM-AIRLINE CUSTOMIZATION: 
"let g:airline_theme='random' " sierra, raven, understated, peaksea, base16_gruvbox_dark_hard, seoul256, 
"" let g:airline_left_sep='>'
"let g:airline_detect_paste=1
"let g:airline_powerline_fonts = 1
"let g:airline#parts#ffenc#skip_expected_string='utf-8[unix]'
"let g:airline#extensions#nerdtree_status = 1
"
" }}}
"

" VIMSCRIPT ---------------------------- {{{

" This will enable code folding.
" Use the marker method of folding.
augroup filetype_vim
    autocmd!
    autocmd FileType vim setlocal foldmethod=marker
augroup END

" More Vimscripts code goes here.

" 
"
"
" Here are the most important Vim code folding commands you should know:
"
" za – Toggles the current fold open or closed. – The most useful command to
" know of all of these.
" zA – Same as za except it toggles all folds beneath as well. Since folds can
" be nested (such as with indent folding), this will toggle the state of all
" the folds underneath of it, not just the current fold.
" zc – Close the current fold.
" zC – Same as above, but closes folds nested underneath as well.
" zo – Open the current fold.
" zO – Same as above, but opens folds nested underneath as well.
" }}}

" NumberMarkDownHeadings ----------------------------------------- {{{
function! NumberMarkdownHeadings()
  let g:count = [0,0,0,0,0,0]
    g/^#\+/ call s:NumberHeadings()
endfunction

function! s:NumberHeadings()
  let line = getline('.')
  let level = len(matchstr(line, '^#\+'))
  let g:count[level - 1] += 1
  for i in range(level, 5)
    let g:count[i] = 0
  endfor
  let prefix = join(filter(copy(g:count[0:level-1]), 'v:val > 0'), '.') . '. '
  let line = substitute(line, '^#\+\s*', '\=repeat("#", '.level.') . " " . prefix', '')
  call setline('.', line)
endfunction

command! MdNumberHeadings call NumberMarkdownHeadings()
" }}}
