Skip to content

Instantly share code, notes, and snippets.

@lwakefield
lwakefield / deepget.js
Created September 14, 2016 20:33
deepget.js
function get (obj, key, fallback=undefined) {
const keyPath = key.split('.')
try {
return keyPath.reduce((obj, key) => {
if (!(key in obj)) throw new TypeError()
return obj[key]
}, obj)
} catch (e) {
return fallback
}
@lwakefield
lwakefield / tabcomplete.vim
Last active January 23, 2018 21:12
tabcomplete
inoremap <expr> <tab> pumvisible() ? '<c-n>' : '<tab>'
inoremap <expr> <s-tab> pumvisible() ? '<c-p>' : '<tab>'
augroup autocomplete
autocmd!
autocmd TextChangedI * call TypeComplete()
augroup end
fun! TypeComplete()
if getline('.')[col('.') - 2] =~ '\K' && getline('.')[col('.') - 1] !~ '\K'
call feedkeys("\<c-n>")
end
@lwakefield
lwakefield / init.vim
Last active August 27, 2018 18:05
init.vim
call plug#begin('~/.vim/plugged')
Plug 'junegunn/fzf.vim'
Plug 'tpope/vim-surround'
Plug 'tpope/vim-sensible'
Plug 'tpope/vim-commentary'
Plug 'tpope/vim-rsi'
Plug 'tpope/vim-repeat'
Plug 'tpope/vim-repeat'
Plug 'tpope/vim-sleuth'
Plug 'ludovicchabant/vim-gutentags'
class Node
end
class FooNode < Node
end
class BarNode < Node
end
class Parser
%AnonEnv1 = type {
i32,
i32
}
%AnonFn1 = type {
i32*,
i32*
}
@lwakefield
lwakefield / init.vim
Created December 11, 2019 12:36
init.vim
call plug#begin('~/.vim/plugged')
" auto complete
Plug 'neoclide/coc.nvim', {'branch': 'release'} # auto-complete
" fuzzy file opener
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
Plug 'junegunn/fzf.vim'
" horizontal alignment
Plug 'junegunn/vim-easy-align'
" syntax highlighting for everything
Plug 'sheerun/vim-polyglot'