Skip to content

Instantly share code, notes, and snippets.

@medihack
Last active April 9, 2018 21:22
Show Gist options
  • Save medihack/b5f9d34da2734f92c41dda6abc40db15 to your computer and use it in GitHub Desktop.
Save medihack/b5f9d34da2734f92c41dda6abc40db15 to your computer and use it in GitHub Desktop.
".vimrc" for Neovim (lives in ~/.config/nvim/)
set nocompatible " be iMproved, required
" This config file lives in Ubuntu at ~/.config/nvim/init.vim
" vim-plug
" Install vim-plug, see https://github.com/junegunn/vim-plug
" Install plugins inside vim -- :PlugInstall
" Specify a directory for plugins
" - For Neovim: ~/.local/share/nvim/plugged
" - Avoid using standard Vim directory names like 'plugin'
call plug#begin('~/.local/share/nvim/plugged')
" My Plugins here:
" Dependecies
Plug 'MarcWeber/vim-addon-mw-utils' " for vim-snipmate
Plug 'tomtom/tlib_vim' " for vim-snipmate
Plug 'mattn/webapi-vim' " for gist-vim
Plug 'JulesWang/css.vim' " for vim-less
" Themes
Plug 'flazz/vim-colorschemes'
" Languages
Plug 'tpope/vim-markdown'
Plug 'python-mode/python-mode'
Plug 'vim-ruby/vim-ruby'
Plug 'tpope/vim-rails'
Plug 'skwp/vim-rspec'
Plug 'tpope/vim-git'
Plug 'briancollins/vim-jst'
Plug 'slava/vim-spacebars'
Plug 'mmalecki/vim-node.js'
Plug 'vim-scripts/csv.vim'
Plug 'othree/html5.vim'
Plug 'genoma/vim-less'
Plug 'vim-scripts/django.vim'
Plug 'pangloss/vim-javascript'
Plug 'mxw/vim-jsx'
Plug 'mustache/vim-mustache-handlebars'
Plug 'elixir-lang/vim-elixir'
Plug 'posva/vim-vue'
Plug 'medihack/sh.vim'
Plug 'w0rp/ale'
" Tools
Plug 'tmux-plugins/vim-tmux-focus-events'
Plug 'ctrlpvim/ctrlp.vim'
Plug 'scrooloose/nerdtree'
Plug 'EvanDotPro/nerdtree-chmod'
Plug 'mileszs/ack.vim'
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
Plug 'jeetsukumaran/vim-buffergator'
Plug 'mkitt/tabline.vim'
Plug 'tpope/vim-endwise'
Plug 'tpope/vim-fugitive'
Plug 'mattn/gist-vim'
Plug 'sjl/gundo.vim'
Plug 'scrooloose/nerdcommenter'
Plug 'vim-scripts/Rename2'
Plug 'garbas/vim-snipmate'
Plug 'honza/vim-snippets'
Plug 'ervandew/supertab'
Plug 'tpope/vim-surround'
Plug 'majutsushi/tagbar'
Plug 'tpope/vim-unimpaired'
Plug 'vim-scripts/vimwiki'
Plug 'troydm/zoomwintab.vim'
Plug 'tmhedberg/matchit'
Plug 'michaeljsmith/vim-indent-object'
Plug 'ap/vim-css-color'
Plug 'chrisbra/NrrwRgn'
Plug 'skalnik/vim-vroom'
Plug 'vim-scripts/mru.vim'
Plug 'bitc/vim-bad-whitespace'
Plug 'ivanov/vim-ipython'
" Unused
"Plug 'xolox/vim-misc' " dependency for vim-session
"Plug 'xolox/vim-session' " conflict swith CUA editor shortcuts
" All of your Plugins must be added before the following line
call plug#end()
"
" Normal Vim config:
"
set number
set ruler
syntax on
" Create a temporary directory for swap files if it doesn't exist
if !isdirectory($HOME . "/.local/share/nvim/tmp")
call mkdir($HOME . "/.local/share/nvim/tmp", "p")
endif
" Directories for swp files
set backupdir=~/.local/share/nvim/tmp
set directory=~/.local/share/nvim/tmp
" Default color scheme
if has('gui_running')
set background=dark
colorscheme solarized
else
set t_Co=256
" only needs to be set when not using an Putty Solarized color scheme
" https://github.com/altercation/solarized/tree/master/putty-colors-solarized
"let g:solarized_termcolors=256
set background=light
colorscheme solarized
" alterlative good looking theme
"colorscheme jellybeans
endif
" enable horizontal scrollbar
set guioptions+=b
" Set encoding
set encoding=utf-8
" Whitespace stuff
set nowrap
set tabstop=2
set shiftwidth=2
set softtabstop=2
set expandtab
set listchars=tab:>-,trail:.
" Searching
set hlsearch
set incsearch
set ignorecase
set smartcase
" Tab completion
set wildmode=list:longest,list:full
" Ignore files on tab completion, ctrl-p and ack.vim
set wildignore+=*.o,*.obj,.git,*.rbc,*.class,.svn,vendor/gems/*
set wildignore+=.meteor
set wildignore+=node_modules
" Status bar
set laststatus=2
" Make , the leader key
let mapleader = ","
" resize window
map <C-j> <C-W>-
map <C-k> <C-W>+
map <C-l> <C-W>>
map <C-h> <C-W><
" Allow to resize windows and select tabs with mouse in terminal vim
" Unfortunately makes copy&paste with mouse cumbersome, but let's try
set mouse=a
" Remember last location in file
if has("autocmd")
au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$")
\| exe "normal g'\"" | endif
endif
" make uses real tabs
au FileType make set noexpandtab
" Thorfile, Rakefile, Vagrantfile and Gemfile are Ruby
au BufRead,BufNewFile {Gemfile,Rakefile,Vagrantfile,Thorfile,config.ru} set ft=ruby
" add json syntax highlighting
au BufNewFile,BufRead *.json set ft=javascript
" use zsh syntax highlighting for also for bash (better)
au BufNewFile,BufRead *.sh set ft=zsh
" make Python follow PEP8 ( http://www.python.org/dev/peps/pep-0008/ )
au FileType python set softtabstop=4 tabstop=4 shiftwidth=4 textwidth=79
" make javascript to use jQuery code style
" Rails.vim always overrides the above (with autoload) but allows this:
au User Rails/**/*.js set shiftwidth=2 softtabstop=2 expandtab
" and also set it for non Rails Javascript files
au FileType javascript set shiftwidth=2 softtabstop=2 expandtab
" make htmldjango use 4 spaces as Django
au FileType htmldjango set softtabstop=4 tabstop=4 shiftwidth=4 expandtab
" make html files use 4 spaces
au FileType html set softtabstop=4 tabstop=4 shiftwidth=4 expandtab
" shortcuts to enable Django templates syntax in .html files
autocmd BufEnter *html map <F8> :setfiletype htmldjango<CR>
autocmd BufEnter *html map <S-F8> :setfiletype django<CR>
" shortcut to enable Handlebars templates syntax in .html files
autocmd BufEnter *html map <F9> :setfiletype html syntax=mustache<CR>
" allow backspacing over everything in insert mode
set backspace=indent,eol,start
" load the plugin and indent settings for the detected filetype
filetype plugin indent on
" Opens an edit command with the path of the currently edited file filled in
" Normal mode: <Leader>e
map <Leader>e :e <C-R>=expand("%:p:h") . "/" <CR>
" Opens a tab edit command with the path of the currently edited file filled in
" Normal mode: <Leader>t
map <Leader>te :tabe <C-R>=expand("%:p:h") . "/" <CR>
" Inserts the path of the currently edited file into a command
" Command mode: Ctrl+P
cmap <C-P> <C-R>=expand("%:p:h") . "/" <CR>
" Automatically reload externally edited files
" Needs the tmux-plugins/vim-tmux-focus-events plugin to work correctly
" see also https://unix.stackexchange.com/a/383044
"set autoread " does not work, see link above
autocmd FocusGained,BufEnter,CursorHold,CursorHoldI * if mode() != 'c' | checktime | endif
autocmd FileChangedShellPost *
\ echohl WarningMsg | echo "File changed on disk. Buffer reloaded." | echohl None
" Unimpaired configuration
" Bubble single lines
nmap <C-Up> [e
nmap <C-Down> ]e
" Bubble multiple lines
vmap <C-Up> [egv
vmap <C-Down> ]egv
" Use modeline overrides
set modeline
set modelines=10
" % to bounce from do to end etc.
runtime! macros/matchit.vim
" Show (partial) command in the status line
set showcmd
" Include user's local vim config
if filereadable(expand("~/.vimrc.local"))
source ~/.vimrc.local
endif
" use system clipboard for yanking and deleting if available
if has('x11') && has('unnamedplus')
set clipboard=unnamedplus
else
set clipboard=unnamed
endif
" allow deleting selection without updating the clipboard (yank buffer)
vnoremap x "_x
vnoremap X "_X
" no bells at all
set noerrorbells
set novisualbell
" Indent with Tab in visual mode
vmap <Tab> >gv
vmap <S-Tab> <gv
" make öö leave edit mode
imap öö <Esc>
" Stay in visual mode after indent
" see http://vim.wikia.com/wiki/Shifting_blocks_visually
vnoremap > >gv
vnoremap < <gv
" Always display the status line (current mode, filename, ...)
set laststatus=2
" For webpack hot module replacement (HMR) to work
" see https://github.com/webpack/webpack/issues/781
set backupcopy=yes
" always use working directory as start point for search in ctrlp
let g:ctrlp_working_path_mode = 0
" List index files in ctrlp
"let g:ctrlp_show_hidden = 1 # this would also list files like .pyc
let g:ctrlp_dotfiles = 1
" NERDTree configuration
let NERDTreeIgnore=['\.pyc$', '\.rbc$', '\~$']
map <Leader>n :NERDTreeToggle<CR>
map <Leader>s :NERDTreeFind<CR>
let NERDTreeShowHidden=1
" Buffergator configuration
let g:buffergator_viewport_split_policy = "T"
let g:buffergator_split_size = 10
let g:buffergator_autoexpand_on_split = 0
" zoomwintab configuration
map <Leader><Leader> :ZoomWinTabToggle<CR>
" CTags
map <Leader>rt :!ctags --extra=+f -R *<CR><CR>
map <C-\> :tnext<CR>
" Enable Flow syntax for vim-javascript plugin
let g:javascript_plugin_flow = 1
" Allow also .js extensions for vim-jsx
let g:jsx_ext_required = 0
" remap pymode toggle breakpoint as it conflicts with buffergator
let g:pymode_breakpoint_bind = '<leader>p'
" let ale handle code checking of python code and not python mode
let g:pymode_lint = 0
" disable folding in python code (enabled by default in klen/python-mode)
let g:pymode_folding = 0
" Turn off rope in python-mode
let g:pymode_rope = 0
" gist-vim defaults
if has("mac")
let g:gist_clip_command = 'pbcopy'
elseif has("unix")
let g:gist_clip_command = 'xclip -selection clipboard'
endif
let g:gist_detect_filetype = 1
let g:gist_open_browser_after_post = 1
" Turn off jslint errors by default
let g:JSLintHighlightErrorLine = 0
" MacVIM shift+arrow-keys behavior (required in .vimrc)
let macvim_hig_shift_movement = 1
" make ack.vim use ack-grep command under debian/ubuntu
let g:ackprg="ack-grep -H --nocolor --nogroup --column"
" Show recently used files (uses mru.vim plugin)
map <leader>f :MRU<CR>
" Better indentations for shell scripts (uses sh.vim plugin)
let g:sh_indent_case_labels=1
" vim-airline configuration
let g:airline_theme = 'solarized'
let g:airline_solarized_bg = 'dark'
" Use the default set of separators with a few customizations
if !exists('g:airline_powerline_fonts')
let g:airline_left_sep=' ›' " Slightly fancier than '>'
let g:airline_right_sep='‹ ' " Slightly fancier than '<'
endif
" Show the name of the currently active git branch
let g:airline#extensions#branch#enabled = 1
" Show open buffer on top
let g:airline#extensions#tabline#enabled = 1
" For project specific settings
set exrc
set secure
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment