Neovim Setup

init.vim

My config for neovim

set nocompatible
set cmdheight=1
filetype off

nnoremap <SPACE> <Nop>
let g:mapleader="\<Space>"
let g:maplocalleader="\<Space>"

call plug#begin()

"Navigation Plugins
Plug 'rbgrouleff/bclose.vim'
Plug 'dbakker/vim-projectroot'
Plug 'preservim/nerdtree'
Plug 'junegunn/fzf'
Plug 'junegunn/fzf.vim'
Plug 'majutsushi/tagbar'
Plug 'ryanoasis/vim-devicons'
Plug 'preservim/nerdtree' |
      \ Plug 'Xuyuanp/nerdtree-git-plugin' |
      \ Plug 'ryanoasis/vim-devicons'
Plug 'PhilRunninger/nerdtree-visual-selection'
Plug 'kevinhwang91/rnvimr'
Plug 'liuchengxu/vim-which-key'
Plug 'ctrlpvim/ctrlp.vim'

"UI Plugins
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
Plug 'bling/vim-bufferline'
Plug 'altercation/vim-colors-solarized'
Plug 'mhartington/oceanic-next'
Plug 'rakr/vim-one'
Plug 'tiagofumo/vim-nerdtree-syntax-highlight'
Plug 'katawful/kat.vim'
Plug 'ayu-theme/ayu-vim'
Plug 'mattn/calendar-vim'
Plug 'morhetz/gruvbox'

"Editor plugins
Plug 'Raimondi/delimitMate'
Plug 'scrooloose/nerdcommenter'
Plug 'tpope/vim-sleuth'
Plug 'Valloric/YouCompleteMe', { 'do': './install.py --clangd-completer --go-completer --rust-completer --ts-completer' }
Plug 'rdnetto/ycm-generator', { 'branch': 'stable' }
"Plug 'SirVer/ultisnips'
"Plug 'honza/vim-snippets'
"Plug 'ludovicchabant/vim-gutentags'
Plug 'tpope/vim-fugitive'
Plug 'airblade/vim-gitgutter'
Plug 'editorconfig/editorconfig-vim'
Plug 'Chiel92/vim-autoformat'
Plug 'simnalamburt/vim-mundo'
"Plug 'vim-syntastic/syntastic'
Plug 'wakatime/vim-wakatime'
Plug 'xolox/vim-session'
Plug 'xolox/vim-misc'

"Language specific
Plug 'tmhedberg/SimpylFold', { 'for': 'python' }
Plug 'lervag/vimtex', { 'for': 'tex' }
Plug 'vim-pandoc/vim-pandoc'
Plug 'vim-pandoc/vim-pandoc-syntax'
Plug 'yuezk/vim-js'
Plug 'HerringtonDarkholme/yats.vim'
"Plug 'leafgarland/typescript-vim'
Plug 'maxmellon/vim-jsx-pretty'
Plug 'tikhomirov/vim-glsl'
Plug 'vhdirk/vim-cmake'
Plug 'ds26gte/scmindent'
Plug 'udalov/kotlin-vim'

if isdirectory("~/dev/mitscript-syntax")
  Plug '~/dev/mitscript-syntax'
endif

"Note taking
Plug 'vimwiki/vimwiki'
Plug 'lukaszkorecki/workflowish'
Plug 'michaelb/vim-tips'

call plug#end()



set rtp^=/usr/share/vim/vimfiles


filetype plugin indent on
set encoding=UTF-8
autocmd BufRead,BufNewFile *.sage,*.pyx,*.spyx set filetype=python

autocmd FileType c,cpp,java,php autocmd BufWritePre <buffer> %s/\s\+$//e

"**************************************************************Session Management****************************************************

"Closes buffers
nnoremap <C-q> :Bclose<CR>

let g:session_directory = '~/.config/nvim/sessions'
let g:session_lock_enabled = 1

let g:session_default_name = strftime("%Y-%m-%d-%H%M'")
let g:session_default_overwrite = 0
let g:session_autosave_periodic = 1
let g:session_default_to_last = 0
let g:session_persist_colors = 1
let g:session_autosave = 'prompt'
"let g:session_autosave_to = 'default'
let g:session_autoload = 'prompt'
let g:session_menu = 1
set sessionoptions+=localoptions
set sessionoptions-=options  " Don't save options

" Press Tab for options to save in existing sessions
nnoremap <Leader>ss :SaveSession 
nnoremap <Leader>so :OpenSession 

"***********************************************************************************************************************************

"**************************************************************Colorschemes*********************************************************

"********Option 1: ayucolor*********************

"let ayucolor="light"  " for light version of theme
""let ayucolor="mirage" " for mirage version of theme
""let ayucolor="dark"   " for dark version of theme
"colorscheme ayu

"***********************************************************************************************************************************

"********Option 2: altercation/vim-colors-solarized*********************************************************************************

syntax enable
let g:solarized_termcolors=256
let g:solarized_degrade=1
"let g:solarized_termtrans=1
let g:solarized_bold=1
let g:solarized_italic=1
let g:solarized_underline=1
let g:solarized_contrast="normal"
let g:solarized_visibility="normal"
colorscheme solarized

if strftime("%H") > 17 || strftime("%H") < 6
  set background=dark
  set termguicolors
  colorscheme OceanicNext
else
  set background=light
  set notermguicolors
  colorscheme solarized
endif
function! ToggleDimTags()
if (&background == "light" && g:colors_name == "solarized")
  set background=dark
  set termguicolors
  colorscheme OceanicNext
else
  set notermguicolors
  set background=light
  colorscheme solarized
endif
endfunction

"***********************************************************************************************************************************

"********Option 3: gruvbox**************************************

"set termguicolors
"set background=light
"let g:gruvbox_transparent_bg=1
"let g:gruvbox_italic=1
"let g:gruvbox_contrast_light='hard'
"colorscheme gruvbox

"***************************************************************

"********Option 4: OceanicNext**********************************

"if (has("termguicolors"))
  "set termguicolors
"endif 
"syntax enable
"let g:solarized_termcolors=256
"colorscheme OceanicNext
"if strftime("%H") > 17 || strftime("%H") < 6
  "colors OceanicNext
"else
  "colors OceanicNextLight
"endif

"function! ToggleDimTags()
"if (g:colors_name == "OceanicNextLight")
  "colors OceanicNext
"else
  "colors OceanicNextLight
"endif
"endfunction

"***************************************************************

nnoremap <C-L> :call ToggleDimTags()<CR>

"***********************************************************************************************************************************


"****************************************************which-key**********************************************************************

source $HOME/.config/nvim/keys/which-key.vim
" Map leader to which_key
nnoremap <silent> <leader> :silent WhichKey '<Space>'<CR>
vnoremap <silent> <leader> :silent <c-u> :silent WhichKeyVisual '<Space>'<CR>

" Create map to add keys to
let g:which_key_map =  {}
" Define a separator
let g:which_key_sep = '→'
" set timeoutlen=100


" Not a fan of floating windows for this
let g:which_key_use_floating_win = 1

" Change the colors if you want
highlight default link WhichKey          Operator
highlight default link WhichKeySeperator DiffAdded
highlight default link WhichKeyGroup     Identifier
highlight default link WhichKeyDesc      Function

" Hide status line
autocmd! FileType which_key
autocmd  FileType which_key set laststatus=0 noshowmode noruler
  \| autocmd BufLeave <buffer> set laststatus=2 noshowmode ruler

" Single mappings
let g:which_key_map['/'] = [ '<Plug>NERDCommenterToggle'  , 'comment' ]
let g:which_key_map['e'] = [ ':CocCommand explorer'       , 'explorer' ]
let g:which_key_map['f'] = [ ':Files'                     , 'search files' ]
let g:which_key_map['h'] = [ '<C-W>s'                     , 'split below']
let g:which_key_map['r'] = [ ':Ranger'                    , 'ranger' ]
let g:which_key_map['S'] = [ ':Startify'                  , 'start screen' ]
let g:which_key_map['T'] = [ ':Rg'                        , 'search text' ]
let g:which_key_map['v'] = [ '<C-W>v'                     , 'split right']
let g:which_key_map['z'] = [ 'Goyo'                       , 'zen' ]

" s is for search
let g:which_key_map.s = {
      \ 'name' : '+search' ,
      \ '/' : [':History/'     , 'history'],
      \ ';' : [':Commands'     , 'commands'],
      \ 'a' : [':Ag'           , 'text Ag'],
      \ 'b' : [':BLines'       , 'current buffer'],
      \ 'B' : [':Buffers'      , 'open buffers'],
      \ 'c' : [':Commits'      , 'commits'],
      \ 'C' : [':BCommits'     , 'buffer commits'],
      \ 'f' : [':Files'        , 'files'],
      \ 'g' : [':GFiles'       , 'git files'],
      \ 'G' : [':GFiles?'      , 'modified git files'],
      \ 'h' : [':History'      , 'file history'],
      \ 'H' : [':History:'     , 'command history'],
      \ 'l' : [':Lines'        , 'lines'] ,
      \ 'm' : [':Marks'        , 'marks'] ,
      \ 'M' : [':Maps'         , 'normal maps'] ,
      \ 'p' : [':Helptags'     , 'help tags'] ,
      \ 'P' : [':Tags'         , 'project tags'],
      \ 's' : [':Snippets'     , 'snippets'],
      \ 'S' : [':Colors'       , 'color schemes'],
      \ 't' : [':Rg'           , 'text Rg'],
      \ 'T' : [':BTags'        , 'buffer tags'],
      \ 'w' : [':Windows'      , 'search windows'],
      \ 'y' : [':Filetypes'    , 'file types'],
      \ 'z' : [':FZF'          , 'FZF'],
      \ }

" Register which key map
call which_key#register('<Space>', "g:which_key_map")

"***********************************************************************************************************************************


"**************************************************************vimwiki**************************************************************

filetype plugin on
nnoremap <leader>l i<c-r>="[" . expand("#") . "]" . "(./" . expand("#") . ")"<cr><esc>
command! Diary VimwikiDiaryIndex
augroup vimwikigroup
    autocmd!
    " automatically update links on read diary
    autocmd BufRead,BufNewFile diary.md VimwikiDiaryGenerateLinks
augroup end

"Add wiki locations for Diary, CP & general wiki
let wiki_1 = {}
let wiki_1.path = '~/programming/CPlibrary/cpwiki/'
let wiki_1.syntax = 'markdown'
let wiki_1.ext = '.md'

let wiki_2 = {}
let wiki_2.path = '~/vimwiki/'
let wiki_2.syntax = 'markdown'
let wiki_2.ext = '.md'

let g:vimwiki_list = [wiki_1, wiki_2]
let g:vimwiki_ext2syntax = {'.md': 'markdown', '.markdown': 'markdown', '.mdown': 'markdown'}

"***********************************************************************************************************************************

"**************************************************************CP Setup ************************************************************

"🟢 press Ctrl+o while in insert mode for executing command "make! test<CR>" or Ctrl+b for compile and run, enables to return back to insert mode 
"Command :cope to see debug info

"🟢Only Option : Compile using ecnerwala setup
autocmd filetype cpp nnoremap <C-B> :w <bar> make! test<CR>
"When multiple answers are possible, then all tests must be run
"For that, go to Makefile of that problem and add "-" before "diff  $*.res $*.out"

"🟢Option 0 : COMPILE <F6> : Compile and see warnings
"Display compile time with errors, if any
autocmd filetype cpp nnoremap <F6> :w <bar> !time g++ -ulimit -Wno-unused-result -std=c++17 -Wall -g   -O2   % -o %:r <CR>

"🟢Option 1 : FILE <F10> : Running with input in inp.txt and output in out.txt
"Display runtime for each test case
"Delete executable after each run so that executables are not pushed to repo
autocmd filetype cpp nnoremap <F10> :w <bar> !g++ -ulimit -Wno-unused-result -std=c++17 -Wall -g   -O2   % -o %:r && time ./%:r < ./inp.txt > ./out.txt; rm %:r <CR>

"🟢Option 2 : TERMINAL <F9> : Running with input and output both in vim terminal
"Display runtime for each test case
"Delete executable after each run so that executables are not pushed to repo
autocmd filetype cpp nnoremap <F9> :w <bar> !g++ -ulimit -Wextra -pedantic -Wshadow -Wformat=2 -Wfloat-equal -Wconversion -Wlogical-op -Wshift-overflow=2 -Wduplicated-cond -Wcast-qual -Wcast-align -Wno-unused-result -Wno-sign-conversion -std=c++17 -Wall -g   -O2   % -o %:r < % <CR> :term time ./%< <CR>

"Commenting a line in cpp file through Ctrl+c
"autocmd filetype cpp nnoremap <C-C> :s/^\(\s*\)/\1\/\/<CR> :s/^\(\s*\)\/\/\/\//\1<CR> $
"🟢Commenting a line in any file through NerdCommenter
"go to line visual mode C-V, then select the lines you need to comment out and press cc to comment and cu to uncomment

"******************CP TEMPLATE

"Precompile the headers
"https://codeforces.com/blog/entry/53909

"🟢Ctrl+Space shows options for YCM snippets
"🟢using fzf, we can see preview as well and open that specific template in buffer and then yank,close the buffer, jump back to the file, paste and go on to submit the solution
autocmd filetype cpp nnoremap <Leader><Space> :FzfFiles ~/programming/CPlibrary/snippets/<CR>
autocmd filetype java nnoremap <F5> :w <bar> !javac % && java -enableassertions %:r <CR>
autocmd filetype python nnoremap <F5> :w <bar> !python3 % < ./inp.txt <CR>

"***********************************************************************************************************************************


"****************************************************************MUNDO Tree*********************************************************

nnoremap <F5> :MundoToggle<CR> " Use J,K to move up and down
set undofile " set undotree to save to file
set undodir=~/.config/nvim/undodir " set undotree file directory
let g:mundo_width = 60
let g:mundo_height = 20
let g:mundo_preview_height = 20
let g:mundo_right = 1

"***********************************************************************************************************************************

set timeoutlen=500
set signcolumn=yes
set clipboard=unnamedplus
set backspace=indent,eol,start
set softtabstop=4
set shiftwidth=4
set tabstop=4
set expandtab
set number
set relativenumber
set ruler
set showcmd
set errorformat^=%-GIn\ file\ included\ %.%#
set foldmethod=syntax
set conceallevel=2
set list lcs=tab:»\ ,trail:␣,extends:▶,precedes:◀

set undofile
inoremap <Esc> <Esc>:w<CR>
nnoremap <Esc> <Esc>:w<CR>
vnoremap <Esc> <Esc>:w<CR>
inoremap jk <Esc>:w<CR>
nnoremap <C-a> <esc>ggVG<CR>

