Ver Fonte

Clean up vimrc

Moved more settings into individual settings files.
Weiyi Lou há 10 anos atrás
pai
commit
bea6a2e6a8

+ 0 - 1
vim/settings/ctrlp.vim

@@ -10,4 +10,3 @@ let g:ctrlp_user_command = {
     \ 'fallback': 'find %s -type f'
 \ }
 let g:ctrlp_extensions = ['funky']
-

+ 10 - 9
vim/settings/easygrep.vim

@@ -1,13 +1,14 @@
 " use ack for grepping if available
-if executable('ack-grep')
-  set grepprg=ack-grep\ --with-filename\ --nocolor\ --nogroup
-elseif executable('ack')
-  set grepprg=ack\ --with-filename\ --nocolor\ --nogroup
-endif
+"if executable('ack-grep')
+  "set grepprg=ack-grep\ --with-filename\ --nocolor\ --nogroup
+"elseif executable('ack')
+  "set grepprg=ack\ --with-filename\ --nocolor\ --nogroup
+"endif
+
 " don't display ack/grep terminal output. NOTE: not reliable
 " https://github.com/mileszs/ack.vim/issues/18
-set shellpipe=&>
+"set shellpipe=&>
 
-let g:EasyGrepRecursive = 1
-let g:EasyGrepHighlightQfMatches = 1
-let g:EasyGrepReplaceWindowMode = 2  " Edit and save in place (no new tabs/splits)
+"let g:EasyGrepRecursive = 1
+"let g:EasyGrepHighlightQfMatches = 1
+"let g:EasyGrepReplaceWindowMode = 2  " Edit and save in place (no new tabs/splits)

+ 1 - 0
vim/settings/folding.vim

@@ -29,6 +29,7 @@
 if has('folding')
 
   " Default Settings {{{
+  set foldenable
   set foldmethod=indent
   set foldlevel=10
   " }}}

+ 1 - 1
vim/settings/gundo.vim

@@ -1,2 +1,2 @@
 " Gundo
-nnoremap <silent> <leader>u :GundoToggle<CR>
+"nnoremap <silent> <leader>u :GundoToggle<CR>

+ 2 - 0
vim/settings/json.vim

@@ -0,0 +1,2 @@
+" Formatting for JSON files
+au FileType json setlocal equalprg=python\ -m\ json.tool

+ 17 - 17
vim/settings/keymaps.vim

@@ -1,19 +1,19 @@
 " Toggle keyboard layout
-nnoremap <silent> <leader><space> :call CycleKeymap()<CR>
+"nnoremap <silent> <leader><space> :call CycleKeymap()<CR>
 
-function! CycleKeymap()
-  if has('keymap')
-    if (&keymap == '')
-      set keymap=colemak
-      echo 'Colemak keymap selected'
-    elseif (&keymap == 'colemak')
-      set keymap=dvorak
-      echo 'Dvorak keymap selected'
-    else
-      set keymap=
-      echo 'Qwerty keymap selected'
-    endif
-  else
-    echo 'Keymaps not supported'
-  endif
-endfunction
+"function! CycleKeymap()
+  "if has('keymap')
+    "if (&keymap == '')
+      "set keymap=colemak
+      "echo 'Colemak keymap selected'
+    "elseif (&keymap == 'colemak')
+      "set keymap=dvorak
+      "echo 'Dvorak keymap selected'
+    "else
+      "set keymap=
+      "echo 'Qwerty keymap selected'
+    "endif
+  "else
+    "echo 'Keymaps not supported'
+  "endif
+"endfunction

+ 3 - 1
vim/settings/mouse.vim

@@ -9,6 +9,9 @@
 "set ttymouse=xterm2 " Needed to allow mouse support to resize windows
 "set ttyfast " Allows for instantaneous refresh when using the mouse to select
 
+" Mouse support enabled.
+set mouse=a
+
 " Toggle mouse support.
 nnoremap <silent> <leader>m :call ToggleMouse()<CR>
 
@@ -21,4 +24,3 @@ function! ToggleMouse()
     echo 'Mouse usage enabled'
   endif
 endfunction
-

+ 9 - 0
vim/settings/search.vim

@@ -0,0 +1,9 @@
+" Backspace to clear current search (and stop highlighting)
+nnoremap <silent> <backspace> :call ClearSearch()<CR>
+
+function! ClearSearch()
+  if (@/ != "")
+    let @/=""
+    redraw
+  endif
+endfunction

+ 0 - 1
vim/settings/supertab.vim

@@ -1,2 +1 @@
-""""""""" Supertab
 let g:SuperTabDefaultCompletionType = 'context'

+ 1 - 1
vim/settings/syntastic.vim

@@ -1,2 +1,2 @@
-""""""""" Syntastic
+" Syntastic should jump to first offending line on save
 let g:syntastic_auto_jump = 1

+ 2 - 3
vim/settings/tagbar.vim

@@ -1,5 +1,4 @@
-" Tagbar
 nnoremap <silent> <leader>t :TagbarToggle<CR>
 
-""""""""" Tagbar
-let g:tagbar_autoclose = 1 " close sidebar after we go to selection
+" Close sidebar after we go to selection
+let g:tagbar_autoclose = 1

+ 11 - 0
vim/settings/toggles.vim

@@ -0,0 +1,11 @@
+" Toggle text wrap - no used as it conflicts with
+"nnoremap <silent> <leader>w :set wrap! wrap?<CR>
+
+" Toggle paste mode - no autoindenting of pasted material
+nnoremap <silent> <leader>p :set paste! paste?<CR>
+
+" Toggle visible whitespace characters
+nnoremap <silent> <leader>l :set list! list?<CR>
+
+" Toggle scrollbind for moving multiple splits in sync together
+nnoremap <silent> <leader>s :set scrollbind! scrollbind?<CR>

+ 0 - 1
vim/settings/vdebug.vim

@@ -1,4 +1,3 @@
-""""""""" Vdebug
 let g:vdebug_options = {
   \ 'break_on_open' : 0,
   \ 'watch_window_style' : 'compact',

+ 10 - 26
vim/settings/version_control.vim

@@ -1,12 +1,4 @@
-" Version Control - Modeline and Notes {{{
-" vim: set sw=2 ts=2 sts=2 et tw=78 foldmarker={{{,}}} foldlevel=0 foldmethod=marker spell:
-"
-"   Settings and functions to do with version control usage. Mostly for using
-"   git through fugitive.
-"
-" }}}
-
-" Fugitive Autocommands {{{
+" Fugitive Autocommands
 if has("autocmd")
   " Fugitive - Go up to previous tree object while exploring git tree with '..'
   autocmd User fugitive
@@ -16,23 +8,15 @@ if has("autocmd")
 
   " Fugitive - Delete buffers when they are not active
   autocmd BufReadPost fugitive://* set bufhidden=delete
-
 endif
-" }}}
-
-" Mappings {{{
-
-  " Search for conflict markers {{{
-  nnoremap <leader>fc /\v^[<\|=>]{7}( .*\|$)<CR>
-  " }}}
 
-  " Git commands with Fugitive {{{
-  nnoremap <silent> <leader>gc :Gcommit -v<CR>
-  nnoremap <silent> <leader>gl :Glog<CR><CR>
-  nnoremap <silent> <leader>gap :Git add -p<CR>
-  nnoremap <silent> <leader>gs :Gstatus<CR>
-  nnoremap <silent> <leader>gd :Gdiff<CR>
-  nnoremap <silent> <leader>gb :Gblame<CR>
-  " }}}
+" Search for conflict markers
+nnoremap <leader>fc /\v^[<\|=>]{7}( .*\|$)<CR>
 
-" }}}
+" Git commands with Fugitive
+nnoremap <silent> <leader>gc :Gcommit -v<CR>
+nnoremap <silent> <leader>gl :Glog<CR><CR>
+nnoremap <silent> <leader>gap :Git add -p<CR>
+nnoremap <silent> <leader>gs :Gstatus<CR>
+nnoremap <silent> <leader>gd :Gdiff<CR>
+nnoremap <silent> <leader>gb :Gblame<CR>

+ 6 - 21
vim/settings/white_space.vim

@@ -1,13 +1,5 @@
-" White Space - Modeline and Notes {{{
-" vim: set sw=2 ts=2 sts=2 et tw=78 foldmarker={{{,}}} foldlevel=0 foldmethod=marker spell:
-"
-"   cinaeco/dotfiles functions to do with manipulation of white space
-"
-" }}}
-
-" Remove trailing spaces before save {{{
+" Remove trailing spaces before save
 if has("autocmd")
-
   " Are there really any files we care about that Need trailing white space?
   "autocmd FileType c,cpp,java,go,php,javascript,python,twig,xml,yml
   autocmd BufWritePre * call StripTrailingWhitespace()
@@ -25,17 +17,10 @@ if has("autocmd")
   endfunction
 
 endif
-" }}}
-
-" Mappings {{{
-
-  " Add extra lines up and down {{{
-  nnoremap <leader>j o<Esc>k
-  nnoremap <leader>k O<Esc>j
-  " }}}
 
-  " Convert tabs to spaces {{{
-  nnoremap <silent> <leader><TAB> :%s/<TAB>/  /g<CR>
-  " }}}
+" Add extra lines up and down
+nnoremap <leader>j o<Esc>k
+nnoremap <leader>k O<Esc>j
 
-" }}}
+" Convert tabs to spaces
+nnoremap <silent> <leader><TAB> :%s/<TAB>/  /g<CR>

+ 1 - 0
vim/settings/yaml.vim

@@ -1 +1,2 @@
+" yaml highlighting
 au BufNewFile,BufRead *.yaml,*.yml so ~/.vim/bundle/yaml.vim/colors/yaml.vim

+ 40 - 70
vim/vimrc

@@ -1,11 +1,8 @@
-" Do not try to be compatible with vi
+" Being vi-compatible disables more advanced features
 set nocompatible
 
-" Formatting for JSON files
-au FileType json setlocal equalprg=python\ -m\ json.tool
-
+" Clear all existing autocommands first to avoid unwanted side effects
 if has("autocmd")
-  " Clear existing autocmd
   autocmd!
 endif
 
@@ -14,56 +11,47 @@ if filereadable(expand("~/dotfiles/vim/plugins.vim"))
   source ~/dotfiles/vim/plugins.vim
 endif
 
-filetype plugin indent on   " Automatically detect file types.
-
-if has("autocmd")
-
-  " Source the vimrc file after saving it
-  autocmd BufWritePost .vimrc nested source $MYVIMRC
-
-endif
+" Automatically detect file types.
+filetype plugin indent on
 
+" Syntax highlighting.
+syntax on
 
 """"""""
 "" Tabs and Text Formatting
 """"""""""""""""""""""""""""""""""""""""""""""""""""""
 
-syntax on                   " Syntax highlighting
-
 set nowrap
-set cursorline      " Highlight current line
-set expandtab       " convert tab characters into spaces
-set tabstop=2       " actual tab press distance
-set softtabstop=2   " let backspace delete by indents
-set shiftround      " indent to nearest tabstops
-set shiftwidth=2    " amount to indent with > and <
-set smarttab        " backspace tabs where appropriate even if spaces
-set textwidth=80    " try to keep text within 80 characters
-set colorcolumn=+1  " mark out the limits of the textwidth
-set hidden
-
-set mouse=a
-set nojoinspaces                " Prevents inserting two spaces after punctuation on a join (J)
-set splitright                  " Puts new vsplit windows to the right of the current
-set splitbelow                  " Puts new split windows to the bottom of the current
-
-set backspace=indent,eol,start  " Backspace for dummies
-set linespace=0                 " No extra spaces between rows
-set number                      " Line numbers on
+set cursorline     " Highlight current line
+set expandtab      " convert tab characters into spaces
+set tabstop=2      " actual tab press distance
+set softtabstop=2  " let backspace delete by indents
+set shiftround     " indent to nearest tabstops
+set shiftwidth=2   " amount to indent with > and <
+set smarttab       " backspace tabs where appropriate even if spaces
+set textwidth=80   " try to keep text within 80 characters
+set colorcolumn=+1 " mark out the limits of the textwidth
+set hidden         " allow changing buffers without unsaved-warnings e.g. for argdo
+
+set nojoinspaces               " Prevents inserting two spaces after punctuation on a join (J)
+set splitright                 " Puts new vsplit windows to the right of the current
+set splitbelow                 " Puts new split windows to the bottom of the current
+set backspace=indent,eol,start " Backspace for dummies
+set linespace=0                " No extra spaces between rows
+set number                     " Line numbers on
 set relativenumber
-set showmatch                   " Show matching brackets/parenthesis
-set incsearch                   " Find as you type search
-set hlsearch                    " Highlight search terms
-set winminheight=0              " Windows can be 0 line high
-set ignorecase                  " Case insensitive search
-set smartcase                   " Case sensitive when uc present
-set wildmenu                    " Show list instead of just completing
-set modeline                    " Support vim modelines at the top of files
-"set wildmode=list:longest,full  " Command <Tab> completion, list matches, then longest common part, then all.
-set whichwrap=b,s,h,l,<,>,[,]   " Backspace and cursor keys wrap too
-set shortmess+=filmnrxoOtT          " Abbrev. of messages (avoids 'hit enter')
-set scrolloff=5                 " Minimum lines to keep above and below cursor
-set foldenable                  " Auto fold code
+set showmatch                  " Show matching brackets/parenthesis
+set incsearch                  " Find as you type search
+set hlsearch                   " Highlight search terms
+set winminheight=0             " Windows can be 0 line high
+set ignorecase                 " Case insensitive search
+set smartcase                  " Case sensitive when uc present
+set wildmenu                   " Show list instead of just completing
+set modeline                   " Support vim modelines at the top of files
+set whichwrap=b,s,h,l,<,>,[,]  " Backspace and cursor keys wrap too
+set shortmess+=filmnrxoOtT     " Abbrev. of messages (avoids 'hit enter')
+set scrolloff=5                " Minimum lines to keep above and below cursor
+
 set list
 set listchars=tab:›\ ,trail:•,extends:#,nbsp:. " Highlight problematic whitespace
 
@@ -75,7 +63,7 @@ endif
 
 """"""""
 "" Key Remaps
-""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+""""""""""""""""""""""""""""""""""""""""""""""""""""""
 
 let mapleader = ','
 
@@ -89,32 +77,14 @@ nnoremap Y y$
 " Remap vim's 'increment next number' to <C-b> since <C-a> is used by tmux.
 nnoremap <C-b> <C-a>
 
-nnoremap <silent> <leader>w :set wrap! wrap?<CR>
-
-" Toggle paste mode - no autoindenting of pasted material
-nnoremap <silent> <leader>p :set paste! paste?<CR>
-
-" Toggle visible whitespace characters
-nnoremap <silent> <leader>l :set list! list?<CR>
-
-" Toggle scrollbind for moving multiple splits in sync together
-nnoremap <silent> <leader>s :set scrollbind! scrollbind?<CR>
-
-" Backspace to clear current search (and stop highlighting)
-nnoremap <silent> <backspace> :call ClearSearch()<CR>
-
-function! ClearSearch()
-  if (@/ != "")
-    let @/=""
-    redraw
-  endif
-endfunction
-
 " Allow using the repeat operator with a visual selection (!)
 " http://stackoverflow.com/a/8064607/127816
 vnoremap . :normal .<CR>
 
-""""""""" Source local scripts/plugins
+""""""""
+"" Load Settings Files
+""""""""""""""""""""""""""""""""""""""""""""""""""""""
+
 for filePath in split(globpath('~/dotfiles/vim/settings', '*.vim'), '\n')
   execute 'source' filePath
 endfor