Skip to content

Instantly share code, notes, and snippets.

@aeruhxi
Last active February 7, 2018 05:42
Show Gist options
  • Save aeruhxi/6dac279b2981437a3a6975dd9dff88d4 to your computer and use it in GitHub Desktop.
Save aeruhxi/6dac279b2981437a3a6975dd9dff88d4 to your computer and use it in GitHub Desktop.
vimrc
call plug#begin('~/.vim/plugged')
Plug 'sbdchd/neoformat'
Plug 'godlygeek/tabular'
Plug 'neovimhaskell/haskell-vim'
" Plug 'parsonsmatt/intero-neovim'
Plug 'terryma/vim-multiple-cursors'
Plug 'jiangmiao/auto-pairs'
Plug 'alvan/vim-closetag'
Plug 'sbdchd/neoformat'
Plug 'neomake/neomake'
Plug 'reasonml-editor/vim-reason-plus'
Plug 'autozimu/LanguageClient-neovim', {
\ 'branch': 'next',
\ 'do': './install.sh'
\ }
Plug 'airblade/vim-gitgutter'
Plug 'Xuyuanp/nerdtree-git-plugin'
Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' }
Plug 'morhetz/gruvbox'
Plug 'metakirby5/codi.vim'
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
Plug 'tpope/vim-surround'
Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
Plug 'wakatime/vim-wakatime'
Plug 'Yggdroot/indentLine'
Plug 'drewtempelmeyer/palenight.vim'
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
Plug 'junegunn/fzf.vim'
Plug 'ntpeters/vim-better-whitespace'
Plug 'ElmCast/elm-vim'
" elixir
Plug 'elixir-lang/vim-elixir', { 'for': 'elixir' }
Plug 'slashmili/alchemist.vim', { 'for': 'elixir' }
Plug 'tpope/vim-endwise', { 'for': 'elixir' }
" go
" Plug 'fatih/vim-go', { 'do': ':GoInstallBinaries', 'for': 'go'}
" Plug 'zchee/deoplete-go', { 'for': 'go' }
" purescript
Plug 'purescript-contrib/purescript-vim', { 'for': 'purescript' }
" javascript/typescript
" Plug 'prettier/vim-prettier', {
" \ 'for': ['javascript', 'typescript', 'css', 'less', 'scss', 'graphql'] }
Plug 'flowtype/vim-flow', { 'for': 'javascript' }
Plug 'pangloss/vim-javascript', { 'for': 'javascript' }
Plug 'leafgarland/typescript-vim', { 'for': 'typescript' }
Plug 'mxw/vim-jsx', { 'for': 'javascript' }
Plug 'Galooshi/vim-import-js', { 'for': 'javascript' }
Plug 'ternjs/tern_for_vim', { 'for': 'javascript' }
call plug#end()
" Use deoplete.
let g:deoplete#enable_at_startup = 1
inoremap <expr><tab> pumvisible() ? "\<c-n>" : "\<tab>"
set showcmd " Show (partial) command in status line.
set showmatch " Show matching brackets.
set ruler " Show the line and column numbers of the cursor.
set number " Show the line numbers on the left side.
set relativenumber
set expandtab " Insert spaces when TAB is pressed.
set tabstop=2 " Render TABs using this many spaces.
set shiftwidth=2 " Indentation amount for < and > commands.
set autowrite
set expandtab
"perf
set ttyfast
set lazyredraw
set nocursorcolumn
syntax sync minlines=256
set hid
set linespace=0 " Set line-spacing to minimum.
set nojoinspaces " Prevents inserting two spaces after punctuation on a join (J)
" More natural splits
set splitbelow " Horizontal split below current.
set splitright " Vertical split to right of current.
if !&scrolloff
set scrolloff=3 " Show next 3 lines while scrolling.
endif
if !&sidescrolloff
set sidescrolloff=5 " Show next 5 columns while side-scrolling.
endif
set nostartofline " Do not jump to first character with page commands.
set ignorecase " Make searching case insensitive
set smartcase " ... unless the query has capital letters.
set gdefault " Use 'g' flag by default with :s/foo/bar/.
set magic " Use 'magic' patterns (extended regular expressions).
let mapleader="\<SPACE>"
set incsearch
set hlsearch
" jk is escape
inoremap jk <esc>
inoremap kj <esc>
" vim airline
let g:airline#extensions#tabline#enabled = 1
let g:airline#extensions#tabline#left_sep = ' '
let g:airline#extensions#tabline#left_alt_sep = '|'
let g:airline_theme = 'monochrome'
" appearance
set termguicolors
filetype plugin indent on
syntax on
colorscheme palenight
set background=dark
" set guicursor=n-v-c-sm:block,i-ci-ve:ver25,r-cr-o:hor20
set colorcolumn=80
" fold
set foldmethod=syntax
set foldlevel=99
" navigating split pane
map <C-j> <C-w>j
map <C-k> <C-w>k
map <C-h> <C-w>h
map <C-l> <C-w>l
" For reason
" let g:LanguageClient_serverCommands = {
" \ 'reason': ['ocaml-language-server', '--stdio'],
" \ 'ocaml': ['ocaml-language-server', '--stdio'],
" \ 'haskell': ['hie', '--lsp']
" \ }
"
" Automatically start language servers.
let g:LanguageClient_autoStart = 1
let g:LanguageClient_serverCommands = {
\ 'haskell': ['hie', '--lsp'],
\ }
nnoremap <silent> gd :call LanguageClient_textDocument_definition()<cr>
nnoremap <silent> gf :call LanguageClient_textDocument_formatting()<cr>
nnoremap <silent> <cr> :call LanguageClient_textDocument_hover()<cr>
" For go
" augroup Go
" autocmd!
" autocmd FileType go setlocal tabstop=4 shiftwidth=4 expandtab
" autocmd FileType go nmap <leader>b <Plug>(go-build)
" autocmd FileType go nmap <leader>r <Plug>(go-run)
" autocmd Filetype go command! -bang A call go#alternate#Switch(<bang>0, 'edit')
" autocmd Filetype go command! -bang AV call go#alternate#Switch(<bang>0, 'vsplit')
" autocmd Filetype go command! -bang AS call go#alternate#Switch(<bang>0, 'split')
" autocmd Filetype go command! -bang AT call go#alternate#Switch(<bang>0, 'tabe')
" augroup END
" let g:go_metalinter_enabled = ['vet', 'golint', 'errcheck']
" let g:go_metalinter_autosave = 1
" let g:go_metalinter_autosave_enabled = ['vet', 'golint']
" let g:go_metalinter_deadline = "5s"
" let g:go_fmt_command = "goimports"
" let g:go_addtags_transform = "camelcase"
" let g:go_list_type = "quickfix"
"
" let g:go_highlight_types = 1
" let g:go_highlight_fields = 1
" let g:go_highlight_structs = 1
" let g:go_highlight_functions = 1
" let g:go_highlight_methods = 1
" let g:go_hightlight_operators = 1
" let g:go_highlight_extra_types = 1
" let g:go_highlight_build_constraints = 1
" let g:go_highlight_generate_tags = 1
" let g:go_auto_type_info = 1
"
" " run :GoBuild or :GoTest based on the file
" function! s:build_go_files()
" let l:file = expand('%')
" if l:file =~# '^\f\+_test\.go$'
" call go#cmd#Test(0,1)
" elseif l:file =~# '^\f\+\.go$'
" call go#cmd#Build(0)
" endif
" endfunction
" turn off hlsearch in insert mode
nnoremap i :noh<CR>i
nnoremap <Esc><Esc> :noh<CR>
" Navigating buffers
nnoremap <leader>n :bprev<CR>
nnoremap <leader>m :bnext<CR>
" normal save
noremap <c-s> :w<CR>
" better whitespace
let g:better_whitespace_filetypes_blacklist=['js', 'ts', 'elm', 're', 'rei', 'diff', 'gitcommit', 'unite', 'qf', 'help', 'markdown' ]
" JSX
let g:jsx_ext_required = 0
" indent guide
let g:indentLine_enabled = 1
let g:indentLine_char = '┆'
" ternjs
nnoremap <leader>d :TernDef<CR>
nnoremap <leader>t :TernType<CR>
nnoremap <leader>R :TernRefs<CR>
nnoremap <leader>r :TernRename<CR>
" neomake
let g:neomake_python_enabled_makers=[]
let g:neomake_javascript_enabled_makers = ['eslint']
let g:neomake_javascript_eslint_exe = 'eslint_d'
let g:neomake_reason_enabled_makers = ['merlin']
let g:neomake_open_list = 0
call neomake#configure#automake('nw', 750)
" neoformat
augroup NeoformatAutoFormat
autocmd!
autocmd FileType javascript setlocal formatprg=prettier_dnc\ --local-only\ --pkg-conf\ --fallback
autocmd BufWritePre *.js undojoin | Neoformat
augroup END
let g:neoformat_try_formatprg = 1
let g:neoformat_only_msg_on_error = 1
" reason
let g:vimreason_extra_args_expr_reason = '"--print-width " . ' . "min([80, winwidth('.')])"
" mouse
set mouse=a
" fzf
nnoremap <C-p> :Files<CR>
imap <c-x><c-l> <plug>(fzf-complete-line)
" Remove trailing whitespaces
augroup WhiteSpace
autocmd!
autocmd BufEnter * EnableStripWhitespaceOnSave
augroup END
" NERD TREE
map <leader>f :NERDTreeToggle<CR>
map <leader>ff :NERDTreeFind<CR>
augroup NerdTree
autocmd!
autocmd StdinReadPre * let s:std_in=1
autocmd VimEnter * if argc() == 1 && isdirectory(argv()[0]) && !exists("s:std_in") | exe 'NERDTree' argv()[0] | wincmd p | ene | endif
augroup END
" close tags
let g:closetag_filenames = '*.html,*.xhtml,*.phtml,*.js,*.jsx'
let g:closetag_xhtml_filenames = '*.xhtml,*.jsx,*.js'
let g:closetag_emptyTags_caseSensitive = 1
let g:closetag_shortcut = '>'
" flow
" Use locally installed flow
let local_flow = finddir('node_modules', '.;') . '/.bin/flow'
if matchstr(local_flow, "^\/\\w") == ''
let local_flow= getcwd() . "/" . local_flow
endif
if executable(local_flow)
let g:flow#flowpath = local_flow
endif
" Called once right before you start selecting multiple cursors
function! Multiple_cursors_before()
if exists('g:deoplete#disable_auto_complete')
let g:deoplete#disable_auto_complete = 1
endif
endfunction
" Called once only when the multiple selection is canceled (default <Esc>)
function! Multiple_cursors_after()
if exists('g:deoplete#disable_auto_complete')
let g:deoplete#disable_auto_complete = 0
endif
endfunction
" HASKELL
" augroup interoMaps
" au!
" " Maps for intero. Restrict to Haskell buffers so the bindings don't collide.
"
" " Background process and window management
" au FileType haskell nnoremap <silent> <leader>is :InteroStart<CR>
" au FileType haskell nnoremap <silent> <leader>ik :InteroKill<CR>
"
" " Open intero/GHCi split horizontally
" au FileType haskell nnoremap <silent> <leader>io :InteroOpen<CR>
" " Open intero/GHCi split vertically
" au FileType haskell nnoremap <silent> <leader>iov :InteroOpen<CR><C-W>H
" au FileType haskell nnoremap <silent> <leader>ih :InteroHide<CR>
"
" " Reloading (pick one)
" " Automatically reload on save
" au BufWritePost *.hs InteroReload
" " Manually save and reload
" au FileType haskell nnoremap <silent> <leader>wr :w \| :InteroReload<CR>
"
" " Load individual modules
" au FileType haskell nnoremap <silent> <leader>il :InteroLoadCurrentModule<CR>
" au FileType haskell nnoremap <silent> <leader>if :InteroLoadCurrentFile<CR>
"
" " Type-related information
" " Heads up! These next two differ from the rest.
" au FileType haskell map <silent> <leader>t <Plug>InteroGenericType
" au FileType haskell map <silent> <leader>T <Plug>InteroType
" au FileType haskell nnoremap <silent> <leader>it :InteroTypeInsert<CR>
"
" " Navigation
" au FileType haskell nnoremap <silent> <leader>jd :InteroGoToDef<CR>
"
" " Managing targets
" " Prompts you to enter targets (no silent):
" au FileType haskell nnoremap <leader>ist :InteroSetTargets<SPACE>
" augroup END
" let g:haskell_enable_quantification = 1 " to enable highlighting of `forall`
" let g:haskell_enable_recursivedo = 1 " to enable highlighting of `mdo` and `rec`
" let g:haskell_enable_arrowsyntax = 1 " to enable highlighting of `proc`
" let g:haskell_enable_pattern_synonyms = 1 " to enable highlighting of `pattern`
" let g:haskell_enable_typeroles = 1 " to enable highlighting of type roles
" let g:haskell_enable_static_pointers = 1 " to enable highlighting of `static`
" let g:haskell_backpack = 1 " to enable highlighting of backpack keywords
" Normal mode in terminal
:tnoremap <Esc> <C-\><C-n>
" Tabularize
inoremap <silent> <Bar> <Bar><Esc>:call <SID>align()<CR>a
function! s:align()
let p = '^\s*|\s.*\s|\s*$'
if exists(':Tabularize') && getline('.') =~# '^\s*|' && (getline(line('.')-1) =~# p || getline(line('.')+1) =~# p)
let column = strlen(substitute(getline('.')[0:col('.')],'[^|]','','g'))
let position = strlen(matchstr(getline('.')[0:col('.')],'.*|\s*\zs.*'))
Tabularize/|/l1
normal! 0
call search(repeat('[^|]*|',column).'\s\{-\}'.repeat('.',position),'ce',line('.'))
endif
endfunction
" Elm
let g:neomake_elm_elmmake_maker = {
\ 'exe': 'elm-make',
\ 'buffer_output': 1,
\ 'errorformat':
\ '%E%.%#--\ %m\ -%# %f' . ',' .
\ '%C%l\\|' . ',' .
\ '%C%.%#'
\ }
" enable elm-make on elm
let g:neomake_elm_enabled_makers = [ 'elmmake' ]
" (Assuming settings like the following)
let g:deoplete#omni#functions = {}
let g:deoplete#sources = {}
let g:deoplete#sources._ = ['file', 'neosnippet']
let g:deoplete#omni#input_patterns = {}
"
let g:deoplete#omni#functions.elm = ['elm#Complete']
let g:deoplete#omni#input_patterns.elm = '[^ \t]+'
let g:deoplete#sources.elm = ['omni'] + g:deoplete#sources._
" use neomake to build different files
augroup neomake_neomake_build
autocmd! BufRead,BufWritePost *.elm Neomake elmmake
augroup end
let g:elm_jump_to_error = 0
let g:elm_make_output_file = "elm.js"
let g:elm_make_show_warnings = 0
let g:elm_syntastic_show_warnings = 0
let g:elm_browser_command = "brave"
let g:elm_detailed_complete = 0
let g:elm_format_autosave = 1
let g:elm_format_fail_silently = 0
let g:elm_setup_keybindings = 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment