Created
March 4, 2020 16:09
-
-
Save zindel/1bbf67f7c66edcd135168a87427c42d0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" {{{ Plugins | |
call plug#begin('~/.vim/plugged2') | |
Plug 'altercation/vim-colors-solarized' | |
Plug 'editorconfig/editorconfig-vim' | |
Plug '/usr/local/opt/fzf' | |
Plug 'junegunn/fzf.vim' | |
Plug 'zindel/vim-reasonml' | |
Plug 'let-def/ocp-indent-vim' | |
Plug 'tpope/vim-commentary' | |
Plug 'dense-analysis/ale' | |
Plug 'mattn/webapi-vim' | |
Plug 'mattn/gist-vim' | |
Plug 'pangloss/vim-javascript' | |
Plug 'mxw/vim-jsx' | |
Plug 'purescript-contrib/purescript-vim' | |
call plug#end() | |
" }}} | |
" {{{ Base settings | |
scriptencoding utf-8 | |
set autochdir | |
set expandtab | |
set tabstop=4 | |
set softtabstop=4 | |
set sw=4 | |
set rtp+=/usr/local/opt/fzf | |
set clipboard=unnamed | |
set list | |
set listchars=trail:•,tab:>- | |
" Save cursor position within the file | |
set viminfo='100,\"200,n~/.nviminfo | |
autocmd BufReadPost * | |
\ if line("'\"") >= 1 && line("'\"") <= line("$") && &ft !~# 'commit' | |
\ | exe "normal! g`\"" | |
\ | endif | |
let mapleader="," | |
let g:solarized_visibility="high" | |
colorscheme solarized | |
highlight Comment cterm=italic gui=italic | |
command! -nargs=0 Only :only | |
nnoremap <Enter> :nohl<CR> | |
nnoremap <C-n> :tabnew<CR> | |
nnoremap <C-t> :tabnext<CR> | |
nnoremap <C-c> :tabclose<CR> | |
nnoremap <C-Right> :tabnext<CR> | |
nnoremap <C-Left> :tabprevious<CR> | |
" }}} | |
" {{{ FZF | |
let $FZF_DEFAULT_COMMAND = 'ag -l --nocolor | |
\ --hidden | |
\ --ignore .git | |
\ --ignore .svn | |
\ --ignore .hg | |
\ --ignore .DS_Store | |
\ --ignore coverage | |
\ --ignore build | |
\ --ignore node_modules | |
\ --ignore site-packages | |
\ --ignore "*.egg-info" | |
\ --ignore "**/*.pyc" | |
\ --ignore "*.pyc" | |
\ -g ""' | |
" make sure fzf quits easily | |
let g:fzf_buffers_jump = 1 | |
:au FileType fzf tnoremap <nowait><buffer> <esc> <c-g> | |
function! FindRepoRoot() | |
let current = expand('%:p:h') | |
let home = expand("$HOME") | |
while 1 | |
if isdirectory(expand(current . "/./.git")) | |
\ || isdirectory(expand(current . "/./.hg")) | |
break | |
endif | |
if current == home | |
break | |
endif | |
let current = fnamemodify(current . "/../", ":p:h") | |
endwhile | |
return current | |
endfunction | |
function! OpenRepoRoot() | |
exe 'Files '. FindRepoRoot() | |
endfunction | |
nnoremap <C-p> :call OpenRepoRoot()<CR> | |
nnoremap <C-b> :Buffers<CR> | |
nnoremap <C-f> :Ag | |
" }}} | |
" {{{ Tab Autocompletion | |
function! TabForward() | |
if col('.')>1 && strpart( getline('.'), col('.')-2, 3 ) =~ '^\w' | |
return "\<C-N>" | |
else | |
return "\<Tab>" | |
endfunction | |
inoremap <Tab> <C-R>=TabForward()<CR> | |
" }}} | |
" {{{ Prettier | |
function! Prettier() | |
let save_cursor = getpos(".") | |
exe "normal! gggqG" | |
if v:shell_error | |
let line = getline(1) | |
undo | |
echo line | |
else | |
write | |
endif | |
call setpos('.', save_cursor) | |
endfunction | |
" }}} | |
" {{{ OCaml | |
let g:opamshare = substitute(system('opam var share'),'\n$','','''') | |
" this is not from OPAM since I don't want merlin-type-history to be closed | |
" on CursorMoved | |
execute "set rtp+=/Users/zindel/.vim/merlin/vim/merlin" | |
execute "set rtp+=" . g:opamshare . "/ocp-indent/vim" | |
" execute "set rtp+=" . g:opamshare . "/ocp-index/vim" | |
let g:merlin_type_history_auto_open = 0 | |
function! SetupOcamlBuffer() | |
nnoremap <leader>t :MerlinTypeOf<CR> | |
nnoremap <leader>d :MerlinDestruct<CR> | |
nnoremap <leader>l :MerlinLocate<CR> | |
nnoremap <leader><Enter> :MerlinClearEnclosing<CR> :call merlin_type#HideTypeHistory(0)<CR> | |
nnoremap <buffer> <leader>f :call Prettier()<CR> | |
nnoremap <buffer> <leader>f :call Prettier()<CR> | |
if expand('%:t') =~ '.mli$' | |
setlocal formatprg=ocamlformat\ --name=input.mli\ - | |
endif | |
endfunction | |
autocmd FileType reason setlocal formatprg=refmt\ --parse\ re | |
autocmd FileType ocaml setlocal formatprg=ocamlformat\ --name=input.ml\ - | |
autocmd FileType ocaml,reason call SetupOcamlBuffer() | |
" }}} | |
" {{{ Ale | |
nnoremap <leader>n :ALENextWrap<CR> | |
let g:ale_lint_on_text_changed = 'never' | |
let g:ale_lint_on_insert_leave = 0 | |
" }}} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment