1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 | " {{{
" Maintainer: Johannes Steudle
" .vimrc
" for Unix and macOS: ~/.vimrc
" }}}
" Use Vim defaults (much better!)
set nocompatible
syntax on
" Shell {{{
if $SHELL =~ 'bin/fish'
set shell=/bin/sh
endif
" }}}
set hidden " Allow switching edited buffers without saving
set title " Show filename
" Layout {{{
set cmdheight=2 " Make command line two lines high
set laststatus=2 " Always show status line, even for one window
set termencoding=utf-8
set encoding=utf-8 " Use UTF-8 as the default buffer encoding
" }}}
" Indentation {{{
set autoindent " copy indent from current line
set smartindent " Set indention
set shiftround " shift to nearest indent
" }}}
" Behavior {{{
set autoread " read open files again when changed outside Vim
set ttyfast " Improves redrawing on newer computers
set switchbuf=useopen " reveal already opened files from the
" quickfix window instead of opening new
" buffers
set nostartofline " Keep cursor in current column when using page commands
set autochdir " automatically set current directory to directory of last opened file
set visualbell " Set visual bell instead of acustic
set mouse=a " enable the use of the mouse
set number relativenumber " hybrid relative numbers
set matchtime=4 " Jump to matching bracket for n/10 seconds
set nospell
set nojoinspaces " Insert only one space when joining lines
set magic " Use magic escaping
set completeopt=menu,menuone,longest,preview " Insert mode completion options
set backspace=indent,eol,start
" }}}
" Show some invisible characters {{{
set listchars=tab:▸\ ,trail:·,extends:#,nbsp:·
set nolist
" }}}
" Tab settings {{{
set tabstop=4 " Tab size
set shiftwidth=4 " Shift width
set softtabstop=4
set expandtab " Tabs to spaces
set smarttab
" }}}
" Handle long lines {{{
set wrap
set textwidth=79
set formatoptions=qrn1
set colorcolumn=85
set linebreak
set display+=lastline
" }}}
" Search {{{ See http://stevelosh.com/blog/2010/09/coming-home-to-vim/
set hlsearch " Highlight search
set incsearch " incremental searching
set ignorecase smartcase " Case-insensitive searching
set showmatch " When a bracket is inserted, briefly jump to a matching one
nnoremap <tab> %
vnoremap <tab> %
" }}}
" Wildmenu {{{
set wildmenu " Use menu to show command-line completion (in 'full' case)
set wildmode=list:longest,full " set command-line completion mode:
" - on first <Tab>, when more than one match, list all matches and complete the longest common string
" - on second <Tab>, complete the next full match and show menu
" Ignore these filenames during enhanced command line completion.
set wildignore+=*/.idea/*,*/.project/* " ignore IDE project files
set wildignore+=*/.git/*,*/.hg/*,*/.svn/* " ignore version control files
set wildignore+=*.aux,*.out,*.toc " LaTeX intermediate files
set wildignore+=*.jpg,*.bmp,*.gif " binary images
set wildignore+=*.luac " Lua byte code
set wildignore+=*.o,*.obj,*.exe,*.dll,*.manifest,*.so,*.zip " compiled object files
set wildignore+=*.pyc " Python byte code
set wildignore+=*.spl " compiled spelling word lists
set wildignore+=*.sw? " Vim swap files
set wildignore+=.DS_Store " Mac files
set wildignore+=*/tmp/* " MacOSX/Linux
set wildignore+=*\\tmp\\* " Windows
" }}}
" Python {{{
let g:python_host_prog = '/usr/local/bin/python'
let g:python3_host_prog = '/usr/local/bin/python3'
" Temporary workaround for python 3.7: https://github.com/vim/vim/issues/3117#issuecomment-402622616
if has('python3')
silent! python3 1
endif
" }}}
" PlugIn-Configuration {{{
call plug#begin('$HOME/.vim/plugged')
" Motion
Plug 'chaoren/vim-wordmotion'
" Plugins for handling various formats
Plug 'plasticboy/vim-markdown', { 'for': 'markdown' }
Plug 'itspriddle/vim-marked', { 'for': 'markdown' }
" git plugins
Plug 'tpope/vim-fugitive'
Plug 'airblade/vim-gitgutter'
" syntax checker for vim
Plug 'w0rp/ale'
" syntax plugins
Plug 'keith/swift.vim'
Plug 'b4winckler/vim-objc'
Plug 'darfink/vim-plist'
Plug 'aliva/vim-fish'
Plug 'mileszs/ack.vim'
Plug 'vim-python/python-syntax'
Plug 'aklt/plantuml-syntax'
Plug 'vim-scripts/Rainbow-Parenthsis-Bundle'
Plug 'vim-scripts/confluencewiki.vim'
" Add global syntax formatting config capability
Plug 'editorconfig/editorconfig-vim'
" Auto formatting various files
Plug 'sbdchd/neoformat'
" Add Theme
Plug 'altercation/vim-colors-solarized'
Plug 'ryanoasis/vim-devicons'
Plug 'sonph/onehalf', { 'rtp': 'vim/' }
Plug 'ErichDonGubler/vim-sublime-monokai'
" Buffer manager
Plug 'jeetsukumaran/vim-buffergator'
Plug 'vim-scripts/YankRing.vim'
" Nice status bar
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
" Completion plugins
Plug 'Rip-Rip/clang_complete'
Plug 'ervandew/supertab'
Plug 'prabirshrestha/asyncomplete.vim'
Plug 'prabirshrestha/asyncomplete-buffer.vim'
Plug 'Raimondi/delimitMate'
Plug 'Valloric/YouCompleteMe'
" Region expanding
Plug 'terryma/vim-expand-region'
Plug 'terryma/vim-multiple-cursors'
Plug 'tpope/vim-surround'
" Use the fancy silver searcher
Plug 'rking/ag.vim'
" Nice filetree
Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' }
Plug 'Xuyuanp/nerdtree-git-plugin', { 'on': 'NERDTreeToggle' }
" Little file manager
Plug 'ctrlpvim/ctrlp.vim'
Plug 'tpope/vim-eunuch'
" Own plugins
Plug 'tweetjay/tweetjay-theme'
Plug 'tweetjay/vim-backstate'
" Fancy starting screen
Plug 'mhinz/vim-startify'
call plug#end()
" }}}
" Colorscheme {{{
if has('gui_running')
set background=dark
colorscheme onehalfdark
elseif &t_Co < 256
colorscheme default
set nocursorline " looks bad in this mode
else
set background=dark
let g:solarized_termcolors=256 " instead of 16 color with mapping in terminal
colorscheme solarized
" customized colors
highlight SignColumn ctermbg=234
highlight StatusLine cterm=bold ctermfg=245 ctermbg=235
highlight StatusLineNC cterm=bold ctermfg=245 ctermbg=235
highlight SpellBad cterm=underline
endif
" highlight current line, but only in active window
augroup CursorLineOnlyInActiveWindow
autocmd!
autocmd VimEnter,WinEnter,BufWinEnter * setlocal cursorline
autocmd WinLeave * setlocal nocursorline
augroup END
" }}}
" Configure CTRL-P {{{
let g:ctrlp_custom_ignore = {
\ 'dir': '\v[\/]\.(git|hg|svn)$',
\ 'file': '\v\.(exe|so|dll)$',
\ 'link': 'some_bad_symbolic_links',
\ }
" }}}
" Configure Syntastic {{{
if has('syntastic')
set statusline+=%#warningmsg#
set statusline+=%{SyntasticStatuslineFlag()}
set statusline+=%*
let g:syntastic_always_populate_loc_list = 1
let g:syntastic_auto_loc_list = 1
let g:syntastic_check_on_open = 1
let g:syntastic_check_on_wq = 0
let g:syntastic_swift_swiftlint_use_defaults = 1
let g:syntastic_swift_checkers = ['swiftpm', 'swiftlint']
endif
" }}}
" StatusLine {{{ configure airline status bar
let g:airline#extensions#tabline#enabled = 1
let g:airline_powerline_fonts = 1
let g:airline_theme='onehalfdark'
" let g:airline_solarized_bg='dark'
" }}}
" Configure markdown {{{
" let g:vim_markdown_folding_level = 6
let g:vim_markdown_folding_disabled = 1
let g:vim_markdown_new_list_item_indent = 2
let g:markdown_fenced_languages = [
\ 'bash=sh',
\ 'c',
\ 'javascript',
\ 'json',
\ 'python',
\ 'ruby',
\ 'yaml',
\ 'swift',
\ 'objc'
\]
" }}}
" SuperTab {{{ option for context aware completion
let g:SuperTabDefaultCompletionType = "context"
" }}}
" Clang autocomplete {{{
" Disable auto popup, use <Tab> to autocomplete
let g:clang_complete_auto = 0
" Show clang errors in the quickfix window
let g:clang_complete_copen = 1
au CursorMovedI,InsertLeave * if pumvisible() == 0|silent! pclose|endif
" }}}
" Key mappings {{{
let mapleader = "\<Space>" " Change <Leader>
" let maplocalleader = "," " Change <LocalLeader>
" Disable arrow keys
nnoremap <up> <nop>
nnoremap <down> <nop>
nnoremap <left> <nop>
nnoremap <right> <nop>
inoremap <up> <nop>
inoremap <down> <nop>
inoremap <left> <nop>
inoremap <right> <nop>
nnoremap j gj
nnoremap k gk
" Better window navigation
nnoremap <C-j> <C-w>j
nnoremap <C-k> <C-w>k
nnoremap <C-h> <C-w>h
nnoremap <C-l> <C-w>l
inoremap <F1> <ESC>
nnoremap <F1> <ESC>
vnoremap <F1> <ESC>
" Use jj to escape
inoremap jj <ESC>
nnoremap <Leader>o :CtrlP<CR>
" Copy & paste to system clipboard with <Space>p and <Space>y
vmap <Leader>y "+y
" vmap <Leader>d "+d
nmap <Leader>p "+p
nmap <Leader>P "+P
vmap <Leader>p "+p
vmap <Leader>P "+P
" Enter visual line mode with <Space><Space>:
nmap <Leader><Leader> V
" Hit v to select one character
" Hit v again to expand selection to word
" Hit v again to expand to paragraph
vmap v <Plug>(expand_region_expand)
vmap <C-v> <Plug>(expand_region_shrink)
" Automatically jump to end of text you pasted
vnoremap <silent> y y`]
vnoremap <silent> p p`]
nnoremap <silent> p p`]
" Remove all highlightings
nnoremap <silent><ESC><ESC> :nohl<CR>
" quickly insert newline in normalmode without leaving
nnoremap <silent><A-o> o<Esc>k
nnoremap <silent><A-S-o> O<Esc>j
" map ,f to display all lines with keyword under cursor and ask which one to jump to
nnoremap <leader>f [I:let nr = input("Which one: ")<Bar>exe "normal " . nr ."[\t"<CR>
map <F3> :NERDTreeToggle<CR>
" }}}
" Special filetypes and encoding {{{
if has('autocmd')
"autocmd BufEnter * cd %:p:h
filetype plugin indent on
endif
" }}}
" Encoding {{{
" Always check for UTF-8 when trying to determine encodings
if &fileencodings !~? "utf-8"
set fileencodings+=utf-8
endif
" Make sure we have a sane fallback for encoding detection
set fileencodings+=default
" }}}
" Load local vim config {{{
let $LOCALFILE=expand("~/.vimrc_local")
if filereadable($LOCALFILE)
source $LOCALFILE
endif
" }}}
|
x