Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save jimmiebtlr/57464d16819a8407f4deeea637e63d2f to your computer and use it in GitHub Desktop.
Save jimmiebtlr/57464d16819a8407f4deeea637e63d2f to your computer and use it in GitHub Desktop.
" Modeline and Notes {{{ vim: set foldmethod=marker foldmarker={{{,}}} foldlevel=0 foldnestmax=2:
" To be used inside docker.
" }}}
" Theme {{{
set background=dark
colorscheme slate
" }}}
" Kitchen sink {{{
set clipboard+=unnamedplus
set t_Co=256
set autoread
set backupcopy=yes
set showmatch
set modeline
au BufNewFile,BufFilePre,BufRead *.md set filetype=markdown
filetype plugin indent on
" }}}
" Setup plugins {{{
call plug#begin('/home/jimmie/.config/nvim/bundle')
Plug 'neomake/neomake'
Plug 'benjie/neomake-local-eslint.vim'
Plug 'fatih/vim-go'
Plug 'mileszs/ack.vim'
Plug 'ctrlpvim/ctrlp.vim'
Plug 'pangloss/vim-javascript'
Plug 'mxw/vim-jsx'
Plug 'tpope/vim-surround'
Plug 'tpope/vim-dispatch'
Plug 'vim-airline/vim-airline'
Plug 'ruanyl/vim-fixmyjs'
Plug 'chrisbra/Colorizer'
" Add plugins to &runtimepath
call plug#end()
" }}}
" GO {{{
let g:go_fmt_command = "goimports"
set rtp+=$GOPATH/src/github.com/golang/lint/misc/vim
" }}}
" Linting + Formatting {{{
" Golang {{{
let g:go_metalinter_enabled = ['vet', 'golint', 'errcheck', 'vetshadow', 'golint', 'ineffassign', 'goconst']
let g:go_metalinter_autosave = 1
let g:go_fmt_fail_silently = 1
let g:go_auto_type_info = 1
let g:go_highlight_functions = 1
let g:go_highlight_methods = 1
let g:neomake_go_checkers = []
"autocmd! FileType go autocmd FileReadPost,BufEnter,BufWinEnter,InsertEnter,InsertChange,InsertLeave,BufWritePre Neomake
" }}}
" JS {{{
let g:neomake_javascript_enabled_makers = ['eslint']
" autocmd! InsertLeave * Neomake
autocmd! FileType javascript,css,scss ColorHighlight
" }}}
" }}}
" Strip Whitespace {{{
function! StripTrailingWhitespace()
" Preparation: save last search, and cursor position.
let _s=@/
let l = line(".")
let c = col(".")
" do the business:
%s/\s\+$//e
" clean up: restore previous search history, and cursor position
let @/=_s
call cursor(l, c)
endfunction
autocmd FileType c,cpp,java,php,javascript,puppet,python,rust,twig,xml,yml,perl,sql autocmd InsertLeave <buffer> if !exists('g:spf13_keep_trailing_whitespace') | call StripTrailingWhitespace() | endif
" }}}
" Display Formatting {{{
set number " Line numbers on
set showmatch " Show matching brackets/parenthesis
set hlsearch
set nowrap " Do not wrap long lines
set autoindent " Indent at the same level of the previous line
set shiftwidth=2 " Use indents of 4 spaces
set expandtab " Tabs are spaces, not tabs
set tabstop=2 " An indentation every four columns
set softtabstop=2 " Let backspace delete indent
set nojoinspaces " Prevents inserting two spaces after punctuation on a join (J)
set splitright " Puts new vsplit windows to the right of the current
set splitbelow " Puts new split windows to the bottom of the current
"set matchpairs+=<:> " Match, to be used with %
set pastetoggle=<F12> " pastetoggle (sane indentation on pastes)
"set comments=sl:/*,mb:*,elx:*/ " auto format comment blocks
autocmd BufNewFile,BufRead *.html.twig set filetype=html.twig
autocmd FileType haskell,puppet,ruby,yml,html,jsx,js setlocal expandtab shiftwidth=2 softtabstop=2
autocmd FileType markdown set tw=79
autocmd FileType markdown set wrap linebreak nolist
autocmd BufNewFile,BufRead *.coffee set filetype=coffee
" }}}
" Shortcuts {{{
let mapleader = "\<Space>"
nnoremap <Leader>o :CtrlPClearCache<CR>:CtrlP<CR>
nnoremap <Leader>s :w<CR>
"nnoremap <Leader>f gg=G
autocmd FileType javascript nnoremap <Leader>f :Fixmyjs<CR>:Neomake<CR>
let g:fixmyjs_use_local = 1
"}}}
" Triggers {{{
" autocmd InsertLeave * write
"}}}
" cntrl-p {{{
" ignore several folders
let g:ctrlp_custom_ignore = 'node_modules\|DS_Store\|meteor\|coverage\|dist\|build\|karma*\|jest\|vendor'
" }}}
"
" Local vimrc (per folder) {{{
if filereadable(".vim.custom")
so .vim.custom
endif
" }}}
" Persistant Undo {{{
set undodir=~/.config/nvim/undos
set undofile
" }}}
" Folding {{{
set foldenable
set foldmethod=indent
set foldlevel=2
set foldnestmax=1
" }}}
syntax on
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment