From c911f34027353f243cdaf75031545abaab932a52 Mon Sep 17 00:00:00 2001 From: Steffen Rademacker Date: Tue, 5 May 2015 13:18:25 +0200 Subject: [PATCH] Split up vimrc in separate files With default configs and configs for plugins. Wrap autocommands in a vimrc group as well. --- vim/config/autocommands.vim | 32 ++ vim/config/bundles.vim | 47 +++ vim/config/colorscheme.vim | 26 ++ vim/config/defaultconfig.vim | 38 ++ vim/config/functions.vim | 10 + vim/config/gui.vim | 10 + vim/config/keymappings.vim | 64 ++++ vim/config/leaderkeys.vim | 34 ++ vim/config/plugins/fugitive.vim | 7 + vim/config/plugins/incsearch.vim | 15 + vim/config/plugins/lightline.vim | 62 +++ vim/config/plugins/neocomplete.vim | 23 ++ vim/config/plugins/neosnippet.vim | 18 + vim/config/plugins/sneak.vim | 10 + vim/config/plugins/syntastic.vim | 15 + vim/config/plugins/tabularize.vim | 7 + vim/config/plugins/tcomment.vim | 6 + vim/config/plugins/unite.vim | 51 +++ vim/config/plugins/wildfire.vim | 6 + vim/config/search.vim | 17 + vim/config/tmux.vim | 10 + vim/config/whitespace.vim | 11 + vimrc | 579 ++--------------------------- 23 files changed, 545 insertions(+), 553 deletions(-) create mode 100644 vim/config/autocommands.vim create mode 100644 vim/config/bundles.vim create mode 100644 vim/config/colorscheme.vim create mode 100644 vim/config/defaultconfig.vim create mode 100644 vim/config/functions.vim create mode 100644 vim/config/gui.vim create mode 100644 vim/config/keymappings.vim create mode 100644 vim/config/leaderkeys.vim create mode 100644 vim/config/plugins/fugitive.vim create mode 100644 vim/config/plugins/incsearch.vim create mode 100644 vim/config/plugins/lightline.vim create mode 100644 vim/config/plugins/neocomplete.vim create mode 100644 vim/config/plugins/neosnippet.vim create mode 100644 vim/config/plugins/sneak.vim create mode 100644 vim/config/plugins/syntastic.vim create mode 100644 vim/config/plugins/tabularize.vim create mode 100644 vim/config/plugins/tcomment.vim create mode 100644 vim/config/plugins/unite.vim create mode 100644 vim/config/plugins/wildfire.vim create mode 100644 vim/config/search.vim create mode 100644 vim/config/tmux.vim create mode 100644 vim/config/whitespace.vim diff --git a/vim/config/autocommands.vim b/vim/config/autocommands.vim new file mode 100644 index 00000000..1ac68656 --- /dev/null +++ b/vim/config/autocommands.vim @@ -0,0 +1,32 @@ +" autocommands, filetypes, spelling, keywords for specific filetypes +"====================================================================== + +" define a group `vimrc` and initialize. +augroup vimrc + autocmd! + + " Remember last location/cursor in file + autocmd BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$") | exe "normal g'\"" | endif + + " spell correction on text-files + autocmd BufNewFile,BufRead *.md setlocal spell + + " add the dash to keywords -- makes better css/js/html search + " do this for specific files only (not in php/rb e.g.) + autocmd BufNewFile,BufRead *.{js,scss,html} set iskeyword+=- + autocmd BufNewFile,BufRead *.{js,scss,html} set iskeyword-=_ + autocmd BufNewFile,BufRead *.php set iskeyword-=- + + " scss.css snippets and stuff + autocmd BufNewFile,BufRead *.scss set filetype=scss.css + + " Syntaxes for other files + autocmd BufNewFile,BufRead *.twig set filetype=html.twig + + " omnicompletion for some filetypes + autocmd FileType css,scss setlocal omnifunc=csscomplete#CompleteCSS + autocmd FileType html,php,twig setlocal omnifunc=htmlcomplete#CompleteTags + autocmd FileType php setlocal omnifunc=phpcomplete#CompletePHP + autocmd FileType javascript setlocal omnifunc=javascriptcomplete#CompleteJS + autocmd FileType xml setlocal omnifunc=xmlcomplete#CompleteTags +augroup END diff --git a/vim/config/bundles.vim b/vim/config/bundles.vim new file mode 100644 index 00000000..7707cad9 --- /dev/null +++ b/vim/config/bundles.vim @@ -0,0 +1,47 @@ +" All bundles, syntaxes and plugins +"====================================================================== + +NeoBundle 'Shougo/neocomplete' +NeoBundle 'Shougo/neosnippet' +NeoBundle 'Shougo/unite.vim' +NeoBundle 'Shougo/vimproc.vim', { + \ 'build': { + \ 'mac': 'make -f make_mac.mak', + \ 'linux': 'make', + \ 'unix': 'gmake' + \ } + \ } + +NeoBundle 'altercation/vim-colors-solarized' +NeoBundle 'beyondwords/vim-twig' +NeoBundle 'cakebaker/scss-syntax.vim' +NeoBundle 'christoomey/vim-tmux-navigator' +NeoBundle 'editorconfig/editorconfig-vim' +NeoBundle 'elzr/vim-json' +NeoBundle 'gcmt/wildfire.vim' +NeoBundle 'godlygeek/tabular' +NeoBundle 'hail2u/vim-css3-syntax' +NeoBundle 'haya14busa/incsearch.vim' +NeoBundle 'itchyny/lightline.vim' +NeoBundle 'joshtronic/php.vim' +NeoBundle 'justinmk/vim-sneak' +NeoBundle 'moll/vim-node' +NeoBundle 'othree/html5.vim' +NeoBundle 'othree/javascript-libraries-syntax.vim' +NeoBundle 'othree/yajs.vim' +NeoBundle 'scrooloose/syntastic' +NeoBundle 'tomtom/tcomment_vim' +NeoBundle 'tpope/vim-fugitive' +NeoBundle 'tpope/vim-git' +NeoBundle 'tpope/vim-markdown' +NeoBundle 'tpope/vim-ragtag' +NeoBundle 'tpope/vim-repeat' +NeoBundle 'tpope/vim-surround' +NeoBundle 'tpope/vim-unimpaired' +NeoBundle 'tpope/vim-vinegar' +NeoBundle 'vim-scripts/matchit.zip' +NeoBundle 'webgefrickel/vim-snippets' +NeoBundle 'wellle/tmux-complete.vim' + +" end neobundle config +call neobundle#end() diff --git a/vim/config/colorscheme.vim b/vim/config/colorscheme.vim new file mode 100644 index 00000000..056d15bc --- /dev/null +++ b/vim/config/colorscheme.vim @@ -0,0 +1,26 @@ +" colorscheme and optical stuff +"====================================================================== + +" custom list/invisible chars +set list! " nice Whitespace chars +set listchars=extends:»,precedes:«,tab:▸\ ,trail:· +set fillchars= + +set laststatus=2 " statusbar is 2 high +set cmdheight=2 " command window is 2 high +set cpoptions+=$ " Add a $ to the end of a selection +set cpoptions+=J " 2 spaces after a sentence for easier text manupulation + +colorscheme solarized +let g:solarized_termtrans = 1 +set background=dark " and a dark background of course +set t_Co=256 " 256 color terminal FTW + +" minor optical fix vor syntastic - background for extra-error-column +highlight SignColumn ctermbg=0 + +" italic comments, yeah +highlight Comment cterm=italic + +" bold concealed functions +highlight Conceal cterm=bold diff --git a/vim/config/defaultconfig.vim b/vim/config/defaultconfig.vim new file mode 100644 index 00000000..27c39a21 --- /dev/null +++ b/vim/config/defaultconfig.vim @@ -0,0 +1,38 @@ +" Default sane config +"====================================================================== + +filetype plugin indent on +syntax on + +set autoread " Automatically read a file that has changed on disk +set backspace=indent,eol,start " Allow backspacing over everything in insert mode +set cursorline " highlight current line +set encoding=utf-8 " Yeah. UTF-8 FTW! +set grepprg=ag " use ag for grepping +set hidden " allows for switching buffers without writing +set lazyredraw " Don't redraw while executing macros +set mouse=a " mouse for scrolling +set nobackup " no backups +set noerrorbells " don't beep +set noesckeys " no delay for escaping +set noshowmode " dont show active mode +set noswapfile " no swp-files +set nowrap " dont wrap lines around +set nowritebackup " no stupid backup files +set pastetoggle= " toggle paste-mode for c&p with F2 +set relativenumber " relative line numbers are mothereffin awesome -- see how far your commands will go +set ruler " show where you are in the document +set scrolljump=5 " Lines to scroll when cursor leaves screen +set scrolloff=3 " Minimum lines to keep above and below cursor +set showcmd " show me what im doing. helps alot +set sidescroll=10 " smoother side-scrolling +set sidescrolloff=5 " jump by 5 when scrolling sideways +set timeout ttimeoutlen=100 " get rid of the delay when pressing O (for example) +set ttyfast " faster terminal usage +set ttymouse=xterm2 " xterm/tmux compatible mouse +set virtualedit=all " every mode active from v V to StrgV +set visualbell " don't flicker +set complete-=i " dont complete from files +set nrformats-=octal " nobody uses octal anyway +set display+=lastline " shorten long lastlines +set formatoptions+=j " Delete comment character when joining commented lines diff --git a/vim/config/functions.vim b/vim/config/functions.vim new file mode 100644 index 00000000..b225beae --- /dev/null +++ b/vim/config/functions.vim @@ -0,0 +1,10 @@ +" Custom functions +"====================================================================== + +" for stripping trailing whitespace +function! StripTrailingWhitespaces() + let l = line(".") + let c = col(".") + %s/\s\+$//e + call cursor(l, c) +endfunction diff --git a/vim/config/gui.vim b/vim/config/gui.vim new file mode 100644 index 00000000..5504eb17 --- /dev/null +++ b/vim/config/gui.vim @@ -0,0 +1,10 @@ +" gui options for macvim / gvim +"====================================================================== + +if has('gui_running') + set guifont=Menlo\ for\ Powerline:h12 " a nice font here + set linespace=1 " menlo is nice, but very dense... + set guioptions-=T " no toolbar + set guioptions-=L " no left scrollbar + set guioptions-=r " no right scrollbar +endif diff --git a/vim/config/keymappings.vim b/vim/config/keymappings.vim new file mode 100644 index 00000000..2c4bbb85 --- /dev/null +++ b/vim/config/keymappings.vim @@ -0,0 +1,64 @@ +" Custom key mappings and shortcuts +"====================================================================== + +" remap semi-colon to be colon in normal an visual mode +nnoremap ; : +vnoremap ; : + +" Swap v and CTRL-V, because Block mode is more useful +nnoremap v +nnoremap v +vnoremap v +vnoremap v + +" jk nice behaviour (screen lines vs. shown lines) +nnoremap j gj +nnoremap k gk + +" behave - yank just like D and C +nnoremap Y y$ + +" auto-yanking with clipper for selected yanking, see leader-y mapping +vnoremap y y :call system('nc localhost 8377', @0) + +" Search mappings: These will make it so that going to the next one in a +" search will center on the line it's found in. +nnoremap N Nzz +nnoremap n nzz + +" use the arrowkeys for usefull stuff in normal mode -- switching buffers +nnoremap :bfirst +nnoremap :blast +nnoremap :bp +nnoremap :bn + +" Bubble/indent lines using unimpaired +" using left alt + hjkl on mac usgerman keyboard +nmap ˚ [e +nmap ∆ ]e +nmap ˙ << +nmap ¬ >> +vmap ˚ [egv +vmap ∆ ]egv +vmap ˙ gv + +" Fast Switch between windows/buffers with tab +nnoremap +nnoremap W + +" no help while mishitting ESC - awesome +noremap + +" deactivate stupid ex-mode and man-page stuff +nnoremap Q +nnoremap K + +" reload files when set autoread is active with F5 +nnoremap :checktime + +" Autoformat plugin +nnoremap :Autoformat + +" For when you forget to sudo.. Really Write the file. +cmap w!! w !sudo tee % >/dev/null diff --git a/vim/config/leaderkeys.vim b/vim/config/leaderkeys.vim new file mode 100644 index 00000000..a37095ea --- /dev/null +++ b/vim/config/leaderkeys.vim @@ -0,0 +1,34 @@ +" take me to your leader! +"====================================================================== + +let g:mapleader = "," +let g:maplocalleader = "," + +" open new vertical split and change to split +nnoremap \ vl +nnoremap - sj + +" Adjust viewports/splits to equal widths/heights +nnoremap = = + +" open a new split and edit the vimrc // easy sourcing vimrc +nnoremap ve vl :e ~/.vimrc +nnoremap vs :source ~/.vimrc + +" Opens an edit command with the path of the currently edited file filled in +nnoremap o :e =expand("%:p:h") . "/" + +" Yank to clipboard with clipper -- see https://github.com/wincent/clipper +nnoremap y :call system('nc localhost 8377', @0) + +" reset search +nnoremap :noh + +" short command to strip trainling whitepsace +nnoremap w :call StripTrailingWhitespaces() + +" Find merge conflict markers +nnoremap g /\v^[<\|=>]{7}( .*\|$) + +" paste keeping indentation +nnoremap p p`[v`]= diff --git a/vim/config/plugins/fugitive.vim b/vim/config/plugins/fugitive.vim new file mode 100644 index 00000000..7aebc3eb --- /dev/null +++ b/vim/config/plugins/fugitive.vim @@ -0,0 +1,7 @@ +" Fugitive +"====================================================================== + +nnoremap gs :Gstatus20+ +nnoremap gd :Gdiff20+ +nnoremap gc :Gcommit20+ +nnoremap gw :Gwrite20+ diff --git a/vim/config/plugins/incsearch.vim b/vim/config/plugins/incsearch.vim new file mode 100644 index 00000000..fc41aebf --- /dev/null +++ b/vim/config/plugins/incsearch.vim @@ -0,0 +1,15 @@ +" incsearch +"====================================================================== + +let g:incsearch#auto_nohlsearch = 1 +let g:incsearch#consistent_n_direction = 1 +let g:incsearch#magic = '\v' +map / (incsearch-forward) +map ? (incsearch-backward) +map g/ (incsearch-stay) +map n (incsearch-nohl-n) +map N (incsearch-nohl-N) +map * (incsearch-nohl-*) +map # (incsearch-nohl-#) +map g* (incsearch-nohl-g*) +map g# (incsearch-nohl-g#) diff --git a/vim/config/plugins/lightline.vim b/vim/config/plugins/lightline.vim new file mode 100644 index 00000000..ad93cbdd --- /dev/null +++ b/vim/config/plugins/lightline.vim @@ -0,0 +1,62 @@ +" Lightline config +"====================================================================== + +let g:lightline = { + \ 'colorscheme': 'solarized_dark', + \ 'active': { + \ 'left': [ [ 'mode', 'paste' ], [ 'fugitive', 'filename' ] ], + \ 'right': [ [ 'lineinfo' ], [ 'fileformat', 'fileencoding', 'filetype' ] ] + \ }, + \ 'component_function': { + \ 'modified': 'LightlineModified', + \ 'readonly': 'LightlineReadonly', + \ 'fugitive': 'LightlineFugitive', + \ 'filename': 'LightlineFilename', + \ 'fileformat': 'LightlineFileformat', + \ 'filetype': 'LightlineFiletype', + \ 'fileencoding': 'LightlineFileencoding', + \ 'mode': 'LightlineMode', + \ }, + \ 'separator': { 'left': '⮀', 'right': '⮂' }, + \ 'subseparator': { 'left': '⮁', 'right': '⮃' } + \ } + +function! LightlineModified() + return &ft =~ 'help' ? '' : &modified ? '+' : &modifiable ? '' : '-' +endfunction + +function! LightlineReadonly() + return &ft !~? 'help' && &readonly ? '⭤' : '' +endfunction + +function! LightlineFilename() + return ('' != LightlineReadonly() ? LightlineReadonly() . ' ' : '') . + \ (&ft == 'unite' ? unite#get_status_string() : + \ '' != expand('%:t') ? expand('%:t') : '[No Name]') . + \ ('' != LightlineModified() ? ' ' . LightlineModified() : '') +endfunction + +function! LightlineFugitive() + if exists("*fugitive#head") + let _ = fugitive#head() + return strlen(_) ? '⭠ '._ : '' + endif + return '' +endfunction + +function! LightlineFileformat() + return winwidth(0) > 70 ? &fileformat : '' +endfunction + +function! LightlineFiletype() + return winwidth(0) > 70 ? (strlen(&filetype) ? &filetype : 'no ft') : '' +endfunction + +function! LightlineFileencoding() + return winwidth(0) > 70 ? (strlen(&fenc) ? &fenc : &enc) : '' +endfunction + +function! LightlineMode() + let fname = expand('%:t') + return &ft == 'unite' ? 'Unite' : winwidth(0) > 60 ? lightline#mode() : '' +endfunction diff --git a/vim/config/plugins/neocomplete.vim b/vim/config/plugins/neocomplete.vim new file mode 100644 index 00000000..662b8f28 --- /dev/null +++ b/vim/config/plugins/neocomplete.vim @@ -0,0 +1,23 @@ +" Neocomplete +"====================================================================== + +let g:acp_enableAtStartup = 0 +let g:neocomplete#enable_at_startup = 1 +let g:neocomplete#auto_completion_start_length = 3 +let g:neocomplete#force_overwrite_completefunc = 1 +inoremap neocomplete#undo_completion() +inoremap neocomplete#complete_common_string() +inoremap =neocomplete_cr_function() +inoremap neocomplete#smart_close_popup()."\" +inoremap neocomplete#smart_close_popup()."\" +inoremap neocomplete#close_popup() +inoremap neocomplete#cancel_popup() + +function! s:neocomplete_cr_function() + return neocomplete#close_popup() . "\" +endfunction + +if !exists('g:neocomplete#sources#omni#input_patterns') + let g:neocomplete#sources#omni#input_patterns = {} + let g:neocomplete#sources#omni#input_patterns.php = '[^. \t]->\h\w*\|\h\w*::' +endif diff --git a/vim/config/plugins/neosnippet.vim b/vim/config/plugins/neosnippet.vim new file mode 100644 index 00000000..5d443dac --- /dev/null +++ b/vim/config/plugins/neosnippet.vim @@ -0,0 +1,18 @@ +" Neosnippet config +"====================================================================== + +let g:neosnippet#disable_runtime_snippets = { "_": 1 } +let g:neosnippet#scope_aliases = {} +let g:neosnippet#scope_aliases['scss'] = 'scss,css' +let g:neosnippet#scope_aliases['php'] = 'php,html' +let g:neosnippet#snippets_directory = '~/.vim/bundle/vim-snippets/snippets' + +" Neosnippet - SuperTab like snippets behavior. +smap (neosnippet_expand_or_jump) +imap (neosnippet_expand_or_jump) +imap neosnippet#expandable_or_jumpable() ? + \ "\(neosnippet_expand_or_jump)" + \: pumvisible() ? "\" : "\" +smap neosnippet#expandable_or_jumpable() ? + \ "\(neosnippet_expand_or_jump)" + \: "\" diff --git a/vim/config/plugins/sneak.vim b/vim/config/plugins/sneak.vim new file mode 100644 index 00000000..7f9157cb --- /dev/null +++ b/vim/config/plugins/sneak.vim @@ -0,0 +1,10 @@ +" Vim sneak +"====================================================================== + +let g:sneak#use_ic_scs = 1 +let g:sneak#map_netrw = 0 +let g:sneak#streak = 1 +nmap SneakNext +nmap \| SneakPrevious +xmap VSneakNext +xmap \| VSneakPrevious diff --git a/vim/config/plugins/syntastic.vim b/vim/config/plugins/syntastic.vim new file mode 100644 index 00000000..a4a6ed14 --- /dev/null +++ b/vim/config/plugins/syntastic.vim @@ -0,0 +1,15 @@ +" Syntastic +"====================================================================== + +" no checking for xhtml/html -- because of fluidtemplate for TYPO3 +" and no checking for scss.css because of CSS3 and SASS-Variable +let g:syntastic_auto_jump = 0 +let g:syntastic_scss_scss_lint_exec = '/Users/webgefrickel/.rbenv/shims/scss-lint' +let g:syntastic_scss_checkers = ['scss_lint'] +let g:syntastic_javascript_checkers = ['eslint'] +let g:syntastic_json_checkers = ['jsonlint'] +let g:syntastic_mode_map = { + \ 'mode': 'active', + \ 'active_filetypes': ['php', 'scss', 'javascript', 'json'], + \ 'passive_filetypes': ['xhtml', 'html'] + \ } diff --git a/vim/config/plugins/tabularize.vim b/vim/config/plugins/tabularize.vim new file mode 100644 index 00000000..0b038490 --- /dev/null +++ b/vim/config/plugins/tabularize.vim @@ -0,0 +1,7 @@ +" Tabularize +"====================================================================== + +vmap t= :Tabularize /= +vmap t{ :Tabularize /{ +vmap t: :Tabularize /: +vmap t, :Tabularize /, diff --git a/vim/config/plugins/tcomment.vim b/vim/config/plugins/tcomment.vim new file mode 100644 index 00000000..88801e69 --- /dev/null +++ b/vim/config/plugins/tcomment.vim @@ -0,0 +1,6 @@ +" TComment +"====================================================================== + +nnoremap / :TComment +vnoremap / :TComment +inoremap / :TComment diff --git a/vim/config/plugins/unite.vim b/vim/config/plugins/unite.vim new file mode 100644 index 00000000..bdf86f5c --- /dev/null +++ b/vim/config/plugins/unite.vim @@ -0,0 +1,51 @@ +" The Unite Plugin +"====================================================================== + +let g:unite_prompt='❯ ' +let g:unite_source_grep_command='ag' +let g:unite_source_grep_default_opts='--nocolor --nogroup -S' +let g:unite_source_grep_recursive_opt='' +let g:unite_split_rule = "botright" +let g:unite_force_overwrite_statusline = 0 + +call unite#filters#matcher_default#use(['matcher_fuzzy']) +call unite#filters#sorter_default#use(['sorter_rank']) +call unite#set_profile('files', 'context.smartcase', 1) +call unite#custom#source('line,outline', 'matchers', 'matcher_fuzzy') +call unite#custom_source('file_rec, file_rec/async, file_mru, file, buffer, grep', + \ 'ignore_pattern', join([ + \ '\.git', + \ '\.svn', + \ '\.sass-cache', + \ '_srcs', + \ 'node_modules', + \ 'bower_components', + \ 'vim\/bundle', + \ '\.\(png\|gif\|jpg\|pdf\|ico\|mp4\|webm\|mp3\|woff\|ttf\|eot\|min\.js\|min\.map\|css\)$', + \ ], '\|')) + +nmap [unite] +nnoremap [unite] + +nnoremap [unite], :Unite -start-insert -toggle -auto-resize file_rec/async +nnoremap [unite]b :Unite -short-source-names -quick-match buffer +nnoremap [unite]. :Unite -start-insert -auto-resize buffer +nnoremap [unite]l :Unite -start-insert -auto-resize line +nnoremap [unite]y :Unite history/yank +nnoremap [unite]f :UniteWithCursorWord -start-insert -toggle -auto-resize file_rec/async +nnoremap [unite]a :Unite grep:. +nnoremap [unite]A :UniteWithCursorWord grep:. + +autocmd FileType unite call s:unite_settings() + +function! s:unite_settings() + nmap (unite_exit) + imap (unite_select_next_line) + imap (unite_select_previous_line) + nmap (unite_redraw) + imap (unite_redraw) + inoremap unite#do_action('split') + nnoremap unite#do_action('split') + inoremap unite#do_action('vsplit') + nnoremap unite#do_action('vsplit') +endfunction diff --git a/vim/config/plugins/wildfire.vim b/vim/config/plugins/wildfire.vim new file mode 100644 index 00000000..42b34a98 --- /dev/null +++ b/vim/config/plugins/wildfire.vim @@ -0,0 +1,6 @@ +" wildfire -- selecting with enter/backspace +"====================================================================== + +let g:wildfire_objects = ['iw', 'iW', 'i"', "i\'", 'i)', 'i]', 'i}', 'i>', 'ip', 'it'] +let g:wildfire_fuel_map = "" +let g:wildfire_water_map = "" diff --git a/vim/config/search.vim b/vim/config/search.vim new file mode 100644 index 00000000..a735a6a6 --- /dev/null +++ b/vim/config/search.vim @@ -0,0 +1,17 @@ +" Searching, completion and folds +"====================================================================== + +set ignorecase +set smartcase +set hlsearch +set showmatch +set wrapscan + +set wildmode=list:longest,list:full +set wildmenu + +set foldignore= +set foldmethod=indent " indent folding +set foldnestmax=20 " max 20 levels of folding +set nofoldenable " dont fold by default - let me do it +set foldlevelstart=1 " deactivate folding on fileload diff --git a/vim/config/tmux.vim b/vim/config/tmux.vim new file mode 100644 index 00000000..f337fb01 --- /dev/null +++ b/vim/config/tmux.vim @@ -0,0 +1,10 @@ +" mac terminal-vim play nicely with tmux +"====================================================================== + +if &term =~ '^screen' + " tmux will send xterm-style keys when its xterm-keys option is on + execute "set =\e[1;*A" + execute "set =\e[1;*B" + execute "set =\e[1;*C" + execute "set =\e[1;*D" +endif diff --git a/vim/config/whitespace.vim b/vim/config/whitespace.vim new file mode 100644 index 00000000..ee18324f --- /dev/null +++ b/vim/config/whitespace.vim @@ -0,0 +1,11 @@ +" Tabs and Whitespace -- can be overridden by editorconfig +"====================================================================== + +set fileformat=unix +set tabstop=2 +set softtabstop=2 +set shiftwidth=2 +set shiftround +set smarttab +set expandtab +set autoindent diff --git a/vimrc b/vimrc index e6a4bf75..875869e6 100644 --- a/vimrc +++ b/vimrc @@ -1,4 +1,5 @@ -" Neobundle Setup +" my vimrc - this file basically initalies neobundle and loads +" other config files from vim/config + the plugins-subfolder "====================================================================== if has('vim_starting') @@ -11,555 +12,27 @@ call neobundle#begin(expand('~/.vim/bundle/')) " Let NeoBundle manage NeoBundle NeoBundleFetch 'Shougo/neobundle.vim' - -" All bundles, syntaxes and plugins -"====================================================================== - -NeoBundle 'Shougo/neocomplete' -NeoBundle 'Shougo/neosnippet' -NeoBundle 'Shougo/unite.vim' -NeoBundle 'Shougo/vimproc.vim', { - \ 'build': { - \ 'mac': 'make -f make_mac.mak', - \ 'linux': 'make', - \ 'unix': 'gmake' - \ } - \ } -NeoBundle 'altercation/vim-colors-solarized' -NeoBundle 'beyondwords/vim-twig' -NeoBundle 'christoomey/vim-tmux-navigator' -NeoBundle 'editorconfig/editorconfig-vim' -NeoBundle 'ekalinin/Dockerfile.vim' -NeoBundle 'elzr/vim-json' -NeoBundle 'gcmt/wildfire.vim' -NeoBundle 'godlygeek/tabular' -NeoBundle 'haya14busa/incsearch.vim' -NeoBundle 'itchyny/lightline.vim' -NeoBundle 'joshtronic/php.vim' -NeoBundle 'justinmk/vim-sneak' -NeoBundle 'mattn/emmet-vim' -NeoBundle 'moll/vim-node' -NeoBundle 'othree/html5.vim' -NeoBundle 'pangloss/vim-javascript' -NeoBundle 'scrooloose/syntastic' -NeoBundle 'tomtom/tcomment_vim' -NeoBundle 'tpope/vim-fugitive' -NeoBundle 'tpope/vim-git' -NeoBundle 'tpope/vim-haml' " for sass as well -NeoBundle 'tpope/vim-markdown' -NeoBundle 'tpope/vim-ragtag' -NeoBundle 'tpope/vim-repeat' -NeoBundle 'tpope/vim-surround' -NeoBundle 'tpope/vim-unimpaired' -NeoBundle 'tpope/vim-vinegar' -NeoBundle 'vim-scripts/matchit.zip' -NeoBundle 'webgefrickel/vim-snippets' -NeoBundle 'wellle/tmux-complete.vim' - -" end neobundle config -call neobundle#end() - - -" Default sane config -"====================================================================== - -filetype plugin indent on -syntax on - -set autoread " Automatically read a file that has changed on disk -set backspace=indent,eol,start " Allow backspacing over everything in insert mode -set cursorline " highlight current line -set encoding=utf-8 " Yeah. UTF-8 FTW! -set grepprg=ag " use ag for grepping -set hidden " allows for switching buffers without writing -set lazyredraw " Don't redraw while executing macros -set mouse=a " mouse for scrolling -set nobackup " no backups -set noerrorbells " don't beep -set noesckeys " no delay for escaping -set noshowmode " dont show active mode -set noswapfile " no swp-files -set nowrap " dont wrap lines around -set nowritebackup " no stupid backup files -set pastetoggle= " toggle paste-mode for c&p with F2 -set relativenumber " relative line numbers are mothereffin awesome -- see how far your commands will go -set ruler " show where you are in the document -set scrolljump=5 " Lines to scroll when cursor leaves screen -set scrolloff=3 " Minimum lines to keep above and below cursor -set showcmd " show me what im doing. helps alot -set sidescroll=10 " smoother side-scrolling -set sidescrolloff=5 " jump by 5 when scrolling sideways -set timeout ttimeoutlen=100 " get rid of the delay when pressing O (for example) -set ttyfast " faster terminal usage -set ttymouse=xterm2 " xterm/tmux compatible mouse -set virtualedit=all " every mode active from v V to StrgV -set visualbell " don't flicker -set complete-=i " dont complete from files -set nrformats-=octal " nobody uses octal anyway -set display+=lastline " shorten long lastlines -set formatoptions+=j " Delete comment character when joining commented lines - - -" Searching, completion and folds -"====================================================================== - -set ignorecase -set smartcase -set hlsearch -set showmatch -set wrapscan - -set wildmode=list:longest,list:full -set wildmenu - -set foldignore= -set foldmethod=indent " indent folding -set foldnestmax=20 " max 20 levels of folding -set nofoldenable " dont fold by default - let me do it -set foldlevelstart=1 " deactivate folding on fileload - - -" Tabs and Whitespace -- can be overridden by editorconfig -"====================================================================== - -set fileformat=unix -set tabstop=2 -set softtabstop=2 -set shiftwidth=2 -set shiftround -set smarttab -set expandtab -set autoindent - - -" gui options for macvim / gvim -"====================================================================== - -if has('gui_running') - set guifont=Menlo\ for\ Powerline:h12 " a nice font here - set linespace=1 " menlo is nice, but very dense... - set guioptions-=T " no toolbar - set guioptions-=L " no left scrollbar - set guioptions-=r " no right scrollbar -endif - - -" mac terminal-vim play nicely with tmux -"====================================================================== - -if &term =~ '^screen' - " tmux will send xterm-style keys when its xterm-keys option is on - execute "set =\e[1;*A" - execute "set =\e[1;*B" - execute "set =\e[1;*C" - execute "set =\e[1;*D" -endif - - -" colorscheme and optical stuff -"====================================================================== - -" custom list/invisible chars -set list! " nice Whitespace chars -set listchars=extends:»,precedes:«,tab:▸\ ,trail:· -set fillchars= - -set laststatus=2 " statusbar is 2 high -set cmdheight=2 " command window is 2 high -set cpoptions+=$ " Add a $ to the end of a selection -set cpoptions+=J " 2 spaces after a sentence for easier text manupulation - -colorscheme solarized -let g:solarized_termtrans = 1 -set background=dark " and a dark background of course -set t_Co=256 " 256 color terminal FTW - -" minor optical fix vor syntastic - background for extra-error-column -highlight SignColumn ctermbg=0 - -" italic comments, yeah -highlight Comment cterm=italic - -" bold concealed functions -highlight Conceal cterm=bold - - -" Custom functions -"====================================================================== - -" for stripping trailing whitespace -function! StripTrailingWhitespaces() - let l = line(".") - let c = col(".") - %s/\s\+$//e - call cursor(l, c) -endfunction - - -" autocommands, filetypes, spelling, keywords for specific filetypes -"====================================================================== - -" define a group `vimrc` and initialize. -augroup vimrc - autocmd! -augroup END - -" Remember last location/cursor in file -autocmd vimrc BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$") | exe "normal g'\"" | endif - -" spell correction on text-files -autocmd vimrc BufNewFile,BufRead *.md setlocal spell - -" add the dash to keywords -- makes better css/js/html search -" do this for specific files only (not in php/rb e.g.) -autocmd vimrc BufNewFile,BufRead *.{js,scss,html} set iskeyword+=- -autocmd vimrc BufNewFile,BufRead *.{js,scss,html} set iskeyword-=_ -autocmd vimrc BufNewFile,BufRead *.php set iskeyword-=- - -" scss.css snippets and stuff -autocmd vimrc BufNewFile,BufRead *.scss set filetype=scss.css - -" Syntaxes for other files -autocmd vimrc BufNewFile,BufRead *.twig set filetype=html.twig - -" omnicompletion for some filetypes -autocmd vimrc FileType css,scss setlocal omnifunc=csscomplete#CompleteCSS -autocmd vimrc FileType html,php,twig setlocal omnifunc=htmlcomplete#CompleteTags -autocmd vimrc FileType php setlocal omnifunc=phpcomplete#CompletePHP -autocmd vimrc FileType javascript setlocal omnifunc=javascriptcomplete#CompleteJS -autocmd vimrc FileType xml setlocal omnifunc=xmlcomplete#CompleteTags - - -" Custom key mappings and shortcuts -"====================================================================== - -" remap semi-colon to be colon in normal an visual mode -nnoremap ; : -vnoremap ; : - -" Swap v and CTRL-V, because Block mode is more useful -nnoremap v -nnoremap v -vnoremap v -vnoremap v - -" jk nice behaviour (screen lines vs. shown lines) -nnoremap j gj -nnoremap k gk - -" behave - yank just like D and C -nnoremap Y y$ - -" auto-yanking with clipper for selected yanking, see leader-y mapping -vnoremap y y :call system('nc localhost 8377', @0) - -" Search mappings: These will make it so that going to the next one in a -" search will center on the line it's found in. -nnoremap N Nzz -nnoremap n nzz - -" use the arrowkeys for usefull stuff in normal mode -- switching buffers -nnoremap :bfirst -nnoremap :blast -nnoremap :bp -nnoremap :bn - -" Bubble/indent lines using unimpaired -" using left alt + hjkl on mac usgerman keyboard -nmap ˚ [e -nmap ∆ ]e -nmap ˙ << -nmap ¬ >> -vmap ˚ [egv -vmap ∆ ]egv -vmap ˙ gv - -" Fast Switch between windows/buffers with tab -nnoremap -nnoremap W - -" no help while mishitting ESC - awesome -noremap - -" deactivate stupid ex-mode and man-page stuff -nnoremap Q -nnoremap K - -" reload files when set autoread is active with F5 -nnoremap :checktime - -" Autoformat plugin -nnoremap :Autoformat - -" For when you forget to sudo.. Really Write the file. -cmap w!! w !sudo tee % >/dev/null - - -" take me to your leader! -"====================================================================== - -let g:mapleader = "," -let g:maplocalleader = "," - -" open new vertical split and change to split -nnoremap \ vl -nnoremap - sj - -" Adjust viewports/splits to equal widths/heights -nnoremap = = - -" open a new split and edit the vimrc // easy sourcing vimrc -nnoremap ve vl :e ~/.vimrc -nnoremap vs :source ~/.vimrc - -" Opens an edit command with the path of the currently edited file filled in -nnoremap o :e =expand("%:p:h") . "/" - -" Yank to clipboard with clipper -- see https://github.com/wincent/clipper -nnoremap y :call system('nc localhost 8377', @0) - -" reset search -nnoremap :noh - -" short command to strip trainling whitepsace -nnoremap w :call StripTrailingWhitespaces() - -" Find merge conflict markers -nnoremap g /\v^[<\|=>]{7}( .*\|$) - -" paste keeping indentation -nnoremap p p`[v`]= - - -" Plugin configuration and keymappings -"====================================================================== - -" incsearch -let g:incsearch#auto_nohlsearch = 1 -let g:incsearch#consistent_n_direction = 1 -let g:incsearch#magic = '\v' -map / (incsearch-forward) -map ? (incsearch-backward) -map g/ (incsearch-stay) -map n (incsearch-nohl-n) -map N (incsearch-nohl-N) -map * (incsearch-nohl-*) -map # (incsearch-nohl-#) -map g* (incsearch-nohl-g*) -map g# (incsearch-nohl-g#) - - -" emmet -let g:user_emmet_install_global = 0 -autocmd vimrc FileType html,css,scss,php EmmetInstall - - -" vim sneak -let g:sneak#use_ic_scs = 1 -let g:sneak#map_netrw = 0 -let g:sneak#streak = 1 -nmap SneakNext -nmap \| SneakPrevious -xmap VSneakNext -xmap \| VSneakPrevious - - -" fugitive -nnoremap gs :Gstatus20+ -nnoremap gd :Gdiff20+ -nnoremap gc :Gcommit20+ -nnoremap gw :Gwrite20+ - - -" Tabularize -vmap t= :Tabularize /= -vmap t{ :Tabularize /{ -vmap t: :Tabularize /: -vmap t, :Tabularize /, - - -" TComment -nnoremap / :TComment -vnoremap / :TComment -inoremap / :TComment - - -" neosnippet -let g:neosnippet#disable_runtime_snippets = { "_": 1 } -let g:neosnippet#scope_aliases = {} -let g:neosnippet#scope_aliases['scss'] = 'scss,css' -let g:neosnippet#scope_aliases['php'] = 'php,html' -let g:neosnippet#snippets_directory = '~/.vim/bundle/vim-snippets/snippets' - - -" Neosnippet - SuperTab like snippets behavior. -smap (neosnippet_expand_or_jump) -imap (neosnippet_expand_or_jump) -imap neosnippet#expandable_or_jumpable() ? - \ "\(neosnippet_expand_or_jump)" - \: pumvisible() ? "\" : "\" -smap neosnippet#expandable_or_jumpable() ? - \ "\(neosnippet_expand_or_jump)" - \: "\" - - -" Syntastic -" no checking for xhtml/html -- because of fluidtemplate for TYPO3 -" and no checking for scss.css because of CSS3 and SASS-Variable -let g:syntastic_auto_jump = 0 -let g:syntastic_scss_scss_lint_exec = '/Users/webgefrickel/.rbenv/shims/scss-lint' -let g:syntastic_scss_checkers = ['scss_lint'] -let g:syntastic_javascript_checkers = ['eslint'] -let g:syntastic_json_checkers = ['jsonlint'] -let g:syntastic_mode_map = { - \ 'mode': 'active', - \ 'active_filetypes': ['php', 'scss', 'javascript', 'json'], - \ 'passive_filetypes': ['xhtml', 'html'] - \ } - - -" wildfire -- selecting with enter/backspace -let g:wildfire_objects = ['iw', 'iW', 'i"', "i\'", 'i)', 'i]', 'i}', 'i>', 'ip', 'it'] -let g:wildfire_fuel_map = "" -let g:wildfire_water_map = "" - - -" NEOCOMPLETE -let g:acp_enableAtStartup = 0 -let g:neocomplete#enable_at_startup = 1 -let g:neocomplete#auto_completion_start_length = 3 -let g:neocomplete#force_overwrite_completefunc = 1 -inoremap neocomplete#undo_completion() -inoremap neocomplete#complete_common_string() -inoremap =neocomplete_cr_function() -inoremap neocomplete#smart_close_popup()."\" -inoremap neocomplete#smart_close_popup()."\" -inoremap neocomplete#close_popup() -inoremap neocomplete#cancel_popup() - -function! s:neocomplete_cr_function() - return neocomplete#close_popup() . "\" -endfunction - -if !exists('g:neocomplete#sources#omni#input_patterns') - let g:neocomplete#sources#omni#input_patterns = {} - let g:neocomplete#sources#omni#input_patterns.php = '[^. \t]->\h\w*\|\h\w*::' -endif - - -" The Lightline Plugin -"====================================================================== - -let g:lightline = { - \ 'colorscheme': 'solarized_dark', - \ 'active': { - \ 'left': [ [ 'mode', 'paste' ], [ 'fugitive', 'filename' ] ], - \ 'right': [ [ 'lineinfo' ], [ 'fileformat', 'fileencoding', 'filetype' ] ] - \ }, - \ 'component_function': { - \ 'modified': 'LightlineModified', - \ 'readonly': 'LightlineReadonly', - \ 'fugitive': 'LightlineFugitive', - \ 'filename': 'LightlineFilename', - \ 'fileformat': 'LightlineFileformat', - \ 'filetype': 'LightlineFiletype', - \ 'fileencoding': 'LightlineFileencoding', - \ 'mode': 'LightlineMode', - \ }, - \ 'separator': { 'left': '⮀', 'right': '⮂' }, - \ 'subseparator': { 'left': '⮁', 'right': '⮃' } - \ } - -function! LightlineModified() - return &ft =~ 'help' ? '' : &modified ? '+' : &modifiable ? '' : '-' -endfunction - -function! LightlineReadonly() - return &ft !~? 'help' && &readonly ? '⭤' : '' -endfunction - -function! LightlineFilename() - return ('' != LightlineReadonly() ? LightlineReadonly() . ' ' : '') . - \ (&ft == 'unite' ? unite#get_status_string() : - \ '' != expand('%:t') ? expand('%:t') : '[No Name]') . - \ ('' != LightlineModified() ? ' ' . LightlineModified() : '') -endfunction - -function! LightlineFugitive() - if exists("*fugitive#head") - let _ = fugitive#head() - return strlen(_) ? '⭠ '._ : '' - endif - return '' -endfunction - -function! LightlineFileformat() - return winwidth(0) > 70 ? &fileformat : '' -endfunction - -function! LightlineFiletype() - return winwidth(0) > 70 ? (strlen(&filetype) ? &filetype : 'no ft') : '' -endfunction - -function! LightlineFileencoding() - return winwidth(0) > 70 ? (strlen(&fenc) ? &fenc : &enc) : '' -endfunction - -function! LightlineMode() - let fname = expand('%:t') - return &ft == 'unite' ? 'Unite' : winwidth(0) > 60 ? lightline#mode() : '' -endfunction - - -" The Unite Plugin -"====================================================================== - -let g:unite_prompt='❯ ' -let g:unite_source_grep_command='ag' -let g:unite_source_grep_default_opts='--nocolor --nogroup -S' -let g:unite_source_grep_recursive_opt='' -let g:unite_split_rule = "botright" -let g:unite_force_overwrite_statusline = 0 - -call unite#filters#matcher_default#use(['matcher_fuzzy']) -call unite#filters#sorter_default#use(['sorter_rank']) -call unite#set_profile('files', 'context.smartcase', 1) -call unite#custom#source('line,outline', 'matchers', 'matcher_fuzzy') -call unite#custom_source('file_rec, file_rec/async, file_mru, file, buffer, grep', - \ 'ignore_pattern', join([ - \ '\.git', - \ '\.svn', - \ '\.sass-cache', - \ '_srcs', - \ 'node_modules', - \ 'bower_components', - \ 'vim\/bundle', - \ '\.\(png\|gif\|jpg\|pdf\|ico\|mp4\|webm\|mp3\|woff\|ttf\|eot\|min\.js\|min\.map\|css\)$', - \ ], '\|')) - -nmap [unite] -nnoremap [unite] - -nnoremap [unite], :Unite -start-insert -toggle -auto-resize file_rec/async -nnoremap [unite]b :Unite -short-source-names -quick-match buffer -nnoremap [unite]. :Unite -start-insert -auto-resize buffer -nnoremap [unite]l :Unite -start-insert -auto-resize line -nnoremap [unite]y :Unite history/yank -nnoremap [unite]f :UniteWithCursorWord -start-insert -toggle -auto-resize file_rec/async -nnoremap [unite]a :Unite grep:. -nnoremap [unite]A :UniteWithCursorWord grep:. - -autocmd FileType unite call s:unite_settings() - -function! s:unite_settings() - nmap (unite_exit) - imap (unite_select_next_line) - imap (unite_select_previous_line) - nmap (unite_redraw) - imap (unite_redraw) - inoremap unite#do_action('split') - nnoremap unite#do_action('split') - inoremap unite#do_action('vsplit') - nnoremap unite#do_action('vsplit') -endfunction +" Let Neobundle handle the rest, and start by loading bundles and defaults +source ~/.vim/config/bundles.vim +source ~/.vim/config/defaultconfig.vim +source ~/.vim/config/search.vim +source ~/.vim/config/whitespace.vim +source ~/.vim/config/gui.vim +source ~/.vim/config/tmux.vim +source ~/.vim/config/colorscheme.vim +source ~/.vim/config/functions.vim +source ~/.vim/config/keymappings.vim +source ~/.vim/config/leaderkeys.vim + +" and the configs and mappings for plugins loaded in bundles.vim +source ~/.vim/config/plugins/fugitive.vim +source ~/.vim/config/plugins/incsearch.vim +source ~/.vim/config/plugins/lightline.vim +source ~/.vim/config/plugins/neocomplete.vim +source ~/.vim/config/plugins/neosnippet.vim +source ~/.vim/config/plugins/syntastic.vim +source ~/.vim/config/plugins/tabularize.vim +source ~/.vim/config/plugins/tcomment.vim +source ~/.vim/config/plugins/unite.vim +source ~/.vim/config/plugins/sneak.vim +source ~/.vim/config/plugins/wildfire.vim