ソースを参照

made some changes to vimrc, and added vimoutlinerrc

wreed4 9 年 前
コミット
613109fe65
3 ファイル変更167 行追加34 行削除
  1. 86 26
      autoload/plug.vim
  2. 67 0
      vimoutlinerrc
  3. 14 8
      vimrc

+ 86 - 26
autoload/plug.vim

@@ -171,14 +171,22 @@ function! s:assoc(dict, key, val)
   let a:dict[a:key] = add(get(a:dict, a:key, []), a:val)
 endfunction
 
-function! s:ask(message)
+function! s:ask(message, ...)
   call inputsave()
   echohl WarningMsg
-  let proceed = input(a:message.' (y/N) ') =~? '^y'
+  let answer = input(a:message.(a:0 ? ' (y/N/a) ' : ' (y/N) '))
   echohl None
   call inputrestore()
   echo "\r"
-  return proceed
+  return (a:0 && answer =~? '^a') ? 2 : (answer =~? '^y') ? 1 : 0
+endfunction
+
+function! s:ask_no_interrupt(...)
+  try
+    return call('s:ask', a:000)
+  catch
+    return 0
+  endtry
 endfunction
 
 function! plug#end()
@@ -267,7 +275,7 @@ function! plug#end()
       syntax enable
     end
   else
-    call s:reload()
+    call s:reload_plugins()
   endif
 endfunction
 
@@ -275,9 +283,13 @@ function! s:loaded_names()
   return filter(copy(g:plugs_order), 'get(s:loaded, v:val, 0)')
 endfunction
 
-function! s:reload()
+function! s:load_plugin(spec)
+  call s:source(s:rtp(a:spec), 'plugin/**/*.vim', 'after/plugin/**/*.vim')
+endfunction
+
+function! s:reload_plugins()
   for name in s:loaded_names()
-    call s:source(s:rtp(g:plugs[name]), 'plugin/**/*.vim', 'after/plugin/**/*.vim')
+    call s:load_plugin(g:plugs[name])
   endfor
 endfunction
 
@@ -605,6 +617,7 @@ function! s:syntax()
   syn match plugRelDate /([^)]*)$/ contained
   syn match plugNotLoaded /(not loaded)$/
   syn match plugError /^x.*/
+  syn region plugDeleted start=/^\~ .*/ end=/^\ze\S/
   syn match plugH2 /^.*:\n-\+$/
   syn keyword Function PlugInstall PlugStatus PlugUpdate PlugClean
   hi def link plug1       Title
@@ -624,6 +637,7 @@ function! s:syntax()
   hi def link plugUpdate  Type
 
   hi def link plugError   Error
+  hi def link plugDeleted Ignore
   hi def link plugRelDate Comment
   hi def link plugEdge    PreProc
   hi def link plugSha     Identifier
@@ -701,6 +715,12 @@ function! s:prepare(...)
     throw 'Invalid current working directory. Cannot proceed.'
   endif
 
+  for evar in ['$GIT_DIR', '$GIT_WORK_TREE']
+    if exists(evar)
+      throw evar.' detected. Cannot proceed.'
+    endif
+  endfor
+
   call s:job_abort()
   if s:switch_in()
     normal q
@@ -716,10 +736,9 @@ function! s:prepare(...)
   let s:plug_buf = winbufnr(0)
   call s:assign_name()
 
-  silent! unmap <buffer> <cr>
-  silent! unmap <buffer> L
-  silent! unmap <buffer> o
-  silent! unmap <buffer> X
+  for k in ['<cr>', 'L', 'o', 'X', 'd', 'dd']
+    execute 'silent! unmap <buffer>' k
+  endfor
   setlocal buftype=nofile bufhidden=wipe nobuflisted noswapfile nowrap cursorline modifiable
   setf vim-plug
   if exists('g:syntax_on')
@@ -785,7 +804,12 @@ function! s:do(pull, force, todo)
       let error = ''
       let type = type(spec.do)
       if type == s:TYPE.string
-        let error = s:bang(spec.do)
+        if spec.do[0] == ':'
+          call s:load_plugin(spec)
+          execute spec.do[1:]
+        else
+          let error = s:bang(spec.do)
+        endif
       elseif type == s:TYPE.funcref
         try
           let status = installed ? 'installed' : (updated ? 'updated' : 'unchanged')
@@ -1024,14 +1048,14 @@ function! s:update_finish()
       if v:shell_error
         call add(s:update.errors, name)
         call s:regress_bar()
-        execute pos 'd _'
+        silent execute pos 'd _'
         call append(4, msg) | 4
       elseif !empty(out)
         call setline(pos, msg)
       endif
       redraw
     endfor
-    4 d _
+    silent 4 d _
     call s:do(s:update.pull, s:update.force, filter(copy(s:update.all), 'index(s:update.errors, v:key) < 0 && has_key(v:val, "do")'))
     call s:finish(s:update.pull)
     call setline(1, 'Updated. Elapsed time: ' . split(reltimestr(reltime(s:update.start)))[0] . ' sec.')
@@ -1148,7 +1172,7 @@ function! s:log(bullet, name, lines)
   if s:switch_in()
     let pos = s:logpos(a:name)
     if pos > 0
-      execute pos 'd _'
+      silent execute pos 'd _'
       if pos > winheight('.')
         let pos = 4
       endif
@@ -1974,16 +1998,48 @@ function! s:clean(force)
   if empty(todo)
     call append(line('$'), 'Already clean.')
   else
-    if a:force || s:ask('Proceed?')
-      for dir in todo
-        call s:rm_rf(dir)
-      endfor
-      call append(3, ['Removed.', ''])
+    let s:clean_count = 0
+    call append(3, ['Directories to delete:', ''])
+    redraw!
+    if a:force || s:ask_no_interrupt('Delete all directories?')
+      call s:delete([6, line('$')], 1)
     else
-      call append(3, ['Cancelled.', ''])
+      call setline(4, 'Cancelled.')
+      nnoremap <silent> <buffer> d :set opfunc=<sid>delete_op<cr>g@
+      nmap     <silent> <buffer> dd d_
+      xnoremap <silent> <buffer> d :<c-u>call <sid>delete_op(visualmode(), 1)<cr>
+      echo 'Delete the lines (d{motion}) to delete the corresponding directories'
     endif
   endif
   4
+  setlocal nomodifiable
+endfunction
+
+function! s:delete_op(type, ...)
+  call s:delete(a:0 ? [line("'<"), line("'>")] : [line("'["), line("']")], 0)
+endfunction
+
+function! s:delete(range, force)
+  let [l1, l2] = a:range
+  let force = a:force
+  while l1 <= l2
+    let line = getline(l1)
+    if line =~ '^- ' && isdirectory(line[2:])
+      execute l1
+      redraw!
+      let answer = force ? 1 : s:ask('Delete '.line[2:].'?', 1)
+      let force = force || answer > 1
+      if answer
+        call s:rm_rf(line[2:])
+        setlocal modifiable
+        call setline(l1, '~'.line[1:])
+        let s:clean_count += 1
+        call setline(4, printf('Removed %d directories.', s:clean_count))
+        setlocal nomodifiable
+      endif
+    endif
+    let l1 += 1
+  endwhile
 endfunction
 
 function! s:upgrade()
@@ -2125,11 +2181,15 @@ function! s:preview_commit()
     return
   endif
 
-  execute 'pedit' sha
-  wincmd P
-  setlocal filetype=git buftype=nofile nobuflisted modifiable
-  execute 'silent read !cd' s:shellesc(g:plugs[name].dir) '&& git show --no-color --pretty=medium' sha
-  normal! gg"_dd
+  if exists('g:plug_pwindow') && !s:is_preview_window_open()
+    execute g:plug_pwindow
+    execute 'e' sha
+  else
+    execute 'pedit' sha
+    wincmd P
+  endif
+  setlocal previewwindow filetype=git buftype=nofile nobuflisted modifiable
+  execute 'silent %!cd' s:shellesc(g:plugs[name].dir) '&& git show --no-color --pretty=medium' sha
   setlocal nomodifiable
   nnoremap <silent> <buffer> q :q<cr>
   wincmd p
@@ -2215,7 +2275,7 @@ function! s:revert()
   setlocal modifiable
   normal! "_dap
   setlocal nomodifiable
-  echo 'Reverted.'
+  echo 'Reverted'
 endfunction
 
 function! s:snapshot(force, ...) abort

+ 67 - 0
vimoutlinerrc

@@ -0,0 +1,67 @@
+"Extra configurations and mappings  ******************************************
+"This mapping is fold-level and fold-state dependent 
+"map <S-Down> dd p
+"map <S-Up> dd <up>P
+
+"Common Plugins
+" The vo_modules_load variable holds name of all VO modules you want to load. 
+" If you do not want to load any VO modules leave it blank
+
+" This setting loads the checkboxes, tags and smart_paste plugins as default.
+let g:vo_modules_load = "checkbox:tags:smart_paste"
+
+" Uncomment the following line to enable the math plugin.
+let g:vo_modules_load .= ':math'
+
+" Uncomment the following line to enable new hoisting.
+let g:vo_modules_load .= ':newhoist'
+
+" Uncomment the following line to enable the format plugin.
+let g:vo_modules_load .= ':format'
+
+" Uncomment the following line to enable clocking.
+"let g:vo_modules_load .= ':clock'
+
+"User Preferences ***************************************************
+"let maplocalleader = ',,'		" uncomment for compatibility with
+                                        " previous versions of VO
+
+"setlocal ignorecase			" searches ignore case
+"setlocal smartcase			" searches use smart case
+"setlocal wrapmargin=5
+"setlocal tw=78
+"setlocal tabstop=4			" tabstop and shiftwidth must match
+"setlocal shiftwidth=4			" values from 2 to 8 work well
+"setlocal background=dark		" for dark backgrounds
+"setlocal nowrap
+
+" colorscheme votl_light			" set a VO specific colorscheme
+
+"Checkbox Tags
+" Tags can contain any word characters (:help word)
+" tags must not contain whitespace
+" tags must be unique
+"    there can be no intersections between lists
+"   'high', 'High', and 'HIGH' are considered to be unique and nonintersecting
+" each sub-list represents a unique circular 'ring' of tags
+" currently, these options do not affect checkboxes
+"    status indicators like DONE, NOT DONE and CANCELED are
+"    refelected in the checkbox state: [X], [_] and [-], respectively
+" each tag is a [] block, just like a checkbox; chosen for possible future integration
+" each tag must be delimited by whitespace
+"    [TODO] [Feature] <-- this
+"    [TODO][Feature] <-- not this
+
+let g:cbTags = [
+\ ['TODO','FEEDBACK','VERIFY','DELEGATED','HOLDING']
+\,['Feature','Enhancement','Bug']
+\,['Low','Normal','High','URGENT']
+\,['@Home','@Lab','@Work','@Shopping']
+\]
+
+
+"Hoisting ***********************************************************
+"Uncomment and set to 1 to debug hoisting
+"let g:hoistParanoia=0
+
+" vim: filetype=vim

+ 14 - 8
vimrc

@@ -14,7 +14,7 @@ call plug#begin('~/.vim/bundle')
 
 " ***** plugins that require more stuff (compilation)
 " As-you-type semantic completion. 
-Plug 'Valloric/YouCompleteMe', { 'frozen': 1, 'for': ['cpp', 'c', 'java', 'python', 'sh'], 'on': ['YcmCompleter', 'YcmDiags', 'YcmForceCompileAndDiagnostics']}
+Plug 'Valloric/YouCompleteMe', { 'frozen': 1, 'for': ['cpp', 'c', 'java', 'python', 'xonsh', 'sh'], 'on': ['YcmCompleter', 'YcmDiags', 'YcmForceCompileAndDiagnostics']}
 autocmd! User YouCompleteMe if !has('vim_starting') | call youcompleteme#Enable() | endif
 
 
@@ -99,6 +99,9 @@ Plug 'AndrewRadev/linediff.vim'
 Plug 'tpope/vim-sleuth'
 " Show differences with style
 Plug 'mhinz/vim-signify'
+" Write outlines in vim
+Plug 'vimoutliner/vimoutliner'
+
 
 "SYNTAX Files
 Plug 'linkinpark342/xonsh-vim'
@@ -112,6 +115,7 @@ Plug 'NLKNguyen/papercolor-theme'
 Plug 'freeo/vim-kalisi'
 Plug 'sickill/vim-monokai'
 Plug 'chriskempson/base16-vim'
+Plug 'chriskempson/vim-tomorrow-theme'
 
 
 "Machine-specific plugins
@@ -191,6 +195,7 @@ let g:airline#extensions#tabline#enabled = 1
 let g:airline#extensions#tabline#show_tab_nr = 1
 let g:airline#extensions#tabline#tab_nr_type = 1
 let g:airline#extensions#tabline#show_close_button =1
+let g:airline#extensions#ycm#enabled = 1
 
 let g:airline#extensions#tagbar#flags = 'f'
 let g:airline#extensions#tagbar#enabled = 1
@@ -293,7 +298,8 @@ let g:ycm_filetype_blacklist = {
             \}
 
 " Python3 completion by default
-let g:ycm_python_binary_path = system('which python3')
+" let g:ycm_python_binary_path = system('readlink -f ' . system('which python3'))
+let g:ycm_python_binary_path = 'python3'
 
 " Mappings
 nnoremap <leader>] :YcmCompleter GoTo<CR>
@@ -492,7 +498,7 @@ let g:html_dynamic_folds=1
 set foldlevelstart=99
 set foldmethod=syntax
 augroup folding_settings
-  autocmd FileType python set foldmethod=indent
+  autocmd FileType python,xonsh set foldmethod=indent
 augroup END
 
 
@@ -525,11 +531,10 @@ autocmd BufWinEnter * if line2byte(line("$") + 1) > 10000000 | syntax clear | en
 " colorscheme gruvbox
 
 " Paper-color settings
-" colorscheme PaperColor
-" set background=dark
+colorscheme PaperColor
+set background=dark
 
-" Monokai settings
-colorscheme monokai
+" colorscheme monokai
 
 " colorscheme bubblegum
 " set background=dark
@@ -722,7 +727,8 @@ function! VisualSelection(direction) range
     " elseif a:direction == 'replace'
         " call CmdLine("%s" . '/'. l:pattern . '/')
     elseif a:direction == 'f'
-        execute "normal /" . l:pattern . "^M"
+        " execute "normal /" . l:pattern . "^M"
+        execute "normal /" . l:pattern 
     endif
 
     let @/ = l:pattern