Skip to content

Instantly share code, notes, and snippets.

@amass01
Last active March 10, 2022 17:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amass01/75707d86968a66def56f34b45108876f to your computer and use it in GitHub Desktop.
Save amass01/75707d86968a66def56f34b45108876f to your computer and use it in GitHub Desktop.
.vimrc
" PLUGINS VIA VUNDLE
" Vundle Commands
" :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
" :PluginUpdate - checks installed plugins for updates
" when making changes, you must reload the file before running Vundle commands
" :so %
" Package dependencies
" tagbar: universal-ctags
" vim-markdown-preview: grip
" Necessary settings for Vundle
set nocompatible
filetype off
" Global settings
set autoindent " Auto indent new lines
set nonumber " Do not show line numbers
set ruler " Show line/column number in bottom right
set rulerformat=%l,%v " Format ruler
set expandtab " Insert space characters on tab
set tabstop=2 " Number of space chars for tab
set shiftwidth=2 " Number of space chars for indentation
set wildmenu " Enable menu at bottom of the vim window
set wildmode=longest:list,full " File system tab completion
set splitright " Open verticle split pane to the right
set splitbelow " Open horizontal split plane below
set foldcolumn=0 " Column spaces between left border and text
set wrap " Wrap words at EOL
set linebreak " Only insert line breaks on enter key press
set nolist " List disables linebreak
set wrap linebreak nolist " Do not automatically insert line breaks
set clipboard=unnamedplus " Use the system clipboard
set autoread " Automatically read in amended files
set hlsearch " Highlight the search terms during a search
set nowrapscan " Do not wrap around to top of search results
set colorcolumn=80 " Show marker at column 80
set laststatus=0 " Do not show status line
set fillchars="" " Remove verticle split seperator
" Put vim generated files in the vim application directory. These directories
" need to be created manually.
set backupdir=~/.vim/backup_files// " Backup files dir
set directory=~/.vim/swap_files// " Swap files dir
set undodir=~/.vim/undo_files// " Undo files dir
" Solarized color scheme needs to be installed manually.
" https://github.com/altercation/vim-colors-solarized
syntax enable
set background=dark
colorscheme solarized
set t_Co=16
highlight SignColumn ctermbg=0
highlight ColorColumn ctermbg=0
highlight VertSplit ctermbg=0 ctermfg=0
" Make navigating between panes easier. Right/left navigations are able to
" wrap around
nnoremap <C-J> <C-W><C-J>
nnoremap <C-K> <C-W><C-K>
nnoremap <C-L> <C-W>w
nnoremap <C-H> <C-W>W
" Set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
" Plugins must be defined in between vundle#begin/end.
call vundle#begin()
" Let Vundle manage Vundle (required)
Plugin 'VundleVim/Vundle.vim'
" Show the git diff in the sign column
Plugin 'airblade/vim-gitgutter'
" File structure tree
Plugin 'scrooloose/nerdtree'
" Tagbar that parses file structure
Plugin 'majutsushi/tagbar'
" ACK
Plugin 'mileszs/ack.vim'
" vim-gutentags auto-generates ctags so you don't have to worry about it.
" Requires universal-ctags.
Plugin 'ludovicchabant/vim-gutentags'
" Save the tag file in the hidden git directory
let g:gutentags_ctags_tagfile=".git/tags"
" Don't generate a tag file for golang files
function! GutentagsEnable(path) abort
return fnamemodify(a:path, ':e') != 'go'
endfunction
let g:gutentags_enabled_user_func = 'GutentagsEnable'
" Syntax checking
Plugin 'scrooloose/syntastic'
let g:syntastic_always_populate_loc_list = 1 " enables :lnext and :lprev commands
let g:syntastic_auto_loc_list = 0 " don't automatically open location list window
let g:syntastic_loc_list_height = 10 " height of the error location list
let g:syntastic_check_on_open = 0 " don't check syntax on open
let g:syntastic_check_on_wq = 0 " skip syntax check if :wq command is used
let g:syntastic_aggregate_errors = 1 " don't stop on first error found
let g:syntastic_javascript_checkers = ['eslint']
let g:syntastic_typescript_checkers = ['eslint']
let g:syntastic_go_checkers = ['golint', 'govet']
let g:syntastic_mode_map = { 'mode': 'active', 'passive_filetypes': ['go'] }
":Bdelete - close a buffer without exiting split pane
Plugin 'moll/vim-bbye'
" Markdown preview
Plugin 'iamcco/markdown-preview.nvim'
" tmux navigation keybindings
Plugin 'christoomey/vim-tmux-navigator'
" Disable tmux navigator when zooming the Vim pane
let g:tmux_navigator_disable_when_zoomed = 1
" Fuzzy file finder
" Plugin 'wincent/command-t'
Plugin 'ctrlpvim/ctrlp.vim'
" Git wrapper
Plugin 'tpope/vim-fugitive'
Plugin 'tpope/vim-rhubarb' " Gbrowse cmd handler for Github
" Syntax highlighting
"
" Plugin 'pangloss/vim-javascript'
" let g:javascript_plugin_jsdoc = 1
"
" Plugin 'leafgarland/typescript-vim'
" Plugin 'elzr/vim-json'
" Plugin 'ekalinin/Dockerfile.vim'
" Plugin 'gabrielelana/vim-markdown'
" Syntax highlighting for all languages
Plugin 'sheerun/vim-polyglot'
" Go tools and syntax highlighting
Plugin 'fatih/vim-go'
let g:go_list_type = "quickfix" " use quickfix instead of location list
let g:go_list_height = 10 " specify window height of quickfix
autocmd FileType qf wincmd J " open quickfix on the bottom, use full screen
let g:go_fmt_command = "goimports" " run goimports on save
call vundle#end() " required
filetype plugin indent on " required
" vim-tmux-navigator
" vim-go
" vim-json
let g:vim_json_syntax_conceal = 0
" tagbar
let g:tagbar_foldlevel = 0 " have folds closed by default
let g:tagbar_autoshowtag = 2 " don't automatically open tag folds
let g:tagbar_iconchars = ['+', '-'] " fold icons to use
let g:tagbar_vertical = 20 " display tagbar on bottom of screen
let g:tagbar_autofocus = 1 " move cursor to tagbar window when opened
let g:tagbar_autoclose = 1 " close tagbar window when tag is selected
let g:tagbar_sort = 0 " sort tags by file position by default
let g:tagbar_compact = 1 " omit blank lines in between top-level scopes
" gitgutter
set signcolumn=yes " show signcolum even when empty
let g:gitgutter_diff_base = 'head' " default diff against head
let g:gitgutter_max_signs = 2000 " number of signs allowed per file
" ctrlp
let g:ctrlp_prompt_mappings = {
\ 'ToggleByFname()': ['<F7>'],
\ 'PrtDeleteEnt()': ['<c-d>'],
\ 'PrtClearCache()': ['<c-f>'],
\}
" Markdown preview
" set syntax=off
let g:mkdp_refresh_slow = 1
let g:mkdp_preview_options = {
\ 'disable_sync_scroll': 1,
\ }
" ---NERDTree---
" Togglethe NERDTree file structure
nmap <Esc>n :NERDTreeToggle<CR><C-w>
" Open NERDTree to the local directory and highlight the opened file
nmap <Esc>l :NERDTreeFind<CR><C-w>
" Open NERDTree to the global working directory (:pwd)
nmap <Esc>g :NERDTreeCWD<CR><C-w>
" Toggle tagbar
nmap <Esc>m :TagbarToggle<CR>
" Update gitgutter and unset the 'last search pattern' register
nnoremap <CR> :GitGutterAll<CR>:noh<CR><CR>
" ctags - close the current buffer and go one step up the godef stack
noremap <Esc>t :Bdelete<CR>:GoDefPop<CR>
" Toggle line numbers
nmap <Leader>n :set invnumber<CR>
" Toggle spellcheck
nmap <Leader>s :set spell! spelllang=en_us<CR>
" Git blame
nmap <Esc>b :Git blame<CR>
" CtrlP
nmap <Leader>t :CtrlPMixed<CR>
nmap <Leader>b :CtrlPBuffer<CR>
" Markdown preview
nmap <C-p> :MarkdownPreview<CR>
" COMMANDS
" copy filename to clipboard
cnoreabbrev cpfilename let @*=expand("%")
"
" copy filepath to clipboard
cnoreabbrev cppath let @*=expand("%:p")
" set working directory to current file
cnoreabbrev cdcf cd %:p:h
" vim/bbye
cnoreabbrev bd Bdelete
" vim-go
cnoreabbrev gb GoBuild
cnoreabbrev gt GoTest
cnoreabbrev gtc GoTestCompile
" GoReferrers shows a list of all package invocations of a method
cnoreabbrev gr GoReferrers
" GoDescribe shows the method set and fields of a struct
cnoreabbrev gd GoDescribe
" GoImplements shows the interfaces that a type implements
cnoreabbrev gi GoImplements
cnoreabbrev gitdiffmaster let g:gitgutter_diff_base = 'master'
cnoreabbrev gitdiffhead let g:gitgutter_diff_base = 'HEAD'
" CUSTOM TAGS
" tagbar - go support
let g:tagbar_type_go = {
\ 'ctagstype' : 'go',
\ 'kinds' : [
\ 'p:package',
\ 'i:imports:1',
\ 'c:constants',
\ 'v:variables',
\ 't:types',
\ 'n:interfaces',
\ 'w:fields',
\ 'e:embedded',
\ 'm:methods',
\ 'r:constructor',
\ 'f:functions'
\ ],
\ 'sro' : '.',
\ 'kind2scope' : {
\ 't' : 'ctype',
\ 'n' : 'ntype'
\ },
\ 'scope2kind' : {
\ 'ctype' : 't',
\ 'ntype' : 'n'
\ },
\ 'ctagsbin' : 'gotags',
\ 'ctagsargs' : '-sort -silent'
\ }
" FUNCTIONS
"" Zoom / Restore window.
function! s:ZoomToggle() abort
if exists('t:zoomed') && t:zoomed
execute t:zoom_winrestcmd
let t:zoomed = 0
else
let t:zoom_winrestcmd = winrestcmd()
resize
vertical resize
let t:zoomed = 1
endif
endfunction
command! ZoomToggle call s:ZoomToggle()
nnoremap <silent> <C-A> :ZoomToggle<CR>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment