restrucutre and add search function

This commit is contained in:
James Dixon 2020-05-17 14:24:45 -04:00
parent 89056915d1
commit 0b64b275a8

365
vim/vimrc
View File

@ -3,8 +3,9 @@
" \ V /| | | | | | | | | (__ " \ V /| | | | | | | | | (__
" \_/ |_|_| |_| |_|_| \___| " \_/ |_|_| |_| |_|_| \___|
"(((((((((((( general settings )))))))))))) "------------------------------------------------------------------------------
set nocompatible "general settings
"------------------------------------------------------------------------------
"tab/indent "tab/indent
set tabstop=4 set tabstop=4
@ -70,20 +71,37 @@ set directory=~/.vim/.swap//,/tmp//
"leader key "leader key
let mapleader=',' let mapleader=','
"(((((((((((( normal keybinds )))))))))))) "------------------------------------------------------------------------------
"normal mode keybinds
"------------------------------------------------------------------------------
"normal keybinds
nnoremap <silent><leader><space> :let @/ = ""<CR> nnoremap <silent><leader><space> :let @/ = ""<CR>
nnoremap <leader>p :set invpaste<CR> nnoremap <leader>p :set invpaste<CR>
nnoremap <silent><leader>lb :call ToggleLineBreak()<CR> nnoremap <silent><leader>lb :call ToggleLineBreak()<CR>
nnoremap <silent><leader>wr :call ToggleWrap()<CR> nnoremap <silent><leader>wr :call ToggleWrap()<CR>
nnoremap <silent><leader>cc :call ToggleColorColumn()<CR> nnoremap <silent><leader>cc :call ToggleColorColumn()<CR>
nnoremap <leader>ts "=strftime("%F %T%z")<CR>p nnoremap <leader>ts "=strftime("%F %T%z")<CR>p
nnoremap =j :%!python -m json.tool<CR> nnoremap =j :%!python -m json.tool<CR>
"(((((((((((( abbreviations )))))))))))) "plugin keybinds
nnoremap <silent><leader>e :call ToggleNetrw()<CR>
nnoremap <leader>at :ALEToggle<CR>
if !exists('##TextYankPost')
map y <Plug>(highlightedyank)
endif
"------------------------------------------------------------------------------
"abbreviations
"------------------------------------------------------------------------------
inoreabbrev <expr> #!! "#!/usr/bin/env" inoreabbrev <expr> #!! "#!/usr/bin/env"
"(((((((((((( commands )))))))))))) "------------------------------------------------------------------------------
"custom commands
"------------------------------------------------------------------------------
"common typos and abbreviations
cnoremap w!! w !sudo tee % > /dev/null cnoremap w!! w !sudo tee % > /dev/null
command! W w !sudo tee % > /dev/null command! W w !sudo tee % > /dev/null
command! Trim %s/\s\+$// command! Trim %s/\s\+$//
@ -91,191 +109,248 @@ command! Q q
command! WQ wq command! WQ wq
command! Q1 q! command! Q1 q!
"(((((((((((( plugins )))))))))))) "------------------------------------------------------------------------------
"plugins (vim-plug)
"------------------------------------------------------------------------------
"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
\ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim \ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
autocmd VimEnter * PlugInstall --sync | source $MYVIMRC autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
endif endif
"filetype may interfere with 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'
"== general ==
"## quality of life ##
Plug 'tpope/vim-surround'
Plug 'tpope/vim-commentary'
Plug 'tpope/vim-unimpaired'
Plug 'tpope/vim-rsi'
Plug 'tpope/vim-eunuch'
Plug 'tpope/vim-repeat'
"## git ##
Plug 'tpope/vim-fugitive'
Plug 'airblade/vim-gitgutter'
"## editorconfig ##
Plug 'editorconfig/editorconfig-vim'
"## colors, highlights and indents ##
Plug 'machakann/vim-highlightedyank'
"== language specific == "## vim plug ##
Plug 'junegunn/vim-plug'
"-------------
"== general ==
"-------------
"## quality of life ##
Plug 'tpope/vim-surround'
Plug 'tpope/vim-commentary'
Plug 'tpope/vim-unimpaired'
Plug 'tpope/vim-rsi'
Plug 'tpope/vim-eunuch'
Plug 'tpope/vim-repeat'
Plug 'editorconfig/editorconfig-vim'
"## git ##
Plug 'tpope/vim-fugitive'
Plug 'airblade/vim-gitgutter'
"## visual ##
Plug 'machakann/vim-highlightedyank'
"-----------------------
"== language 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 ##
"## linting ##
Plug 'w0rp/ale' Plug 'w0rp/ale'
call plug#end() call plug#end()
"(((((((((((( plugin keybinds )))))))))))) "------------------------------------------------------------------------------
nnoremap <silent><leader>e :call ToggleNetrw()<CR> "plugin settings
nnoremap <leader>at :ALEToggle<CR> "------------------------------------------------------------------------------
if !exists('##TextYankPost')
map y <Plug>(highlightedyank)
endif
"(((((((((((( plugin settings )))))))))))) " this function gets called with the VimEnter autocommand to set plugin
" options
function! SetPluginSettings() function! SetPluginSettings()
"netrw
let g:netrw_banner = 0 "netrw
let g:netrw_winsize = 24 let g:netrw_banner = 0
let g:netrw_liststyle = 3 let g:netrw_winsize = 24
let g:netrw_preview = 1 let g:netrw_liststyle = 3
let g:netrw_alto = 0 let g:netrw_preview = 1
let g:netrw_usetab = 1 let g:netrw_alto = 0
"git gutter let g:netrw_usetab = 1
augroup git_gutter let g:netrw_browsex_viewer = "xdg-open"
if exists(':GitGutter') let g:NetrwIsOpen = 0 "for toggle function
autocmd!
let g:gitgutter_map_keys = 0 "don't use mapped keys "git gutter
autocmd BufWritePost * GitGutter "update GitGutter after writing augroup git_gutter
endif if exists(':GitGutter')
augroup END autocmd!
if exists(':ALEToggle') let g:gitgutter_map_keys = 0 "don't use mapped keys
let g:ale_fixers = { autocmd BufWritePost * GitGutter "update GitGutter after writing
\ '*': ['remove_trailing_lines', 'trim_whitespace'], endif
\ 'javascript': ['eslint'], augroup END
\}
let g:ale_sign_error = '->' "ale
let g:ale_sign_warning = '--' if exists(':ALEToggle')
endif let g:ale_fixers = {
\ '*': ['remove_trailing_lines', 'trim_whitespace'],
\ 'javascript': ['eslint'],
\}
let g:ale_sign_error = '->'
let g:ale_sign_warning = '--'
endif
endfunction endfunction
"(((((((((((( general use functions )))))))))))) "------------------------------------------------------------------------------
"general functions
"------------------------------------------------------------------------------
"----------------
"toggle functions
"----------------
function! ToggleColorColumn() function! ToggleColorColumn()
if &cc == '' if &cc == ''
set cc=80 set cc=80
else else
set cc= set cc=
endif endif
endfunction endfunction
function! ToggleLineBreak() function! ToggleLineBreak()
if &lbr == '' if &lbr == ''
set fo+=t "Autowraps text with textwidth set fo+=t "Autowraps text with textwidth
set fo-=l "Wraps long lines in --insert-- mode set fo-=l "Wraps long lines in --insert-- mode
set lbr set lbr
else else
set fo-=t set fo-=t
set fo+=l set fo+=l
set lbr! set lbr!
endif endif
endfunction endfunction
function! ToggleWrap() function! ToggleWrap()
if &wrap == '' if &wrap == ''
set wrap set wrap
else else
set nowrap set nowrap
endif endif
endfunction endfunction
"make netrw toggleable function! ToggleNetrw() "make netrw toggleable
"https://vi.stackexchange.com/questions/10988/toggle-explorer-window "https://vi.stackexchange.com/questions/10988/toggle-explorer-window
let g:NetrwIsOpen=0 if g:NetrwIsOpen
function! ToggleNetrw() let i = bufnr("$")
if g:NetrwIsOpen while (i >= 1)
let i = bufnr("$") if (getbufvar(i, "&filetype") == "netrw")
while (i >= 1) silent exe "bwipeout " . i
if (getbufvar(i, "&filetype") == "netrw") endif
silent exe "bwipeout " . i let i-=1
endif endwhile
let i-=1 let g:NetrwIsOpen=0
endwhile else
let g:NetrwIsOpen=0 let g:NetrwIsOpen=1
else silent Lexplore
let g:NetrwIsOpen=1 endif
silent Lexplore
endif
endfunction endfunction
"(((((((((((( enable syntax/filetype )))))))))))) "----------------
"search functions
"----------------
"------------------------------------------------------------------------------
"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
if has("gui_gtk2") if has("gui_gtk2")
set guifont=Inconsolata\ 12 set guifont=Inconsolata\ 12
elseif has("gui_macvim") elseif has("gui_macvim")
set guifont=Menlo\ Regular:h14 set guifont=Menlo\ Regular:h14
elseif has("gui_win32") elseif has("gui_win32")
set guifont=Consolas:h10 set guifont=Consolas:h10
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 set_plugin_settings
autocmd!
autocmd VimEnter * call SetPluginSettings()
augroup END
augroup auto_resize_windows "------------
autocmd! "## global ##
autocmd VimResized * wincmd = "------------
augroup END
"## save cursor position in a file ## "set plugin settings on VimEnter
au BufReadPost * if line("'\"") > 1 && line("'\"") augroup set_plugin_settings
\ <= line("$") | exe "normal! g'\"" | endif autocmd!
autocmd VimEnter * call SetPluginSettings()
augroup END
"## language/filetype specific ## "keep equal proportions when windows resized
augroup filetype_shell augroup auto_resize_windows
autocmd! autocmd!
autocmd BufNewFile,BufRead *bash* set syntax=sh autocmd VimResized * wincmd =
augroup END augroup END
augroup filetype_python "save cursor position in a file
autocmd! au BufReadPost * if line("'\"") > 1 && line("'\"")
autocmd FileType python xnoremap <leader>r <esc>:'<,'>:w !python3<CR> \ <= line("$") | exe "normal! g'\"" | endif
augroup END
augroup filetype_go "--------------------------------
autocmd! "## language/filetype specific ##
set expandtab! "--------------------------------
augroup END
augroup filetype_html "shell
autocmd! augroup filetype_shell
autocmd FileType html :syntax sync fromstart autocmd!
augroup END autocmd BufNewFile,BufRead *bash* set syntax=sh
augroup END
augroup half_tab "python
autocmd! augroup filetype_python
autocmd FileType html,javascript,css,json,yaml,yml,sh autocmd!
\ setlocal ts=2 sts=2 sw=2 expandtab autocmd FileType python xnoremap <leader>r <esc>:'<,'>:w !python3<CR>
augroup END augroup END
"go
augroup filetype_go
autocmd!
set expandtab!
augroup END
"html
augroup filetype_html
autocmd!
autocmd FileType html :syntax sync fromstart
augroup END
"where tabs should = 2 spaces
augroup half_tab
autocmd!
autocmd FileType html,javascript,css,json,yaml,yml,sh
\ setlocal ts=2 sts=2 sw=2 expandtab
augroup END
endif endif