123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564 |
- """"" My (demuredemeanor) .vimrc
- "" Uses tabstop=4; shiftwidth=4; foldmarker={{{,}}};
- """"""""vim: set tabstop=4 shiftwidth=4:
- "" Above is an attempt at a modeline, which seems to have a issue
- "" where long pastes get a new line...
- "" https://notabug.org/demure/dotfiles/
- "" legacy repo http://github.com/demure/dotfiles
- """ Commands at Start """ {{{
- "" This one needs to be first
- set nocompatible " Choose no comp with legacy vi
- if has("syntax")
- syntax on " Adds vim color based on file
- endif
- "" Enable filetype settings
- if has("eval")
- filetype on
- filetype plugin on
- filetype indent on
- endif
- """ Folds Settings """ {{{
- if has("folding")
- set foldenable " Enable folds
- "" These next two would save which folds are open/close, as well
- "" as view location, but seems to force set foldmethod=indent...
- "au BufWinLeave ?* mkview
- "au BufWinEnter ?* silent loadview
- set foldmethod=marker
- set fillchars=fold:<
- highlight Folded ctermfg=Grey ctermbg=Black
- "set foldlevelstart=99 " Effectively disable auto folding
- """ Foldtext """ {{{
- "" Inspired by http://www.gregsexton.org/2011/03/improving-the-text-displayed-in-a-fold/
- set foldtext=CustomFoldText()
- function! CustomFoldText()
- "" Process line
- let fs = v:foldstart
- let fLinePrep = substitute(getline(fs), '\t\| ', '+---', 'g')
- let fLine = substitute(fLinePrep, ' {\{3}', '', 'g')
- "" Process line count and fold precentage
- let fSize = 1 + v:foldend - v:foldstart
- let fSizeStr = " (" . fSize . " lines) "
- let fLineCount = line("$")
- let fPercent = printf(" [%.1f", (fSize*1.0)/fLineCount*100) . "%] "
- "" Process fold level
- let fLevel = " {".v:foldlevel."} "
- "" Process filler string
- let w = winwidth(0) - &foldcolumn - (&number ? 8 : 0)
- let expansionString = repeat(".", w - strwidth(fSizeStr.fLine.fPercent.fLevel))
- "return fLine . expansionString . fSizeStr . foldPercent . foldLevel
- return fLine . fSizeStr . fPercent . fLevel
- endfunction
- """ End Foldtext """ }}}
- endif
- """ End Folds Settings """ }}}
- "" Stop auto comment on new line
- autocmd FileType * setlocal formatoptions-=cro
- set shortmess+=atIT " Stop messages at vim launch
- runtime macros/matchit.vim " Add '%' matching to if/elsif/else/end
- "" Mutt settings
- " Support Format-Flowed in email (mutt).
- " Because it is a good-ness? http://joeclark.org/ffaq.html
- autocmd FileType mail setlocal fo+=aw tw=72
- "" vimdiff settings
- if &diff
- set cursorline
- map ] ]c
- map [ [c
- colorscheme slate
- endif
- "" Disable cache for pass
- autocmd VimEnter
- \ /dev/shm/pass.?*/?*.txt
- \,$TMPDIR/pass.?*/?*.txt
- \,/tmp/pass.?*/?*.txt
- \ set nobackup nowritebackup noswapfile noundofile
- "" auto resize slits on window resize
- autocmd VimResized * wincmd =
- "" auto detech csv files
- if exists("did_load_csvfiletype")
- finish
- endif
- let did_load_csvfiletype=1
- augroup filetypedetect
- au! BufRead,BufNewFile *.csv,*.dat setfiletype csv
- augroup END
- """ End Commands at Start """ }}}
- """ Plugins """ {{{
- if $USER != 'mobile'
- """ Setting up Vundle """ {{{
- "" From http://www.erikzaadi.com/2012/03/19/auto-installing-vundle-from-your-vimrc/
- let iCanHazVundle=1
- let vundle_readme=expand('~/.vim/bundle/Vundle.vim/README.md')
- if !filereadable(vundle_readme)
- echo "Installing Vundle.."
- echo ""
- silent !mkdir -p ~/.vim/bundle
- "" Disabled for git url
- silent !git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim
- let iCanHazVundle=0
- endif
- set rtp+=~/.vim/bundle/Vundle.vim/
- """""""call vundle#rc() ""commented out for vundle version bump change??
- call vundle#begin()
- "" Use git instead of http
- "let g:vundle_default_git_proto = 'git'
- "" Have vundle first...
- Plugin 'VundleVim/Vundle.vim'
- """ Bundles """ {{{
- ""Add your bundles here
- """ Style """ {{{
- Plugin 'altercation/vim-colors-solarized' " Solarized theme
- Plugin 'syntax-highlighting-for-tintinttpp' " Tintin++ syntax
- Plugin 'bling/vim-airline' " Even better than powerline/neatstatus
- Plugin 'nathanaelkane/vim-indent-guides' " vim-indent-guides default binding: <Leader>ig
- Plugin 'kien/rainbow_parentheses.vim' " Colorize parentheses and similar chars
- Plugin 'myusuf3/numbers.vim' " Make num ruler auto switch absolute/rel for insert/norm
- Plugin 'mhinz/vim-signify' " Add git diff
- Plugin 'mboughaba/i3config.vim' " i3 conf syntax
- """ End Style """ }}}
- """ Added Interface """ {{{
- Plugin 'scrooloose/nerdtree' " File browser
- Plugin 'bufexplorer.zip' " buffer browser
- Plugin 'sjl/gundo.vim' " Undo history tree
- "Plugin 'szw/vim-ctrlspace' " Super buffer controlness, disabled due to never using
- Plugin 'haya14busa/incsearch.vim' " Improved incremental searching
- Plugin 'spolu/dwm.vim' " dwm like split control
- Plugin 'will133/vim-dirdiff' " vimdiff dirs
- """ End Interface """ }}}
- """ Added Functionality """ {{{
- Plugin 'tpope/vim-repeat' " Makes '.' repeat work with plugins
- Plugin 'scrooloose/nerdcommenter' " Make commenting easy
- Plugin 'YankRing.vim' " Improves copy/paste
- Plugin 'tpope/vim-fugitive' " git from vim
- Plugin 'scrooloose/syntastic' " Code syntax checker
- "Plugin 'SearchComplete' " Disabled due to killing UP arrow in search
- Plugin 'Lokaltog/vim-easymotion' " <prefix><prefix>motion
- Plugin 'chrisbra/csv.vim' " Good CVS file handling
- Plugin 'dhruvasagar/vim-table-mode' " Make easy tables
- "Plugin 'vim-scripts/Smart-Tabs' " Use \t for indents, and spaces elsewhere
- Plugin 'jamessan/vim-gnupg' " Transparent editing of gpg encrypted files
- Plugin 'ConradIrwin/vim-bracketed-paste' " Auto set pastemode when a bracketed paste detected. https://cirw.in/blog/bracketed-paste
- """ End Functionality """ }}}
- """ Misc """ {{{
- Plugin 'uguu-org/vim-matrix-screensaver' " Add unnecessary matrix screen saver
- Plugin 'takac/vim-hardtime' " Plugin to break bad movement habits
- """ End Misc """ }}}
- ""...All your other bundles...
- """ End Bundles """ }}}
- call vundle#end() " required
- if iCanHazVundle == 0
- echo "Installing Bundles, please ignore key map error messages"
- echo ""
- :PluginInstall
- endif
- """ End Setting Up Vundle """ }}}
- """ Plugin Confs """ {{{
- """ NERDtree config """ {{{
- "" Starts NERDtree if no file is give to vim at start
- "autocmd vimenter * if !argc() | NERDTree | endif
- """ End NERDtree """ }}}
- """ Vim Repeat Conf """ {{{
- "" This is to make repeat work for plugins too
- silent! call repeat#set("\<Plug>MyWonderfulMap", v:count)
- """ End Vim Repeat """ }}}
- """ Better Rainbow Parentheses """ {{{
- "" https://github.com/kien/rainbow_parentheses.vim
- """ Auto Rainbow """ {{{
- au VimEnter * RainbowParenthesesToggle
- au Syntax * RainbowParenthesesLoadRound
- au Syntax * RainbowParenthesesLoadSquare
- au Syntax * RainbowParenthesesLoadBraces
- """ End Auto """ }}}
- nmap <leader>[ :RainbowParenthesesToggle <CR>
- """ End Rainbow Parenthesis """ }}}
- """ YankRing Conf """ {{{
- "" :h yankring-tutorial
- nnoremap <silent> <F3> :YRShow<CR>
- inoremap <silent> <F3> <ESC>:YRShow<CR>
- map <silent> <prefix>y :YRShow<CR>
- let g:yankring_history_dir = '~/.vim'
- """ End YankRing """ }}}
- """ Solarized Theme """ {{{
- "call togglebg#map("<F6>")
- if has('gui_running')
- set background=light
- colorscheme solarized
- endif
- """ End Solarized """ }}}
- """ Gundo Conf """ {{{
- "" http://sjl.bitbucket.org/gundo.vim/
- nnoremap <F4> :GundoToggle<CR>
- """ End Gundo """ }}}
- """ Numbers.vim Conf""" {{{
- "" https://github.com/myusuf3/numbers.vim
- nnoremap <leader>n :NumbersToggle<CR>
- """ End Nunmbers.vim """ }}}
- """ Vim Indent Guides """ {{{
- "" https://github.com/nathanaelkane/vim-indent-guides
- "" <Leader>ig
- let g:indent_guides_auto_colors = 0
- "autocmd VimEnter,Colorscheme * :hi IndentGuidesOdd guibg=red ctermbg=236
- autocmd VimEnter,Colorscheme * :hi IndentGuidesOdd guibg=red ctermbg=240
- autocmd VimEnter,Colorscheme * :hi IndentGuidesEven guibg=green ctermbg=244
- let g:indent_guides_enable_on_vim_startup = 1
- "let g:indent_guides_guide_size = 2
- let g:indent_guides_start_level = 2
- """ End Indent Guides """ }}}
- """ Airline Conf """ {{{
- "" Added to fix airline (forces status visibility)
- set laststatus=2
- "" Disable auto echo?
- let g:bufferline_echo = 0
- "" Remove default mode indicator
- set noshowmode
- "" Populate powerline symols
- let g:airline_powerline_fonts = 1
- """ End Airline Conf """ }}}
- """ Hardtime Conf """ {{{
- let g:hardtime_default_on = 0
- let g:hardtime_ignore_buffer_patterns = [ "CustomPatt[ae]rn", "NERD.*", "Task.*" ]
- nmap <leader>n :HardTimeToggle<CR>
- """ End Hardtime """ }}}
- """ Syntastic Conf """ {{{
- let g:syntastic_auto_loc_list=1
- """ End Syntastic """ }}}
- """ Vim-CtrlSpace Conf """ {{{
- "" https://github.com/szw/vim-ctrlspace
- "" Make work with airline
- let g:airline_exclude_preview = 1
- """ End Vim-CtrlSpace """ }}}
- """ Incsearch.vim Conf """ {{{
- "" https://github.com/haya14busa/incsearch.vim
- let g:incsearch#magic = '\v'
- map / <Plug>(incsearch-forward)
- map ? <Plug>(incsearch-backward)
- map g/ <Plug>(incsearch-stay)
- """ End Incsearch.vim """ }}}
- """ DWM.vim Conf """ {{{
- nnoremap <silent> <C-b> :call DWM_New()<CR>
- """ End DWM.vim Conf """ }}}
- """ End Plugin Confs """ }}}
- endif
- """ End Plugins """ }}}
- """ Theming """ {{{
- if has('gui_running')
- set background=light
- colorscheme solarized
- else
- colorscheme torte
- endif
- "" fix transparency
- hi! Normal ctermbg=NONE guibg=NONE
- """ End Theming """ }}}
- """ Options """ {{{
- """ Assorted """ {{{
- set autoread " Reload files changed outside vim
- set encoding=utf8 " Sets encoding View
- set scrolloff=3 " Show next three lines scrolling
- set sidescrolloff=2 " Show next two columns scrolling
- set ttyfast " Indicates a fast terminal connection
- set splitbelow " New horizontal splits are below
- set splitright " New vertical splits are to the right
- set history=1000 " Increase command/search history
- set confirm " Vim prompts for :q/:qa/:w issues
- """ End Assorted """ }}}
- """ HUD """ {{{
- set number " Adds line numbers
- set showcmd " Show incomplete cmds down the bottom
- "" Disabled for air-line
- "set showmode " Shows input or replace mode at bottom
- set ruler " Show position in bottom right
- """ End HUD """ }}}
- """ Input """ {{{
- set virtualedit=block,onemore " Cursor can move one past EOL, and free in Visual mode
- " set virtualedit=all " Allow virtual editing, all modes.
- set mouse=a " Enable mouse, all modes
- set backspace=indent,eol,start " Allow backspace in insert mode
- """ End Input """ }}}
- """ Mac kill damn bold """ {{{
- if has('mac')
- set t_Co=256 " FORCE 256 colors in vim
- endif
- """ End Mac """ }}}
- """ Wild Stuffs... """ {{{
- set wildmenu " Show list instead of just completing
- set wildmode=list:longest,full " Command <Tab> completion, list matches, then longest common part, then all.
- "" From http://blog.sanctum.geek.nz/lazier-tab-completion/
- if exists("&wildignorecase")
- set wildignorecase " Ignore case in file name completion
- endif
- "" From http://bitbucket.org/sjl/dotfiles/overview
- set wildignore+=.hg,.git,.svn " Version control
- set wildignore+=*.aux,*.out,*.toc " LaTeX intermediate files
- set wildignore+=*.jpg,*.bmp,*.gif,*.png,*.jpeg " binary images
- set wildignore+=*.o,*.obj,*.exe,*.dll,*.manifest " compiled object files
- set wildignore+=*.spl " compiled spelling word lists
- set wildignore+=*.sw? " Vim swap files
- set wildignore+=*.DS_Store " OSX bullshit
- set wildignore+=*.luac " Lua byte code
- set wildignore+=migrations " Django migrations
- set wildignore+=*.pyc " Python byte code
- set wildignore+=*.orig " Merge resolution files
- "" Clojure/Leiningen
- set wildignore+=classes
- set wildignore+=lib
- """ End Wild """ }}}
- """ Show Hidden Chars """ {{{
- set list " Shows certain hidden chars
- set listchars=eol:¬,tab:▶-,trail:~,extends:>,precedes:<,nbsp:·
- hi NonText ctermfg=darkgray " Makes trailing darkgray
- hi SpecialKey ctermfg=darkgray " Makes Leading darkgray
- """ End Hidden Chars """ }}}
- """ Spelling """ {{{
- set spell " Spelling hilight on
- " highlight SpellBad cterm=underline ctermfg=red
- hi SpellBad cterm=underline ctermbg=NONE
- hi SpellCap cterm=underline ctermbg=NONE
- """ End Spelling """ }}}
- """ Tab Windows """ {{{
- set hidden " Hides buffers, instead of closing, or forcing save
- set showtabline=2 " shows the tab bar at all times
- set tabpagemax=100 " max num of tabs to open on startup
- hi TabLineSel ctermbg=Yellow " Current Tab
- hi TabLine ctermfg=Grey ctermbg=DarkGrey " Other Tabs
- hi TabLineFill ctermfg=Black " Rest of line
- hi Title ctermfg=DarkBlue ctermbg=None " Windows in Tab
- """ End Tab Windows """ }}}
- """ Tab Key Settings """ {{{
- "" prefer tabs now...
- set expandtab "" use spaces, not tabs
- set tabstop=4 " Set Tab length
- set shiftwidth=4 " Affects when you press >>, << or ==. And auto indent.
- set shiftround " Uses multiple of shiftwidth when indenting with '<' and '>'
- set softtabstop=4 " With space indenting, lets vim delete multiple spaces at once
- "" disabled per https://stackoverflow.com/questions/234564/tab-key-4-spaces-and-auto-indent-after-curly-braces-in-vim
- " set smarttab " Insert Tabs at ^ per shiftwidth, not tabstop
- set autoindent " Always set auto indenting on
- set copyindent " Copy prior indentation on autoindent
- """ End Tab Key """ }}}
- """ Searching """ {{{
- " Use real regex search
- nnoremap / /\v
- vnoremap / /\vi
- set hlsearch " Highlight matches
- set incsearch " Incremental searching
- set ignorecase " Searches are case insensitive...
- "" Disabled as was annoying with command completion
- "set smartcase " ...unless contains oneplus Cap letter
- set showmatch " Show matching brackets/parenthesis
- set gdefault " Applies substitutions globally on lines. Append 'g' to invert back.
- set synmaxcol=800 " Don't highlight lines longer than 800 chars
- set wrapscan " Scan wraps around the file
- """ End Searching """ }}}
- """ Backup Settings """ {{{
- """ Dir Validation """ {{{
- if !isdirectory(expand("~/.vim/back/"))
- call mkdir(expand("~/.vim/back/"), "p")
- endif
- if !isdirectory(expand("~/.vim/swap/"))
- call mkdir(expand("~/.vim/swap/"), "p")
- endif
- if !isdirectory(expand("~/.vim/undo/"))
- call mkdir(expand("~/.vim/undo/"), "p")
- endif
- """ End Dir """ }}}
- set backup " Enable backups
- set undofile " Enable undo file
- set undoreload=10000
- set backupdir=~/.vim/back// " back files, // for full path
- set directory=~/.vim/swap// " swap files, // for full path
- set undodir=~/.vim/undo// " undo files, // for full path
- """ End Backup Settings """ }}}
- """ Timeout Settings """ {{{
- set timeout " :mapping time out
- set timeoutlen=1000 " :mapping time out length
- set ttimeout " Key code time out
- set ttimeoutlen=50 " key code time out length
- """ End Timeout """ }}}
- """ End Options """ }}}
- """ Aliases """ {{{
- command! BI BundleInstall
- """ End Aliases """ }}}
- """ Functions """ {{{
- """ DiffSaved """ {{{
- "" To compare current vs saved version
- "" http://vim.wikia.com/wiki/Diff_current_buffer_and_the_original_file
- "" To get out of diff view you can use the :diffoff command.
- function! s:DiffWithSaved()
- let filetype=&ft
- diffthis
- vnew | r # | normal! 1Gdd
- diffthis
- exe "setlocal bt=nofile bh=wipe nobl noswf ro ft=" . filetype
- endfunction
- com! DiffSaved call s:DiffWithSaved()
- """End DiffSaved """ }}}
- """ HighlightRepeats """ {{{
- "" from https://stackoverflow.com/questions/1268032/how-can-i-mark-highlight-duplicate-lines-in-vi-editor
- function! HighlightRepeats() range
- let lineCounts = {}
- let lineNum = a:firstline
- while lineNum <= a:lastline
- let lineText = getline(lineNum)
- if lineText != ""
- let lineCounts[lineText] = (has_key(lineCounts, lineText) ? lineCounts[lineText] : 0) + 1
- endif
- let lineNum = lineNum + 1
- endwhile
- exe 'syn clear Repeat'
- for lineText in keys(lineCounts)
- if lineCounts[lineText] >= 2
- exe 'syn match Repeat "^' . escape(lineText, '".\^$*[]') . '$"'
- endif
- endfor
- endfunction
- command! -range=% HighlightRepeats <line1>,<line2>call HighlightRepeats()<F29>
- """ End HighlightRepeats """ }}}
- """ End Functions """ }}}
- """ Key Bindings """ {{{
- let mapleader="," " Change the mapleader from '\' to ','
- map <leader>/ :noh<return> " <leader>/ will clear search hilights!
- """ Quickly edit/reload the vimrc file """ {{{
- "" maps the ,ev and ,sv keys to edit/reload .vimrc.
- nmap <silent> <leader>ev :tabedit $MYVIMRC<CR>
- nmap <silent> <leader>sv :so $MYVIMRC<CR>
- """ End reload """ }}}
- """ Paste Toggle, for stopping formating of pastes """ {{{
- nnoremap <F2> :set invpaste paste?<CR>
- set pastetoggle=<F2>
- nmap <leader>p :set invpaste paste?<CR>
- """ End Paste Toggle """ }}}
- """ Vim Tab Window Keysbindings """ {{{
- " nnoremap <C-Left> :tabprevious<CR>
- " nnoremap <C-Right> :tabnext<CR>
- " nnoremap <silent> <A-Left> :execute 'silent! tabmove ' . (tabpagenr()-2)<CR>
- " nnoremap <silent> <A-Right> :execute 'silent! tabmove ' . tabpagenr()<CR>
- """ End Tab Window Keys """ }}}
- """ Navigate Splits """ {{{
- "" uses ',' key first
- map <leader>h :wincmd h<CR>
- map <leader>j :wincmd j<CR>
- map <leader>k :wincmd k<CR>
- map <leader>l :wincmd l<CR>
- map <leader> <Left> :wincmd h<CR>
- map <leader> <Down> :wincmd j<CR>
- map <leader> <Up> :wincmd k<CR>
- map <leader> <Right> :wincmd l<CR>
- """ End Navigate Splits """ }}}
- """ Toggle colorcolumn """ {{{
- highlight ColorColumn ctermbg=Brown
- function! g:ToggleColorColumn()
- if &colorcolumn != ''
- setlocal colorcolumn&
- else
- setlocal colorcolumn=77
- endif
- endfunction
- nnoremap <silent> <leader>L :call g:ToggleColorColumn()<CR>
- """ End Toggle colorcolumn """ }}}
- """ Cross Hairs """ {{{
- hi CursorLine cterm=NONE ctermbg=brown ctermfg=white guibg=darkred guifg=white
- hi CursorColumn cterm=NONE ctermbg=brown ctermfg=white guibg=darkred guifg=white
- nnoremap <Leader>+ :set cursorline! cursorcolumn!<CR>
- """ End Cross Hair """ }}}
- """ DiffOrig """ {{{
- "command DiffOrig let g:diffline = line('.') | vert new | set bt=nofile | r # | 0d_ | diffthis | :exe "norm! ".g:diffline."G" | wincmd p | diffthis | wincmd p
- command! DiffOrig let g:diffline = line('.') | vert new | set bt=nofile | r # | 0d_ | diffthis | :exe 'norm! '.g:diffline.'G' | wincmd p | diffthis | wincmd p
- nnoremap <Leader>do :DiffOrig<cr>
- nnoremap <leader>dc :q<cr>:diffoff<cr>:exe "norm! ".g:diffline."G"<cr>
- """ End DiffOrig """ }}}
- """ Sudo Save Edit """ {{{
- "" Use :W to sudo save, may mess with permissions
- command! WW w !sudo tee % > /dev/null
- """ End Sudo Save """ }}}
- """ Typo Commands """ {{{
- "" http://blog.sanctum.geek.nz/vim-command-typos/
- if has("user_commands")
- command! -bang -nargs=? -complete=file E e<bang> <args>
- command! -bang -nargs=? -complete=file W w<bang> <args>
- command! -bang -nargs=? -complete=file Wq wq<bang> <args>
- command! -bang -nargs=? -complete=file WQ wq<bang> <args>
- command! -bang Wa wa<bang>
- command! -bang WA wa<bang>
- command! -bang Q q<bang>
- command! -bang QA qa<bang>
- command! -bang Qa qa<bang>
- endif
- """ End Typo """ }}}
- """ End Key Bindings """ }}}
- """ Notes To Self """ {{{
- "" Consider:
- " set foldopen=
- """ End Notes """ }}}
|