Skip to content

Instantly share code, notes, and snippets.

@willdavidow
Last active December 11, 2019 03:03
Show Gist options
  • Save willdavidow/4e30ac44fab8d8707907 to your computer and use it in GitHub Desktop.
Save willdavidow/4e30ac44fab8d8707907 to your computer and use it in GitHub Desktop.
Current .vimrc
"===============================================================================================================
" Will Davidow: (N)VIM(R) Configuration.
"===============================================================================================================
set nocompatible " disable vi compaibility mode
filetype off " required
" default settings
"===============================================================================================================
" high level stuff
"=================
set modifiable " set buffers modifiable (remove any ambiquity here)
set termguicolors " terminal color++
set novisualbell " no visual flash 'bell' either
set timeout timeoutlen=350 " extend keystroke combination timeout
set foldmethod=indent " set fold method (manual|marker|diff|expr|indent)
set encoding=utf-8 " set all the UTF-8's
set fileencoding=utf-8 " set all the UTF-8's
set fileencodings=utf-8 " set all the UTF-8's
set fileformats=unix,dos,mac " prefer Unix over Windows over OS 9 formats
set noerrorbells " fuck yo' bells n' beeps n' boops
set ruler " show cursor position
set laststatus=2 " show status line
set history=1000 " maximum history
set wildignore+=*/.git/*,*/.bzr/*,*~,*/build/*,*.pyc/*.DS_Store " ignore things
set scrolloff=500 " scroll screen when 2 lines from bottom/top
set sidescrolloff=2 " two columns context
set nobackup " don't create backup files
set nowritebackup " don't write backup files
set noswapfile " don't use swapfile
set splitright " split vertical windows right ofthe current windows
set splitbelow " split horizontal windows below of the current window
set autowrite " automatically save before :next, :make etc.
set autoread " automatically re-read changed files without asking me anything
" search stuff
"=================
set gdefault " regExp global by default
set magic " enable extended regex
set hlsearch " highlight search matches
set incsearch " shows the match while typing
set ignorecase " search case insensitive...
set smartcase " ... but not when search pattern contains uppercase characters
set wildmenu " tab completion (command line completion)
if !exists("g:syntax_on")
syntax enable
endif
" editor stuff
"=================
set cursorline " highlight current cursor line
set cursorcolumn " highlight current cursor column
set showmatch " do not show matching brackets by flickering
set number " Show line numbers
set relativenumber " Show relative line to help with movement
au InsertEnter * set norelativenumber " show absolute line numbers enering insert mode
au InsertLeave * set relativenumber " show reslative line numbers leaving insert mode
set matchtime=3 " speed up showmatch
set nowrap " don't wrap lines
set hidden " hide buffers instead of closing them
" reminder: tab settings will get overridden by editorconfig or filetype-specific settings
set tabstop=4 " tell vim how many columns a tab counts for
set softtabstop=4 " control how many columns vim uses when you hit Tab in insert mode
set shiftwidth=4 " control how many columns text is indented with the reindent operations
set smarttab " <TAB> key inserts indentation according to 'shiftwidth'
set expandtab " hitting Tab in insert mode will insert spaces instead of tab characters
set autoindent " turns on indentation settings
set backspace=indent,eol,start " allow backspacing over everything.
set nostartofline " make j/k respect column position
set mouse=a " Enable GUI mouse behavior
" map leader key to ,
let g:mapleader = ','
map <Space> <Leader>
" some sweet key maps
"===============================================================================================================
" Action: jj, kk, jk, and kj to Escape key (in insert mode)
inoremap jj <Esc>
inoremap kk <Esc>
inoremap jk <Esc>
inoremap kj <Esc>
" Action: <leader>cd to set current working directory
nnoremap <leader>cd :cd %:p:h<CR>
" Action: Convenient save/write stuff...
noremap <Leader>w :w<CR> " write
noremap <Leader>wa :wa<CR> " write all open files
" Action: retain cursor position post-visual (y)ank
vmap y ygv<Esc>
" Action: clear search highlights
nnoremap <esc> :noh<return><esc>
" Action: this only gets hit by accident
nnoremap Q <Nop>
" Action: redo
nnoremap U <C-r>
" Action: insert mode at beginning/end of line with extra space before
nnoremap <Leader>I I<Space><Esc>i
nnoremap <Leader>A A<Space>
" Action: move around window splits
" nmap <Leader>h <C-w>h " Left
" nmap <Leader>j <C-w>j " Down
" nmap <Leader>k <C-w>k " Up
" nmap <Leader>l <C-w>l " Right
" using option-(h|j|k|l)
nmap ˙ <C-w>h " Left
nmap ∆ <C-w>j " Down
nmap ˚ <C-w>k " Up
nmap ¬ <C-w>l " Right
" using command-(h|j|k|l)
"nmap <D-h> <C-w>h " Left
"nmap <D-j> <C-w>j " Down
"nmap <D-k> <C-w>k " Up
"nmap <D-l> <C-w>l " Right
if has("gui_vimr")
"
" indent lines with cmd+[ and cmd+]
nmap <D-]> >>
nmap <D-[> <<
vmap <D-]> >gv
vmap <D-[> <gv
endif
noremap <C-Tab> :tabnext<CR>
noremap <C-S-Tab> :tabprev<CR>
noremap tl :tabnext<CR>
noremap th :tabprev<CR>
noremap tn :tabnew<CR>
" buffer actions
"===============================================================================================================
" open a new empty buffer
" Replaces :tabnew
nmap <Leader>t :enew<CR>
" unmap key combinations...
" nunmap <leader>[
" nunmap <leader>]
" move to the next buffer
nmap <Leader>l :bnext<CR>
nmap <Leader>kk :bnext<cr>
nmap <Leader>ll :bnext<cr>
" move to the previous buffer
nmap <Leader>h :bprevious<CR>
nmap <Leader>hh :bprevious<cr>
nmap <Leader>jj :bprevious<cr>
" close the current buffer and move to the previous one
" replicates the idea of closing a tab
nmap <Leader>bq :bp <BAR> bd #<CR>
" show all open buffers and their status
nmap <Leader>bl :ls<CR>
" kill a buffer
nmap <Leader>d :bd<CR>
" kill a buffer (force)
nmap <Leader>bd :bd!<CR>
" plugins
"===============================================================================================================
" install VIM-Plug if not present
if empty(glob('~/.vim/autoload/plug.vim'))
silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs
\ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
endif
call plug#begin(expand('~/.vim/share/nvim/plugged'))
" utility packages
"===============================================================================================================
Plug 'mhinz/vim-startify' " nifty start page
" Plug 'tpope/vim-sensible' " Defaults everyone can agree on
" Plug 'junegunn/fzf.vim' " fuzzy finder (ctrp-p, fuzzy find... disabled because I never use this)
Plug 'mileszs/ack.vim' " grep in files
Plug 'matze/vim-move' " visually move lines and blocks up/down
Plug 'RRethy/vim-illuminate' " Highlight word under cursor in active session
Plug 'chaoren/vim-wordmotion' " Better word motions
Plug 'junegunn/vim-easy-align' " 🌻 A Vim alignment plugin
Plug 'Yggdroot/indentLine' " Display the indention levels with thin vertical lines
Plug 'jeetsukumaran/vim-buffergator' " List, select and switch between buffers
" status and display
"===============================================================================================================
Plug 'ryanoasis/vim-devicons' " Dev icons for various file extensions
Plug 'vim-airline/vim-airline' " Airline status bar
Plug 'vim-airline/vim-airline-themes' " Airline status bar themes
" dev-related
"===============================================================================================================
Plug 'tpope/vim-fugitive' " GIT stuff
Plug 'editorconfig/editorconfig-vim' " EditorConfig support
Plug 'airblade/vim-gitgutter' " Show GIT diffs in left column
Plug 'tomtom/tcomment_vim' " Extensible commenting for VIM
Plug 'tpope/vim-surround' " Surround selection with entry
Plug 'airblade/vim-rooter' " Change to current directory when opening file(s)
" Plug 'LucHermitte/lh-vim-lib'
" Plug 'LucHermitte/lh-brackets' " Maybe better bracketing/pairing system?
Plug 'AndrewRadev/splitjoin.vim' " Join / Split lines functions
Plug 'othree/html5.vim' " HTML 5 Syntax Stuff
Plug 'neoclide/vim-jsx-improve', { 'for': [ 'javascript', 'js', 'jsx' ]} " JSX syntax stuff
Plug 'MaxMEllon/vim-jsx-pretty' " JSX'yness
Plug 'styled-components/vim-styled-components', { 'branch': 'main' } " Styled Component syntax stuff
Plug 'tpope/vim-cucumber' " support for cucumber syntax
Plug 'neoclide/coc.nvim', {'branch': 'release'}
"
" color schemes
"===============================================================================================================
"Plug 'hukl/Smyck-Color-Scheme'
"Plug 'mkarmona/colorsbox' " colorsbox-stnight
"Plug 'arcticicestudio/nord-vim' " nord
"Plug 'wesgibbs/vim-irblack'
"Plug 'vim-scripts/Gummybears'
"Plug 'tjammer/blayu.vim'
"Plug 'widatama/vim-phoenix'
"Plug 'chriskempson/base16-vim'
"Plug 'jacoborus/tender.vim'
"Plug 'turly/vimstuff' " bluish
"Plug 'chase/focuspoint-vim'
"Plug 'wmvanvliet/vim-blackboard'
"Plug 'flrnd/candid.vim'
"Plug 'exitface/synthwave.vim'
"Plug 'artanikin/vim-synthwave84'
"Plug 'flrnd/plastic.vim'
"Plug 'vim-scripts/phd'
"Plug 'sainnhe/edge'
"Plug 'ayu-theme/ayu-vim'
"Plug 'rakr/vim-one'
Plug 'drewtempelmeyer/palenight.vim'
" Calling plug#end initializes plugin system
call plug#end()
" let base16colorspace=256
set background=dark " Set background (should be before colorscheme)
colorscheme palenight
" let ayucolor="mirage" " for dark version of theme
" colorscheme ayu " Set colorscheme
" ayu indent line settings
" " IndentLine {{
" let g:indentLine_char = '|'
" let g:indentLine_first_char = '|'
" let g:indentLine_showFirstIndentLevel = 1
" let g:indentLine_setColors = 0
" " }}
"
" Plugin: coc-vim
" Extensions in-use: coc-css, coc-tsserver, coc-pairs, coc-explorer, coc-json,
" coc-phpls, coc-html, coc-markdownlint
"===============================================================================================================
" coc-vim: Use <Tab> and <S-Tab> to navigate the completion list:
inoremap <expr> <Tab> pumvisible() ? "\<C-n>" : "\<Tab>"
inoremap <expr> <S-Tab> pumvisible() ? "\<C-p>" : "\<S-Tab>"
" coc-vim: Use <cr> to confirm completion
inoremap <expr> <cr> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>"
" coc-vim: make <cr> select the first completion item and confirm the completion when no item has been selected
inoremap <silent><expr> <cr> pumvisible() ? coc#_select_confirm() : "\<C-g>u\<CR>"
" Extension: coc-pairs: Insert line on enter inside pairs
inoremap <silent><expr> <cr> pumvisible() ? coc#_select_confirm() : "\<C-g>u\<CR>\<c-r>=coc#on_enter()\<CR>"
" Extension: coc-explorer
nmap <Leader>\ :CocCommand explorer<CR>
" Plugin Settings: vim-easy-align
"===============================================================================================================
" Start interactive EasyAlign in visual mode (e.g. vipga)
xmap ga <Plug>(EasyAlign)
" Start interactive EasyAlign for a motion/text object (e.g. gaip)
nmap ga <Plug>(EasyAlign)
" Plugin Settings: vim-illuminate
"===============================================================================================================
let g:Illuminate_highlightUnderCursor = 1
let g:Illuminate_delay = 250
" Plugin Settings: vim-startify
"===============================================================================================================
nnoremap <leader>st :Startify<cr>
let g:startify_list_order = [
\ [' MRU'], 'files' ,
\ [' MRU '.getcwd()], 'dir',
\ [' Sessions'], 'sessions',
\ [' Bookmarks'], 'bookmarks',
\ ]
let g:startify_skiplist = [
\ 'COMMIT_EDITMSG',
\ 'bundle/.*/doc',
\ '/data/repo/neovim/runtime/doc',
\ '/Users/mhi/local/vim/share/vim/vim74/doc',
\ ]
let g:startify_bookmarks = [
\ '~/.vimrc',
\ '~/.zshenv',
\ '~/.zshrc'
\ ]
let g:startify_change_to_dir = 1
let g:startify_disable_at_vimenter = 0
let g:startify_change_to_vcs_root = 1
let g:startify_enable_special = 0
let g:startify_files_number = 8
let g:startify_session_autoload = 1
let g:startify_session_delete_buffers = 1
let g:startify_session_persistence = 1
let g:startify_update_oldfiles = 1
let g:startify_use_env = 1
" Plugin Settings: vim-buffergator
"===============================================================================================================
let g:buffergator_viewport_split_policy = 'R'
let g:buffergator_suppress_keymaps = 1
let g:buffergator_split_size=30
nmap ; :BuffergatorToggle<CR>
" Plugin: lh-brackets config
" let g:usemarks = 0 " turn off annoying <<>> insertion
" let b:cb_jump_on_close = 1 " not sure what this does
" Plugin: Camel Case Motion Mappings
" map <silent> w <Plug>CamelCaseMotion_w
" map <silent> b <Plug>CamelCaseMotion_b
" map <silent> e <Plug>CamelCaseMotion_e
" map <silent> ge <Plug>CamelCaseMotion_ge
" sunmap w
" sunmap b
" sunmap e
" sunmap ge
" Plugin Settings: ack.vim
"===============================================================================================================
let g:ackprg = 'ag --nogroup --nocolor --column --vimgrep'
nnoremap <Leader>a :Ack!<Space>
" Plugin Settings: vim-airline
"===============================================================================================================
" let g:airline_theme = 'base16_spacemacs'
let g:airline_theme = 'palenight'
let g:airline_powerline_fonts = 1
let g:_powerline_fonts = 1
if !exists('g:airline_symbols')
let g:airline_symbols = {}
endif
let g:airline#extensions#tabline#enabled = 1
let g:airline#extensions#tabline#fnamemod = ':t' " only show filename in buffer tabline tabs
" unicode symbols
let g:airline_left_sep = '»'
let g:airline_left_sep = '▶'
let g:airline_right_sep = '«'
let g:airline_right_sep = '◀'
let g:airline_symbols.linenr = '␊'
let g:airline_symbols.linenr = '␤'
let g:airline_symbols.linenr = '¶'
let g:airline_symbols.branch = '⎇'
let g:airline_symbols.paste = 'ρ'
let g:airline_symbols.paste = 'Þ'
let g:airline_symbols.paste = '∥'
let g:airline_symbols.whitespace = 'Ξ'
" airline symbols
let g:airline_left_sep = ''
let g:airline_left_alt_sep = ''
let g:airline_right_sep = ''
let g:airline_right_alt_sep = ''
let g:airline_symbols.branch = ''
let g:airline_symbols.readonly = ''
let g:airline_symbols.linenr = ''
" coc-vim integration
let g:airline_section_error = '%{airline#util#wrap(airline#extensions#coc#get_error(),0)}'
let g:airline_section_warning = '%{airline#util#wrap(airline#extensions#coc#get_warning(),0)}'
" Plugin Settings: indentLine
"===============================================================================================================
let g:indentLine_char = '|'
" Plugin Settings: vim-move
"===============================================================================================================
" find better non-command-key based maps for this (doesn't work in terminal-based sessions, so for now we'll make sure we're in vimr)
if has("gui_vimr")
" Visual Mode cmd+j moves selected block down
vmap <D-j> <Plug>MoveBlockDown
" vmap <C-j> <Plug>MoveBlockDown
vmap <Leader>j <Plug>MoveBlockDown
" Visual Mode cmd+k moves selected block up
vmap <D-k> <Plug>MoveBlockUp
" vmap <C-k> <Plug>MoveBlockUp
vmap <Leader>k <Plug>MoveBlockDown
" Cmd+j Move current line down
nmap <D-j> <plug>MoveLineDown
" nmap <C-j> <plug>MoveLineDown
nmap <Leader>j <plug>MoveLineDown
" Cmd+k Move current line up
nmap <D-k> <Plug>MoveLineUp
" nmap <C-k> <Plug>MoveLineUp
nmap <Leader>k <plug>MoveLineUp
endif
@willdavidow
Copy link
Author

Started using VimR over MacVim - runs a bit more smoothly, and is based on NeoVim.

@willdavidow
Copy link
Author

Cleaned up a lot; comments and separators
Switched from Plug to Minpac (might switch back?)
Reduced number of plugins used
Language Server working (requires external configuration - see plugin readme)
FZF working using homebrew (required adding path for homebrew fzf install)

@willdavidow
Copy link
Author

Lots of cleanup
Add coc (language server stuff)
w0rp/ale configuration working nicely
added line to retain logical cursor position after visual yanking (e.g. yank after visual selection goes to cursor position at the time of yanking, which is not the default behavior)
...lots of other small tweaks

@willdavidow
Copy link
Author

Refactored and cleaned up. Removed a lot of cruft and not-used commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment