Skip to content

Instantly share code, notes, and snippets.

@andreibosco
Last active May 17, 2020 18:39
Show Gist options
  • Save andreibosco/04414d4ef153cdd2bbc131b1eb57bf17 to your computer and use it in GitHub Desktop.
Save andreibosco/04414d4ef153cdd2bbc131b1eb57bf17 to your computer and use it in GitHub Desktop.
Vim settings
# EditorConfig is awesome: https://EditorConfig.org
# top-most EditorConfig file
root = true
# Unix-style newlines with a newline ending every file
[*]
charset = utf-8
end_of_line = lf
indent_style = space
indent_size = 2
trim_trailing_whitespace = true
insert_final_newline = true
[*.md]
trim_trailing_whitespace = false
[*.py]
indent_size = 4
# Tab indentation (no size specified)
[Makefile]
indent_style = tab
" Specify a directory for plugins
" - For Neovim: stdpath('data') . '/plugged'
" - Avoid using standard Vim directory names like 'plugin'
" More info: https://github.com/junegunn/vim-plug"
call plug#begin('~/.vim/plugged')
" Insert plugins here"
Plug 'airblade/vim-gitgutter'
Plug 'editorconfig/editorconfig-vim'
Plug 'itchyny/lightline.vim'
Plug 'junegunn/fzf'
Plug 'junegunn/fzf.vim'
Plug 'mattn/emmet-vim'
Plug 'preservim/nerdtree'
Plug 'preservim/nerdcommenter'
Plug 'terryma/vim-multiple-cursors'
Plug 'tpope/vim-eunuch'
Plug 'tpope/vim-surround'
"Plug 'w0rp/ale'
Plug 'frazrepo/vim-rainbow'
Plug 'sickill/vim-monokai'
Plug 'mileszs/ack.vim'
Plug 'majutsushi/tagbar'
Plug 'tpope/vim-fugitive'
Plug 'scrooloose/syntastic'
Plug 'psf/black', { 'branch': 'stable' }
Plug 'jiangmiao/auto-pairs'
Plug 'vim-scripts/django.vim'
" Enable if you want autocomple
" It requires to be compile after installing the plugin
" Full instructions here:
" https://github.com/ycm-core/YouCompleteMe/
Plug 'valloric/youcompleteme'
" Initialize plugin system
call plug#end()
" Use silver-searcher (ag) instead of ack
let g:ackprg = 'ag --nogroup --nocolor --column'
" Syntastic settings
set statusline+=%#warningmsg#
set statusline+=%{SyntasticStatuslineFlag()}
set statusline+=%*
let g:syntastic_always_populate_loc_list = 1
let g:syntastic_auto_loc_list = 1
let g:syntastic_check_on_open = 1
let g:syntastic_check_on_wq = 0
" Turn on syntax highlighting.
syntax on
" Set colorscheme to monokai
colorscheme monokai
" Enable rainbow brackets
let g:rainbow_active = 1
" Black settings (python autoformatter)
autocmd BufWritePre *.py execute ':Black'
" Toggle to enable past mode (necessary to avoid issues with autoindentation)
set pastetoggle=<F2>
" Custom key mapping
map <C-p> :Files<CR>
map <C-b> :NERDTreeToggle<CR>
map <C-t> :tabnew<CR>
map <F3> :TagbarToggle<CR>
map <F4> :botright terminal ++rows=15<CR>
map <F6> :Black<CR>
" Autofocus on tagbar when it gets opened
let g:tagbar_autofocus = 1
" Automatically wrap text that extends beyond the screen length.
set wrap
" Uncomment below to set the max textwidth. Use a value corresponding to the width of your screen.
" set textwidth=79
set formatoptions=tcqrn1
set tabstop=2
set autoindent
set shiftwidth=2
set softtabstop=2
set expandtab
set noshiftround
" Highlight current line
set cursorline
" Status bar
set laststatus=2
" Display options
set showmode
set showcmd
" Highlight matching pairs of brackets. Use the '%' character to jump between them.
set matchpairs+=<:>
" Display different types of white spaces.
set list
set listchars=tab:›\ ,trail:•,extends:#,nbsp:.
" Show line numbers
set number
" Highlight matching search patterns
set hlsearch
" Enable incremental search
set incsearch
" Include matching uppercase words with lowercase search term
set ignorecase
" Include only uppercase words with uppercase search term
set smartcase
" Display 5 lines above/below the cursor when scrolling with a mouse.
set scrolloff=5
" Fixes common backspace problems
set backspace=indent,eol,start

How to use these files

  1. Install vim-plug
  2. Install the following packages:
  • Ubuntu-based distro: sudo apt install exuberant-ctags silversearcher-ag
  • MacOS homebrew:
    brew install the_silver_searcher
    brew install --HEAD universal-ctags/universal-ctags/universal-ctags
    
  1. If you want to use youcompleteme, also install these:
  • Ubuntu-based distro:
    sudo apt install build-essential cmake vim python3-dev mono-complete golang
    curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash -
    sudo apt install -y nodejs
    
  1. Copy the files .vimrc and .editorconfig to your user home directory
  2. Open vim and run the following command: :PlugInstall
  3. Customize .vimrc to your liking (mine is mostly set up for python and django development)
  • If you edit .vimrc, to reload your settings run this command: :source %
  1. Enjoy :D
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment