Created
October 29, 2020 15:51
-
-
Save rphuber/0a0110a44b7edb7bcd0588cc668d8b66 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
"========================================================================= | |
" ~My vimrc~ | |
"========================================================================= | |
" | |
" Author: Ryan Huber | |
" | |
"------------------------------------------------------------------------- | |
" | |
set nocompatible | |
set t_Co=256 | |
"------------------------------------------------------------------------- | |
" Package Setup | |
"------------------------------------------------------------------------- | |
"------------------------------------------------------------------------- | |
" Plugin Setup | |
"------------------------------------------------------------------------- | |
call plug#begin('~/.vim/plugged') | |
"Fuzzyfinder | |
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' } | |
Plug 'junegunn/fzf.vim' | |
"Statusline | |
Plug 'itchyny/lightline.vim' | |
Plug 'edkolev/tmuxline.vim' | |
Plug 'mengelbrecht/lightline-bufferline' | |
Plug 'maximbaz/lightline-ale' | |
Plug 'ryanoasis/vim-devicons' | |
"Plug 'vim-scripts/buftabline' | |
"Plug 'vim-airline/vim-airline' | |
"Plug 'vim-airline/vim-airline-themes' | |
"Undo | |
Plug 'simnalamburt/vim-mundo' | |
"Search | |
Plug 'haya14busa/vim-asterisk' | |
Plug 'haya14busa/incsearch.vim' | |
"Plug 'haya14busa/incsearch-fuzzy.vim' | |
Plug 'osyo-manga/vim-anzu' | |
"Colorschemes | |
Plug 'flazz/vim-colorschemes' | |
"Plug 'trevordmiller/nova-vim' | |
"Plug 'haishanh/night-owl.vim' | |
"Plug 'drewtempelmeyer/palenight.vim' | |
Plug 'jiangmiao/auto-pairs' | |
Plug 'tpope/vim-commentary' | |
Plug 'tpope/vim-repeat' | |
Plug 'tpope/vim-fugitive' | |
" Plug 'justinmk/vim-dirvish' | |
Plug 'tpope/vim-eunuch' | |
Plug 'tpope/vim-vinegar' | |
Plug 'jlanzarotta/bufexplorer' | |
Plug 'machakann/vim-sandwich' | |
"Plug 'tpope/vim-surround' | |
"Plug 'airblade/vim-gitgutter' | |
"Plug 'mhinz/vim-signify' | |
"Snippets | |
Plug 'SirVer/ultisnips' | |
Plug 'honza/vim-snippets' | |
"Syntax | |
Plug 'othree/html5.vim' | |
Plug 'hail2u/vim-css3-syntax' | |
Plug 'pangloss/vim-javascript' | |
Plug 'othree/javascript-libraries-syntax.vim' | |
Plug 'maxmellon/vim-jsx-pretty' | |
Plug 'Quramy/vim-js-pretty-template' | |
Plug 'herringtondarkholme/yats.vim' | |
"Plug 'leafgarland/typescript-vim' | |
Plug 'jparise/vim-graphql' | |
Plug 'elixir-lang/vim-elixir' | |
Plug 'reasonml-editor/vim-reason-plus' | |
"Linting/Fixing | |
Plug 'w0rp/ale' | |
Plug 'prettier/vim-prettier' | |
" Plug 'neoclide/coc.nvim', {'branch': 'release'} | |
call plug#end() | |
filetype plugin indent on " required | |
" To ignore plugin indent changes, instead use: | |
" filetype plugin on | |
" | |
" Brief help | |
" :PluginList - lists configured plugins | |
" :PluginInstall - installs plugins; append `!` to update or just | |
" :PluginUpdate | |
" :PluginSearch foo - searches for foo; append `!` to refresh local cache | |
" :PluginClean - confirms removal of unused plugins; append `!` to | |
" auto-approve removal | |
" | |
"------------------------------------------------------------------------- | |
" NERDTree config settings | |
" enable line numbers | |
"let NERDTreeShowLineNumbers=1 | |
"map <C-n> :NERDTreeToggle<CR> | |
"autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif | |
" make sure relative line numbers are used | |
"autocmd FileType nerdtree setlocal relativenumber | |
if executable('tmux') && $TMUX !=# '' | |
let g:vimIsInTmux = 1 | |
let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum" | |
let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum" | |
set termguicolors | |
else | |
let g:vimIsInTmux = 0 | |
endif | |
if has("patch-8.1.1564") | |
set signcolumn=number | |
else | |
set signcolumn=yes | |
endif | |
" Use incsearch.vim for all search functions (with anzu for indication) | |
set hlsearch | |
map * <Plug>(asterisk-z*)<Plug>(is-nohl-1) | |
map g* <Plug>(asterisk-gz*)<Plug>(is-nohl-1) | |
map # <Plug>(asterisk-z#)<Plug>(is-nohl-1) | |
map g# <Plug>(asterisk-gz#)<Plug>(is-nohl-1) | |
let g:anzu_status_format = "%p(%i/%l) %w" | |
map z/ <Plug>(incsearch-fuzzy-/) | |
map z? <Plug>(incsearch-fuzzy-?) | |
map zg/ <Plug>(incsearch-fuzzy-stay) | |
" Javascript Syntax Formatting | |
let g:javascript_plugin_flow = 1 | |
let g:used_javascript_libs = 'underscore,react,jasmine,chai,d3,ramda,vue' | |
set concealcursor=nc | |
set conceallevel=1 | |
let g:jsx_ext_required = 0 | |
" let g:javascript_conceal_null = "ø" | |
" let g:javascript_conceal_this = "@" | |
" let g:javascript_conceal_return = "⇚" | |
" let g:javascript_conceal_undefined = "¿" | |
" let g:javascript_conceal_NaN = "ℕ" | |
" let g:javascript_conceal_prototype = "¶" | |
" let g:javascript_conceal_static = "•" | |
let g:vim_jsx_pretty_colorful_config = 1 | |
" ultisnops | |
let g:UltiSnipsExpandTrigger="<tab>" | |
let g:UltiSnipsJumpForwardTrigger="<c-f>" | |
let g:UltiSnipsJumpBackwardTrigger="<c-b>" | |
colorscheme jellybeans | |
let g:lightline = { | |
\ 'component': { | |
\ 'lineinfo': ' %3l:%-2c', | |
\ }, | |
\ 'component_function': { | |
\ 'readonly': 'LightlineReadonly', | |
\ 'fugitive': 'LightlineFugitive' | |
\ }, | |
\ } | |
let g:lightline.colorscheme = 'wombat' | |
let g:lightline.component_expand = { | |
\ 'linter_checking': 'lightline#ale#checking', | |
\ 'linter_infos': 'lightline#ale#infos', | |
\ 'linter_warnings': 'lightline#ale#warnings', | |
\ 'linter_errors': 'lightline#ale#errors', | |
\ 'linter_ok': 'lightline#ale#ok', | |
\ 'buffers': 'lightline#bufferline#buffers', | |
\ } | |
let g:lightline.component_type = { | |
\ 'linter_checking': 'right', | |
\ 'linter_infos': 'right', | |
\ 'linter_warnings': 'warning', | |
\ 'linter_errors': 'error', | |
\ 'linter_ok': 'right', | |
\ 'buffers': 'tabsel' | |
\ } | |
let g:lightline.component_function = { | |
\ 'filename': 'LightlineFilename', | |
\ 'gitbranch': 'LightlineFugitive', | |
\} | |
let g:lightline.active = { 'right': [[ 'linter_checking', 'linter_errors', 'linter_warnings', 'linter_infos', 'linter_ok' ], [ 'fileformat' ], ['filetype'], [ 'percent' ] ], 'left': [ ['mode', 'paste'], ['filename'] ] } | |
let g:lightline.tabline = { | |
\ 'left': [ ['buffers'] ], | |
\ 'right': [ ['gitbranch'] ] | |
\ } | |
let g:lightline.tab = { | |
\ 'active': ['tabnum', 'filename', 'filetype', 'modified'], | |
\ 'inactive': [ 'tabnum', 'filename', 'modified' ] | |
\} | |
let g:lightline.tab_component_function = { | |
\ 'cwd': 'LightlineCurrentDirectory', | |
\ 'filename': 'MyTabFilename', | |
\} | |
let g:lightline#bufferline#show_number = 1 | |
let g:lightline#bufferline#shorten_path = 0 | |
let g:lightline#bufferline#unnamed = '[No Name]' | |
function! LightlineFilename() | |
let filename = expand('%:t') !=# '' ? expand('%:t') : '[No Name]' | |
let modified = &modified ? ' +' : '' | |
return filename . modified | |
endfunction | |
function! LightlineCurrentDirectory(n) abort | |
return fnamemodify(getcwd(tabpagewinnr(a:n), a:n), ':t') | |
endfunction | |
function! MyTabFilename(n) | |
let buflist = tabpagebuflist(a:n) | |
let winnr = tabpagewinnr(a:n) | |
let bufnum = buflist[winnr - 1] | |
let bufname = expand('#'.bufnum.':t') | |
let buffullname = expand('#'.bufnum.':p') | |
let buffullnames = [] | |
let bufnames = [] | |
for i in range(1, tabpagenr('$')) | |
if i != a:n | |
let num = tabpagebuflist(i)[tabpagewinnr(i) - 1] | |
call add(buffullnames, expand('#' . num . ':p')) | |
call add(bufnames, expand('#' . num . ':t')) | |
endif | |
endfor | |
let i = index(bufnames, bufname) | |
if strlen(bufname) && i >= 0 && buffullnames[i] != buffullname | |
return substitute(buffullname, '.*/\([^/]\+/\)', '\1', '') | |
else | |
return strlen(bufname) ? bufname : '[No Name]' | |
endif | |
endfunction | |
function! Devicons_Filetype()"{{{ | |
" return winwidth(0) > 70 ? (strlen(&filetype) ? WebDevIconsGetFileTypeSymbol() . ' ' . &filetype : 'no ft') : '' | |
return winwidth(0) > 70 ? (strlen(&filetype) ? &filetype . ' ' . WebDevIconsGetFileTypeSymbol() : 'no ft') : '' | |
endfunction"}}} | |
function! Devicons_Tab_Filetype(n)"{{{ | |
" return winwidth(0) > 70 ? (strlen(&filetype) ? WebDevIconsGetFileTypeSymbol() : 'no ft') : '' | |
return winwidth(0) > 70 ? (strlen(&filetype) ? WebDevIconsGetFileTypeSymbol() : 'no ft') : '' | |
endfunction"}}} | |
function! Devicons_Fileformat()"{{{ | |
return winwidth(0) > 70 ? (&fileformat . ' ' . WebDevIconsGetFileFormatSymbol()) : '' | |
endfunction"}}} | |
function! LightlineReadonly() | |
return &readonly ? '' : '' | |
endfunction | |
function! LightlineFugitive() | |
if exists('*FugitiveHead') | |
let branch = FugitiveHead() | |
return branch !=# '' ? branch : '' | |
endif | |
return '' | |
endfunction | |
let g:lightline.separator = { 'left': "\ue0b8", 'right': "\ue0be" } | |
let g:lightline.subseparator = { 'left': "", 'right': "" } | |
let g:lightline.tabline_separator = { 'left': "\ue0bc", 'right': "\ue0ba" } | |
let g:lightline.tabline_subseparator = { 'left': "", 'right': "" } | |
if g:vimIsInTmux == 1 | |
let g:tmuxline_separators = { | |
\ 'left' : "\ue0bc", | |
\ 'left_alt': "", | |
\ 'right' : "\ue0ba", | |
\ 'right_alt' : "", | |
\ 'space' : ' '} | |
endif | |
" " GoTo code navigation. | |
" nmap <silent> gd <Plug>(coc-definition) | |
" nmap <silent> gy <Plug>(coc-type-definition) | |
" nmap <silent> gi <Plug>(coc-implementation) | |
" nmap <silent> gr <Plug>(coc-references) | |
" Use K to show documentation in preview window. | |
nnoremap <silent> K :call <SID>show_documentation()<CR> | |
function! s:show_documentation() | |
if (index(['vim','help'], &filetype) >= 0) | |
execute 'h '.expand('<cword>') | |
else | |
call CocAction('doHover') | |
endif | |
endfunction | |
" ALE | |
let g:ale_fixers = { | |
\ '*': ['remove_trailing_lines', 'trim_whitespace'], | |
\ 'javascript': ['prettier', 'eslint'], | |
\ 'typescript': ['prettier', 'eslint'], | |
\ 'json': ['eslint', 'prettier'], | |
\ 'graphql': ['eslint', 'prettier'], | |
\ 'css': ['eslint'], | |
\ 'scss': ['eslint'], | |
\ 'elixir': ['mix_format'], | |
\ 'reason': ['refmt'], | |
\ 'html': ['prettier'], | |
\ 'go': ['gofmt'], | |
\} | |
let g:ale_linters_ignore = { | |
\ 'javascript': ['tsserver'], | |
\ 'javascriptreact': ['tsserver'], | |
\} | |
let g:ale_fix_on_save = 1 | |
let g:ale_echo_msg_error_str = 'E' | |
let g:ale_echo_msg_warning_str = 'W' | |
let g:ale_echo_msg_format = '[%linter%] %s [%severity%]' | |
let g:ale_elixir_elixir_ls_release = '/Users/rphuber/.vim/language-server/elixir-ls/rel' | |
let g:ale_reason_ls_executable = '/Users/rphuber/.vim/language-server/reason-language-server.exe' | |
let g:ale_reasonml_refmt_executable = 'bsrefmt' | |
let g:ale_sign_column_always = 1 | |
let g:ale_sign_error= '=>' | |
let g:ale_sign_warning= '->' | |
let g:sandwich#recipes = deepcopy(g:sandwich#default_recipes) | |
" add spaces inside bracket | |
let g:sandwich#recipes += [ | |
\ {'buns': ['{ ', ' }'], 'nesting': 1, 'match_syntax': 1, 'kind': ['add', 'replace'], 'action': ['add'], 'input': ['{']}, | |
\ {'buns': ['[ ', ' ]'], 'nesting': 1, 'match_syntax': 1, 'kind': ['add', 'replace'], 'action': ['add'], 'input': ['[']}, | |
\ {'buns': ['( ', ' )'], 'nesting': 1, 'match_syntax': 1, 'kind': ['add', 'replace'], 'action': ['add'], 'input': ['(']}, | |
\ {'buns': ['{\s*', '\s*}'], 'nesting': 1, 'regex': 1, 'match_syntax': 1, 'kind': ['delete', 'replace', 'textobj'], 'action': ['delete'], 'input': ['{']}, | |
\ {'buns': ['\[\s*', '\s*\]'], 'nesting': 1, 'regex': 1, 'match_syntax': 1, 'kind': ['delete', 'replace', 'textobj'], 'action': ['delete'], 'input': ['[']}, | |
\ {'buns': ['(\s*', '\s*)'], 'nesting': 1, 'regex': 1, 'match_syntax': 1, 'kind': ['delete', 'replace', 'textobj'], 'action': ['delete'], 'input': ['(']}, | |
\ ] | |
set completeopt=menu,menuone,preview,noselect,noinsert | |
set diffopt+=vertical | |
set showtabline=2 | |
set modelines=0 | |
set vb "flash screen rather than sound bell | |
set laststatus=2 " Always display the statusline in all windows | |
set list " show trailing whiteshace and tabs | |
"set listchars=eol:↲,tab:▶▹,nbsp:␣,extends:…,trail:• | |
set listchars=tab:▸\ ,extends:>,precedes:<,nbsp:+,trail:• | |
set mouse=a | |
set wildmenu | |
set showtabline=2 | |
set scrolloff=4 | |
set autoindent | |
set cursorline | |
set backspace=indent,eol,start | |
set noshowmode " Hide the default mode text (e.g. -- INSERT -- below the statusline) | |
set number | |
set relativenumber | |
set lazyredraw | |
set regexpengine=1 | |
set hlsearch | |
set incsearch | |
set ignorecase | |
set smartcase | |
"let g:netrw_bufsettings = 'noma nomod nu nowrap ro nobl' | |
"let g:netrw_winsize = 25 | |
"let g:netrw_browse_split = 4 | |
"let g:netrw_banner=0 | |
set linebreak | |
set textwidth=80 | |
set clipboard=unnamed | |
" Undo | |
set undofile " Save undos after file closes | |
set undodir=~/.vim/undo " where to save undo histories | |
set undolevels=1000 " How many undos | |
set undoreload=10000 " number of lines to save for undo | |
" Tabs | |
set tabstop=2 | |
set shiftwidth=2 | |
set expandtab | |
set softtabstop=2 | |
" Formatting | |
syntax on | |
set noswapfile | |
set splitright | |
set splitbelow | |
" Key Mappings | |
nnoremap 0 ^ | |
nnoremap j gj | |
nnoremap k gk | |
nmap <silent> <Left> :tabp<CR> | |
nmap <silent> <Right> :tabn<CR> | |
nmap <silent> <Up> :bnext<CR> | |
nmap <silent> <Down> :bprevious<CR> | |
nnoremap ∆ :m .+1<CR>== | |
nnoremap ˚ :m .-2<CR>== | |
inoremap ∆ <Esc>:m .+1<CR>==gi | |
inoremap ˚ <Esc>:m .-2<CR>==gi | |
vnoremap ∆ :m '>+1<CR>gv=gv | |
vnoremap ˚ :m '<-2<CR>gv=gv | |
vnoremap <silent> <Down> :m '>+1<CR>gv=gv | |
vnoremap <silent> <Up> :m '<-2<CR>gv=gv | |
let mapleader = "\<Space>" | |
" Edit another file in the same directory as the current file | |
" " uses expression to extract path from current file's path | |
map <Leader>e :e <C-R>=escape(expand("%:p:h"),' ') . '/'<CR> | |
map <Leader>s :split <C-R>=escape(expand("%:p:h"), ' ') . '/'<CR> | |
nnoremap <silent> <Leader>v :vnew <C-R>=escape(expand("%:p:h"), ' ') . '/'<CR> | |
nnoremap <silent> <Leader>tnf :tabnew<C-R>=escape(expand("%:p:h"), ' ') . '/'<CR> | |
nnoremap <silent> <Leader>tn :tabnew<CR> | |
nnoremap <silent> <Leader>tc :tabclose<CR> | |
nnoremap <silent> <Leader>ts :tab split<CR> | |
nnoremap <silent> <Leader>to :tabonly<CR> | |
nnoremap <silent> <Leader>ut :MundoToggle<CR> | |
nnoremap <silent> <Leader>gd :ALEGoToDefinition -tab<CR> | |
nnoremap <silent> <Leader>ho :ALEHover<CR> | |
nnoremap <silent> <Leader>ff :Files<CR> | |
nnoremap <silent> <Leader>gf :GFiles<CR> | |
nmap <silent> <C-k> <Plug>(ale_previous_wrap) | |
nmap <silent> <C-j> <Plug>(ale_next_wrap) | |
nmap <silent> <leader>fix <Plug>(ale_fix) | |
" Split edit your vimrc. Type space, v, r in sequence to trigger | |
nmap <Leader>vr :vsp $MYVIMRC<cr> | |
" Source (reload) your vimrc. Type space, s, o in sequence to trigger | |
nmap <Leader>so :source $MYVIMRC<cr> | |
" Explore using leader | |
nmap <Leader>ex :Explore<cr> | |
" Show keyword for formatting of text under cursor | |
nmap <Leader>sI :call <SID>SynStack()<CR> | |
let g:javascript_plugin_flow = 1 | |
autocmd BufRead,BufNewFile .{jscs,jshint,eslint,babel}rc set filetype=json | |
autocmd InsertEnter * setlocal conceallevel=2 concealcursor=nc | |
autocmd InsertLeave * setlocal conceallevel=2 concealcursor=inc | |
autocmd BufWritePre *.js,*.json,*.css,*.scss,*.less,*.graphql ALEFix | |
autocmd BufRead,BufNewFile *.json setlocal conceallevel=2 concealcursor=nc | |
augroup VimCSS3Syntax | |
autocmd! | |
autocmd FileType css setlocal iskeyword+=- | |
augroup END | |
" set background=dark | |
highlight clear SignColumn | |
highlight CursorLineNr cterm=NONE ctermbg=NONE ctermfg=green | |
highlight cssIdentifier ctermfg=5 | |
highlight cssClassName ctermfg=214 | |
set concealcursor=nc | |
set conceallevel=2 | |
hi comment cterm=italic | |
hi Special cterm=italic | |
hi htmlArg cterm=italic ctermfg=214 | |
hi jsxAttrib cterm=italic ctermfg=214 | |
" Functions | |
" Show keyword for formatting of text under cursor | |
function! <SID>SynStack() | |
if !exists("*synstack") | |
return | |
endif | |
echo map(synstack(line('.'), col('.')), 'synIDattr(v:val, "name")') | |
endfunc | |
" Gitgutter | |
" let g:gitgutter_override_sign_column_highlight=0 | |
" let g:gitgutter_sign_added = '+' | |
" let g:gitgutter_sign_modified = '•' | |
" let g:gitgutter_sign_removed = '-' | |
" let g:gitgutter_sign_removed_first_line = '|' | |
" let g:gitgutter_sign_modified_removed = '|' | |
" highlight GitGutterAdd ctermfg=2 ctermbg=NONE | |
" highlight GitGutterChange ctermfg=3 ctermbg=NONE | |
" highlight GitGutterDelete ctermfg=1 ctermbg=NONE | |
highlight ALEErrorSign ctermbg=NONE ctermfg=124 | |
hi SpellBad guifg=NONE guibg=NONE gui=undercurl ctermfg=124 ctermbg=NONE cterm=bold,underline | |
highlight ALEWarningSign ctermbg=NONE ctermfg=11 | |
hi SpellCap guifg=NONE guibg=NONE gui=undercurl ctermfg=11 ctermbg=NONE cterm=bold,underline |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment