reorganize, remove plugins, add colors

This commit is contained in:
James Dixon 2020-05-28 20:23:55 -04:00
parent 387d44c489
commit b627c4d0dd

314
vim/vimrc
View File

@ -3,133 +3,14 @@
" \ V /| | | | | | | | | (__ " \ V /| | | | | | | | | (__
" \_/ |_|_| |_| |_|_| \___| " \_/ |_|_| |_| |_|_| \___|
"------------------------------------------------------------------------------ "sources defaults if available
"general settings
"------------------------------------------------------------------------------
"load defaults if available
if filereadable(expand('$VIMRUNTIME/defaults.vim')) if filereadable(expand('$VIMRUNTIME/defaults.vim'))
unlet! g:skip_defaults_vim unlet! g:skip_defaults_vim
source $VIMRUNTIME/defaults.vim source $VIMRUNTIME/defaults.vim
endif endif
"encoding/format
set encoding=utf-8
set fileformats=unix,dos,mac
"file/buffer
set autoread
set autowrite
set confirm
"display
set background=dark
set number
set wrap
set showbreak=↪\
set listchars=tab:→\ ,extends:,precedes:,nbsp,trail,eol
set foldmethod=marker
set lazyredraw
set regexpengine=1
set redrawtime=10000
"tab/indent
set tabstop=4
set softtabstop=4
set shiftwidth=4
set expandtab
set autoindent
"status bar
set showcmd
set wildmenu
set ruler
set laststatus=2
"search
set incsearch
set hlsearch
set ignorecase
set smartcase
"cursor behaviour
set virtualedit=block
set backspace=indent,eol,start
set showmatch
set scrolloff=2
set sidescrolloff=8
"input/timeout
set esckeys
set timeoutlen=1000 "for mappings
set ttimeoutlen=20 "for keycodes
"window behaviour (ltr)
set splitbelow
set splitright
"undo/bkup dirs
set undofile
set undodir=~/.vim/.undo//,/tmp//
set backupdir=~/.vim/.backup//,/tmp//
set directory=~/.vim/.swap//,/tmp//
"leader key
let mapleader=' '
"------------------------------------------------------------------------------
"normal/visual mode keybinds
"------------------------------------------------------------------------------
"normal keybinds
nnoremap <silent><leader><space> :let @/ = ""<CR>
nnoremap <leader>p :set invpaste<CR>
nnoremap <silent><leader>lb :call ToggleLineBreak()<CR>
nnoremap <silent><leader>wr :call ToggleWrap()<CR>
nnoremap <silent><leader>cc :call ToggleColorColumn()<CR>
nnoremap <leader>ts "=strftime("%F %T%z")<CR>
nnoremap <leader>dt :r !date<CR>
nnoremap <leader>rc :vsplit $MYVIMRC<CR>
nnoremap <leader>so :source $MYVIMRC<CR>
nnoremap =j :%!python -m json.tool<CR>
"plugin keybinds
nnoremap <silent><leader>e :call ToggleNetrw()<CR>
nnoremap <leader>at :ALEToggle<CR>
if !exists('##TextYankPost')
map y <Plug>(highlightedyank)
endif
"------------------------------------------------------------------------------
"insert mode keybinds and abbreviations
"------------------------------------------------------------------------------
inoreabbrev <expr> #!! "#!/usr/bin/env"
"------------------------------------------------------------------------------
"custom commands
"------------------------------------------------------------------------------
"common typos and abbreviations
cnoremap w!! w !sudo tee % > /dev/null
command! W w !sudo tee % > /dev/null
command! Trim %s/\s\+$//
command! Q q
command! WQ wq
command! Q1 q!
"function calls
command! -nargs=+ SearchGoogle call SearchGoogle(join([<f-args>]))
"------------------------------------------------------------------------------
"plugins (vim-plug) "plugins (vim-plug)
"------------------------------------------------------------------------------ "------------------
"ensure vim-plug is installed on VimEnter "ensure vim-plug is installed on VimEnter
if empty(glob('~/.vim/autoload/plug.vim')) if empty(glob('~/.vim/autoload/plug.vim'))
silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs
@ -140,17 +21,12 @@ endif
"filetype *may* interfere with certain plugins "filetype *may* interfere with certain plugins
filetype off filetype off
"entry function
call plug#begin('~/.vim/plugged') call plug#begin('~/.vim/plugged')
"## vim plug ##
Plug 'junegunn/vim-plug' Plug 'junegunn/vim-plug'
"------------- "general
"== general == "-------
"------------- "quality of life
"## quality of life ##
Plug 'tpope/vim-surround' Plug 'tpope/vim-surround'
Plug 'tpope/vim-commentary' Plug 'tpope/vim-commentary'
Plug 'tpope/vim-unimpaired' Plug 'tpope/vim-unimpaired'
@ -158,38 +34,27 @@ call plug#begin('~/.vim/plugged')
Plug 'tpope/vim-eunuch' Plug 'tpope/vim-eunuch'
Plug 'tpope/vim-repeat' Plug 'tpope/vim-repeat'
Plug 'editorconfig/editorconfig-vim' Plug 'editorconfig/editorconfig-vim'
"git
"## git ##
Plug 'tpope/vim-fugitive' Plug 'tpope/vim-fugitive'
Plug 'airblade/vim-gitgutter' "visual
Plug 'flazz/vim-colorschemes'
"## visual ## "linting
Plug 'machakann/vim-highlightedyank' Plug 'w0rp/ale'
"-----------------------
"== language specific ==
"-----------------------
"language/ft specific
"--------------------
"javascript/css/html "javascript/css/html
Plug 'pangloss/vim-javascript' Plug 'pangloss/vim-javascript'
Plug 'mattn/emmet-vim' Plug 'mattn/emmet-vim'
"go "go
Plug 'fatih/vim-go' Plug 'fatih/vim-go'
"## linting ##
Plug 'w0rp/ale'
call plug#end() call plug#end()
"------------------------------------------------------------------------------
"plugin settings "plugin settings
"------------------------------------------------------------------------------ "---------------
"this function gets called with the VimEnter autocommand to set plugin "this function gets called with the VimEnter autocommand to set plugin
"options "options
function! SetPluginSettings() function! SetPluginSettings()
"netrw "netrw
let g:netrw_banner = 0 let g:netrw_banner = 0
let g:netrw_winsize = 24 let g:netrw_winsize = 24
@ -197,18 +62,8 @@ function! SetPluginSettings()
let g:netrw_preview = 1 let g:netrw_preview = 1
let g:netrw_alto = 0 let g:netrw_alto = 0
let g:netrw_usetab = 1 let g:netrw_usetab = 1
let g:netrw_browsex_viewer = "xdg-open"
let g:NetrwIsOpen = 0 "for toggle function let g:NetrwIsOpen = 0 "for toggle function
"git gutter
augroup git_gutter
if exists(':GitGutter')
autocmd!
let g:gitgutter_map_keys = 0 "don't use mapped keys
autocmd BufWritePost * GitGutter "update GitGutter after writing
endif
augroup END
"ale "ale
if exists(':ALEToggle') if exists(':ALEToggle')
let g:ale_fixers = { let g:ale_fixers = {
@ -219,16 +74,116 @@ function! SetPluginSettings()
let g:ale_sign_warning = '--' let g:ale_sign_warning = '--'
endif endif
"colors
"set background=dark
"colorscheme 1989
"colorscheme PaperColor
"colorscheme dracula
"colorscheme gruvbox
colorscheme jellybeans
"colorscheme molokai
"colorscheme badwolf
endfunction endfunction
"------------------------------------------------------------------------------ "general settings
"----------------
"encoding/format
set encoding=utf-8
set fileformats=unix,dos,mac
"file/buffer
set autoread
set autowrite
set confirm
"display
set background=dark
set number
set wrap
set showbreak=↪\
set listchars=tab:→\ ,extends:,precedes:,nbsp,trail,eol
set foldmethod=marker
set lazyredraw
set regexpengine=1
set redrawtime=10000
"tab/indent
set tabstop=4
set softtabstop=4
set shiftwidth=4
set expandtab
set autoindent
"status bar
set showcmd
set wildmenu
set ruler
set laststatus=2
"search
set incsearch
set hlsearch
set ignorecase
set smartcase
"cursor behaviour
set virtualedit=block
set backspace=indent,eol,start
set showmatch
set scrolloff=2
set sidescrolloff=8
"input/timeout
set esckeys
set timeoutlen=1000 "for mappings
set ttimeoutlen=20 "for keycodes
"window behaviour (ltr)
set splitbelow
set splitright
"undo/bkup dirs
set undofile
set undodir=~/.vim/.undo//,/tmp//
set backupdir=~/.vim/.backup//,/tmp//
set directory=~/.vim/.swap//,/tmp//
"leader key
let mapleader=' '
"normal/visual mode keybinds
"---------------------------
"paste and search
nnoremap <silent><leader><space> :let @/ = ""<CR>
nnoremap <leader>p :set invpaste<CR>
"toggles
nnoremap <silent><leader>lb :call ToggleLineBreak()<CR>
nnoremap <silent><leader>wr :call ToggleWrap()<CR>
nnoremap <silent><leader>cc :call ToggleColorColumn()<CR>
"dates
nnoremap <leader>ts "=strftime("%F %T%z")<CR>
nnoremap <leader>dt :r !date<CR>
"rc files
nnoremap <leader>rc :vsplit $MYVIMRC<CR>
nnoremap <leader>so :source $MYVIMRC<CR>
"formatting tools
nnoremap =j :%!python -m json.tool<CR>
"plugin keybinds
nnoremap <silent><leader>e :call ToggleNetrw()<CR>
nnoremap <leader>at :ALEToggle<CR>
"insert mode keybinds/abbreviations
"--------------------
inoreabbrev <expr> #!! "#!/usr/bin/env"
"custom commands
"---------------
"common typos and abbreviations
cnoremap w!! w !sudo tee % > /dev/null
command! W w !sudo tee % > /dev/null
command! Trim %s/\s\+$//
command! Q q
command! WQ wq
command! Q1 q!
"function calls
command! -nargs=+ SearchGoogle call SearchGoogle(join([<f-args>]))
"general functions "general functions
"------------------------------------------------------------------------------ "-----------------
"----------------
"toggle functions "toggle functions
"----------------
function! ToggleColorColumn() function! ToggleColorColumn()
if &cc == '' if &cc == ''
set cc=80 set cc=80
@ -274,10 +229,7 @@ function! ToggleNetrw() "make netrw toggleable
endif endif
endfunction endfunction
"----------------
"search functions "search functions
"----------------
function! SearchGoogle(string) function! SearchGoogle(string)
let l:google = "https://www.google.com/search?q=" let l:google = "https://www.google.com/search?q="
let l:browser = "xdg-open >/dev/null 2>/dev/null" let l:browser = "xdg-open >/dev/null 2>/dev/null"
@ -285,18 +237,14 @@ function! SearchGoogle(string)
execute "!" l:browser . "\ " . l:google . l:query execute "!" l:browser . "\ " . l:google . l:query
endfunction endfunction
"------------------------------------------------------------------------------
"syntax/filetype "syntax/filetype
"------------------------------------------------------------------------------ "---------------
syntax enable syntax enable
filetype plugin indent on filetype plugin indent on
runtime macros/matchit.vim runtime macros/matchit.vim
"------------------------------------------------------------------------------
"gui settings "gui settings
"------------------------------------------------------------------------------ "------------
if has("gui_running") if has("gui_running")
set guioptions -=m set guioptions -=m
set guioptions -=T set guioptions -=T
@ -309,23 +257,16 @@ if has("gui_running")
endif endif
endif endif
"------------------------------------------------------------------------------
"win32 settings "win32 settings
"------------------------------------------------------------------------------ "--------------
if has('win32') if has('win32')
endif endif
"------------------------------------------------------------------------------
"auto commands "auto commands
"------------------------------------------------------------------------------ "-------------
if has("autocmd") if has("autocmd")
"global
"------------ augroup global
"## global ##
"------------
augroup general
autocmd! autocmd!
"set plugin settings on VimEnter "set plugin settings on VimEnter
autocmd VimEnter * call SetPluginSettings() autocmd VimEnter * call SetPluginSettings()
@ -336,9 +277,7 @@ if has("autocmd")
\ <= line("$") | exe "normal! g'\"" | endif \ <= line("$") | exe "normal! g'\"" | endif
augroup END augroup END
"-------------------------------- "language/filetype
"## language/filetype specific ##
"--------------------------------
augroup languages augroup languages
autocmd! autocmd!
"shell "shell
@ -353,5 +292,4 @@ if has("autocmd")
autocmd FileType html,javascript,css,json,yaml,sh autocmd FileType html,javascript,css,json,yaml,sh
\ setlocal ts=2 sts=2 sw=2 expandtab \ setlocal ts=2 sts=2 sw=2 expandtab
augroup END augroup END
endif endif