Skip to content

Instantly share code, notes, and snippets.

@herrera-ignacio
Last active April 26, 2020 23:54
Show Gist options
  • Save herrera-ignacio/68ac5c1f0aa9329390e022f0490d2b1a to your computer and use it in GitHub Desktop.
Save herrera-ignacio/68ac5c1f0aa9329390e022f0490d2b1a to your computer and use it in GitHub Desktop.
Vim configuration

Used plugins

Useful links

Spell checking

By default, spell check will be off. If you want to turn it on, run setlocal spell in the Vim command line (if you want spell check to always be on, add set spell to your .vimrc). After turning spell check on, misspelled words will now be highlighted. To move your cursor to the next misspelled word, enter ]s. To move your cursor to the previous misspelled word, enter [s.

Most likely, the word lists you configure with the spelllang option won’t contain some common words you use, thus causing them to be marked as misspelled. Luckily, you can mitigate this issue by adding these words to your spellfile. Your spellfile is a personal word list you can add words to on the fly. To mark a word as good and add it to your spellfile, move your cursor to the word and enter zg.

Customization

  • Incremental search option: :set is? :set is :set nois
  • Highlight search option: :set hls? :set hls :nohls :set nohls
  • Column number :set nu

Tutorials

Windows Nerd Fonts

Install the fonts with Scoop if you are using Powershell/CMD. This fonts support Unicode, which is usefull with nerdTREE plugin.

scoop search '-NF'
scoop install <font>

.vimrc

Neovim for windows: ~\AppData\Local\nvim\init.vim'

" Vim's default behavior
if &compatible
  set nocompatible
endif

" Use the internal diff if available.
" Otherwise use the special 'diffexpr' for Windows.
if &diffopt !~# 'internal'
  set diffexpr=MyDiff()
endif
function MyDiff()
  let opt = '-a --binary '
  if &diffopt =~ 'icase' | let opt = opt . '-i ' | endif
  if &diffopt =~ 'iwhite' | let opt = opt . '-b ' | endif
  let arg1 = v:fname_in
  if arg1 =~ ' ' | let arg1 = '"' . arg1 . '"' | endif
  let arg1 = substitute(arg1, '!', '\!', 'g')
  let arg2 = v:fname_new
  if arg2 =~ ' ' | let arg2 = '"' . arg2 . '"' | endif
  let arg2 = substitute(arg2, '!', '\!', 'g')
  let arg3 = v:fname_out
  if arg3 =~ ' ' | let arg3 = '"' . arg3 . '"' | endif
  let arg3 = substitute(arg3, '!', '\!', 'g')
  if $VIMRUNTIME =~ ' '
    if &sh =~ '\<cmd'
      if empty(&shellxquote)
        let l:shxq_sav = ''
        set shellxquote&
      endif
      let cmd = '"' . $VIMRUNTIME . '\diff"'
    else
      let cmd = substitute($VIMRUNTIME, ' ', '" ', '') . '\diff"'
    endif
  else
    let cmd = $VIMRUNTIME . '\diff'
  endif
  let cmd = substitute(cmd, '!', '\!', 'g')
  silent execute '!' . cmd . ' ' . opt . arg1 . ' ' . arg2 . ' > ' . arg3
  if exists('l:shxq_sav')
    let &shellxquote=l:shxq_sav
  endif
endfunction

let $PYTHONHOME = 'C:\Python27-32b\'

set hls
set is
set backspace=indent,eol,start
set guifont=GoMono_NF:h12:cANSI:qDRAFT

call plug#begin('~\AppData\Local\vim\plugged')

"
" DIRECTORY TREE
" 
Plug 'preservim/nerdtree'
Plug 'tiagofumo/vim-nerdtree-syntax-highlight'
let g:NERDTreeDisableFileExtensionHighlight = 1
let g:NERDTreeDisableExactMatchHighlight = 1
let g:NERDTreeDisablePatternMatchHighlight = 1
let g:NERDTreeHighlightFolders = 1 " enables folder icon highlighting using exact match
let g:NERDTreeHighlightFoldersFullName = 1 " highlights the folder name
let g:NERDTreeLimitedSyntax = 1 " limits highlight to specific extensions
" map Ctrl+N to open nerdtree
map <C-n> :NERDTreeToggle<CR>
autocmd FileType nerdtree setlocal nolist

"
" CODE COMPLETION
"
Plug 'xavierd/clang_complete'
let g:clang_library_path='C:\Program Files (x86)\LLVM\bin'

"
" INTELLISENSE
" 
Plug 'neoclide/coc.nvim', {'branch': 'release'}
set updatetime=300
" Use tab for trigger completion with characters ahead and navigate.
" NOTE: Use command ':verbose imap <tab>' to make sure tab is not mapped by
" " other plugin before putting this into your config.
inoremap <silent><expr> <TAB>
       \ pumvisible() ? "\<C-n>" :
             \ <SID>check_back_space() ? "\<TAB>" :
                   \ coc#refresh()
inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>"
function! s:check_back_space() abort
	  let col = col('.') - 1
	    return !col || getline('.')[col - 1]  =~# '\s'
    endfunction

" GoTo code navigation.
nmap <silent> gd <Plug>(coc-definition)
nmap <silent> gy <Plug>(coc-type-definition)
nmap <silent> gi <Plug>(coc-implementation)
nmap <silent> gr <Plug>(coc-references)

"
" Icons / Glyphs
"
Plug 'ryanoasis/vim-devicons'

"
" Keybindings list
"
let g:mapleader = "\<Space>"
Plug 'liuchengxu/vim-which-key'
nnoremap <silent> <leader> :WhichKey '<Space>'<CR>

"
" Tab line
"
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
let g:airline#extensions#tabline#enabled = 1
let g:airline_theme='iceberg'

call plug#end()

"
" Color & Theme
"
colorscheme iceberg
highlight clear LineNr " column number transparent
highlight clear SignColumn
set nocursorline
highlight clear CursorLine
highlight CursorLineNR ctermbg=darkgrey
set nu

"
" Identation
"
set tabstop=4
set softtabstop=4
set shiftwidth=0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment