mirror of
https://github.com/tomru/DotfilesOld.git
synced 2026-03-03 06:27:21 +01:00
335 lines
8.8 KiB
VimL
335 lines
8.8 KiB
VimL
" vim: set fenc=utf-8 nu et sts=4 sw=4 ft=vim fdm=marker fmr={{{,}}}:
|
||
" file: ~/.vimrc
|
||
" author: Thomas Ruoff (with the help of a myriad others)
|
||
|
||
scriptencoding utf-8
|
||
|
||
" Plugins {{{
|
||
call plug#begin('~/.vim/plugged')
|
||
|
||
Plug 'tpope/vim-sensible'
|
||
|
||
Plug 'L9'
|
||
Plug 'unimpaired.vim'
|
||
Plug 'surround.vim'
|
||
Plug 'Align'
|
||
Plug 'Raimondi/delimitMate'
|
||
|
||
Plug 'editorconfig/editorconfig-vim'
|
||
|
||
Plug 'Valloric/YouCompleteMe', { 'do': './install.sh --tern-completer' }
|
||
|
||
Plug 'ludovicchabant/vim-gutentags'
|
||
|
||
Plug 'nathanaelkane/vim-indent-guides'
|
||
|
||
Plug 'SirVer/ultisnips'
|
||
Plug 'honza/vim-snippets'
|
||
|
||
Plug 'w0rp/ale'
|
||
|
||
Plug 'tpope/vim-fugitive'
|
||
Plug 'rhysd/conflict-marker.vim'
|
||
Plug 'airblade/vim-gitgutter'
|
||
|
||
Plug 'inside/vim-search-pulse'
|
||
|
||
Plug 'itchyny/lightline.vim'
|
||
|
||
Plug 'chriskempson/base16-vim'
|
||
|
||
Plug 'pangloss/vim-javascript'
|
||
Plug 'marijnh/tern_for_vim', { 'do': 'npm install' }
|
||
Plug 'mxw/vim-jsx'
|
||
|
||
Plug 'suan/vim-instant-markdown', { 'for': 'markdown' }
|
||
Plug 'xuhdev/vim-latex-live-preview', { 'for': 'tex' }
|
||
|
||
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
|
||
Plug 'junegunn/fzf.vim'
|
||
|
||
Plug 'sheerun/vim-polyglot'
|
||
|
||
call plug#end()
|
||
" }}}
|
||
|
||
" Basics {{{
|
||
set encoding=utf-8
|
||
set nocompatible " choose no compatibility with legacy vi
|
||
filetype plugin indent on " Load filetype plugin/indent files.
|
||
syntax on " Enable syntax highlighting.
|
||
set hidden
|
||
set ttyfast
|
||
set synmaxcol=512 " Limit syntax highlighting to 512 characters per line
|
||
set modeline " Use file-specific settings, if available.
|
||
set nobackup " Make backup files.
|
||
set noswapfile
|
||
set mouse=a " Mouse support everywhere.
|
||
set mousehide " Auto-hide cursor while typing.
|
||
set wildmode=list:longest,full " Make completion more like zsh.
|
||
set wildmenu " Turn on command-line completion wild style.
|
||
set wildignore+=*.swp,*.bak,*.jpg,*.gif,*.png,*.git,
|
||
set ignorecase " Ignore case, except...
|
||
set smartcase " ...when search string contains uppercase.
|
||
set incsearch " Highlight as you type search phrase.
|
||
set hlsearch
|
||
set number " Show line numbers.
|
||
set report=0 " Tell me when anything is changed via :...
|
||
set ruler " Show current positions along bottom.
|
||
set scrolloff=5 " Keep 5 lines (top/bottom) for scope.
|
||
set showcmd " Show command being typed.
|
||
set showmatch " Show matching brackets.
|
||
set spell " Highlight misspelled words.
|
||
set spellcapcheck= " Don't highlight uncapitalized first word.
|
||
set complete+=kspell " Use <C-n> and <C-p> to get suggested spelling completions.
|
||
set splitright " Split to the right when executing :vsplit.
|
||
let g:netrw_liststyle=3 " Use tree style directory listing.
|
||
set background=dark
|
||
set path+=**
|
||
|
||
set clipboard=unnamed
|
||
|
||
" }}}
|
||
|
||
" Local .vimrc {{{
|
||
set exrc " Enable use of directory-specific .vimrc
|
||
set secure " Only run autocommands owned by me
|
||
" }}}
|
||
|
||
" Text Formatting {{{
|
||
set list " Show real tabs (so they can be removed).
|
||
set listchars=tab:▸\ ,extends:❯,precedes:❮,nbsp:␣,trail:-
|
||
set linebreak " Don't soft-wrap in the middle of a word.
|
||
set showbreak=↳ " Show `…' at the beginning of a soft-broken line.
|
||
set tabstop=4 " Real tabs are 4 columns long.
|
||
set expandtab " No real tabs (use spaces for tabs).
|
||
set softtabstop=4 " Set # of spaces when hitting tab/delete.
|
||
set shiftwidth=4 " Set # of softtabs when using cindent, <<, >>, ...
|
||
set textwidth=80 " Set max # of characters on each line.
|
||
set autoindent " Use indentation level of previous line.
|
||
set nojoinspaces " Don't add extra space after ., !, etc. when joining.
|
||
set formatoptions+=j " Delete comment character when joining commented lines.
|
||
" }}}
|
||
|
||
" Folding {{{
|
||
set foldmethod=indent
|
||
set foldlevelstart=10
|
||
" }}}
|
||
|
||
" Diff settings {{{
|
||
set fillchars+=diff:⣿
|
||
set diffopt=vertical " Use in vertical diff mode
|
||
set diffopt+=filler " blank lines to keep sides aligned
|
||
set diffopt+=iwhite " Ignore whitespace changes
|
||
" }}}
|
||
|
||
" {{{ Undo
|
||
set undodir=~/.vim/undos
|
||
set undofile
|
||
set undolevels=1000
|
||
set undoreload=10000
|
||
" }}}
|
||
|
||
" Visual Setting {{{
|
||
set cursorline
|
||
let base16colorspace=256
|
||
colorscheme base16-solarized-dark
|
||
|
||
set number
|
||
if exists('+relativenumber')
|
||
set relativenumber
|
||
endif
|
||
" }}}
|
||
|
||
" GUI Settings {{{
|
||
if has("gui_running")
|
||
"disable menu, toolsbar, scrollbar
|
||
set guioptions -=m
|
||
set guioptions -=T
|
||
set guioptions -=r
|
||
endif
|
||
" }}}
|
||
|
||
" Key mappings {{{
|
||
|
||
let mapleader=','
|
||
let maplocalleader=','
|
||
set timeoutlen=400
|
||
|
||
"" fast escaping
|
||
inoremap jj <ESC>
|
||
|
||
"" fast editing
|
||
nnoremap <leader>e :e<space>
|
||
|
||
"" fast saving
|
||
nnoremap <leader>w :update<cr>
|
||
|
||
"" clear highlight
|
||
nnoremap <leader><space> :noh<cr>
|
||
|
||
"" fast window switching
|
||
noremap <leader>, <C-W>w
|
||
|
||
"" open next,prev buffer, cycle
|
||
noremap <leader>. :bn<cr>
|
||
noremap <leader>m :bp<cr>
|
||
noremap <leader>: :b#<cr>
|
||
|
||
"" delete buffer
|
||
noremap <leader>bd :bd<cr>
|
||
|
||
"" indent visual selected code without unselecting and going back to normal mode
|
||
vnoremap > >gv
|
||
vnoremap < <gv
|
||
|
||
"" allow using . with visual mode
|
||
vnoremap . :norm.<cr>
|
||
|
||
"" Visually select the text that was last edited/pasted
|
||
nnoremap gV `[v`]
|
||
|
||
"" pull word under cursor into lhs of a substitute (for quick search and replace)
|
||
nnoremap <leader>r :%s#\<<C-r>=expand("<cword>")<CR>\>#
|
||
|
||
"" fast editing of the .vimrc
|
||
nnoremap <silent> <leader>ev :e $MYVIMRC<cr>
|
||
|
||
"" turn on spell checking
|
||
noremap <leader>spl :setlocal spell!<cr>
|
||
"" spell checking shortcuts
|
||
noremap <leader>sn ]s
|
||
noremap <leader>sp [s
|
||
noremap <leader>sa zg
|
||
noremap <leader>s? z=
|
||
|
||
"" toggle states
|
||
nnoremap <silent> <leader>hh :set invhlsearch<CR>
|
||
nnoremap <silent> <leader>ll :set invlist<CR>
|
||
nnoremap <silent> <leader>pp :set invpaste<CR>
|
||
|
||
nnoremap <silent> <leader>nn :set invnumber<CR>
|
||
nnoremap <silent> <leader>ii :set invrelativenumber<CR>
|
||
|
||
"" <Leader>0: Run the visually selected code in node and replace it with the output
|
||
vnoremap <silent> <Leader>0 :!node<cr>
|
||
|
||
" debugging, use leader-DD to start, do a slow action, then leader-DQ to
|
||
" finish. Your output will be in profile.log
|
||
nnoremap <silent> <leader>DD :exe ":profile start profile.log"<cr>:exe ":profile func *"<cr>:exe ":profile file *"<cr>
|
||
nnoremap <silent> <leader>DQ :exe ":profile pause"<cr>:noautocmd qall!<cr>
|
||
|
||
"" abbreviations
|
||
cnoreabbrev W! w!
|
||
cnoreabbrev Q! q!
|
||
cnoreabbrev Qall! qall!
|
||
cnoreabbrev Wq wq
|
||
cnoreabbrev Wa wa
|
||
cnoreabbrev wQ wq
|
||
cnoreabbrev WQ wq
|
||
cnoreabbrev W w
|
||
cnoreabbrev Q q
|
||
cnoreabbrev Qall qall
|
||
|
||
iab xnow <c-r>=strftime("%Y-%m-%d %H:%M")<cr>
|
||
" }}}
|
||
|
||
" Plugin Configuration {{{
|
||
|
||
"" youcompleteme
|
||
let g:ycm_autoclose_preview_window_after_insertion = 1
|
||
|
||
"" gutentags
|
||
|
||
let g:gutentags_cache_dir="~/.tags"
|
||
let g:gutentags_file_list_command = {
|
||
\ 'markers': {
|
||
\ '.git': 'git ls-files',
|
||
\ '.hg': 'hg files',
|
||
\ },
|
||
\ }
|
||
|
||
"" fzf
|
||
nnoremap <leader>fb :Buffers<cr>
|
||
nnoremap <leader>ff :GFiles<cr>
|
||
nnoremap <leader>FF :Files<cr>
|
||
vnoremap <leader>ff y:Files <c-r>"<cr>
|
||
nnoremap <leader>fa :Ag<space>
|
||
vnoremap <leader>fa y:Ag <c-r>"<cr>
|
||
nnoremap <leader>FA :Ag <c-r><c-w><cr>
|
||
nnoremap <leader>fc :Commits<cr>
|
||
|
||
"" minibufexpl
|
||
map <Leader>t :MBEToggle<cr>
|
||
|
||
"" ale
|
||
nmap <silent> <C-k> <Plug>(ale_previous_wrap)
|
||
nmap <silent> <C-j> <Plug>(ale_next_wrap)
|
||
|
||
"" lightline
|
||
if filereadable(expand("~/.vim/lightline.vim"))
|
||
source ~/.vim/lightline.vim
|
||
augroup ale-statusline
|
||
autocmd!
|
||
autocmd User ALELint call lightline#update()
|
||
augroup END
|
||
endif
|
||
|
||
"" Unimpaired
|
||
"" bubble single lines
|
||
nnoremap <leader>k [e
|
||
nnoremap <leader>j ]e
|
||
"" bubble multiple lines
|
||
vnoremap <leader>k [egv
|
||
vnoremap <leader>j ]egv
|
||
|
||
"" Indent Guides
|
||
nnoremap <leader>g :IndentGuidesToggle<CR>
|
||
|
||
"" Ultisnips
|
||
let g:UltiSnipsExpandTrigger="<c-j>"
|
||
let g:UltiSnipsJumpForwardTrigger="<c-j>"
|
||
let g:UltiSnipsJumpBackwardTrigger="<c-k>"
|
||
|
||
|
||
" Tex
|
||
let g:tex_flavor = "latex"
|
||
let g:livepreview_previewer = 'zathura'
|
||
|
||
" markdown
|
||
let g:markdown_fenced_languages = [
|
||
\ 'html',
|
||
\ 'javascript', 'js=javascript', 'json=javascript'
|
||
\ ]
|
||
" }}}
|
||
|
||
" Autocmd Rules {{{
|
||
|
||
"" do syntax highlight syncing from start
|
||
augroup general
|
||
autocmd!
|
||
autocmd BufEnter * :syntax sync fromstart
|
||
augroup END
|
||
|
||
"" txt, mail, tex
|
||
augroup text
|
||
autocmd!
|
||
autocmd FileType text,markdown,mail,tex set wrap wm=2 textwidth=78 nocindent spell
|
||
augroup END
|
||
|
||
"" Python
|
||
augroup python
|
||
autocmd FileType python set noexpandtab
|
||
augroup END
|
||
|
||
"" JavaScript
|
||
augroup web
|
||
autocmd!
|
||
autocmd FileType javascript map <leader>r <esc>:TernRename<CR>
|
||
autocmd BufRead,BufNewFile *.json set ft=json
|
||
autocmd BufRead,BufNewFile *.template set filetype=html.mustache syntax=mustache
|
||
augroup END
|
||
|
||
" }}}
|
||
|