diff --git a/.vimrc b/.vimrc index 6aa3c57..4bfd979 100644 --- a/.vimrc +++ b/.vimrc @@ -1,4 +1,5 @@ "Basic setup for all files {{{ +call system('message.py vimrc start') set nocompatible "VIM over VI filetype plugin indent on "turn plugins/indent on @@ -19,16 +20,10 @@ set ignorecase "Ignore case in search patterns set laststatus=2 "Always show statusbar set lazyredraw "Don't update screen while executing macros -"set listchars=tab:▸⎯,eol:â—¦ "Strings to use in 'list' mode. list is off by default. -"set listchars=tab:▸⎯,eol:· "Strings to use in 'list' mode. list is off by default. -"set listchars=tab:⇄·,eol:↵ "Strings to use in 'list' mode. list is off by default. -"set listchars=tab:▸⎯,eol:↲,trail:· "Strings to use in 'list' mode. list is off by default. set listchars=tab:▸⎯,trail:· "Strings to use in 'list' mode. list is off by default. set number "show line numbers "set ruler "Show the cursor position all the time set rulerformat=%l,%c%V%=#%n\ %3p%% "Content of the ruler string -"set statusline=%<%F\ %h%m%r%=%-14.(%l,%c%V%=#%n\ %3p%%)\ %P -"set statusline=%<%F\ %h%m%r%=%-14.(%l,%c%V%)\ #%n\ %3p%% set scrolloff=5 "Minimal number of screen lines to keep above and below the cursor set selection=exclusive "Define the behavior of the selection @@ -75,45 +70,20 @@ set noswapfile :let html_ignore_folding = 1 :let html_use_encoding = "utf-8" "}}} -"PYTHON: specific vim behaviour for Python files {{{ +"COMMON: specific vim behaviour for Python files {{{ " -"remove all trailing withitespace for python before write +"remove all trailing whitespace for python before write autocmd BufWritePre *.py :call StripTrailingWhitespaces() autocmd BufWritePre *.rst :call StripTrailingWhitespaces() autocmd BufWritePre *.wiki :call StripTrailingWhitespaces() autocmd BufWritePre *.js :call StripTrailingWhitespaces() autocmd BufWritePre *.css :call StripTrailingWhitespaces() autocmd BufWritePre *.xml :call StripTrailingWhitespaces() -"autocmd BufWritePre *.py :!message.py '%' -"Load views for py files -autocmd BufWinLeave *.py mkview -autocmd BufWinEnter *.py silent loadview -"Set python custom editor behaviour. Note, smartindent is not recommended for -"python files! -autocmd FileType python set tabstop=4|set softtabstop=4|set shiftwidth=4 -autocmd FileType python set expandtab|set smarttab|set noautoindent -autocmd FileType python set smartindent cinwords=if,elif,else,for,while,try,except,finally,def,class,with -autocmd FileType python set foldmethod=indent|set foldlevel=100|set list|set textwidth=78|set cinkeys-=0# -autocmd FileType python set indentkeys-=0#|inoremap # X# -"autocmd FileType python set ofu=syntaxcomplete#Complete -autocmd FileType python compiler pylint -let g:pylint_onwrite = 0 " I don't want to run pylint on every save - -"autocmd FileType python setlocal omnifunc=pysmell#Complete -let python_highlight_all=1 " }}} " OTHER FILES: {{{ -"autocmd FileType python :!echo '%' -autocmd FileType sql set nolist|set nosmartindent|set autoindent|set foldmethod=manual -autocmd FileType vim set nolist|set nosmartindent|set autoindent|set foldmethod=manual -autocmd FileType snippet set nolist|set tabstop=4|set autoindent|set foldmethod=manual|set noexpandtab|set shiftwidth=4 -autocmd FileType snippets set noexpandtab, nolist -autocmd FileType rst set spf=/home/gryf/.vim/pol.utf8.add|set textwidth=80 +autocmd BufRead *.tmux.conf set filetype=tmux -"}}} -"LaTeX: option for LaTeX files {{{ -autocmd FileType tex compiler rubber|map :make "}}} "TERMINAL: options for terminal emulators {{{ if $TERM == 'rxvt-unicode' || $TERM == 'xterm' @@ -122,6 +92,11 @@ if $TERM == 'rxvt-unicode' || $TERM == 'xterm' "repair urxvt ctrl+pgup/down behaviour map [5^ map [6^ +elseif $TERM == 'screen' || $TERM == 'screen-256color' + set t_Co=256 "Enable 256 colors support + set term=screen-256color "Set terminal type + set t_kN=[6;*~ + set t_kP=[5;*~ endif if $TERM == 'linux' "For term like linux terminal keep interface simple @@ -171,6 +146,9 @@ let g:pydiction_location = '/home/gryf/.vim/after/ftplugin/pytdiction/complete-d "TagListToo {{{2 let g:VerticalToolWindowSide = 'right' "}}} +"{{{ Pydoc +let g:pydoc_cmd = "/usr/bin/pydoc" +"}}} "}}} "KEYS: User definied keyboard shortcuts {{{ @@ -351,17 +329,17 @@ endfunction " GUI: here goes all the gvim customizations {{{ if has('gui_running') "set guifont=Consolas\ 12 "I like this font, but it looks like crap on linux - "set listchars=tab:▸⎼,eol:↲ "Strings to use in 'list' mode. this is different from console fixed-misc font. set guifont=Fixed\ 14 "I like this font better. set mouse=a "Enable mouse support set guioptions-=T "No toolbar + set guioptions-=m "Nor menu "add menuitem OpenInFirefox nmenu 666 PopUp.&Open\ in\ browser :call OpenInFirefox() "Turn off annoying beep au GUIEnter * set vb t_vb= endif "}}} -" HIGHLIGHT: colorscheme and highlight, which should be applyed on after {{{ +" HIGHLIGHT: colorscheme and highlight, which should be applied on after {{{ " some vim initialization if $TERM == 'linux' colorscheme pablo @@ -374,3 +352,4 @@ highlight OverLength ctermbg=black guibg=black match OverLength /\%81v.*/ "}}} " vim:ts=4:sw=4:wrap:fdm=marker: +call system('message.py vimrc end') diff --git a/GetLatest/GetLatestVimScripts.dat b/GetLatest/GetLatestVimScripts.dat index a6dc50e..8721ab5 100644 --- a/GetLatest/GetLatestVimScripts.dat +++ b/GetLatest/GetLatestVimScripts.dat @@ -3,16 +3,18 @@ ScriptID SourceID Filename ### plugins 102 9375 DirDiff.vim 1658 11834 NERD_tree.vim -2754 13139 :AutoInstall: delimitMate.vim +#2754 13139 :AutoInstall: delimitMate.vim 1984 11852 fuzzyfinder.vim 642 8136 :AutoInstall: getscript.vim 311 7645 grep.vim 2727 11120 jsbeautify.vim 2666 12423 Mark 2262 8944 occur.vim -2421 9423 pysmell.vim +910 13092 pydoc.vim +#2421 9423 pysmell.vim 152 3342 showmarks.vim 2540 11006 snipMate.vim +1697 12566 :AutoInstall: surround.vim #273 7701 taglist.vim # exchanged with taglisttoo 2607 10388 tasklist.vim 90 12743 vcscommand.vim @@ -26,7 +28,7 @@ ScriptID SourceID Filename # compiler 891 10365 pylint.vim # ftplugin -2441 13229 pyflakes.vim +2441 13300 pyflakes.vim 30 9196 python_fn.vim 1542 10872 pythoncomplete.vim ### indent diff --git a/colors/wombat.vim b/colors/wombat.vim deleted file mode 100644 index 9ad1e56..0000000 --- a/colors/wombat.vim +++ /dev/null @@ -1,51 +0,0 @@ -" Maintainer: Lars H. Nielsen (dengmao@gmail.com) -" Last Change: January 22 2007 - -set background=dark - -hi clear - -if exists("syntax_on") - syntax reset -endif - -let colors_name = "wombat" - - -" Vim >= 7.0 specific colors -if version >= 700 - hi CursorLine guibg=#2d2d2d - hi CursorColumn guibg=#2d2d2d - hi MatchParen guifg=#f6f3e8 guibg=#857b6f gui=bold - hi Pmenu guifg=#f6f3e8 guibg=#444444 - hi PmenuSel guifg=#000000 guibg=#cae682 -endif - -" General colors -hi Cursor guifg=NONE guibg=#656565 gui=none -hi Normal guifg=#f6f3e8 guibg=#242424 gui=none -hi NonText guifg=#808080 guibg=#303030 gui=none -hi LineNr guifg=#857b6f guibg=#000000 gui=none -hi StatusLine guifg=#f6f3e8 guibg=#444444 gui=italic -hi StatusLineNC guifg=#857b6f guibg=#444444 gui=none -hi VertSplit guifg=#444444 guibg=#444444 gui=none -hi Folded guibg=#384048 guifg=#a0a8b0 gui=none -hi Title guifg=#f6f3e8 guibg=NONE gui=bold -hi Visual guifg=#f6f3e8 guibg=#444444 gui=none -hi SpecialKey guifg=#808080 guibg=#343434 gui=none - -" Syntax highlighting -hi Comment guifg=#99968b gui=italic -hi Todo guifg=#8f8f8f gui=italic -hi Constant guifg=#e5786d gui=none -hi String guifg=#95e454 gui=italic -hi Identifier guifg=#cae682 gui=none -hi Function guifg=#cae682 gui=none -hi Type guifg=#cae682 gui=none -hi Statement guifg=#8ac6f2 gui=none -hi Keyword guifg=#8ac6f2 gui=none -hi PreProc guifg=#e5786d gui=none -hi Number guifg=#e5786d gui=none -hi Special guifg=#e7f6da gui=none - - diff --git a/colors/wombat256_.vim b/colors/wombat256_.vim deleted file mode 100644 index c7ae0f8..0000000 --- a/colors/wombat256_.vim +++ /dev/null @@ -1,348 +0,0 @@ -" Vim color file -" Maintainer: David Liang (bmdavll at gmail dot com) -" Last Change: November 28 2008 -" -" wombat256.vim - a modified version of Wombat by Lars Nielsen that also -" works on xterms with 88 or 256 colors. The algorithm for approximating the -" GUI colors with the xterm palette is from desert256.vim by Henry So Jr. - -set background=dark - -if version > 580 - hi clear - if exists("syntax_on") - syntax reset - endif -endif - -let g:colors_name = "wombat256" - -if !has("gui_running") && &t_Co != 88 && &t_Co != 256 - finish -endif - -" functions {{{ -" returns an approximate grey index for the given grey level -fun grey_number(x) - if &t_Co == 88 - if a:x < 23 - return 0 - elseif a:x < 69 - return 1 - elseif a:x < 103 - return 2 - elseif a:x < 127 - return 3 - elseif a:x < 150 - return 4 - elseif a:x < 173 - return 5 - elseif a:x < 196 - return 6 - elseif a:x < 219 - return 7 - elseif a:x < 243 - return 8 - else - return 9 - endif - else - if a:x < 14 - return 0 - else - let l:n = (a:x - 8) / 10 - let l:m = (a:x - 8) % 10 - if l:m < 5 - return l:n - else - return l:n + 1 - endif - endif - endif -endfun - -" returns the actual grey level represented by the grey index -fun grey_level(n) - if &t_Co == 88 - if a:n == 0 - return 0 - elseif a:n == 1 - return 46 - elseif a:n == 2 - return 92 - elseif a:n == 3 - return 115 - elseif a:n == 4 - return 139 - elseif a:n == 5 - return 162 - elseif a:n == 6 - return 185 - elseif a:n == 7 - return 208 - elseif a:n == 8 - return 231 - else - return 255 - endif - else - if a:n == 0 - return 0 - else - return 8 + (a:n * 10) - endif - endif -endfun - -" returns the palette index for the given grey index -fun grey_color(n) - if &t_Co == 88 - if a:n == 0 - return 16 - elseif a:n == 9 - return 79 - else - return 79 + a:n - endif - else - if a:n == 0 - return 16 - elseif a:n == 25 - return 231 - else - return 231 + a:n - endif - endif -endfun - -" returns an approximate color index for the given color level -fun rgb_number(x) - if &t_Co == 88 - if a:x < 69 - return 0 - elseif a:x < 172 - return 1 - elseif a:x < 230 - return 2 - else - return 3 - endif - else - if a:x < 75 - return 0 - else - let l:n = (a:x - 55) / 40 - let l:m = (a:x - 55) % 40 - if l:m < 20 - return l:n - else - return l:n + 1 - endif - endif - endif -endfun - -" returns the actual color level for the given color index -fun rgb_level(n) - if &t_Co == 88 - if a:n == 0 - return 0 - elseif a:n == 1 - return 139 - elseif a:n == 2 - return 205 - else - return 255 - endif - else - if a:n == 0 - return 0 - else - return 55 + (a:n * 40) - endif - endif -endfun - -" returns the palette index for the given R/G/B color indices -fun rgb_color(x, y, z) - if &t_Co == 88 - return 16 + (a:x * 16) + (a:y * 4) + a:z - else - return 16 + (a:x * 36) + (a:y * 6) + a:z - endif -endfun - -" returns the palette index to approximate the given R/G/B color levels -fun color(r, g, b) - " get the closest grey - let l:gx = grey_number(a:r) - let l:gy = grey_number(a:g) - let l:gz = grey_number(a:b) - - " get the closest color - let l:x = rgb_number(a:r) - let l:y = rgb_number(a:g) - let l:z = rgb_number(a:b) - - if l:gx == l:gy && l:gy == l:gz - " there are two possibilities - let l:dgr = grey_level(l:gx) - a:r - let l:dgg = grey_level(l:gy) - a:g - let l:dgb = grey_level(l:gz) - a:b - let l:dgrey = (l:dgr * l:dgr) + (l:dgg * l:dgg) + (l:dgb * l:dgb) - let l:dr = rgb_level(l:gx) - a:r - let l:dg = rgb_level(l:gy) - a:g - let l:db = rgb_level(l:gz) - a:b - let l:drgb = (l:dr * l:dr) + (l:dg * l:dg) + (l:db * l:db) - if l:dgrey < l:drgb - " use the grey - return grey_color(l:gx) - else - " use the color - return rgb_color(l:x, l:y, l:z) - endif - else - " only one possibility - return rgb_color(l:x, l:y, l:z) - endif -endfun - -" returns the palette index to approximate the 'rrggbb' hex string -fun rgb(rgb) - let l:r = ("0x" . strpart(a:rgb, 0, 2)) + 0 - let l:g = ("0x" . strpart(a:rgb, 2, 2)) + 0 - let l:b = ("0x" . strpart(a:rgb, 4, 2)) + 0 - return color(l:r, l:g, l:b) -endfun - -" sets the highlighting for the given group -fun X(group, fg, bg, attr) - if a:fg != "" - exec "hi ".a:group." guifg=#".a:fg." ctermfg=".rgb(a:fg) - endif - if a:bg != "" - exec "hi ".a:group." guibg=#".a:bg." ctermbg=".rgb(a:bg) - endif - if a:attr != "" - if a:attr == 'italic' - exec "hi ".a:group." gui=".a:attr." cterm=none" - else - exec "hi ".a:group." gui=".a:attr." cterm=".a:attr - endif - endif -endfun -" }}} - -" X(fg, bg, attr) -call X("Normal", "dddddd", "242424", "none") -call X("NonText", "4c4c36", "", "none") -call X("Cursor", "222222", "ecee90", "none") -call X("CursorLine", "", "32322e", "none") -call X("CursorColumn", "", "2d2d2d", "") - "CursorIM - "Question - "IncSearch -call X("Search", "444444", "af87d7", "") -call X("MatchParen", "ecee90", "857b6f", "bold") -call X("SpecialKey", "6c6c6c", "2d2d2d", "none") -call X("Visual", "ecee90", "597418", "none") -call X("LineNr", "857b6f", "121212", "none") -call X("SignColumn", "", "121212", "none") -call X("Folded", "a0a8b0", "404048", "none") -call X("Title", "f6f3e8", "", "bold") -call X("VertSplit", "444444", "444444", "none") -call X("StatusLine", "f6f3e8", "444444", "italic") -call X("StatusLineNC", "857b6f", "444444", "none") - "Scrollbar - "Tooltip - "Menu - "WildMenu -call X("Pmenu", "f6f3e8", "444444", "") -call X("PmenuSel", "121212", "caeb82", "") -call X("WarningMsg", "ff0000", "", "") - "ErrorMsg - "ModeMsg - "MoreMsg - "Directory - "DiffAdd - "DiffChange - "DiffDelete - "DiffText - -" syntax highlighting -call X("Number", "e5786d", "", "none") -call X("Constant", "e5786d", "", "none") -call X("String", "95e454", "", "italic") -call X("Comment", "c0bc6c", "", "italic") -call X("Identifier", "caeb82", "", "none") -call X("Keyword", "87afff", "", "none") -call X("Statement", "87afff", "", "none") -call X("Function", "caeb82", "", "none") -call X("PreProc", "e5786d", "", "none") -call X("Type", "caeb82", "", "none") -call X("Special", "ffdead", "", "none") -call X("Todo", "857b6f", "", "italic") - "Underlined - "Error - "Ignore -hi! link VisualNOS Visual -hi! link FoldColumn Folded -hi! link TabLineSel StatusLine -hi! link TabLineFill StatusLineNC -hi! link TabLine StatusLineNC -call X("TabLineSel", "f6f3e8", "", "none") - -" Python Highlighting for python.vim -"call X("pythonCoding", "ff0086", "", "none") -"call X("pythonRun", "ff0086", "", "none") -"call X("pythonBuiltinObji", "2b6ba2", "", "bold") -"call X("pythonBuiltinFunc", "2b6ba2", "", "bold") -"call X("pythonException", "ee0000", "", "bold") -"call X("pythonExClass", "66cd66", "", "bold") -"call X("pythonSpaceError", "270000", "", "none") -"call X("pythonDocTest", "2f5f49", "", "none") -"call X("pythonDocTest2", "3b916a", "", "none") -"call X("pythonFunction", "ee0000", "", "bold") -"call X("pythonClass", "ff0086", "", "bold") - -call X("ShowMarksHLl", "ab8042", "121212", "bold") -"call X("ShowMarksHLu", "ab4242", "121212", "bold") -call X("ShowMarksHLu", "aaab42", "121212", "bold") -call X("ShowMarksHLo", "42ab47", "121212", "bold") -call X("ShowMarksHLm", "aaab42", "121212", "bold") - -" Diff colors -"call X("DiffAdd", "", "1d1d50", "bold") -"call X("DiffText", "", "9f1e1e", "bold") -"call X("DiffDelete", "", "1d5050", "bold") -"call X("DiffChange", "", "4c1c4c", "bold") - -call X("DiffAdd", "", "646464", "bold") -call X("DiffText", "", "bf5f00", "bold") -call X("DiffDelete", "343434", "101010", "bold") -call X("DiffChange", "", "424242", "bold") - -" DiffAdd xxx term=bold ctermbg=4 -" DiffChange xxx term=bold ctermbg=5 -" DiffDelete xxx term=bold ctermfg=12 ctermbg=6 -" DiffText xxx term=reverse cterm=bold ctermbg=9 - -" spell, make it underline, and less bright colors -call X("SpellBad", "", "880000", "underline") -call X("SpellCap", "", "000088", "underline") -call X("SpellRare", "", "880088", "underline") -call X("SpellLocal", "", "008888", "underline") - -" delete functions {{{ -delf X -delf rgb -delf color -delf rgb_color -delf rgb_level -delf rgb_number -delf grey_color -delf grey_level -delf grey_number -" }}} - -" vim:set ts=4 sw=4 noet fdm=marker: diff --git a/compiler/pylint.vim b/compiler/pylint.vim index 662e7d7..fb2ece5 100644 --- a/compiler/pylint.vim +++ b/compiler/pylint.vim @@ -38,7 +38,6 @@ " other compiler. " - if exists('current_compiler') finish endif diff --git a/doc/tags b/doc/tags index f206a27..2d3704e 100644 --- a/doc/tags +++ b/doc/tags @@ -226,6 +226,7 @@ b:VCSCommandCommand vcscommand.txt /*b:VCSCommandCommand* b:VCSCommandOriginalBuffer vcscommand.txt /*b:VCSCommandOriginalBuffer* b:VCSCommandSourceFile vcscommand.txt /*b:VCSCommandSourceFile* b:VCSCommandVCSType vcscommand.txt /*b:VCSCommandVCSType* +cs surround.txt /*cs* cvscommand-changes vcscommand.txt /*cvscommand-changes* delimitMate delimitMate.txt /*delimitMate* delimitMate#ExpandReturn() delimitMate.txt /*delimitMate#ExpandReturn()* @@ -253,6 +254,7 @@ delimitMateSyntax delimitMate.txt /*delimitMateSyntax* delimitMateTodo delimitMate.txt /*delimitMateTodo* delimitMateVisualWrapping delimitMate.txt /*delimitMateVisualWrapping* delimitMate_WithinEmptyPair delimitMate.txt /*delimitMate_WithinEmptyPair* +ds surround.txt /*ds* fuf fuf.txt /*fuf* fuf-abbreviation fuf.txt /*fuf-abbreviation* fuf-about fuf.txt /*fuf-about* @@ -421,6 +423,8 @@ glvs-install pi_getscript.txt /*glvs-install* glvs-options pi_getscript.txt /*glvs-options* glvs-plugins pi_getscript.txt /*glvs-plugins* glvs-usage pi_getscript.txt /*glvs-usage* +i_CTRL-G_S surround.txt /*i_CTRL-G_S* +i_CTRL-G_s surround.txt /*i_CTRL-G_s* i_CTRL-R_ snipMate.txt /*i_CTRL-R_* list-snippets snipMate.txt /*list-snippets* mark-configuration mark.txt /*mark-configuration* @@ -479,6 +483,15 @@ snipMate.txt snipMate.txt /*snipMate.txt* snippet snipMate.txt /*snippet* snippet-syntax snipMate.txt /*snippet-syntax* snippets snipMate.txt /*snippets* +surround surround.txt /*surround* +surround-author surround.txt /*surround-author* +surround-customizing surround.txt /*surround-customizing* +surround-issues surround.txt /*surround-issues* +surround-mappings surround.txt /*surround-mappings* +surround-replacements surround.txt /*surround-replacements* +surround-targets surround.txt /*surround-targets* +surround.txt surround.txt /*surround.txt* +vS surround.txt /*vS* vcscommand vcscommand.txt /*vcscommand* vcscommand-buffer-management vcscommand.txt /*vcscommand-buffer-management* vcscommand-buffer-variables vcscommand.txt /*vcscommand-buffer-variables* @@ -502,6 +515,7 @@ vcscommand-ssh-other vcscommand.txt /*vcscommand-ssh-other* vcscommand-ssh-wrapper vcscommand.txt /*vcscommand-ssh-wrapper* vcscommand-statusline vcscommand.txt /*vcscommand-statusline* vcscommand.txt vcscommand.txt /*vcscommand.txt* +vgS surround.txt /*vgS* vimwiki vimwiki.txt /*vimwiki* vimwiki-calendar vimwiki.txt /*vimwiki-calendar* vimwiki-changelog vimwiki.txt /*vimwiki-changelog* @@ -576,3 +590,8 @@ vimwiki_i_ vimwiki.txt /*vimwiki_i_* vimwiki_i_ vimwiki.txt /*vimwiki_i_* viwmiki-global-options vimwiki.txt /*viwmiki-global-options* viwmiki-local-options vimwiki.txt /*viwmiki-local-options* +vs surround.txt /*vs* +yS surround.txt /*yS* +ySS surround.txt /*ySS* +ys surround.txt /*ys* +yss surround.txt /*yss* diff --git a/ftplugin/python/common.vim b/ftplugin/python/common.vim new file mode 100644 index 0000000..211c7db --- /dev/null +++ b/ftplugin/python/common.vim @@ -0,0 +1,27 @@ +set cinkeys-=0# +set expandtab +set foldlevel=100 +set foldmethod=indent +set indentkeys-=0# +set list +set noautoindent +set shiftwidth=4 +set smartindent cinwords=if,elif,else,for,while,try,except,finally,def,class,with +set smarttab +set softtabstop=4 +set tabstop=4 +set textwidth=78 + +inoremap # X# + +"set ofu=syntaxcomplete#Complete + +let g:pylint_onwrite = 0 " I don't want to run pylint on every save +compiler pylint + +"autocmd FileType python setlocal omnifunc=pysmell#Complete +let python_highlight_all=1 + +"Load views for py files +autocmd BufWinLeave *.py mkview +autocmd BufWinEnter *.py silent loadview diff --git a/ftplugin/python/jpythonfold.vim b/ftplugin/python/jpythonfold.vim new file mode 100644 index 0000000..fa6e98f --- /dev/null +++ b/ftplugin/python/jpythonfold.vim @@ -0,0 +1,231 @@ +" Fold routines for python code, version 3.2 +" Source: http://www.vim.org/scripts/script.php?script_id=2527 +" Last Change: 2009 Feb 25 +" Author: Jurjen Bos +" Bug fixes and helpful comments: Grissiom, David Froger, Andrew McNabb + +" Principles: +" - a def/class starts a fold +" a line with indent less than the previous def/class ends a fold +" empty lines and comment lines are linked to the previous fold +" comment lines outside a def/class are never folded +" other lines outside a def/class are folded together as a group +" for algorithm, see bottom of script + +" - optionally, you can get empty lines between folds, see (***) +" - another option is to ignore non-python files see (**) +" - you can also modify the def/class check, +" allowing for multiline def and class definitions see (*) + +" Note for vim 7 users: +" Vim 6 line numbers always take 8 columns, while vim 7 has a numberwidth variable +" you can change the 8 below to &numberwidth if you have vim 7, +" this is only really useful when you plan to use more than 8 columns (i.e. never) + +" Note for masochists trying to read this: +" I wanted to keep the functions short, so I replaced occurences of +" if condition +" statement +" by +" if condition | statement +" wherever I found that useful + +" (*) +" class definitions are supposed to ontain a colon on the same line. +" function definitions are *not* required to have a colon, to allow for multiline defs. +" I you disagree, use instead of the pattern '^\s*\(class\s.*:\|def\s\)' +" to enforce : for defs: '^\s*\(class\|def\)\s.*:' +" you'll have to do this in two places. +let s:defpat = '^\s*\(@\|class\s.*:\|def\s\)' + +" (**) Ignore non-python files +" Commented out because some python files are not recognized by Vim +"if &filetype != 'python' +" finish +"endif + +setlocal foldmethod=expr +setlocal foldexpr=GetPythonFold(v:lnum) +setlocal foldtext=PythonFoldText() + +function! PythonFoldText() + let fs = v:foldstart + while getline(fs) =~ '^\s*@' | let fs = nextnonblank(fs + 1) + endwhile + let line = getline(fs) + let nnum = nextnonblank(fs + 1) + let nextline = getline(nnum) + "get the document string: next line is ''' or """ + if nextline =~ "^\\s\\+[\"']\\{3}\\s*$" + let line = line . " " . matchstr(getline(nextnonblank(nnum + 1)), '^\s*\zs.*\ze$') + "next line starts with qoutes, and has text + elseif nextline =~ "^\\s\\+[\"']\\{1,3}" + let line = line." ".matchstr(nextline, "^\\s\\+[\"']\\{1,3}\\zs.\\{-}\\ze['\"]\\{0,3}$") + elseif nextline =~ '^\s\+pass\s*$' + let line = line . ' pass' + endif + "compute the width of the visible part of the window (see Note above) + let w = winwidth(0) - &foldcolumn - (&number ? 8 : 0) + let size = 1 + v:foldend - v:foldstart + "compute expansion string + let spcs = '................' + while strlen(spcs) < w | let spcs = spcs . spcs + endwhile + "expand tabs (mail me if you have tabstop>10) + let onetab = strpart(' ', 0, &tabstop) + let line = substitute(line, '\t', onetab, 'g') + return strpart(line.spcs, 0, w-strlen(size)-7).'.'.size.' lines' +endfunction + +function! GetBlockIndent(lnum) + " Auxiliary function; determines the indent level of the surrounding def/class + " "global" lines are level 0, first def &shiftwidth, and so on + " scan backwards for class/def that is shallower or equal + let ind = 100 + let p = a:lnum+1 + while indent(p) >= 0 + let p = p - 1 + " skip empty and comment lines + if getline(p) =~ '^$\|^\s*#' | continue + " zero-level regular line + elseif indent(p) == 0 | return 0 + " skip deeper or equal lines + elseif indent(p) >= ind || getline(p) =~ '^$\|^\s*#' | continue + " indent is strictly less at this point: check for def/class + elseif getline(p) =~ s:defpat && getline(p) !~ '^\s*@' + " level is one more than this def/class + return indent(p) + &shiftwidth + endif + " shallower line that is neither class nor def: continue search at new level + let ind = indent(p) + endwhile + "beginning of file + return 0 +endfunction + +" Clever debug code, use as: call PrintIfCount(n,"Line: ".a:lnum.", value: ".x) +let s:counter=0 +function! PrintIfCount(n,t) + "Print text the nth time this function is called + let s:counter = s:counter+1 + if s:counter==a:n | echo a:t + endif +endfunction + +function! GetPythonFold(lnum) + " Determine folding level in Python source (see "higher foldlevel theory" below) + let line = getline(a:lnum) + let ind = indent(a:lnum) + " Case D***: class and def start a fold + " If previous line is @, it is not the first + if line =~ s:defpat && getline(prevnonblank(a:lnum-1)) !~ '^\s*@' + " let's see if this range of 0 or more @'s end in a class/def + let n = a:lnum + while getline(n) =~ '^\s*@' | let n = nextnonblank(n + 1) + endwhile + " yes, we have a match: this is the first of a real def/class with decorators + if getline(n) =~ s:defpat + return ">".(ind/&shiftwidth+1) + endif + " Case E***: empty lines fold with previous + " (***) change '=' to -1 if you want empty lines/comment out of a fold + elseif line == '' | return '=' + endif + " now we need the indent from previous + let p = prevnonblank(a:lnum-1) + while p>0 && getline(p) =~ '^\s*#' | let p = prevnonblank(p-1) + endwhile + let pind = indent(p) + " If previous was definition: count as one level deeper + if getline(p) =~ s:defpat && getline(prevnonblank(a:lnum - 1)) !~ '^\s*@' + let pind = pind + &shiftwidth + " if begin of file: take zero + elseif p==0 | let pind = 0 + endif + " Case S*=* and C*=*: indent equal + if ind>0 && ind==pind | return '=' + " Case S*>* and C*>*: indent increase + elseif ind>pind | return '=' + " All cases with 0 indent + elseif ind==0 + " Case C*=0*: separate global code blocks + if pind==0 && line =~ '^#' | return 0 + " Case S*<0* and S*=0*: global code + elseif line !~'^#' + " Case S*<0*: new global statement if/while/for/try/with + if 01' + " Case S*=0*, after level 0 comment + elseif 0==pind && getline(prevnonblank(a:lnum-1)) =~ '^\s*#' | return '>1' + " Case S*=0*, other, stay 1 + else | return '=' + endif + endif + " Case C*<0= and C*<0<: compute next indent + let n = nextnonblank(a:lnum+1) + while n>0 && getline(n) =~'^\s*#' | let n = nextnonblank(n+1) + endwhile + " Case C*<0=: split definitions + if indent(n)==0 | return 0 + " Case C*<0<: shallow comment + else | return -1 + end + endif + " now we really need to compute the actual fold indent + " do the hard computation + let blockindent = GetBlockIndent(a:lnum) + " Case SG<* and CG<*: global code, level 1 + if blockindent==0 | return 1 + endif + " now we need the indent from next + let n = nextnonblank(a:lnum+1) + while n>0 && getline(n) =~'^\s*#' | let n = nextnonblank(n+1) + endwhile + let nind = indent(n) + " Case CR<= and CR<> + "if line !~ '^\s*#' | call PrintIfCount(4,"Line: ".a:lnum.", blockindent: ".blockindent.", n: ".n.", nind: ".nind.", p: ".p.", pind: ".pind) + endif + if line =~ '^\s*#' && ind>=nind | return -1 + " Case CR<<: return next indent + elseif line =~ '^\s*#' | return nind / &shiftwidth + " Case SR<*: return actual indent + else | return blockindent / &shiftwidth + endif +endfunction + +" higher foldlevel theory +" There are five kinds of statements: S (code), D (def/class), E (empty), C (comment) + +" Note that a decorator statement (beginning with @) counts as definition, +" but that of a sequence of @,@,@,def only the first one counts +" This means that a definiion only counts if not preceded by a decorator + +" There are two kinds of folds: R (regular), G (global statements) + +" There are five indent situations with respect to the previous non-emtpy non-comment line: +" > (indent), < (dedent), = (same); < and = combine with 0 (indent is zero) +" Note: if the previous line is class/def, its indent is interpreted as one higher + +" There are three indent situations with respect to the next (non-E non-C) line: +" > (dedent), < (indent), = (same) + +" Situations (in order of the script): +" stat fold prev next +" SDEC RG ><=00 ><= +" D * * * begin fold level if previous is not @: '>'.ind/&sw+1 +" E * * * keep with previous: '=' +" S * = * stays the same: '=' +" C * = * combine with previous: '=' +" S * > * stays the same: '=' +" C * > * combine with previous: '=' +" C * =0 * separate blocks: 0 +" S * <0 * becomes new level 1: >1 (except except/else: 1) +" S * =0 * stays 1: '=' (after level 0 comment: '>1') +" C * <0 = split definitions: 0 +" C * <0 < shallow comment: -1 +" C * <0 > [never occurs] +" S G < * global, not the first: 1 +" C G < * indent isn't 0: 1 +" C R < = foldlevel as computed for next line: -1 +" C R < > foldlevel as computed for next line: -1 +" S R < * compute foldlevel the hard way: use function +" C R < < foldlevel as computed for this line: use function diff --git a/ftplugin/python/pyflakes.vim b/ftplugin/python/pyflakes.vim index 4739c2f..8aa508b 100644 --- a/ftplugin/python/pyflakes.vim +++ b/ftplugin/python/pyflakes.vim @@ -43,6 +43,7 @@ sys.path.insert(0, scriptdir) from pyflakes import checker, ast, messages from operator import attrgetter +import re class SyntaxError(messages.Message): message = 'could not compile: %s' @@ -55,7 +56,20 @@ class blackhole(object): def check(buffer): filename = buffer.name - contents = '\n'.join(buffer[:]) + '\n' + contents = buffer[:] + + # shebang usually found at the top of the file, followed by source code encoding marker. + # assume everything else that follows is encoded in the encoding. + encoding_found = False + for n, line in enumerate(contents): + if not encoding_found: + if re.match(r'^# -\*- coding: .+? -*-', line): + encoding_found = True + else: + # skip all preceeding lines + contents = [''] * n + contents[n:] + break + contents = '\n'.join(contents) + '\n' vimenc = vim.eval('&encoding') if vimenc: diff --git a/ftplugin/rst/commons.vim b/ftplugin/rst/commons.vim new file mode 100644 index 0000000..dca77d4 --- /dev/null +++ b/ftplugin/rst/commons.vim @@ -0,0 +1,4 @@ +set textwidth=80 +set formatoptions+=tn +set makeprg=rst2html.py\ %\ %.html +map :make diff --git a/ftplugin/snippet/common.vim b/ftplugin/snippet/common.vim new file mode 100644 index 0000000..908cd46 --- /dev/null +++ b/ftplugin/snippet/common.vim @@ -0,0 +1,8 @@ +set nolist +set tabstop=4 +set autoindent +"set foldmethod=manual +set noexpandtab +set shiftwidth=4 +set noexpandtab +set list diff --git a/ftplugin/sql/common.vim b/ftplugin/sql/common.vim new file mode 100644 index 0000000..b45b038 --- /dev/null +++ b/ftplugin/sql/common.vim @@ -0,0 +1,4 @@ +set nolist +set nosmartindent +set autoindent +set foldmethod=manual diff --git a/ftplugin/tex/common.vim b/ftplugin/tex/common.vim new file mode 100644 index 0000000..bd19e67 --- /dev/null +++ b/ftplugin/tex/common.vim @@ -0,0 +1,2 @@ +compiler rubber +map :make diff --git a/ftplugin/vim/common.vim b/ftplugin/vim/common.vim new file mode 100644 index 0000000..b45b038 --- /dev/null +++ b/ftplugin/vim/common.vim @@ -0,0 +1,4 @@ +set nolist +set nosmartindent +set autoindent +set foldmethod=manual diff --git a/plugin/delimitMate.vim b/plugin/delimitMate.vim deleted file mode 100644 index 8b59ed1..0000000 --- a/plugin/delimitMate.vim +++ /dev/null @@ -1,124 +0,0 @@ -" ============================================================================ -" File: plugin/delimitMate.vim -" Version: 2.3.1 -" Modified: 2010-06-06 -" Description: This plugin provides auto-completion for quotes, parens, etc. -" Maintainer: Israel Chauca F. -" Manual: Read ":help delimitMate". - -" Initialization: {{{ -if exists("g:loaded_delimitMate") "{{{ - " User doesn't want this plugin, let's get out! - finish -endif -let g:loaded_delimitMate = 1 - -if exists("s:loaded_delimitMate") && !exists("g:delimitMate_testing") - " Don't define the functions if they already exist: just do the work - " (unless we are testing): - call s:DelimitMateDo() - finish -endif - -if v:version < 700 - echoerr "delimitMate: this plugin requires vim >= 7!" - finish -endif - -let s:loaded_delimitMate = 1 " }}} -let delimitMate_version = "2.3.1" - -"}}} - -" Tools: {{{ -function! s:TestMappingsDo() "{{{ - if !exists("g:delimitMate_testing") - silent call delimitMate#TestMappings() - else - let temp_varsDM = [b:delimitMate_expand_space, b:delimitMate_expand_cr, b:delimitMate_autoclose] - for i in [0,1] - let b:delimitMate_expand_space = i - let b:delimitMate_expand_cr = i - for a in [0,1] - let b:delimitMate_autoclose = a - call delimitMate#Init() - call delimitMate#TestMappings() - exec "normal i\" - endfor - endfor - let b:delimitMate_expand_space = temp_varsDM[0] - let b:delimitMate_expand_cr = temp_varsDM[1] - let b:delimitMate_autoclose = temp_varsDM[2] - unlet temp_varsDM - endif - normal gg -endfunction "}}} - -function! s:DelimitMateDo(...) "{{{ - if exists("g:delimitMate_excluded_ft") - " Check if this file type is excluded: - for ft in split(g:delimitMate_excluded_ft,',') - if ft ==? &filetype - "echomsg "excluded" - call delimitMate#UnMap() - return 1 - endif - endfor - endif - try - "echomsg "included" - let save_cpo = &cpo - let save_keymap = &keymap - set keymap= - set cpo&vim - call delimitMate#Init() - finally - let &cpo = save_cpo - let &keymap = save_keymap - endtry - if a:0 > 0 - echo "delimitMate has been reset." - endif -endfunction "}}} - -function! s:DelimitMateSwitch() "{{{ - if b:delimitMate_enabled - call delimitMate#UnMap() - echo "delimitMate has been disabled." - else - call delimitMate#Init() - echo "delimitMate has been enabled." - endif -endfunction "}}} - -"}}} - -" Commands: {{{ -call s:DelimitMateDo() - -" Let me refresh without re-loading the buffer: -command! DelimitMateReload call s:DelimitMateDo(1) - -" Quick test: -command! DelimitMateTest call s:TestMappingsDo() - -" Switch On/Off: -command! DelimitMateSwitch call s:DelimitMateSwitch() - -" Run on file type events. -"autocmd VimEnter * autocmd FileType * call DelimitMateDo() -autocmd FileType * call DelimitMateDo() - -" Run on new buffers. -autocmd BufNewFile,BufRead,BufEnter * if !exists("b:loaded_delimitMate") | call DelimitMateDo() | endif - -" Flush the char buffer: -autocmd InsertEnter * call delimitMate#FlushBuffer() -autocmd BufEnter * if mode() == 'i' | call delimitMate#FlushBuffer() | endif - -"function! s:GetSynRegion () | echo synIDattr(synIDtrans(synID(line('.'), col('.'), 1)), 'name') | endfunction - -"}}} - -" GetLatestVimScripts: 2754 1 :AutoInstall: delimitMate.vim -" vim:foldmethod=marker:foldcolumn=4 diff --git a/plugin/pydoc.vim b/plugin/pydoc.vim new file mode 100644 index 0000000..559c748 --- /dev/null +++ b/plugin/pydoc.vim @@ -0,0 +1,106 @@ +"pydoc.vim: pydoc integration for vim +"performs searches and can display the documentation of python modules +"Author: André Kelpe +"Author: Romain Chossart +"Author: Matthias Vogelgesang +"http://www.vim.org/scripts/script.php?script_id=910 +"This plugin integrates the pydoc into vim. You can view the +"documentation of a module by using :Pydoc foo.bar.baz or search +"a word (uses pydoc -k) in the documentation by typing PydocSearch +"foobar. You can also view the documentation of the word under the +"cursor by pressing pw or the WORD (see :help WORD) by pressing +"pW. "This is very useful if you want to jump to a module which was found by +"PydocSearch. To have a browser like feeling you can use u and CTRL-R to +"go back and forward, just like editing normal text. + +"If you want to use the script and pydoc is not in your PATH, just put a +"line like + +" let g:pydoc_cmd = \"/usr/bin/pydoc" (without the backslash!!) + +"in your .vimrc + + +"pydoc.vim is free software, you can redistribute or modify +"it under the terms of the GNU General Public License Version 2 or any +"later Version (see http://www.gnu.org/copyleft/gpl.html for details). + +"Please feel free to contact me. + + +set switchbuf=useopen +function! ShowPyDoc(name, type) + if !exists('g:pydoc_cmd') + let g:pydoc_cmd = 'pydoc' + endif + + if bufloaded("__doc__") >0 + let l:buf_is_new = 0 + else + let l:buf_is_new = 1 + endif + + if bufnr("__doc__") >0 + execute "sb __doc__" + else + execute 'split __doc__' + endif + setlocal noswapfile + set buftype=nofile + setlocal modifiable + normal ggdG + let s:name2 = substitute(a:name, '(.*', '', 'g' ) + let s:name2 = substitute(a:name, ':', '', 'g' ) + if a:type==1 + execute "silent read ! " . g:pydoc_cmd . " " . s:name2 + else + execute "silent read ! " . g:pydoc_cmd . " -k " . s:name2 + endif + setlocal nomodified + set filetype=man + normal 1G + + if !exists('g:pydoc_wh') + let g:pydoc_wh = 10 + end + resize -999 + execute "silent resize +" . g:pydoc_wh + + if !exists('g:pydoc_highlight') + let g:pydoc_highlight = 1 + endif + if g:pydoc_highlight == 1 + call Highlight(s:name2) + endif + + let l:line = getline(2) + if l:line =~ "^no Python documentation found for.*$" + if l:buf_is_new + execute "bd!" + else + normal u + endif + redraw + echohl WarningMsg | echo l:line | echohl None + endif +endfunction + + +function! Highlight(name) + execute "sb __doc__" + set filetype=man + syn on + execute 'syntax keyword pydoc '.s:name2 + hi pydoc gui=reverse +endfunction + + +"mappings +au FileType python,man map pw :call ShowPyDoc('', 1) +au FileType python,man map pW :call ShowPyDoc('', 1) +au FileType python,man map pk :call ShowPyDoc('', 0) +au FileType python,man map pK :call ShowPyDoc('', 0) + +"commands +command -nargs=1 Pydoc :call ShowPyDoc('', 1) +command -nargs=* PydocSearch :call ShowPyDoc('', 0) diff --git a/plugin/surround.vim b/plugin/surround.vim new file mode 100644 index 0000000..ea28c02 --- /dev/null +++ b/plugin/surround.vim @@ -0,0 +1,625 @@ +" surround.vim - Surroundings +" Author: Tim Pope +" Version: 1.90 +" GetLatestVimScripts: 1697 1 :AutoInstall: surround.vim +" +" See surround.txt for help. This can be accessed by doing +" +" :helptags ~/.vim/doc +" :help surround +" +" Licensed under the same terms as Vim itself. + +" ============================================================================ + +" Exit quickly when: +" - this plugin was already loaded or disabled +" - when 'compatible' is set +if (exists("g:loaded_surround") && g:loaded_surround) || &cp + finish +endif +let g:loaded_surround = 1 + +let s:cpo_save = &cpo +set cpo&vim + +" Input functions {{{1 + +function! s:getchar() + let c = getchar() + if c =~ '^\d\+$' + let c = nr2char(c) + endif + return c +endfunction + +function! s:inputtarget() + let c = s:getchar() + while c =~ '^\d\+$' + let c = c . s:getchar() + endwhile + if c == " " + let c = c . s:getchar() + endif + if c =~ "\\|\\|\0" + return "" + else + return c + endif +endfunction + +function! s:inputreplacement() + "echo '-- SURROUND --' + let c = s:getchar() + if c == " " + let c = c . s:getchar() + endif + if c =~ "\" || c =~ "\" + return "" + else + return c + endif +endfunction + +function! s:beep() + exe "norm! \" + return "" +endfunction + +function! s:redraw() + redraw + return "" +endfunction + +" }}}1 + +" Wrapping functions {{{1 + +function! s:extractbefore(str) + if a:str =~ '\r' + return matchstr(a:str,'.*\ze\r') + else + return matchstr(a:str,'.*\ze\n') + endif +endfunction + +function! s:extractafter(str) + if a:str =~ '\r' + return matchstr(a:str,'\r\zs.*') + else + return matchstr(a:str,'\n\zs.*') + endif +endfunction + +function! s:repeat(str,count) + let cnt = a:count + let str = "" + while cnt > 0 + let str = str . a:str + let cnt = cnt - 1 + endwhile + return str +endfunction + +function! s:fixindent(str,spc) + let str = substitute(a:str,'\t',s:repeat(' ',&sw),'g') + let spc = substitute(a:spc,'\t',s:repeat(' ',&sw),'g') + let str = substitute(str,'\(\n\|\%^\).\@=','\1'.spc,'g') + if ! &et + let str = substitute(str,'\s\{'.&ts.'\}',"\t",'g') + endif + return str +endfunction + +function! s:process(string) + let i = 0 + while i < 7 + let i = i + 1 + let repl_{i} = '' + let m = matchstr(a:string,nr2char(i).'.\{-\}\ze'.nr2char(i)) + if m != '' + let m = substitute(strpart(m,1),'\r.*','','') + let repl_{i} = input(substitute(m,':\s*$','','').': ') + endif + endwhile + let s = "" + let i = 0 + while i < strlen(a:string) + let char = strpart(a:string,i,1) + if char2nr(char) < 8 + let next = stridx(a:string,char,i+1) + if next == -1 + let s = s . char + else + let insertion = repl_{char2nr(char)} + let subs = strpart(a:string,i+1,next-i-1) + let subs = matchstr(subs,'\r.*') + while subs =~ '^\r.*\r' + let sub = matchstr(subs,"^\r\\zs[^\r]*\r[^\r]*") + let subs = strpart(subs,strlen(sub)+1) + let r = stridx(sub,"\r") + let insertion = substitute(insertion,strpart(sub,0,r),strpart(sub,r+1),'') + endwhile + let s = s . insertion + let i = next + endif + else + let s = s . char + endif + let i = i + 1 + endwhile + return s +endfunction + +function! s:wrap(string,char,type,...) + let keeper = a:string + let newchar = a:char + let type = a:type + let linemode = type ==# 'V' ? 1 : 0 + let special = a:0 ? a:1 : 0 + let before = "" + let after = "" + if type ==# "V" + let initspaces = matchstr(keeper,'\%^\s*') + else + let initspaces = matchstr(getline('.'),'\%^\s*') + endif + " Duplicate b's are just placeholders (removed) + let pairs = "b()B{}r[]a<>" + let extraspace = "" + if newchar =~ '^ ' + let newchar = strpart(newchar,1) + let extraspace = ' ' + endif + let idx = stridx(pairs,newchar) + if newchar == ' ' + let before = '' + let after = '' + elseif exists("b:surround_".char2nr(newchar)) + let all = s:process(b:surround_{char2nr(newchar)}) + let before = s:extractbefore(all) + let after = s:extractafter(all) + elseif exists("g:surround_".char2nr(newchar)) + let all = s:process(g:surround_{char2nr(newchar)}) + let before = s:extractbefore(all) + let after = s:extractafter(all) + elseif newchar ==# "p" + let before = "\n" + let after = "\n\n" + elseif newchar =~# "[tT\<,]" + let dounmapp = 0 + let dounmapb = 0 + if !maparg(">","c") + let dounmapb= 1 + " Hide from AsNeeded + exe "cn"."oremap > " + endif + let default = "" + if newchar ==# "T" + if !exists("s:lastdel") + let s:lastdel = "" + endif + let default = matchstr(s:lastdel,'<\zs.\{-\}\ze>') + endif + let tag = input("<",default) + echo "<".substitute(tag,'>*$','>','') + if dounmapb + silent! cunmap > + endif + if tag != "" + let tag = substitute(tag,'>*$','','') + let before = '<'.tag.'>' + if tag =~ '/$' + let after = '' + else + let after = '' + endif + if newchar == "\" || newchar == "," + if type ==# "v" || type ==# "V" + let before = before . "\n\t" + endif + if type ==# "v" + let after = "\n". after + endif + endif + endif + elseif newchar ==# 'l' || newchar == '\' + " LaTeX + let env = input('\begin{') + let env = '{' . env + let env = env . s:closematch(env) + echo '\begin'.env + if env != "" + let before = '\begin'.env + let after = '\end'.matchstr(env,'[^}]*').'}' + endif + "if type ==# 'v' || type ==# 'V' + "let before = before ."\n\t" + "endif + "if type ==# 'v' + "let after = "\n".initspaces.after + "endif + elseif newchar ==# 'f' || newchar ==# 'F' + let fnc = input('function: ') + if fnc != "" + let before = substitute(fnc,'($','','').'(' + let after = ')' + if newchar ==# 'F' + let before = before . ' ' + let after = ' ' . after + endif + endif + elseif idx >= 0 + let spc = (idx % 3) == 1 ? " " : "" + let idx = idx / 3 * 3 + let before = strpart(pairs,idx+1,1) . spc + let after = spc . strpart(pairs,idx+2,1) + elseif newchar == "\" || newchar == "\" + let before = "{\n\t" + let after = "\n}" + elseif newchar !~ '\a' + let before = newchar + let after = newchar + else + let before = '' + let after = '' + endif + "let before = substitute(before,'\n','\n'.initspaces,'g') + let after = substitute(after ,'\n','\n'.initspaces,'g') + "let after = substitute(after,"\n\\s*\\\s*",'\n','g') + if type ==# 'V' || (special && type ==# "v") + let before = substitute(before,' \+$','','') + let after = substitute(after ,'^ \+','','') + if after !~ '^\n' + let after = initspaces.after + endif + if keeper !~ '\n$' && after !~ '^\n' + let keeper = keeper . "\n" + elseif keeper =~ '\n$' && after =~ '^\n' + let after = strpart(after,1) + endif + if before !~ '\n\s*$' + let before = before . "\n" + if special + let before = before . "\t" + endif + endif + endif + if type ==# 'V' + let before = initspaces.before + endif + if before =~ '\n\s*\%$' + if type ==# 'v' + let keeper = initspaces.keeper + endif + let padding = matchstr(before,'\n\zs\s\+\%$') + let before = substitute(before,'\n\s\+\%$','\n','') + let keeper = s:fixindent(keeper,padding) + endif + if type ==# 'V' + let keeper = before.keeper.after + elseif type =~ "^\" + " Really we should be iterating over the buffer + let repl = substitute(before,'[\\~]','\\&','g').'\1'.substitute(after,'[\\~]','\\&','g') + let repl = substitute(repl,'\n',' ','g') + let keeper = substitute(keeper."\n",'\(.\{-\}\)\(\n\)',repl.'\n','g') + let keeper = substitute(keeper,'\n\%$','','') + else + let keeper = before.extraspace.keeper.extraspace.after + endif + return keeper +endfunction + +function! s:wrapreg(reg,char,...) + let orig = getreg(a:reg) + let type = substitute(getregtype(a:reg),'\d\+$','','') + let special = a:0 ? a:1 : 0 + let new = s:wrap(orig,a:char,type,special) + call setreg(a:reg,new,type) +endfunction +" }}}1 + +function! s:insert(...) " {{{1 + " Optional argument causes the result to appear on 3 lines, not 1 + "call inputsave() + let linemode = a:0 ? a:1 : 0 + let char = s:inputreplacement() + while char == "\" || char == "\" + " TODO: use total count for additional blank lines + let linemode = linemode + 1 + let char = s:inputreplacement() + endwhile + "call inputrestore() + if char == "" + return "" + endif + "call inputsave() + let cb_save = &clipboard + set clipboard-=unnamed + let reg_save = @@ + call setreg('"',"\r",'v') + call s:wrapreg('"',char,linemode) + " If line mode is used and the surrounding consists solely of a suffix, + " remove the initial newline. This fits a use case of mine but is a + " little inconsistent. Is there anyone that would prefer the simpler + " behavior of just inserting the newline? + if linemode && match(getreg('"'),'^\n\s*\zs.*') == 0 + call setreg('"',matchstr(getreg('"'),'^\n\s*\zs.*'),getregtype('"')) + endif + " This can be used to append a placeholder to the end + if exists("g:surround_insert_tail") + call setreg('"',g:surround_insert_tail,"a".getregtype('"')) + endif + "if linemode + "call setreg('"',substitute(getreg('"'),'^\s\+','',''),'c') + "endif + if col('.') >= col('$') + norm! ""p + else + norm! ""P + endif + if linemode + call s:reindent() + endif + norm! `] + call search('\r','bW') + let @@ = reg_save + let &clipboard = cb_save + return "\" +endfunction " }}}1 + +function! s:reindent() " {{{1 + if exists("b:surround_indent") ? b:surround_indent : (exists("g:surround_indent") && g:surround_indent) + silent norm! '[='] + endif +endfunction " }}}1 + +function! s:dosurround(...) " {{{1 + let scount = v:count1 + let char = (a:0 ? a:1 : s:inputtarget()) + let spc = "" + if char =~ '^\d\+' + let scount = scount * matchstr(char,'^\d\+') + let char = substitute(char,'^\d\+','','') + endif + if char =~ '^ ' + let char = strpart(char,1) + let spc = 1 + endif + if char == 'a' + let char = '>' + endif + if char == 'r' + let char = ']' + endif + let newchar = "" + if a:0 > 1 + let newchar = a:2 + if newchar == "\" || newchar == "\" || newchar == "" + return s:beep() + endif + endif + let cb_save = &clipboard + set clipboard-=unnamed + let append = "" + let original = getreg('"') + let otype = getregtype('"') + call setreg('"',"") + let strcount = (scount == 1 ? "" : scount) + if char == '/' + exe 'norm! '.strcount.'[/d'.strcount.']/' + else + exe 'norm! d'.strcount.'i'.char + endif + let keeper = getreg('"') + let okeeper = keeper " for reindent below + if keeper == "" + call setreg('"',original,otype) + let &clipboard = cb_save + return "" + endif + let oldline = getline('.') + let oldlnum = line('.') + if char ==# "p" + call setreg('"','','V') + elseif char ==# "s" || char ==# "w" || char ==# "W" + " Do nothing + call setreg('"','') + elseif char =~ "[\"'`]" + exe "norm! i \d2i".char + call setreg('"',substitute(getreg('"'),' ','','')) + elseif char == '/' + norm! "_x + call setreg('"','/**/',"c") + let keeper = substitute(substitute(keeper,'^/\*\s\=','',''),'\s\=\*$','','') + else + " One character backwards + call search('.','bW') + exe "norm! da".char + endif + let removed = getreg('"') + let rem2 = substitute(removed,'\n.*','','') + let oldhead = strpart(oldline,0,strlen(oldline)-strlen(rem2)) + let oldtail = strpart(oldline, strlen(oldline)-strlen(rem2)) + let regtype = getregtype('"') + if char =~# '[\[({Dsurround".char,scount) + else + silent! call repeat#set("\Csurround".char.newchar,scount) + endif +endfunction " }}}1 + +function! s:changesurround() " {{{1 + let a = s:inputtarget() + if a == "" + return s:beep() + endif + let b = s:inputreplacement() + if b == "" + return s:beep() + endif + call s:dosurround(a,b) +endfunction " }}}1 + +function! s:opfunc(type,...) " {{{1 + let char = s:inputreplacement() + if char == "" + return s:beep() + endif + let reg = '"' + let sel_save = &selection + let &selection = "inclusive" + let cb_save = &clipboard + set clipboard-=unnamed + let reg_save = getreg(reg) + let reg_type = getregtype(reg) + "call setreg(reg,"\n","c") + let type = a:type + if a:type == "char" + silent exe 'norm! v`[o`]"'.reg.'y' + let type = 'v' + elseif a:type == "line" + silent exe 'norm! `[V`]"'.reg.'y' + let type = 'V' + elseif a:type ==# "v" || a:type ==# "V" || a:type ==# "\" + let ve = &virtualedit + if !(a:0 && a:1) + set virtualedit= + endif + silent exe 'norm! gv"'.reg.'y' + let &virtualedit = ve + elseif a:type =~ '^\d\+$' + let type = 'v' + silent exe 'norm! ^v'.a:type.'$h"'.reg.'y' + if mode() ==# 'v' + norm! v + return s:beep() + endif + else + let &selection = sel_save + let &clipboard = cb_save + return s:beep() + endif + let keeper = getreg(reg) + if type ==# "v" && a:type !=# "v" + let append = matchstr(keeper,'\_s\@Y".(a:0 && a:1 ? "S" : "s")."surround".char,a:type) + endif +endfunction + +function! s:opfunc2(arg) + call s:opfunc(a:arg,1) +endfunction " }}}1 + +function! s:closematch(str) " {{{1 + " Close an open (, {, [, or < on the command line. + let tail = matchstr(a:str,'.[^\[\](){}<>]*$') + if tail =~ '^\[.\+' + return "]" + elseif tail =~ '^(.\+' + return ")" + elseif tail =~ '^{.\+' + return "}" + elseif tail =~ '^<.+' + return ">" + else + return "" + endif +endfunction " }}}1 + +nnoremap Dsurround :call dosurround(inputtarget()) +nnoremap Csurround :call changesurround() +nnoremap Yssurround :call opfunc(v:count1) +nnoremap YSsurround :call opfunc2(v:count1) +" discards the numerical argument but there's not much we can do with it +nnoremap Ysurround :set opfunc=opfuncg@ +nnoremap YSurround :set opfunc=opfunc2g@ +vnoremap Vsurround :call opfunc(visualmode()) +vnoremap VSurround :call opfunc(visualmode(),visualmode() ==# 'V' ? 1 : 0) +vnoremap VgSurround :call opfunc(visualmode(),visualmode() ==# 'V' ? 0 : 1) +inoremap Isurround =insert() +inoremap ISurround =insert(1) + +if !exists("g:surround_no_mappings") || ! g:surround_no_mappings + nmap ds Dsurround + nmap cs Csurround + nmap ys Ysurround + nmap yS YSurround + nmap yss Yssurround + nmap ySs YSsurround + nmap ySS YSsurround + if !hasmapto("Vsurround","v") && !hasmapto("VSurround","v") + if exists(":xmap") + xmap s Vsurround + else + vmap s Vsurround + endif + endif + if !hasmapto("VSurround","v") + if exists(":xmap") + xmap S VSurround + else + vmap S VSurround + endif + endif + if exists(":xmap") + xmap gS VgSurround + else + vmap gS VgSurround + endif + if !hasmapto("Isurround","i") && "" == mapcheck("","i") + imap Isurround + endif + imap s Isurround + imap S ISurround + "Implemented internally instead + "imap ISurround +endif + +let &cpo = s:cpo_save + +" vim:set ft=vim sw=2 sts=2 et: diff --git a/snippets/rst.snippets b/snippets/rst.snippets new file mode 100644 index 0000000..53ff146 --- /dev/null +++ b/snippets/rst.snippets @@ -0,0 +1,52 @@ +snippet author + :Author: ${1}|${2:file-as}|${3:aut} +snippet creator + :Creator: ${1}|${2:file-as}|${3:aut} +snippet contributor + :Contributor: ${1}|${2:file-as}|${3:ill} +snippet organization + :Organization: ${1} +snippet address + :Address: ${1} +snippet contact + :Contact: ${1} +snippet version + :Version: ${1} +snippet revision + :Revision: ${1} +snippet status + :Status: ${1} +snippet copyright + :Copyright: ${1} +snippet rights + :Rights: ${1} +snippet type + :Type: ${1} +snippet language + :Language: ${1:en} +snippet title + :Title: ${1:title} +snippet Description + :Description: ${1} +snippet publisher + :Publisher: ${1} +snippet pubdate + :Date: ${1:2001-02-01} +snippet format + :Format: ${1} +snippet identifier + :Identifier: ${1} +snippet source + :Source: ${1} +snippet relation + :Relation: ${1} +snippet coverage + :Coverage: ${1} +snippet rights + :Rights: ${1} +snippet subject + :Subject: ${1} +snippet code + .. sourcecode:: ${1:python} + + ${2} diff --git a/syntax/tmux.vim b/syntax/tmux.vim new file mode 100644 index 0000000..58bceca --- /dev/null +++ b/syntax/tmux.vim @@ -0,0 +1,103 @@ +" Vim syntax file +" Language: tmux(1) configuration file +" Maintainer: Tiago Cunha +" Last Change: $Date: 2010/07/02 02:46:39 $ +" License: This file is placed in the public domain. + +if version < 600 + syntax clear +elseif exists("b:current_syntax") + finish +endif + +setlocal iskeyword+=- +syntax case match + +syn keyword tmuxAction any current none +syn keyword tmuxBoolean off on + +syn keyword tmuxCmds detach[-client] ls list-sessions neww new-window +syn keyword tmuxCmds bind[-key] unbind[-key] prev[ious-window] last[-window] +syn keyword tmuxCmds lsk list-keys set[-option] renamew rename-window selectw +syn keyword tmuxCmds select-window lsw list-windows attach[-session] +syn keyword tmuxCmds send-prefix refresh[-client] killw kill-window lsc +syn keyword tmuxCmds list-clients linkw link-window unlinkw unlink-window +syn keyword tmuxCmds next[-window] send[-keys] swapw swap-window +syn keyword tmuxCmds rename[-session] kill-session switchc switch-client +syn keyword tmuxCmds has[-session] copy-mode pasteb paste-buffer +syn keyword tmuxCmds new[-session] start[-server] kill-server setw +syn keyword tmuxCmds set-window-option show[-options] showw show-window-options +syn keyword tmuxCmds command-prompt setb set-buffer showb show-buffer lsb +syn keyword tmuxCmds list-buffers deleteb delete-buffer lscm list-commands +syn keyword tmuxCmds movew move-window respawnw respawn-window +syn keyword tmuxCmds source[-file] info server-info clock-mode lock[-server] +syn keyword tmuxCmds saveb save-buffer downp down-pane killp +syn keyword tmuxCmds kill-pane resizep resize-pane selectp select-pane swapp +syn keyword tmuxCmds swap-pane splitw split-window upp up-pane choose-session +syn keyword tmuxCmds choose-window loadb load-buffer copyb copy-buffer suspendc +syn keyword tmuxCmds suspend-client findw find-window breakp break-pane nextl +syn keyword tmuxCmds next-layout rotatew rotate-window confirm[-before] +syn keyword tmuxCmds clearhist clear-history selectl select-layout if[-shell] +syn keyword tmuxCmds display[-message] setenv set-environment showenv +syn keyword tmuxCmds show-environment choose-client displayp display-panes +syn keyword tmuxCmds run[-shell] lockc lock-client locks lock-session lsp +syn keyword tmuxCmds list-panes pipep pipe-pane showmsgs show-messages capturep +syn keyword tmuxCmds capture-pane joinp join-pane choose-buffer + +syn keyword tmuxOptsSet prefix status status-fg status-bg bell-action +syn keyword tmuxOptsSet default-command history-limit status-left status-right +syn keyword tmuxOptsSet status-interval set-titles display-time buffer-limit +syn keyword tmuxOptsSet status-left-length status-right-length message-fg +syn keyword tmuxOptsSet message-bg lock-after-time default-path repeat-time +syn keyword tmuxOptsSet message-attr status-attr status-keys set-remain-on-exit +syn keyword tmuxOptsSet status-utf8 default-terminal visual-activity +syn keyword tmuxOptsSet visual-bell visual-content status-justify +syn keyword tmuxOptsSet terminal-overrides status-left-attr status-left-bg +syn keyword tmuxOptsSet status-left-fg status-right-attr status-right-bg +syn keyword tmuxOptsSet status-right-fg update-environment base-index +syn keyword tmuxOptsSet display-panes-colour display-panes-time default-shell +syn keyword tmuxOptsSet set-titles-string lock-command lock-server +syn keyword tmuxOptsSet mouse-select-pane message-limit quiet escape-time +syn keyword tmuxOptsSet pane-active-border-bg pane-active-border-fg +syn keyword tmuxOptsSet pane-border-bg pane-border-fg +syn keyword tmuxOptsSet display-panes-active-colour alternate-screen +syn keyword tmuxOptsSet detach-on-destroy + +syn keyword tmuxOptsSetw monitor-activity aggressive-resize force-width +syn keyword tmuxOptsSetw force-height remain-on-exit uft8 mode-fg mode-bg +syn keyword tmuxOptsSetw mode-keys clock-mode-colour clock-mode-style +syn keyword tmuxOptsSetw xterm-keys mode-attr window-status-attr +syn keyword tmuxOptsSetw window-status-bg window-status-fg automatic-rename +syn keyword tmuxOptsSetw main-pane-width main-pane-height monitor-content +syn keyword tmuxOptsSetw window-status-current-attr window-status-current-bg +syn keyword tmuxOptsSetw window-status-current-fg mode-mouse synchronize-panes +syn keyword tmuxOptsSetw window-status-format window-status-current-format +syn keyword tmuxOptsSetw word-separators + +syn keyword tmuxTodo FIXME NOTE TODO XXX contained + +syn match tmuxKey /\(C-\|M-\|\^\)\p/ display +syn match tmuxNumber /\d\+/ display +syn match tmuxOptions /\s-\a\+/ display +syn match tmuxVariable /\w\+=/ display +syn match tmuxVariableExpansion /\${\=\w\+}\=/ display + +syn region tmuxComment start=/#/ end=/$/ contains=tmuxTodo display oneline +syn region tmuxString start=/"/ end=/"/ display oneline +syn region tmuxString start=/'/ end=/'/ display oneline + +hi def link tmuxAction Boolean +hi def link tmuxBoolean Boolean +hi def link tmuxCmds Keyword +hi def link tmuxComment Comment +hi def link tmuxKey Special +hi def link tmuxNumber Number +hi def link tmuxOptions Identifier +hi def link tmuxOptsSet Function +hi def link tmuxOptsSetw Function +hi def link tmuxString String +hi def link tmuxTodo Todo +hi def link tmuxVariable Constant +hi def link tmuxVariableExpansion Constant + +let b:current_syntax = "tmux"