set cindent cinoptions=N-s,g0,j1,(s,m1

set splitright splitbelow

set ignorecase smartcase
nnoremap * /\<<C-R>=expand('<cword>')<CR>\><CR>
nnoremap # ?\<<C-R>=expand('<cword>')<CR>\><CR>

" Map <CR> to :nohl, except in quickfix windows
nnoremap <silent> <expr> <CR> &buftype ==# 'quickfix' ? "\<CR>" : ":nohl\<CR>"

nnoremap gA :%y+<CR>

" Necessary for terminal buffers not to die
"set hidden
autocmd TermOpen * set bufhidden=hide

"NERDTree Configuration
" Start NERDTree. If a file is specified, move the cursor to its window.
"autocmd StdinReadPre * let s:std_in=1
"autocmd VimEnter * NERDTree | if argc() > 0 || exists("s:std_in") | wincmd p | endif
" Exit Vim if NERDTree is the only window left.
autocmd BufEnter * if tabpagenr('$') == 1 && winnr('$') == 1 && exists('b:NERDTree') && b:NERDTree.isTabTree() |
"      \ quit | endif
" Open the existing NERDTree on each new tab.
"autocmd BufWinEnter * silent NERDTreeMirror
"let NERDTreeQuitOnOpen = 1


"****************************************************RANGER*************************************************************************

"rnvimr : Ranger inside Neovim
" Make Ranger replace netrw and be the file explorer
nmap <Space>r :RnvimrToggle<CR>
let g:rnvimr_ex_enable = 1
let g:rnvimr_ranger_cmd = 'ranger --cmd="set draw_borders both"'

"***********************************************************************************************************************************



set title

set nojoinspaces

set mouse=a

set autoread
autocmd BufEnter,FocusGained * checktime

" Update gutters 200 ms
set updatetime=200

cmap w!! w !sudo tee > /dev/null %

let g:python_host_prog = '/home/manas/anaconda3/bin/python'
let g:python3_host_prog = '/home/manas/anaconda3/bin/python3'

let g:ycm_global_ycm_extra_conf = '~/.config/nvim/ycm_global_extra_conf.py'

let g:ycm_max_diagnostics_to_display = 0
let g:ycm_autoclose_preview_window_after_completion = 1
let g:ycm_add_preview_to_completeopt = 1
let g:ycm_auto_trigger = 1
let g:ycm_min_num_of_chars_for_completion = 1
let g:ycm_autoclose_preview_window_after_insertion = 1
let g:ycm_semantic_triggers =  {
  \   'c,cpp,objc': ['_', '->', '.', 're!\[[_a-zA-Z]+\w*\s', 're!^\s*[^\W\d]\w*\s',
  \            're!\[.*\]\s'],
  \ }
let g:ycm_key_invoke_completion = '<C-Space>'
let g:ycm_key_list_stop_completion = ['<C-y>']
let g:ycm_key_list_select_completion = ['<TAB>', '<Down>']
let g:ycm_key_list_previous_completion = ['<S-TAB>', '<Up>']
let g:ycm_use_clangd = 1
let g:ycm_clangd_binary_path = "/bin/clangd"

let g:ycm_error_symbol = '✗'
let g:ycm_warning_symbol = '∙∙'

set completeopt+=preview

let delimitMate_expand_cr = 1
autocmd FileType tex let b:delimitMate_autoclose = 0

let g:bufferline_rotate=1
let g:bufferline_fixed_index=-1
let g:bufferline_echo = 0

noremap <silent> <Leader>w :call ToggleWrap()<CR>
function WrapOn()
  setlocal wrap linebreak
  set virtualedit=
  setlocal display+=lastline
  noremap  <buffer> <silent> <Up>   g<Up>
  noremap  <buffer> <silent> <Down> g<Down>
  noremap  <buffer> <silent> <Home> g<Home>
  noremap  <buffer> <silent> <End>  g<End>
  inoremap <buffer> <silent> <Up>   <C-o>gk
  inoremap <buffer> <silent> <Down> <C-o>gj
  inoremap <buffer> <silent> <Home> <C-o>g<Home>
  inoremap <buffer> <silent> <End>  <C-o>g<End>
endfunction
function WrapOff()
  setlocal nowrap
  set virtualedit=
  silent! nunmap <buffer> <Up>
  silent! nunmap <buffer> <Down>
  silent! nunmap <buffer> <Home>
  silent! nunmap <buffer> <End>
  silent! iunmap <buffer> <Up>
  silent! iunmap <buffer> <Down>
  silent! iunmap <buffer> <Home>
  silent! iunmap <buffer> <End>
endfunction
function ToggleWrap()
  if &wrap
    echo "Wrap OFF"
    call WrapOff()
  else
    echo "Wrap ON"
    call WrapOn()
  endif
endfunction
call WrapOn()

if $TERM =~ 'rxvt' || $TERM =~'termite' || $TERM =~ 'gnome-terminal'
  let g:solarized_visibility='low'
  set background=light
  colorscheme solarized
endif

highlight! link SignColumn LineNr

set spellfile=~/.vim/spell/en.utf-8.add

set laststatus=2

let g:airline_powerline_fonts = 1
let g:airline_theme='ayu_dark'

"let g:NERDAltDelims_c = 1

let g:tex_flavor='latex'
if has('nvim')
  let g:vimtex_compiler_progname='nvr'
endif
if has('nvim') && !has('nvim-0.2')
  let g:vimtex_quickfix_latexlog = {'fix_paths':0}
endif
if executable('zathura')
  let g:vimtex_view_method='zathura'
endif
let g:vimtex_quickfix_open_on_warning=0

" lisp/scheme
autocmd filetype lisp,scheme setlocal equalprg=$HOME/.config/nvim/plugged/scmindent/scmindent.rkt

set printoptions+=paper:letter

autocmd BufNewFile,BufReadPost *.md set filetype=markdown
let g:airline#extensions#wordcount#enabled = 1
let g:airline#extensions#wordcount#filetypes = ['help', 'markdown', 'rst', 'org', 'text', 'asciidoc', 'tex', 'mail']
let g:airline#extensions#wordcount#filetypes += ['pandoc']
let g:pandoc#formatting#mode = 'h'
let g:pandoc#formatting#textwidth = 80

let hostfile= $HOME . '/vimrc-' . hostname()
if filereadable(hostfile)
  exe 'source ' . hostfile
endif

let g:kat_theme='light'

autocmd StdinReadPre * let s:std_in=1
"autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTreeToggle | endif
"nnoremap <silent> <Leader>n :silent! NERDTreeFind<CR>:NERDTreeFocus<CR>

if has('nvim')
  " For neovim 0.1.7
  "let $NVIM_TUI_ENABLE_CURSOR_SHAPE = 1
  " For neovim 0.2
  "set guicursor=blah
else
  if $TERM =~ '^xterm\|rxvt'
    " Insert mode
    let &t_SI = "\<Esc>[5 q"
    " Replace mode
    if has("patch-7.4-687")
      let &t_SR = "\<Esc>[3 q"
    endif
    " Normal mode
    let &t_EI = "\<Esc>[2 q"

    " 1 or 0 -> blinking block
    " 2 -> solid block
    " 3 -> blinking underscore
    " 4 -> solid underscore
    " Recent versions of xterm (282 or above) also support
    " 5 -> blinking vertical bar
    " 6 -> solid vertical bar
  endif
endif

if has('nvim')
  tnoremap <S-Esc> <Esc>
  tnoremap <Esc> <C-\><C-n>
  autocmd TermOpen * startinsert
  au FileType fzf tnoremap <buffer> <Esc> <Esc>
endif
" Project root
let g:rootmarkers = ['.projectroot','Makefile','.git','.hg','.svn','.bzr','_darcs','build.xml']


"*******************************************FZF*************************************************************************************

" FZF configs

let g:fzf_action = {
    \ 'ctrl-t': 'tab split',
    \ 'ctrl-x': 'split',
    \ 'ctrl-v': 'vsplit',
    \ 'ctrl-o': ':r !echo',
    \ 'ctrl-y': ':%w !xclip -selection clipboard',
    \ }

let $FZF_DEFAULT_COMMAND = 'rg --files'
let g:fzf_command_prefix = 'Fzf'
let g:fzf_buffers_jump = 1
"command! FzfProjectFiles execute 'FzfFiles' projectroot#guess()
"nnoremap <silent> <Leader><Space> :FzfFiles %:p:h<CR>
nnoremap <silent> <Leader><Space> :FzfFiles ./<CR>
"search in the current file
nnoremap <silent> <Leader>f :FzfBLines<CR>
"search lines in buffers
nnoremap <silent> <Leader>bf :FzfLines<CR>
"See listing of all buffers
nnoremap <silent> <Leader>a :FzfBuffers<CR>
"See listing of all windows
nnoremap <silent> <Leader>A :FzfWindows<CR>

" [Buffers] Jump to the existing window if possible
let g:fzf_buffers_jump = 1

" [[B]Commits] Customize the options used by 'git log':
let g:fzf_commits_log_options = '--graph --color=always --format="%C(auto)%h%d %s %C(black)%C(bold)%cr"'

" [Tags] Command to generate tags file
let g:fzf_tags_command = 'ctags -R'

"***********************************************************************************************************************************


nnoremap <silent> <Leader>yy :YcmCompleter GoTo<CR>
nnoremap <silent> <Leader>yr :YcmCompleter GoToReferences<CR>
nnoremap <Leader>yd :YcmDiags<CR>
nnoremap <Leader>yf :YcmCompleter FixIt<CR>
nnoremap <Leader>y: :YcmCompleter<Space>

"Mixed Keybindings @ gandalf0151
inoremap <C-e> <C-o>$
inoremap <C-a> <C-o>^
inoremap <C-h> <Left>
inoremap <C-j> <Down>
inoremap <C-k> <Up>
inoremap <C-l> <Right>
"inoremap <C-w> <C-o>w

au BufWrite *.go :Autoformat

let g:gutentags_project_root_finder = 'projectroot#guess'
let g:gutentags_generate_on_missing = 0
let g:gutentags_generate_on_new = 0
let g:gutentags_modules = ['ctags', 'cscope']
let g:gutentags_cache_dir = $HOME . '/.cache/gutentags'
let g:gutentags_ctags_tagfile = '.vimtags'
set tags=./.vimtags;,.vimtags,./tags;,tags

let g:cmake_export_compile_commands = 1

set cscopetag

let g:ycm_enable_diagnostic_signs=1
" Thanks to http://superuser.com/questions/558876/how-can-i-make-the-sign-column-show-up-all-the-time-even-if-no-signs-have-been-a
"autocmd BufEnter * sign define dummy
"autocmd BufEnter * execute 'sign place 9999 line=1 name=dummy buffer=' . bufnr('')

com -range=% -nargs=1 P exe "<line1>,<line2>!".<q-args> | y | sil u | echom @"
com -range=% Hash <line1>,<line2>P cpp -P -fpreprocessed | tr -d '[:space:]' | md5sum
au FileType cpp com! -buffer -range=% Hash <line1>,<line2>P cpp -P -fpreprocessed | tr -d '[:space:]' | md5sum

nmap <leader>sp :call <SID>SynStack()<CR>
function! <SID>SynStack()
  if !exists("*synstack")
    return
  endif
  echo map(synstack(line('.'), col('.')), 'synIDattr(v:val, "name")')
endfunc

let g:NERDTreeGitStatusIndicatorMapCustom = {
      \ 'Modified'  :'✹',
      \ 'Staged'    :'✚',
      \ 'Untracked' :'✭',
      \ 'Renamed'   :'➜',
      \ 'Unmerged'  :'═',
      \ 'Deleted'   :'✖',
      \ 'Dirty'     :'✗',
      \ 'Ignored'   :'☒',
      \ 'Clean'     :'✔︎',
      \ 'Unknown'   :'?',
      \ }

let g:NERDTreeGitStatusUseNerdFonts = 1 " you should install nerdfonts by yourself. default: 0
let g:NERDTreeGitStatusShowClean = 1 " default: 0
let g:WebDevIconsDisableDefaultFolderSymbolColorFromNERDTreeDir = 1
let g:WebDevIconsDisableDefaultFileSymbolColorFromNERDTreeFile = 1
let g:NERDTreeDisableFileExtensionHighlight = 1
let g:NERDTreeDisableExactMatchHighlight = 1
let g:NERDTreeDisablePatternMatchHighlight = 1
let g:NERDTreeFileExtensionHighlightFullName = 1
let g:NERDTreeExactMatchHighlightFullName = 1
let g:NERDTreePatternMatchHighlightFullName = 1
let g:NERDTreeHighlightFolders = 1 " enables folder icon highlighting using exact match
let g:NERDTreeHighlightFoldersFullName = 1 " highlights the folder name
" you can add these colors to your .vimrc to help customizing
let s:brown = "905532"
let s:aqua =  "3AFFDB"
let s:blue = "689FB6"
let s:darkBlue = "44788E"
let s:purple = "834F79"
let s:lightPurple = "834F79"
let s:red = "AE403F"
let s:beige = "F5C06F"
let s:yellow = "F09F17"
let s:orange = "D4843E"
let s:darkOrange = "F16529"
let s:pink = "CB6F6F"
let s:salmon = "EE6E73"
let s:green = "8FAA54"
let s:lightGreen = "31B53E"
let s:white = "FFFFFF"
let s:rspec_red = 'FE405F'
let s:git_orange = 'F54D27'

let g:NERDTreeExtensionHighlightColor = {} " this line is needed to avoid error
let g:NERDTreeExtensionHighlightColor['css'] = s:blue " sets the color of css files to blue

let g:NERDTreeExactMatchHighlightColor = {} " this line is needed to avoid error
let g:NERDTreeExactMatchHighlightColor['.gitignore'] = s:git_orange " sets the color for .gitignore files

let g:NERDTreePatternMatchHighlightColor = {} " this line is needed to avoid error
let g:NERDTreePatternMatchHighlightColor['.*_spec\.rb$'] = s:rspec_red " sets the color for files ending with _spec.rb

let g:WebDevIconsDefaultFolderSymbolColor = s:beige " sets the color for folders that did not match any rule
let g:WebDevIconsDefaultFileSymbolColor = s:blue " sets the color for files that did not match any rule
let g:NERDTreeLimitedSyntax = 0

" Select the font for the hardcopy
"set printfont=Courier:h8
command! -range=% HardcopyPdf <line1>,<line2> hardcopy > %.ps | !ps2pdf %.ps && rm %.ps && echo 'Created: %.pdf'