From 17ee0e400bef47c371afcae76037f9ea6a44ad13 Mon Sep 17 00:00:00 2001 From: William Carroll Date: Mon, 10 Sep 2018 14:51:14 -0400 Subject: Support Vim, Tmux, Emacs with Stow After moving off of Meta, Dotfiles has a greater responsibility to manage configs. Vim, Tmux, and Emacs are now within Stow's purview. --- configs/shared/misc/.config/nvim/.netrwhist | 4 + configs/shared/misc/.config/nvim/init.vim | 658 ++++++++++++++++++++++++++++ 2 files changed, 662 insertions(+) create mode 100644 configs/shared/misc/.config/nvim/.netrwhist create mode 100644 configs/shared/misc/.config/nvim/init.vim (limited to 'configs/shared/misc') diff --git a/configs/shared/misc/.config/nvim/.netrwhist b/configs/shared/misc/.config/nvim/.netrwhist new file mode 100644 index 000000000000..e08af1890fae --- /dev/null +++ b/configs/shared/misc/.config/nvim/.netrwhist @@ -0,0 +1,4 @@ +let g:netrw_dirhistmax =10 +let g:netrw_dirhist_cnt =2 +let g:netrw_dirhist_1='/Users/wpcarro' +let g:netrw_dirhist_2='/Users/wpcarro/urbint/grid' diff --git a/configs/shared/misc/.config/nvim/init.vim b/configs/shared/misc/.config/nvim/init.vim new file mode 100644 index 000000000000..ec405eaef4cb --- /dev/null +++ b/configs/shared/misc/.config/nvim/init.vim @@ -0,0 +1,658 @@ +" -- BEGIN: Vundle config -- +set nocompatible " be iMproved, required +filetype off " required + +" set the runtime path to include Vundle and initialize +set rtp+=~/.vim/bundle/Vundle.vim +call vundle#begin() +" alternatively, pass a path where Vundle should install plugins +"call vundle#begin('~/some/path/here') + +" let Vundle manage Vundle, required +Plugin 'VundleVim/Vundle.vim' + +" The following are examples of different formats supported. +" Keep Plugin commands between vundle#begin/end. + +" Displays git information in airline. +Plugin 'tpope/vim-fugitive' + +" easier file navigation +Plugin 'tpope/vim-vinegar' + +" Displays git-tracked C*UD ops within gutter. +Plugin 'airblade/vim-gitgutter' + +" Fuzzy-finder +Plugin 'kien/ctrlp.vim' + +" Grep file contents +Plugin 'mileszs/ack.vim' + +" JS support +Plugin 'pangloss/vim-javascript' + +" JSX support +Plugin 'mxw/vim-jsx' + +" Syntax Highlighting Support +Plugin 'lambdatoast/elm.vim' + +" Elixir Plugins +Plugin 'elixir-lang/vim-elixir' +Plugin 'slashmili/alchemist.vim' +Plugin 'powerman/vim-plugin-AnsiEsc' + +" TypeScript Plugins +Plugin 'rschmukler/typescript-vim' + +" Themes +Plugin 'sickill/vim-monokai' +Plugin 'altercation/vim-colors-solarized' +Plugin 'mhartington/oceanic-next' + +" Executes shell commands and pipes output into new Vim buffer. +Plugin 'sjl/clam.vim' + +" Multiple cursors for simultaneous edits. +" NOTE: use to run miltiple cursors not +Plugin 'terryma/vim-multiple-cursors' + +" Visualize buffers +Plugin 'vim-airline/vim-airline' +Plugin 'vim-airline/vim-airline-themes' + +" Visually align assignments +Plugin 'godlygeek/tabular' + +" Visually Highlight and comment code. +Plugin 'tpope/vim-commentary' + +" Macros for quotes, parens, etc. +Plugin 'tpope/vim-surround' + +" Allows Plugins to be repeated with `.` character +Plugin 'tpope/vim-repeat' + +" Pairs of mappings +Plugin 'tpope/vim-unimpaired' + +" LISPs support +Plugin 'guns/vim-sexp' +Plugin 'tpope/vim-sexp-mappings-for-regular-people' +let g:sexp_enable_insert_mode_mappings = 0 +let g:sexp_filetypes = '' + +" Seamlessly navigate Vim and Tmux with similar bindings. +Plugin 'christoomey/vim-tmux-navigator' + +" Async `:make` for code linting etc. +Plugin 'neomake/neomake' + +" Color pack +Plugin 'flazz/vim-colorschemes' + +" Better buffer mgt than CtrlP +Plugin 'yegappan/mru' + +Plugin 'zanglg/nova.vim' + +" Emulates Emacs's Helm Swoop search +Plugin 'pelodelfuego/vim-swoop' + +" Fish Shell support +Plugin 'dag/vim-fish' + +" Gotham colorscheme +Plugin 'whatyouhide/vim-gotham' + +" Transparent encryption + decryption +Plugin 'jamessan/vim-gnupg' + +" Javascript auto-formatting +Plugin 'prettier/vim-prettier', { + \ 'do': 'yarn install', + \ 'for': ['javascript', 'typescript', 'css', 'less', 'scss', 'json', 'graphql', 'markdown'] } + +" Support Org mode +Plugin 'jceb/vim-orgmode' + +" ReaosnML +Plugin 'reasonml-editor/vim-reason-plus' + +" Autocompletion +Plugin 'junegunn/fzf' + +" Better JSON highlighting +Plugin 'elzr/vim-json' + +" Text objects made easy +Plugin 'kana/vim-textobj-user' + +" Elixir text objects +Plugin 'andyl/vim-textobj-elixir' + +" Making HTML editing faster +Plugin 'mattn/emmet-vim' + +" Snippets for all languages +Plugin 'honza/vim-snippets' + +" Automatic bracket insertion +Plugin 'jiangmiao/auto-pairs' + +" Linting & error warnings +Plugin 'vim-syntastic/syntastic' + +" Atom colorscheme +Plugin 'rakr/vim-one' + +" Nix syntax highlighting +Plugin 'LnL7/vim-nix' + +call vundle#end() " required +filetype plugin indent on " required +" Put your non-Plugin stuff after this line +" -- END: Vundle config -- + +" Changes to character. +let mapleader = " " + + +" Highlight column width +set textwidth=80 +set colorcolumn=+0 + +" autoreload a file when it changes on disk +set autoread + +" default to case-insensitive searching +set ignorecase + +" JSX configuration +let g:jsx_ext_required = 0 + + +autocmd FileType reason nnoremap gd :call LanguageClient_textDocument_definition() +autocmd FileType reason nnoremap gf :call LanguageClient_textDocument_formatting() +autocmd FileType reason nnoremap gh :call LanguageClient_textDocument_hover() +autocmd FileType reason nnoremap gr :call LanguageClient_textDocument_rename() + +" Replace with G for faster navigation +nnoremap G + + +" Syntastic configuration +set statusline+=%#warningmsg# +set statusline+=%{SyntasticStatuslineFlag()} +set statusline+=%* + +let g:syntastic_always_populate_loc_list = 1 +let g:syntastic_auto_loc_list = 1 +let g:syntastic_check_on_open = 1 +let g:syntastic_check_on_wq = 0 +let g:syntastic_javascript_checkers = ['eslint'] +let g:syntastic_javascript_eslint_generic = 1 +" this is a hack to prevent a false negative +" https://github.com/vim-syntastic/syntastic/issues/1692 +let g:syntastic_javascript_eslint_exec = '/bin/ls' +let g:syntastic_javascript_eslint_exe = 'npx eslint' +let g:syntastic_javascript_eslint_args = '-f compact' + +" javascript autocompletion +autocmd FileType javascript setlocal omnifunc=javascriptcomplete#CompleteJS +autocmd FileType javascript nnoremap gf :Prettier + +" Maximize the current window +" Similar to Tmux mapping alt-z in my tmux.conf +nnoremap t% :tab sp + + +" Prettier configuration +let g:prettier#exec_cmd_async = 1 +" force Prettier to run on files even without the @format pragma +let g:prettier#autoformat = 0 + + +" Basic settings +" Thin cursor on INSERT mode +if has('nvim') + let $NVIM_TUI_ENABLE_CURSOR_SHAPE = 1 +endif + +set number +set wrap! +set tabstop=2 +set expandtab +set shiftwidth=2 +set background=dark + +syntax enable +colorscheme one +set background=light + +" Vim in terminal cannot have a different font from the one set within your +" terminal. However, this setting will set the font for the GUI version. +if has('gui_running') + set guifont=Operator\ Mono:h12 +endif + +if has('termguicolors') + set termguicolors +endif + +if &term =~# '^screen' + let &t_8f = "\[38;2;%lu;%lu;%lum" + let &t_8b = "\[48;2;%lu;%lu;%lum" +endif + +set history=1000 +set undolevels=1000 + +set t_Co=255 + +" Support italics +highlight Comment cterm=italic + + +" quickly edit your vimrc +nnoremap ev :vsplit $MYVIMRC + +" quickly source your vimrc +nnoremap sv :source $MYVIMRC + +" quickly edit your snippets +nnoremap es :vsplit:edit ~/.vim/bundle/vim-snippets/snippets/reason.snippets + + +" Auto resize window splits +autocmd VimResized * wincmd = + + +" Neomake Settings +autocmd! BufWritePost * Neomake + +" Elixir linting +let g:neomake_elixir_credo_maker = { + \ 'exe': 'mix', + \ 'args': ['credo', 'list', '%:p', '--format=oneline'], + \ 'errorformat': + \ '%W[F] %. %f:%l:%c %m,' . + \ '%W[F] %. %f:%l %m,' . + \ '%W[R] %. %f:%l:%c %m,' . + \ '%W[R] %. %f:%l %m,' . + \ '%I[C] %. %f:%l:%c %m,' . + \ '%I[C] %. %f:%l %m,' . + \ '%-Z%.%#' + \ } + + +let g:neomake_elixir_enabled_makers = ['mix', 'credo'] + +augroup my_error_signs + au! + autocmd ColorScheme * hi NeomakeErrorSign ctermfg=203 guifg=#ff5f5f + autocmd ColorScheme * hi NeomakeWarningSign ctermfg=209 guifg=#ffaf00 + autocmd ColorScheme * hi NeomakeInfoSign ctermfg=183 guifg=#dfafff + autocmd ColorScheme * hi NeomakeMessageSign ctermfg=27 guifg=#0087ff +augroup END + + +let g:neomake_error_sign = { + \ 'text': '>>', + \ 'texthl': 'NeoMakeErrorSign', + \ } + +let g:neomake_warning_sign = { + \ 'text': '>>', + \ 'texthl': 'NeoMakeWarningSign', + \ } + +let g:neomake_info_sign = { + \ 'text': '>>', + \ 'texthl': 'NeoMakeInfoSign', + \ } + +let g:neomake_message_sign = { + \ 'text': '>>', + \ 'texthl': 'NeoMakeMessageSign', + \ } + +function! LocationPrevious() + try + lprev + catch /^Vim\%((\a\+)\)\=:E553/ + llast + endtry +endfunction + +function! LocationNext() + try + lnext + catch /^Vim\%((\a\+)\)\=:E553/ + lfirst + endtry +endfunction + +nnoremap [ :call LocationPrevious() +nnoremap ] :call LocationNext() + + +" Alchemist settings +let g:alchemist#elixir_erlang_src = '/usr/local/share/src' + + +" Airline Settings +" Enables the list of buffers. +let g:airline#extensions#tabline#enabled = 0 + +" Buffer numbers alongside files +let g:airline#extensions#tabline#buffer_nr_show = 0 + +" Shows the filename only. +let g:airline#extensions#tabline#fnamemod = ':t' + +" Allow glyphs in airline +let g:airline_powerline_fonts = 1 + +" Change Airline theme +let g:airline_theme = 'hybrid' + + +" Vim-Swoop Settings +" Edits colorscheme +let g:swoopHighlight = ["hi! link SwoopBufferLineHi Warning", "hi! link SwoopPatternHi Error"] + + +nnoremap :q + + +" Jump to buffers. +nmap :1b +nmap :2b +nmap :3b +nmap :4b +nmap :5b +nmap :6b +nmap :7b +nmap :8b +nmap :9b + + +" It's the twenty-first century...no swaps. +set noswapfile + + +" Allow visual tab completion in command mode +set wildmenu + + +" Show Vim commands as they're being input. +set showcmd + + +" Code folding +" set foldmethod=indent +" set foldnestmax=10 +" set nofoldenable +" set foldlevel=4 + + +" emulate ci" and ci' behavior +nnoremap ci( f(%ci( +nnoremap ci[ f[%ci[ + + +" extend functionality of & scrolling +nnoremap j +vnoremap j +nnoremap k +vnoremap k + + +" Opens all folds within the buffer +" nnoremap ZZ zR + +" Closes all folds within the buffer +" nnoremap zz zM + +" Opens all folds beneath the cursor +" NOTE: j is the character to go down +" nnoremap zJ zO + +" Opens single fold beneath the cursor +" NOTE: j is the character to go down +" nnoremap zj zo + +" Opens single fold beneath the cursor +" NOTE: k is the character to go down +" nnoremap zK zC + +" Opens single fold beneath the cursor +" NOTE: k is the character to go down +" nnoremap zk zc + + +" Save shortcut +nnoremap :w + + +" Switch to MRU'd buffer +nnoremap + + +" Alternative MRU to CtrlP MRU +nnoremap b :MRU + + +" Supports mouse interaction. +set mouse=a + + +" Highlights matches during a search. +set hlsearch + +" Clear highlight +noremap h :nohlsearch:echo + + +" backspace settings +set backspace=2 +set backspace=indent,eol,start + + +" Javascript specific variables +let g:javascript_plugin_jsdoc = 1 + +" GlobalListchars +set list +set listchars=tab:··,trail:·,nbsp:· + + +" Keeps everything concealed at all times. Even when cursor is on the word. +set conceallevel=1 +set concealcursor=nvic + + +" map jk to +inoremap jk + + +" Hybrid mode for Vim +inoremap I +inoremap A + +inoremap +inoremap + +inoremap +inoremap +inoremap +inoremap + + +" Manage Vertical and Horizontal splits +nnoremap sl :vsl +nnoremap sh :vs +nnoremap sj :spj +nnoremap sk :sp + + +" Delete (i.e. "close") the currently opened buffer +" TODO: unless it's a split window, which should be :q +nnoremap q :bdelete + + +" Set CtrlP runtime path +set runtimepath^=~/.vim/bundle/ctrlp.vim + + +" Pane movement +let g:tmux_navigator_no_mappings = 1 + +nnoremap :TmuxNavigateLeft +nnoremap :TmuxNavigateDown +nnoremap :TmuxNavigateUp +nnoremap :TmuxNavigateRight + +" make Y do what is intuitive given: +" D: deletes until EOL +" C: changes until EOL +" Y: (should) yank until EOL +nnoremap Y y$ + + +" scrolling and maintaing mouse position +" nnoremap j +" nnoremap k + + +" remap redo key that is eclipsed by `rotate` currently +nnoremap U :redo + + +" Define highlighting groups +" NOTE: The ANSII aliases for colors will change when iTerm2 settings are +" changed. +highlight InterestingWord1 ctermbg=Magenta ctermfg=Black +highlight InterestingWord2 ctermbg=Blue ctermfg=Black + +" h1 highlighting +nnoremap 1 :execute '2match InterestingWord1 /\<\>/' +nnoremap x1 :execute '2match none' +vnoremap 1 :execute '2match InterestingWord1 /\<\>/' + +" h2 highlighting +nnoremap 2 :execute '3match InterestingWord2 /\<\>/' +nnoremap x2 :execute '3match none' + +"clear all highlighted groups +nnoremap xx :execute '2match none' :execute '3match none' hh + + +" pasteboard copy & paste +set clipboard+=unnamedplus + + +" Manage 80 char line limits +highlight OverLength1 ctermbg=Magenta ctermfg=Black +highlight OverLength2 ctermbg=LightMagenta ctermfg=Black +highlight OverLength3 ctermbg=White ctermfg=Black +" match OverLength3 /\%81v.\+/ +match OverLength2 /\%91v.\+/ +" match OverLength3 /\%101v.\+/ + +nnoremap w :w + + +" Resize split to 10,20,...,100 chars +" Uncomment the next lines for support at those sizes. +" These bindings interfere with the highlight groups, however. +" Increases the width of a vertical split. +" nnoremap 1 :vertical resize 10 +" nnoremap 2 :vertical resize 20 +nnoremap 3 :vertical resize 30 +nnoremap 4 :vertical resize 40 +nnoremap 5 :vertical resize 50 +nnoremap 6 :vertical resize 60 +nnoremap 7 :vertical resize 70 +nnoremap 8 :vertical resize 80 +nnoremap 9 :vertical resize 90 +nnoremap 0 :vertical resize 100 + + +" Increases the height of a horizontal split. +nnoremap v1 :resize 5 +nnoremap v2 :resize 10 +nnoremap v3 :resize 15 +nnoremap v4 :resize 20 +nnoremap v5 :resize 25 +nnoremap v6 :resize 30 +nnoremap v7 :resize 35 +nnoremap v8 :resize 40 +nnoremap v9 :resize 45 +nnoremap v0 :resize 50 + + +" BOL and EOL +nnoremap H ^ +vnoremap H ^ +nnoremap L $ +vnoremap L $ + + +" Search for visually selected text +vnoremap // y/"N + + +" trim trailing whitespace on save +autocmd BufWritePre *.{js,py,tpl,less,html,ex,exs,txt} :%s/\s\+$//e + + +" Use .gitignore file to populate Ctrl-P +let g:ctrlp_user_command = ['.git', 'cd %s && git ls-files . -co --exclude-standard', 'find %s -type f'] + + +" Ignores dirs and files +let g:ctrlp_custom_ignore = { + \ 'dir': 'node_modules', + \ 'file': '\v\.(exe|dll|png|jpg|jpeg)$' +\} + + +" WIP: Run elixir tests on that line +" TODO: only register binding in *.exs? file extensions +nnoremap t :call ExTestToggle() + + +" Jumps from an Elixir module file to an Elixir test file. +fun! ExTestToggle() + if expand('%:e') == "ex" + + let test_file_name = expand('%:t:r') . "_test.exs" + let test_file_dir = substitute(expand('%:p:h'), "/lib/", "/test/", "") + let full_test_path = join([test_file_dir, test_file_name], "/") + + e `=full_test_path` + + elseif match(expand('%:t'), "_test.exs") != -1 + + let test_file_name = expand('%:t:r') + let offset_amt = strlen(test_file_name) - strlen("_test") + let module_file_name = strpart(test_file_name, 0, offset_amt) . ".ex" + let module_file_dir = substitute(expand('%:p:h'), "/test/", "/lib/", "") + let full_module_path = join([module_file_dir, module_file_name], "/") + + e `=full_module_path` + + endif +endfun + + +" Creates intermediate directories and file to match current buffer's filepath +fun! CreateNonExistingDirsAndFile() + ! echo "Creating directory..." && mkdir -p %:p:h && echo "Created directory." && echo "Creating file..." && touch %:t:p && echo "Created file." + + " Write the buffer to the recently created file. + w +endfun -- cgit 1.4.1