Skip to content

Instantly share code, notes, and snippets.

@mikroskeem
Last active February 7, 2016 22:34
Show Gist options
  • Save mikroskeem/7c8456ca949b1b867202 to your computer and use it in GitHub Desktop.
Save mikroskeem/7c8456ca949b1b867202 to your computer and use it in GitHub Desktop.
Tiny (neo)vim config
" ###### Many settings, wow'
" Better tab completion
set wildmode=longest,list,full
" Airline does this already
set noshowmode
" Do not use double space on some characters
set ambiwidth=single
" Remove startup screen
set shortmess+=I
" Allow placing cursor beyond text/whitespace
set virtualedit=all
set nostartofline
" Wrap lines
set wrap
set textwidth=0
set wrapmargin=0
" Dark background
set background=dark
" Addionational information
set ruler
" Show line numbers
set number
" Line number row design
set numberwidth=3
" Better clipboard
set clipboard+=unnamedplus
set showmatch
set smartcase
set ignorecase
" Better undo/swap/backup file directories
set undofile
set undoreload=100
set viminfo+=n$HOME/.config/nvim/tmp/viminfo
set showtabline=0
set backup
set backupdir=$HOME/.config/nvim/tmp/backup/
set undodir=$HOME/.config/nvim/tmp/undo/
set directory=$HOME/.config/nvim/tmp/swap/
" ###### Functions
" Center the text
function! s:filter_header(lines) abort
let longest_line = max(map(copy(a:lines), 'len(v:val)'))
let centered_lines = map(copy(a:lines),
\ 'repeat(" ", (&columns / 2) - (longest_line / 2)) . v:val')
return centered_lines
endfunction
" mkdir -p function
function! MkdirP(p)
if !isdirectory(expand(a:p))
call mkdir(expand(a:p), "p")
endif
endfunction
" Make missing dirs
silent! call MkdirP(&undodir)
silent! call MkdirP(&backupdir)
silent! call MkdirP(&directory)
" Install vim-plug
" curl -fLo ~/.config/nvim/autoload/plug.vim --create-dirs \
" https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
call plug#begin('~/.config/nvim/plugins')
" ###### Plugins
" ### Syntax-related
" Highlighting/Syntax enchancements
Plug 'kchmck/vim-coffee-script'
Plug 'elzr/vim-json'
Plug 'PotatoesMaster/i3-vim-syntax'
Plug 'tpope/vim-markdown'
Plug 'jelera/vim-javascript-syntax'
Plug 'Matt-Deacalion/vim-systemd-syntax'
Plug 'nelstrom/vim-markdown-folding'
Plug 'digitaltoad/vim-jade'
Plug 'wavded/vim-stylus'
" Syntax checking
Plug 'scrooloose/syntastic'
" ### Looks
" Status/bufferline
Plug 'bling/vim-bufferline'
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
" Colorschemes
Plug 'tomasr/molokai'
" Better startup screen
Plug 'mhinz/vim-startify'
" ZEN (No distractions)
Plug 'junegunn/goyo.vim', { 'on': 'Goyo' }
Plug 'junegunn/limelight.vim', { 'on': 'Limelight' }
" ### More functionality
" Paste-related stuff
Plug 'mattn/webapi-vim', { 'on': 'Gist' }
Plug 'mattn/gist-vim', { 'on': 'Gist' }
" File listing
Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' }
" ###### Plugins end
call plug#end()
" ###### Enable airline
let g:airline_theme = 'powerlineish'
let g:airline#extensions#branch#enabled = 1
let g:airline_powerline_fonts = 0
let g:airline#extensions#whitespace#enabled = 1
let g:airline#extensions#hunks#non_zero_only = 1
"let g:airline#extensions#tabline#enabled = 1
" Fix airline whitespace
if !exists('g:airline_symbols')
let g:airline_symbols = {}
endif
let g:airline_symbols.space = ' '
" ###### Bufferline
let g:bufferline_echo = 0
let g:bufferline_fname_mod = ':t -'
let g:bufferline_active_buffer_left = '<|'
let g:bufferline_active_buffer_right = '|>'
let g:bufferline_show_bufnr = 1
let g:bufferline_modified = '*'
" ###### Colors (y)
silent! colorscheme molokai
let g:molokai_original = 0
let g:rehash256 = 0
" ###### Syntastic
let g:syntastic_enable_balloons = 1
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
let g:syntastic_mode_map = {
\ "mode": "active",
\ "active_filetypes": ["javascript", "python", "coffee", "jade", "i3", "vim"],
\ "passive_filetypes": []}
let g:syntastic_javascript_checkers = ['eslint']
" ###### Startify
let g:startify_session_dir = '~/.config/nvim/startly-session'
let g:startify_custom_header = s:filter_header(map(split(system('fortune | cowsay'), '\n'), '" ". v:val') + ['',''])
" ###### NERDTree
let NERDTreeHijackNetrw = 0
" ###### Indent
set softtabstop=4
set shiftwidth=4
set expandtab
" Fix indent on some files
autocmd! FileType yaml,coffee,vim,jade set shiftwidth=2 softtabstop=2
autocmd! FileType make set shiftwidth=2 tabstop=2 noexpandtab
" Limelight when Goyo
autocmd! User GoyoEnter Limelight
autocmd! User GoyoLeave Limelight!
" ###### Useful keybinds
" ### Tab controls
nnoremap <silent> <C-Left> :tabprevious<CR>
nnoremap <silent> <C-Right> :tabnext<CR>
nnoremap <silent> <C-Up> :tabnew<CR>
nnoremap <silent> <C-Down> :tabclose<CR>
" ### Commonly used commands
" Undo
nnoremap <silent> <C-z> :u<CR>
" Write and gtfo
nnoremap <silent> <C-x> :x<CR>
" Just write
nnoremap <silent> <C-o> :w<CR>
" Quit without writing
nnoremap <silent> <C-A-x> :q!<CR>
" Remove search highlighting
nnoremap <silent> <C-A-a> :noh<CR>
" ### Commands from plugins/neovim
" NeoVim term
if has('nvim')
nnoremap <silent> <C-A-t> :term<CR>
endif
" Goyo mode
nnoremap <silent> <C-A-z> :Goyo<CR>
" Gist
nnoremap <silent> <C-A-g> :Gist -p<CR>
" File listing
nnoremap <silent> <C-n> :NERDTreeToggle<CR>
" Toggle (read: fuck) Syntastic
nnoremap <silent> <C-A-f> :SyntasticToggleMode<CR>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment