Skip to content

Instantly share code, notes, and snippets.

@braidn
Created August 11, 2020 12:20
Show Gist options
  • Save braidn/a1a389377e81f4c8d86d97bfcf6d08c9 to your computer and use it in GitHub Desktop.
Save braidn/a1a389377e81f4c8d86d97bfcf6d08c9 to your computer and use it in GitHub Desktop.
Current vimrc
set nocompatible
call plug#begin('~/.vim/plugged')
set encoding=utf-8
scriptencoding utf-8
set shell=/bin/bash
""Plugs
Plug 'cocopon/iceberg.vim'
Plug 'mattn/gist-vim'
Plug 'mattn/webapi-vim'
Plug 'justinmk/vim-sneak'
Plug 'Yggdroot/indentLine'
Plug 'othree/yajs.vim', { 'for': 'javascript' }
Plug 'HerringtonDarkholme/yats.vim', { 'for': 'typescript' }
Plug 'tpope/vim-rails', { 'for': 'ruby' }
Plug 'tpope/vim-surround'
Plug 'machakann/vim-sandwich'
Plug 'AndrewRadev/switch.vim'
" Plug 'tpope/vim-fugitive'
Plug 'lambdalisue/gina.vim'
Plug 'rhysd/git-messenger.vim'
Plug 'tpope/vim-repeat'
Plug 'janko-m/vim-test'
Plug 'b3niup/numbers.vim'
Plug 'itchyny/lightline.vim'
Plug 'mbbill/undotree'
Plug 'thoughtbot/vim-rspec', { 'for': 'ruby' }
Plug 'tpope/vim-dispatch'
Plug 'fatih/vim-go', { 'for': 'go'}
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
Plug 'junegunn/fzf.vim'
Plug '/usr/local/opt/fzf'
Plug 'tpope/vim-commentary'
Plug 'editorconfig/editorconfig-vim'
Plug 'luochen1990/rainbow'
Plug 'itspriddle/vim-marked'
Plug 'sheerun/vim-polyglot'
Plug 'othree/jspc.vim'
Plug 'honza/vim-snippets'
Plug 'keith/swift.vim', { 'for': 'swift' }
Plug 'kballard/vim-swift', { 'for': 'swift' }
Plug 'dafufer/nvim-cm-swift-completer', { 'for': 'swift' }
Plug 'burner/vim-svelte', { 'for': 'svelte' }
Plug 'Shougo/neosnippet.vim'
Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
Plug 'Shougo/deoplete-lsp'
Plug 'neovim/nvim-lsp'
Plug 'tmsvg/pear-tree'
Plug 'airblade/vim-rooter'
" Plug 'neoclide/coc.nvim', {'do': { -> coc#util#install()}}
Plug 'skywind3000/asynctasks.vim'
Plug 'skywind3000/asyncrun.vim'
Plug 'rizzatti/dash.vim'
Plug 'Shougo/denite.nvim', { 'do': ':UpdateRemotePlugins' }
""Will you make the cut
Plug 'ryanoasis/vim-devicons'
Plug 'kyazdani42/nvim-tree.lua'
Plug 'kyazdani42/nvim-web-devicons'
Plug 'norcalli/nvim-colorizer.lua'
Plug 'elzr/vim-json', { 'for': 'json' }
Plug 'rbong/vim-flog'
Plug 'malkomalko/projections.vim'
Plug 'mxw/vim-jsx'
Plug 'xolox/vim-misc'
Plug 'jparise/vim-graphql'
Plug 'reasonml-editor/vim-reason-plus'
Plug 'othree/csscomplete.vim'
Plug 'othree/html5.vim'
Plug 'othree/jspc.vim'
Plug 'metakirby5/codi.vim'
Plug 'SirVer/ultisnips'
" Plug 'autozimu/LanguageClient-neovim', {
" \ 'branch': 'next',
" \ 'do': 'bash install.sh',
" \ }
call plug#end() " required
filetype plugin indent on
runtime macros/sandwich/keymap/surround.vim
let g:lightline = {
\ 'colorscheme': 'iceberg',
\ 'active': {
\ 'left': [ [ 'mode', 'paste' ], [ 'gitstatus', 'filename' ] ],
\ 'right': [ [ 'lineinfo' ], ['percent'], [ 'fileformat', 'fileencoding', 'filetype' ] ]
\ },
\ 'component_function': {
\ 'gitstatus': 'MyGitStatus',
\ 'filename': 'MyFilename',
\ 'fileformat': 'MyFileformat',
\ 'filetype': 'MyFiletype',
\ 'fileencoding': 'MyFileencoding',
\ 'mode': 'MyMode',
\ },
\ 'subseparator': { 'left': '|', 'right': '|' }
\ }
function! MyModified()
return &ft =~ 'help' ? '' : &modified ? '+' : &modifiable ? '' : '-'
endfunction
function! MyReadonly()
return &ft !~? 'help' && &readonly ? 'RO' : ''
endfunction
function! MyFilename()
let fname = expand('%:t')
return fname == 'vimshell' ? vimshell#get_status_string() :
\ ('' != MyReadonly() ? MyReadonly() . ' ' : '') .
\ ('' != fname ? fname : '[No Name]') .
\ ('' != MyModified() ? ' ' . MyModified() : '')
endfunction
function MyGitStatus() abort
let branch = gina#component#repo#branch()
let status = gina#component#status#preset('fancy')
return printf(
\ '%s %s',
\ branch,
\ status,
\)
endfunction
function! MyFileformat()
return winwidth(0) > 70 ? &fileformat : ''
endfunction
function! MyFiletype()
return winwidth(0) > 70 ? (strlen(&filetype) ? &filetype : 'no ft') : ''
endfunction
function! MyFileencoding()
return winwidth(0) > 70 ? (strlen(&fenc) ? &fenc : &enc) : ''
endfunction
function! MySearch()
highlight fzf1 ctermfg=161 ctermbg=251
highlight fzf2 ctermfg=23 ctermbg=251
highlight fzf3 ctermfg=237 ctermbg=251
setlocal statusline=%#fzf1#\ >\ %#fzf2#fz%#fzf3#f
endfunction
function! MyMode()
let fname = expand('%:t')
return fname == '__Tagbar__' ? 'Tagbar' :
\ &ft == 'fzf' ? 'MySearch' :
\ &ft == 'vimshell' ? 'VimShell' :
\ winwidth(0) > 60 ? lightline#mode() : ''
endfunction
let g:rainbow_active = 1
if executable('ag')
set grepprg=rg
set grepformat=%f:%l:%c%m
endif
set grepprg=rg\ --vimgrep
"Color stuff
syntax enable
set background=dark
colorscheme iceberg
set clipboard=unnamed
" Random personal settings
set smartindent
set linespace=0 " No extra spaces between rows
set backspace=indent,eol,start
set laststatus=2
set t_Co=256
set showmode
set showcmd
set hidden
set visualbell
set number
set cursorline
set ttyfast
set shiftwidth=2
set tabstop=2
set softtabstop=2
set expandtab
set incsearch " find as you type search
set pastetoggle=<F12> " pastetoggle (sane indentation on pastes)
set hlsearch " highlight search terms
set hidden " allow buffer switching without saving
set nobackup
set nowb
set noswapfile
set wildmenu
set wildmode=longest:full,full
set synmaxcol=200
set nrformats=
set splitbelow
set splitright
set nowrap
set ttimeoutlen=100
set complete+=kspell
set shell=/usr/local/bin/zsh
let g:sneak#s_next = 1
let g:rooter_patterns = ['.git/', '.vimroot', 'Rakefile', 'package.json', 'rome.json']
"
" Leader Mapping
let mapleader = "\<Space>"
nnoremap <Leader>sl :set cc=80<CR>
nnoremap <leader>tw :set textwidth=80<cr>
"Preserve indentations from pasteboard
noremap <leader>P :set paste<CR>:put *<CR>:set nopaste<CR>
" Refresh open buffer if changed outside of vim
autocmd FocusGained,BufEnter,CursorHold,CursorHoldI *
\ if mode() !~ '\v(c|r.?|!|t)' && getcmdwintype() == '' | checktime | endif
nnoremap <leader>r :checktime<cr>
"Netrw
let g:netrw_banner = 0
let g:netrw_browse_split = 4
let g:netrw_altv = 1
let g:netrw_winsize = 25
let g:netrw_liststyle=3
let g:netrw_chgwin=2
let g:netrw_bufsettings = 'noma nomod nu nobl nowrap ro'
let g:netrw_localrmdir='rm -r'
noremap <leader>pd :Vexplore <CR>
"LuaTree
nnoremap <leader>e :LuaTreeToggle<CR>
let g:lua_tree_show_icons = {
\ 'git': 1,
\ 'folders': 0,
\ 'files': 1,
\}
"Yank into OS X, might require reattach-to-user clipboard"
noremap <leader>y "*y
noremap <leader>yy "*Y
" Vim Diff
map <silent> <leader>2 :diffget 2<CR>
map <silent> <leader>3 :diffget 3<CR>
map <silent> <leader>4 :diffget 4<CR>
"Git bindings
nnoremap <silent> <leader>gs :Gina status -s <CR>
" nnoremap <silent> <leader>gd <Plug>(gina-diff-vsplit)
nnoremap <silent> <leader>gc :Gina commit -v <CR>
nnoremap <silent> <leader>gl :Gina log <CR>
nnoremap <silent> <leader>gp :Gina push <CR>
nnoremap <silent> <leader>gw :Gina write <CR>
nnoremap <silent> <leader>gm :GitMessenger <CR>
"Indent Lines
hi Conceal ctermfg=red ctermbg=NONE
tnoremap <Leader><ESC> <C-\><C-n>
"
"Tasks
command! -bang -nargs=* -complete=file Make AsyncRun -program=make @ <args>
nnoremap ,tf :AsyncTask file-fix<cr>
nnoremap ,tr :AsyncRun
nnoremap ,tl :AsyncTaskList<cr>
" Testing
nnoremap <Leader>tn :TestNearest<cr>
nnoremap <Leader>tf :TestFile<cr>
nnoremap <Leader>ts :TestSuite<cr>
function! DockerTransform(cmd) abort
return 'docker-compose run --rm test '.a:cmd
endfunction
nnoremap <leader>twd :let g:test#transformation = 'docker'<cr>
let g:test#custom_transformations = {'docker': function('DockerTransform')}
let g:test#strategy = 'asyncrun_background'
"Switch
nnoremap - :Switch<cr>
if has('conceal')
set conceallevel=2 concealcursor=i
endif
"Key remaps
inoremap jj <ESC>
nnoremap ; :
nnoremap : ;
vnoremap ; :
vnoremap : ;
" FT Specific
au BufRead,BufNewFile jquery.*.js set ft=javascript syntax=jquery
au BufRead,BufNewFile *.rabl set ft=ruby
au BufRead,BufNewFile schema.js set ft=graphql
autocmd Filetype gitcommit setlocal spell textwidth=72
autocmd Filetype gina-commit setlocal spell textwidth=72
autocmd FileType markdown let b:dispatch = 'octodown %'
autocmd! CompleteDone * if pumvisible() == 0 | pclose | endif
let g:flog_default_arguments = { 'max_count': 1000 }
let g:vim_markdown_folding_disabled = 1
let g:vim_markdown_conceal = 0
if has('conceal')
set conceallevel=2 concealcursor=niv
endif
"JS
let g:jsx_ext_required = 1
let g:vim_json_syntax_conceal = 0
" Deoplete/Snippets Resurrection
let g:python3_host_prog = '/usr/local/bin/python3'
let g:deoplete#enable_at_startup = 1
let g:neosnippet#disable_runtime_snippets = {
\ '_' : 1,
\ }
let g:neosnippet#enable_snipmate_compatibility = 1
let g:neosnippet#snippets_directory='~/.vim/plugged/vim-snippets/snippets/'
autocmd InsertLeave,CompleteDone * if pumvisible() == 0 | pclose | endif
" Lang Server
lua require'nvim_lsp'.solargraph.setup{}
lua require'nvim_lsp'.tsserver.setup{}
lua require'nvim_lsp'.ocamlls.setup{}
lua require'nvim_lsp'.jsonls.setup{}
lua require'nvim_lsp'.terraformls.setup{}
nnoremap <silent> ,dc <cmd> lua vim.lsp.buf.declaration()<CR>
nnoremap <silent> ,df <cmd> lua vim.lsp.buf.definition()<CR>
nnoremap <silent> ,td <cmd> lua vim.lsp.buf.type_definition()<CR>
nnoremap <silent> ,di <cmd> lua vim.lsp.util.show_line_diagnostics()<CR>
nnoremap <silent> ,h <cmd> lua vim.lsp.buf.hover()<CR>
nnoremap <silent> ,i <cmd> lua vim.lsp.buf.implementation()<CR>
nnoremap <silent> ,r <cmd> lua vim.lsp.buf.references()<CR>
nnoremap <silent> ,s <cmd> lua vim.lsp.buf.signature_help()<CR>
let g:fzf_layout = { 'up': '40%' }
let g:fzf_preview_window = 'right:30%'
if has('nvim') && !exists('g:fzf_layout')
autocmd! FileType fzf
autocmd FileType fzf set laststatus=0 noshowmode noruler nu!
\| autocmd BufLeave <buffer> set laststatus=2 showmode ruler
endif
nnoremap <leader>p :Files<CR>
nnoremap <leader>f :Buffers<CR>
nnoremap <leader>/ :Rg<CR>
nnoremap <leader># :Snippets<CR>
nnoremap <leader>b :AsyncTaskFzf<CR>
function! s:fzf_sink(what)
let p1 = stridx(a:what, '<')
if p1 >= 0
let name = strpart(a:what, 0, p1)
let name = substitute(name, '^\s*\(.\{-}\)\s*$', '\1', '')
if name != ''
exec "AsyncTask ". fnameescape(name)
endif
endif
endfunction
function! s:fzf_task()
let rows = asynctasks#source(&columns * 48 / 100)
let source = []
for row in rows
let name = row[0]
let source += [name . ' ' . row[1] . ' : ' . row[2]]
endfor
let opts = { 'source': source, 'sink': function('s:fzf_sink'),
\ 'options': '+m --nth 1 --inline-info --tac' }
if exists('g:fzf_layout')
for key in keys(g:fzf_layout)
let opts[key] = deepcopy(g:fzf_layout[key])
endfor
endif
call fzf#run(opts)
endfunction
command! -nargs=0 AsyncTaskFzf call s:fzf_task()
let g:numbers_exclude = ['fzf']
set hidden
let g:asyncrun_open = 6
if has('nvim')
set termguicolors
endif
match Todo /\s\+$/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment