GLVS
Change-Id: I73fb1df3adaba7a1248c20664f1654372ad7223e
This commit is contained in:
parent
2c209be16f
commit
82ed35903e
@ -22,11 +22,11 @@ ScriptID SourceID Filename
|
||||
3745 22834 LineDiff
|
||||
39 8196 matchit.vim
|
||||
2092 8095 reloaded.vim (matrix colorscheme)
|
||||
848 14668 SrchRplcHiGrp.vim (Search/Replace on Syntax Group)
|
||||
848 23549 SrchRplcHiGrp.vim (Search/Replace on Syntax Group)
|
||||
294 19633 Align.vim
|
||||
479 9276 MultipleSearch.vba
|
||||
1066 7618 cecutil.vim
|
||||
1173 22422 tComment.vim
|
||||
1173 23636 tComment.vim
|
||||
2701 18988 editsrec
|
||||
3280 14334 Tabbi
|
||||
642 15781 getscript.vim
|
||||
@ -38,6 +38,6 @@ ScriptID SourceID Filename
|
||||
2975 22815 fugitive.vim
|
||||
2830 22798 csv.vim
|
||||
3849 22637 git-time-lapse
|
||||
4932 22924 diffchar.vim
|
||||
4955 22916 Merginal
|
||||
4932 24088 diffchar.vim
|
||||
4955 24218 Merginal
|
||||
3574 16307 gitv: gitk for Vim
|
||||
|
537
vimfiles/autoload/SrchRplcHiGrp.vim
Normal file
537
vimfiles/autoload/SrchRplcHiGrp.vim
Normal file
@ -0,0 +1,537 @@
|
||||
" SrchRplcHiGrp.vim - Search and Replace based on a highlight group
|
||||
"
|
||||
" Version: 7.0
|
||||
" Author: David Fishburn <dfishburn dot vim at gmail dot com>
|
||||
" Last Changed: 2015 Aug 25
|
||||
" Created: Tue Dec 02 2003 10:11:07 PM
|
||||
" Description: Search and Replace based on a syntax highlight group
|
||||
" Script: http://www.vim.org/script.php?script_id=848
|
||||
" License: GPL (http://www.gnu.org/licenses/gpl.html)
|
||||
"
|
||||
" Command Help: {{{
|
||||
" Ensure you have updated the help system:
|
||||
" :helptags $VIM/vimfiles/doc (Windows)
|
||||
" :helptags $VIM/.vim/doc (*nix)
|
||||
"
|
||||
" :h SRHiGrp
|
||||
" }}}
|
||||
|
||||
" If syntax is not enabled, do not bother loading this plugin
|
||||
if exists('g:loaded_srhg_auto') || !exists("syntax_on") || &cp
|
||||
finish
|
||||
endif
|
||||
let g:loaded_srhg_auto = 7
|
||||
|
||||
" Turn on support for line continuations when creating the script
|
||||
let s:cpo_save = &cpo
|
||||
set cpo&vim
|
||||
|
||||
" Default the highlight group to 0
|
||||
let s:srhg_group_id = 0
|
||||
let s:srhg_firstline = 0
|
||||
let s:srhg_lastline = 0
|
||||
|
||||
" SRWarningMsg:
|
||||
function! <SID>SRWarningMsg(msg) "{{{
|
||||
echohl WarningMsg
|
||||
echomsg a:msg
|
||||
echohl None
|
||||
endfunction "}}}
|
||||
|
||||
" SRDispHiGrp:
|
||||
" Echos the currently selected highlight group name to the screen.
|
||||
" If a parameter is supplied, it will display the message in the
|
||||
" colour of the group name.
|
||||
function! SrchRplcHiGrp#SRDispHiGrp(...) "{{{
|
||||
if s:srhg_group_id != 0
|
||||
if s:srhg_group_id < 0
|
||||
let gid = -s:srhg_group_id
|
||||
else
|
||||
let gid = s:srhg_group_id
|
||||
endif
|
||||
|
||||
if a:0 > 0 && strlen(a:1) > 0
|
||||
let msg = a:1
|
||||
else
|
||||
let msg = "SRHiGrp - Group ID: " .gid . " Name: " . synIDattr(gid,"name")
|
||||
endif
|
||||
|
||||
exec 'echohl ' . synIDattr(gid, "name")
|
||||
exec "echomsg '" . msg . "'"
|
||||
echohl None
|
||||
else
|
||||
echo "No highlight group has been choosen yet"
|
||||
endif
|
||||
endfunction "}}}
|
||||
|
||||
" SRChooseHiGrp:
|
||||
" Sets the script variable s:srhg_group_id to the value
|
||||
" of the highlight group underneath the current cursor
|
||||
" position.
|
||||
function! SrchRplcHiGrp#SRChooseHiGrp(use_top_level, ...) "{{{
|
||||
if a:0 > 0 && strlen(a:1) > 0
|
||||
let cursynid = a:1 + 0
|
||||
else
|
||||
if a:use_top_level == 1
|
||||
let cursynid = -synID(line("."),col("."),1)
|
||||
else
|
||||
let cursynid = synIDtrans(synID(line("."),col("."),1))
|
||||
endif
|
||||
endif
|
||||
|
||||
if cursynid == 0
|
||||
call s:SRWarningMsg(
|
||||
\ 'There is no syntax group specified ' .
|
||||
\ 'under the cursor'
|
||||
\ )
|
||||
else
|
||||
let s:srhg_group_id = cursynid
|
||||
call SrchRplcHiGrp#SRDispHiGrp()
|
||||
endif
|
||||
endfunction "}}}
|
||||
|
||||
" SRHiGrp:
|
||||
" Traverses the region selected and performs all search and
|
||||
" replaces over the region for the selected highlight group.
|
||||
function! SrchRplcHiGrp#SRHiGrp(...) range "{{{
|
||||
|
||||
let s:srhg_firstline = a:firstline
|
||||
let s:srhg_lastline = a:lastline
|
||||
|
||||
if s:srhg_group_id == 0
|
||||
call s:SRWarningMsg(
|
||||
\ 'You must specify a syntax group name ' .
|
||||
\ 'by placing the cursor on a character ' .
|
||||
\ 'that is highlighted the way you want ' .
|
||||
\ 'and execute :SRChooseHiGrp or ' .
|
||||
\ ':SRChooseHiGrp!'
|
||||
\ )
|
||||
return
|
||||
endif
|
||||
|
||||
let group_name = synIDattr(s:srhg_group_id, 'name')
|
||||
if group_name == ''
|
||||
let group_name = synIDattr(-s:srhg_group_id, 'name')
|
||||
endif
|
||||
|
||||
if a:0 > 0
|
||||
if a:1 == 0 || a:1 == 1
|
||||
let match_group = a:1
|
||||
endif
|
||||
else
|
||||
" Default to operate on syntax groups that match
|
||||
let match_group = 1
|
||||
endif
|
||||
|
||||
if a:0 > 1
|
||||
let match_exp = a:2
|
||||
else
|
||||
let match_exp = '\(\w\+\>\)'
|
||||
let dialog_msg = "Enter match expression (default word at cursor - " .
|
||||
\ match_exp .
|
||||
\ "): "
|
||||
let l:var_val = inputdialog(dialog_msg, match_exp)
|
||||
let response = 1
|
||||
" Ok or Cancel result in an empty string
|
||||
if l:var_val == ""
|
||||
call s:SRWarningMsg(
|
||||
\ 'You must provide a match expression which ' .
|
||||
\ 'includes a submatch'
|
||||
\ )
|
||||
return
|
||||
endif
|
||||
let match_exp = l:var_val
|
||||
endif
|
||||
|
||||
if a:0 > 2
|
||||
let replace_exp = a:3
|
||||
else
|
||||
let replace_exp = '\U\1'
|
||||
let dialog_msg = "Enter replacement expression for the submatch " .
|
||||
\ "(ie capitalize word - \\U\\1): "
|
||||
let l:var_val = inputdialog(dialog_msg, replace_exp)
|
||||
let response = 1
|
||||
" Ok or Cancel result in an empty string
|
||||
if l:var_val == ""
|
||||
" If empty, check if they want to leave it empty
|
||||
" of skip this variable
|
||||
let response = confirm("Your value is empty!"
|
||||
\ , "&Use blank\n&Cancel", response)
|
||||
endif
|
||||
if response == 1
|
||||
" Replace the variable with what was entered
|
||||
let replace_exp = l:var_val
|
||||
else
|
||||
" Cancel
|
||||
return
|
||||
endif
|
||||
endif
|
||||
|
||||
" let higrpid = synIDtrans(hlID(s:srhg_group_id))
|
||||
let found = 0
|
||||
let firsttime = 1
|
||||
let lastline = line("$")
|
||||
let orgline = line(".")
|
||||
let orgcol = col(".")
|
||||
let curline = line(".")
|
||||
let curcol = col(".")
|
||||
let fenkeep = &fen
|
||||
let saveSearch = @/
|
||||
let saveFoldEnable = &foldenable
|
||||
setlocal nofoldenable
|
||||
|
||||
" Reset visual range if necessary
|
||||
call s:SRSetVisualRange()
|
||||
|
||||
" Restore the cursor position since resetting
|
||||
" the visual area could have moved the cursor
|
||||
call cursor(orgline, orgcol)
|
||||
|
||||
if s:SRPositionWord(orgline,(orgcol-1), firsttime) == -1
|
||||
call s:SRWarningMsg(
|
||||
\ 'Please reselect the visual area (ie gv)'
|
||||
\ )
|
||||
return
|
||||
endif
|
||||
let firsttime = 0
|
||||
|
||||
let gid = s:srhg_group_id
|
||||
if gid < 0
|
||||
let gid = -s:srhg_group_id
|
||||
endif
|
||||
|
||||
while line(".") <= a:lastline
|
||||
let curcol = col(".")
|
||||
let curline = line(".")
|
||||
let cursynid = (s:srhg_group_id < 0) ?
|
||||
\ -synID(line("."),col("."),1) :
|
||||
\ synIDtrans(synID(line("."),col("."),1))
|
||||
let cursynid = (s:srhg_group_id < 0) ? synID(line("."),col("."),1) : synIDtrans(synID(line("."),col("."),1))
|
||||
" Useful debugging statement:
|
||||
" echo col(".").':'.getline(".")[col(".")-1].':'.cursynid.':'.getline(".")
|
||||
|
||||
if line(".") == curline
|
||||
if match_group == 1 && cursynid == gid
|
||||
" Perform the subtitution, but do not report an error
|
||||
" if the match fails
|
||||
exec 's/\%#'.match_exp.'/'.replace_exp.'/e'
|
||||
" Since this command can move the cursor, put the cursor
|
||||
" back to its original position
|
||||
" exe 'norm! '.curline."G\<bar>".(curcol-1)."l"
|
||||
call cursor(curline,curcol)
|
||||
let found = 1
|
||||
elseif match_group == 0 && cursynid != gid
|
||||
" Perform the subtitution, but do not report an error
|
||||
" if the match fails
|
||||
exec 's/\%#'.match_exp.'/'.replace_exp.'/e'
|
||||
" Since this command can move the cursor, put the cursor
|
||||
" back to its original position
|
||||
exe 'norm! '.curline."G\<bar>".(curcol-1)."l"
|
||||
let found = 1
|
||||
endif
|
||||
endif
|
||||
|
||||
let prvcol = curcol
|
||||
let prvline = curline
|
||||
if s:SRPositionWord(prvline, prvcol, firsttime) == -1
|
||||
break
|
||||
endif
|
||||
|
||||
endwhile
|
||||
|
||||
if found == 0
|
||||
call s:SRWarningMsg('Did not find highlight group: "'.group_name.'"')
|
||||
endif
|
||||
|
||||
" cleanup
|
||||
let &fen = fenkeep
|
||||
if foldlevel(".") > 0
|
||||
norm! zO
|
||||
endif
|
||||
let &foldenable = saveFoldEnable
|
||||
unlet curcol
|
||||
" unlet higrpid
|
||||
unlet lastline
|
||||
let @/ = saveSearch
|
||||
if exists("prvcol")
|
||||
unlet prvcol
|
||||
endif
|
||||
endfunction "}}}
|
||||
|
||||
" SRSearch:
|
||||
" Finds the next occurrence of the highlight group within
|
||||
" the range selected from the current cursor position.
|
||||
function! SrchRplcHiGrp#SRSearch(anti, fline, lline, ...) "{{{
|
||||
if s:srhg_group_id == 0
|
||||
call s:SRWarningMsg(
|
||||
\ 'You must use SRChooseHiGrp to specify a syntax group name first'
|
||||
\ )
|
||||
return
|
||||
endif
|
||||
|
||||
let match_group = a:anti
|
||||
let s:srhg_firstline = a:fline
|
||||
let s:srhg_lastline = a:lline
|
||||
|
||||
let group_name = synIDattr(-s:srhg_group_id, 'name')
|
||||
let regex = ""
|
||||
|
||||
if a:0 > 0 && strlen(a:1) > 0
|
||||
" Escape special characters in the regex
|
||||
" let regex = substitute(
|
||||
" \ substitute(
|
||||
" \ escape(a:1 '\\/.*$^~[]'),
|
||||
" \ "\n$",
|
||||
" \ "",
|
||||
" \ ""
|
||||
" \ ),
|
||||
" \ "\n",
|
||||
" \ '\\_[[:return:]]',
|
||||
" \ "g"
|
||||
" \ )
|
||||
let regex = a:1
|
||||
endif
|
||||
|
||||
" let higrpid = synIDtrans(hlID(s:srhg_group_id))
|
||||
let found = 0
|
||||
let lastline = line("$")
|
||||
let orgline = line(".")
|
||||
let orgcol = col(".")
|
||||
let curline = line(".")
|
||||
let curcol = col(".")
|
||||
let fenkeep = &fen
|
||||
let saveSearch = @/
|
||||
let saveFoldEnable = &foldenable
|
||||
setlocal nofoldenable
|
||||
" Set this to false, to force the search to move the cursor
|
||||
" this prevents the user from having to manually move the
|
||||
" cursor between recursive calls.
|
||||
let firsttime = 0
|
||||
|
||||
" Reset visual range if necessary
|
||||
call s:SRSetVisualRange()
|
||||
|
||||
" Restore the cursor position since resetting
|
||||
" the visual area could have moved the cursor
|
||||
call cursor(orgline, orgcol)
|
||||
|
||||
if s:SRPositionWord(orgline,orgcol,firsttime) == -1
|
||||
call s:SRWarningMsg(
|
||||
\ 'Please reselect the visual area (ie gv)'
|
||||
\ )
|
||||
return
|
||||
endif
|
||||
|
||||
let gid = s:srhg_group_id
|
||||
if gid < 0
|
||||
let gid = -s:srhg_group_id
|
||||
endif
|
||||
|
||||
while line(".") <= s:srhg_lastline
|
||||
let curcol = col(".")
|
||||
let curline = line(".")
|
||||
let cursynid = (s:srhg_group_id < 0) ? synID(line("."),col("."),1) : synIDtrans(synID(line("."),col("."),1))
|
||||
let prevsynid = (s:srhg_group_id < 0) ? synID(line("."),(col(".")-1),1) : synIDtrans(synID(line("."),(col(".")-1),1))
|
||||
" Useful debugging statement:
|
||||
" echo col(".").':'.getline(".")[col(".")-1].':'.cursynid.':'.getline(".")
|
||||
|
||||
" if line(".") == curline
|
||||
" Check the current syn id against the previous columns syn id.
|
||||
" If they are the same, assume we are still part of the same "string"
|
||||
" and we need to continue searching until we find a gap between the
|
||||
" highlight groups indicating we are actually on our next match
|
||||
" (Sergio).
|
||||
if line(".") == curline && (cursynid != prevsynid)
|
||||
if cursynid == gid && match_group == 1
|
||||
if regex != ""
|
||||
" Check if the expression matches
|
||||
if strpart(getline('.'), (curcol-1)) =~ regex
|
||||
let found = 1
|
||||
endif
|
||||
else
|
||||
let found = 1
|
||||
endif
|
||||
if found == 1
|
||||
call SrchRplcHiGrp#SRDispHiGrp( "SRSearch - Match found - Group ID: " .
|
||||
\ gid . " Name: " . synIDattr(gid,"name") .
|
||||
\ (regex == "" ? "" : ' Regex: '.regex)
|
||||
\ )
|
||||
break
|
||||
endif
|
||||
elseif cursynid != gid && match_group == 0
|
||||
if regex != ""
|
||||
" Check if the expression matches
|
||||
if strpart(getline('.'), (curcol-1)) =~ regex
|
||||
let found = 1
|
||||
endif
|
||||
else
|
||||
let found = 1
|
||||
endif
|
||||
if found == 1
|
||||
call SrchRplcHiGrp#SRDispHiGrp( "SRSearch - Match found - NOT Group ID: " .
|
||||
\ gid . " Name: " . synIDattr(gid,"name") .
|
||||
\ (regex == "" ? "" : ' Regex: '.regex)
|
||||
\ )
|
||||
break
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
let prvcol = curcol
|
||||
let prvline = curline
|
||||
if s:SRPositionWord(prvline, prvcol, firsttime) == -1
|
||||
break
|
||||
endif
|
||||
|
||||
endwhile
|
||||
|
||||
if found == 0
|
||||
call SrchRplcHiGrp#SRDispHiGrp( "SRSearch - Match NOT found - Group ID: " .
|
||||
\ gid . " Name: " . synIDattr(gid,"name")
|
||||
\ )
|
||||
call cursor(orgline, orgcol)
|
||||
endif
|
||||
|
||||
" cleanup
|
||||
let &fen = fenkeep
|
||||
if foldlevel(".") > 0
|
||||
norm! zO
|
||||
endif
|
||||
let &foldenable = saveFoldEnable
|
||||
unlet curcol
|
||||
" unlet higrpid
|
||||
unlet lastline
|
||||
let @/ = saveSearch
|
||||
if exists("prvcol")
|
||||
unlet prvcol
|
||||
endif
|
||||
endfunction "}}}
|
||||
|
||||
" SRSetVisualRange:
|
||||
" Redefines the visual range if the user called the functions
|
||||
" with 1,5SR*
|
||||
function! <SID>SRSetVisualRange() "{{{
|
||||
" If the current line position is not at the beginning
|
||||
" or the end of the visual region
|
||||
if line(".") != line("'<") && line(".") != line("'>")
|
||||
" Visually select the rows to ensure the correct
|
||||
" range is operated on.
|
||||
" This handles the case that SRHiGrp was run as:
|
||||
" :SRHiGrp
|
||||
" :1,5SRHiGrp
|
||||
" instead of:
|
||||
" :'<,'>SRHiGrp
|
||||
|
||||
exec 'normal! '.s:srhg_firstline."GV"
|
||||
if s:srhg_lastline > s:srhg_firstline
|
||||
exec "normal! " .
|
||||
\ (s:srhg_lastline - s:srhg_firstline) .
|
||||
\ "j"
|
||||
endif
|
||||
exec "normal! \<Esc>"
|
||||
endif
|
||||
return 1
|
||||
endfunction "}}}
|
||||
|
||||
" SRPositionWord:
|
||||
" Places the cursor on the next match following the
|
||||
" previous line and column passed in.
|
||||
function! <SID>SRPositionWord(prvline, prvcol, bfirsttime) "{{{
|
||||
let prvline = a:prvline
|
||||
let prvcol = a:prvcol
|
||||
|
||||
" echo 'L:'. col("'<") . ' R:' . col("'>")
|
||||
" echo 'Visual Mode:'. visualmode()
|
||||
|
||||
if (prvline == 0) && (prvcol == 0)
|
||||
call s:SRSetVisualRange()
|
||||
let leftcol = col("'<") - 1
|
||||
" exe 'norm! '.s:srhg_firstline."G\<bar>".leftcol.(leftcol>0 ? 'l' : '' )
|
||||
call cursor(s:srhg_firstline,leftcol)
|
||||
return 1
|
||||
endif
|
||||
|
||||
while 1==1
|
||||
if visualmode() ==# 'v'
|
||||
if line(".") == s:srhg_firstline
|
||||
" let leftcol = col("'<") - 1
|
||||
let leftcol = col("'<")
|
||||
else
|
||||
let leftcol = 1
|
||||
endif
|
||||
if line(".") == s:srhg_lastline
|
||||
let rightcol = col("'>")
|
||||
else
|
||||
let rightcol = col("$")
|
||||
endif
|
||||
elseif visualmode() ==# 'V'
|
||||
let leftcol = 1
|
||||
let rightcol = col("$")
|
||||
elseif visualmode() ==# "\<C-V>"
|
||||
let leftcol = col("'<") - 1
|
||||
let leftcol = col("'<")
|
||||
let rightcol = col("'>")
|
||||
endif
|
||||
|
||||
" echo 'PrvLine:'.prvline.' prvcol:'.prvcol.
|
||||
" \' L:'.leftcol.' R:'.rightcol.
|
||||
" \' VL:'.leftcol.' VR:'.rightcol
|
||||
|
||||
" Position cursor on leftcol
|
||||
" on each new line based on visual mode
|
||||
if col(".") == leftcol && a:bfirsttime == 1
|
||||
" The cursor is already at it starting position,
|
||||
" do not move the cursor
|
||||
elseif col(".") < leftcol
|
||||
" exe 'norm! '.line(".")."G\<bar>".leftcol.(leftcol>0 ? 'l' : '' )
|
||||
call cursor(line("."),leftcol)
|
||||
else
|
||||
normal! w
|
||||
endif
|
||||
|
||||
" Add additional check to see if the cursor has
|
||||
" moved after the above, if not, exit.
|
||||
if (col(".") == prvcol) && (line(".") == prvline && a:bfirsttime != 1)
|
||||
return -1
|
||||
endif
|
||||
|
||||
|
||||
if col(".") >= leftcol &&
|
||||
\ col(".") <= rightcol &&
|
||||
\ line(".") <= s:srhg_lastline
|
||||
return 1
|
||||
elseif col(".") > rightcol && line(".") < s:srhg_lastline
|
||||
let prvline = prvline + 1
|
||||
" Position the cursor on the next line and move
|
||||
" to the start of the visual region
|
||||
" exe 'norm! '.prvline."G\<bar>".leftcol.(leftcol>0 ? 'l' : '' )
|
||||
call cursor(prvline,leftcol)
|
||||
break
|
||||
elseif col(".") < leftcol && line(".") <= s:srhg_lastline
|
||||
" outside of visual area, move to next word
|
||||
continue
|
||||
else
|
||||
return -1
|
||||
endif
|
||||
endwhile
|
||||
|
||||
return 1
|
||||
endfunction "}}}
|
||||
|
||||
" If a comment is found, skip it
|
||||
function! <SID>SRCommentCheck( lineno, indx ) "{{{
|
||||
if getline(a:lineno) =~ '^\s*--'
|
||||
return 1
|
||||
endif
|
||||
return 0
|
||||
|
||||
let synid = synID(a:lineno,a:indx+1,1)
|
||||
let synname = synIDattr(synIDtrans(synid),"name")
|
||||
let ret= (synname == "String")? 1 : 0
|
||||
return ret
|
||||
endfunction "}}}
|
||||
|
||||
let &cpo = s:cpo_save
|
||||
unlet s:cpo_save
|
||||
|
||||
" vim:fdm=marker:nowrap:ts=4:
|
1262
vimfiles/autoload/diffchar.vim
Normal file
1262
vimfiles/autoload/diffchar.vim
Normal file
File diff suppressed because it is too large
Load Diff
1134
vimfiles/autoload/merginal.vim
Executable file → Normal file
1134
vimfiles/autoload/merginal.vim
Executable file → Normal file
File diff suppressed because it is too large
Load Diff
229
vimfiles/autoload/merginal/buffers/base.vim
Normal file
229
vimfiles/autoload/merginal/buffers/base.vim
Normal file
@ -0,0 +1,229 @@
|
||||
call merginal#modulelib#makeModule(s:, 'base', '')
|
||||
|
||||
let s:f.helpVisible = 0
|
||||
let s:f.filter = ''
|
||||
|
||||
function! s:f.generateHelp() dict abort
|
||||
let l:result = []
|
||||
let l:columnWidths = [4, winwidth(0) - 5]
|
||||
echo l:columnWidths
|
||||
for l:meta in self._meta
|
||||
if has_key(l:meta, 'doc')
|
||||
if !empty(l:meta.keymaps)
|
||||
let l:result += merginal#util#makeColumns(l:columnWidths, [l:meta.keymaps[0], l:meta.doc])
|
||||
for l:keymap in l:meta.keymaps[1:]
|
||||
let l:result += merginal#util#makeColumns(l:columnWidths, [l:keymap, 'same as '.l:meta.keymaps[0]])
|
||||
endfor
|
||||
endif
|
||||
endif
|
||||
endfor
|
||||
return l:result
|
||||
endfunction
|
||||
|
||||
function! s:f.generateHeader() dict abort
|
||||
return []
|
||||
endfunction
|
||||
|
||||
function! s:f.generateBody() dict abort
|
||||
throw 'generateBody() Not implemented for '.self.name
|
||||
endfunction
|
||||
|
||||
function! s:f.bufferName() dict abort
|
||||
return 'Merginal:'.self.name
|
||||
endfunction
|
||||
|
||||
function! s:f.existingWindowNumber() dict abort
|
||||
return bufwinnr(bufnr(self.bufferName()))
|
||||
endfunction
|
||||
|
||||
function! s:f.gitRun(...) dict abort
|
||||
let l:dir = getcwd()
|
||||
execute 'cd '.fnameescape(self.repo.tree())
|
||||
try
|
||||
let l:gitCommand = call(self.repo.git_command, ['--no-pager'] + a:000, self.repo)
|
||||
return merginal#system(l:gitCommand)
|
||||
finally
|
||||
execute 'cd '.fnameescape(l:dir)
|
||||
endtry
|
||||
endfunction
|
||||
|
||||
function! s:f.gitLines(...) dict abort
|
||||
return split(call(self.gitRun, a:000, self), '\r\n\|\n\|\r')
|
||||
endfunction
|
||||
|
||||
function! s:f.gitEcho(...) dict abort
|
||||
let l:lines = call(self.gitLines, a:000, self)
|
||||
if len(l:lines) == 1
|
||||
" Output a single/empty line to make Vim wait for Enter.
|
||||
echo ' '
|
||||
endif
|
||||
for l:line in l:lines
|
||||
let l:line = substitute(l:line, '\t', repeat(' ', &tabstop), 'g')
|
||||
" Remove terminal escape codes for colors (based on
|
||||
" www.commandlinefu.com/commands/view/3584/).
|
||||
let l:line = substitute(l:line, '\v\[([0-9]{1,3}(;[0-9]{1,3})?)?[m|K]', '', 'g')
|
||||
echo "[output]" l:line
|
||||
endfor
|
||||
endfunction
|
||||
|
||||
function! s:f.gitBang(...) dict abort
|
||||
let l:dir = getcwd()
|
||||
execute 'cd '.fnameescape(self.repo.tree())
|
||||
try
|
||||
let l:gitCommand = call(self.repo.git_command, ['--no-pager'] + a:000, self.repo)
|
||||
call merginal#bang(l:gitCommand)
|
||||
finally
|
||||
execute 'cd '.fnameescape(l:dir)
|
||||
endtry
|
||||
endfunction
|
||||
|
||||
|
||||
"Returns 1 if a new buffer was opened, 0 if it already existed
|
||||
function! s:f.openTuiBuffer(targetWindow) dict abort
|
||||
let self.repo = fugitive#repo()
|
||||
|
||||
if -1 < a:targetWindow
|
||||
let l:tuiBufferWindow = -1
|
||||
else
|
||||
let l:tuiBufferWindow = self.existingWindowNumber()
|
||||
endif
|
||||
|
||||
if -1 < l:tuiBufferWindow "Jump to the already open buffer
|
||||
execute l:tuiBufferWindow.'wincmd w'
|
||||
else "Open a new buffer
|
||||
if -1 < a:targetWindow
|
||||
else
|
||||
40vnew
|
||||
endif
|
||||
setlocal buftype=nofile
|
||||
setlocal bufhidden=wipe
|
||||
setlocal nomodifiable
|
||||
setlocal winfixwidth
|
||||
setlocal winfixheight
|
||||
setlocal nonumber
|
||||
setlocal norelativenumber
|
||||
execute 'silent file '.self.bufferName()
|
||||
call fugitive#detect(self.repo.dir())
|
||||
|
||||
for l:meta in self._meta
|
||||
for l:keymap in l:meta.keymaps
|
||||
execute 'nnoremap <buffer> '.l:keymap.' :'.l:meta.execute.'<Cr>'
|
||||
endfor
|
||||
|
||||
if has_key(l:meta, 'command')
|
||||
execute 'command! -buffer -nargs=0 '.l:meta.command.' '.l:meta.execute
|
||||
endif
|
||||
endfor
|
||||
|
||||
call self.refresh()
|
||||
if has_key(self, 'jumpToCurrentItem')
|
||||
call self.jumpToCurrentItem()
|
||||
endif
|
||||
endif
|
||||
|
||||
let b:merginal = self
|
||||
|
||||
"Check and return if a new buffer was created
|
||||
return -1 == l:tuiBufferWindow
|
||||
endfunction
|
||||
|
||||
function! s:f.gotoBuffer(bufferModuleName, ...) dict abort
|
||||
let l:newBufferObject = merginal#modulelib#createObject(a:bufferModuleName)
|
||||
if has_key(l:newBufferObject, 'init')
|
||||
call call(l:newBufferObject.init, a:000, l:newBufferObject)
|
||||
elseif 0 < a:0
|
||||
throw 'gotoBuffer called with arguments but '.a:bufferModuleName.' has no "init" method'
|
||||
endif
|
||||
call l:newBufferObject.openTuiBuffer(winnr())
|
||||
return l:newBufferObject
|
||||
endfunction
|
||||
|
||||
function! s:f._getSpecialMode() dict abort
|
||||
return merginal#getSpecialMode(self.repo)
|
||||
endfunction
|
||||
|
||||
"Returns the buffer moved to
|
||||
function! s:f.gotoSpecialModeBuffer() dict abort
|
||||
let l:mode = self._getSpecialMode()
|
||||
if empty(l:mode) || l:mode == self.name
|
||||
return 0
|
||||
endif
|
||||
let l:newBufferObject = self.gotoBuffer(l:mode)
|
||||
return l:newBufferObject
|
||||
endfunction
|
||||
|
||||
function! s:f.isLineInBody(lineNumber) dict abort
|
||||
if type(a:lineNumber) == type(0)
|
||||
let l:line = a:lineNumber
|
||||
else
|
||||
let l:line = line(a:lineNumber)
|
||||
endif
|
||||
return len(self.header) < l:line
|
||||
endfunction
|
||||
|
||||
function! s:f.verifyLineInBody(lineNumber) dict abort
|
||||
if !self.isLineInBody(a:lineNumber)
|
||||
throw 'In the header section of the merginal buffer'
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:f.jumpToIndexInBody(index) dict abort
|
||||
execute a:index + len(self.header) + 1
|
||||
endfunction
|
||||
|
||||
function! s:f.isStillInSpecialMode() dict abort
|
||||
let l:mode = self._getSpecialMode()
|
||||
return l:mode == self.name
|
||||
endfunction
|
||||
|
||||
|
||||
function! s:f.getFilteredBody() dict abort
|
||||
return filter(copy(self.body), '0 <= match(v:val, self.filter)')
|
||||
endfunction
|
||||
|
||||
|
||||
function! s:f.refresh() dict abort
|
||||
let self.header = []
|
||||
if self.helpVisible
|
||||
call extend(self.header, self.generateHelp())
|
||||
else
|
||||
call add(self.header, 'Press ? for help')
|
||||
endif
|
||||
call add(self.header, '')
|
||||
call extend(self.header, self.generateHeader())
|
||||
let self.body = self.generateBody()
|
||||
|
||||
let l:currentLine = line('.') - len(self.header)
|
||||
let l:currentColumn = col('.')
|
||||
|
||||
setlocal modifiable
|
||||
"Clear the buffer:
|
||||
silent normal! gg"_dG
|
||||
"Write the buffer
|
||||
call setline(1, self.header + self.getFilteredBody())
|
||||
let l:currentLine = l:currentLine + len(self.header)
|
||||
setlocal nomodifiable
|
||||
|
||||
execute l:currentLine
|
||||
execute 'normal! '.l:currentColumn.'|'
|
||||
endfunction
|
||||
call s:f.addCommand('refresh', [], 'MerginalRefresh', 'R', 'Refresh the buffer')
|
||||
|
||||
function! s:f.quit()
|
||||
bdelete
|
||||
endfunction
|
||||
call s:f.addCommand('quit', [], 0, 'q', 'Close the buffer')
|
||||
|
||||
function! s:f.toggleHelp() dict abort
|
||||
let self.helpVisible = !self.helpVisible
|
||||
call self.refresh()
|
||||
endfunction
|
||||
call s:f.addCommand('toggleHelp', [], 0, '?', 'Toggle this help message')
|
||||
|
||||
function! s:f.promptForFilter() dict abort
|
||||
let l:newFilter = input('&/')
|
||||
let self.filter = l:newFilter
|
||||
call self.refresh()
|
||||
endfunction
|
||||
call s:f.addCommand('promptForFilter', [], 0, '&', 'Set filter')
|
||||
|
250
vimfiles/autoload/merginal/buffers/branchList.vim
Normal file
250
vimfiles/autoload/merginal/buffers/branchList.vim
Normal file
@ -0,0 +1,250 @@
|
||||
call merginal#modulelib#makeModule(s:, 'branchList', 'immutableBranchList')
|
||||
|
||||
|
||||
|
||||
function! s:f.checkoutBranch() dict abort
|
||||
let l:branch = self.branchDetails('.')
|
||||
call self.gitEcho('checkout', l:branch.handle)
|
||||
call self.refresh()
|
||||
call self.jumpToCurrentItem()
|
||||
call merginal#reloadBuffers()
|
||||
endfunction
|
||||
call s:f.addCommand('checkoutBranch', [], 'MerginalCheckout', ['cc', 'C'], 'Checkout the branch under the cursor')
|
||||
|
||||
|
||||
function! s:f.trackBranch(promptForName) dict abort
|
||||
let l:branch = self.branchDetails('.')
|
||||
if !l:branch.isRemote
|
||||
throw 'Can not track - branch is not remote'
|
||||
endif
|
||||
let l:newBranchName = l:branch.name
|
||||
if a:promptForName
|
||||
let l:newBranchName = input('Track `'.l:branch.handle.'` as: ', l:newBranchName)
|
||||
if empty(l:newBranchName)
|
||||
echo ' '
|
||||
echom 'Branch tracking canceled by user.'
|
||||
return
|
||||
endif
|
||||
endif
|
||||
call self.gitEcho('checkout', '-b', l:newBranchName, '--track', l:branch.handle)
|
||||
if !v:shell_error
|
||||
call merginal#reloadBuffers()
|
||||
endif
|
||||
call self.refresh()
|
||||
call self.jumpToCurrentItem()
|
||||
endfunction
|
||||
call s:f.addCommand('trackBranch', [0], 'MerginalTrack', 'ct', 'Track the remote branch under the cursor')
|
||||
call s:f.addCommand('trackBranch', [1], 'MerginalTrackPrompt', 'cT', 'Track the remote branch under the cursor, prompting for a name')
|
||||
|
||||
function! s:f.promptToCreateNewBranch() dict abort
|
||||
let l:newBranchName = input('Branch `'.self.repo.head().'` to: ')
|
||||
if empty(l:newBranchName)
|
||||
echo ' '
|
||||
echom 'Branch creation canceled by user.'
|
||||
return
|
||||
endif
|
||||
call self.gitEcho('checkout', '-b', l:newBranchName)
|
||||
call merginal#reloadBuffers()
|
||||
|
||||
call self.refresh()
|
||||
call self.jumpToCurrentItem()
|
||||
endfunction
|
||||
call s:f.addCommand('promptToCreateNewBranch', [], 'MerginalNewBranch', ['aa', 'A'], 'Create a new branch')
|
||||
|
||||
function! s:f.deleteBranchUnderCursor() dict abort
|
||||
let l:branch = self.branchDetails('.')
|
||||
let l:answer = 0
|
||||
if l:branch.isLocal
|
||||
let l:answer = 'yes' == input('Delete branch `'.l:branch.handle.'`? (type "yes" to confirm) ')
|
||||
elseif l:branch.isRemote
|
||||
"Deleting remote branches needs a special warning
|
||||
let l:answer = 'yes-remote' == input('Delete remote(!) branch `'.l:branch.handle.'`? (type "yes-remote" to confirm) ')
|
||||
endif
|
||||
if l:answer
|
||||
if l:branch.isLocal
|
||||
call self.gitEcho('branch', '-D', l:branch.handle)
|
||||
else
|
||||
call self.gitBang('push', l:branch.remote, '--delete', l:branch.name)
|
||||
endif
|
||||
call self.refresh()
|
||||
else
|
||||
echo ' '
|
||||
echom 'Branch deletion canceled by user.'
|
||||
endif
|
||||
endfunction
|
||||
call s:f.addCommand('deleteBranchUnderCursor', [], 'MerginalDelete', ['dd', 'D'], 'Delete the branch under the cursor')
|
||||
|
||||
function! s:f.mergeBranchUnderCursor(...) dict abort
|
||||
let l:branch = self.branchDetails('.')
|
||||
let l:gitArgs = ['merge', '--no-commit', l:branch.handle]
|
||||
call extend(l:gitArgs, a:000)
|
||||
call call(self.gitEcho, l:gitArgs, self)
|
||||
let l:confilctsBuffer = self.gotoSpecialModeBuffer()
|
||||
if empty(l:confilctsBuffer)
|
||||
call self.refresh()
|
||||
else
|
||||
if empty(l:confilctsBuffer.body)
|
||||
"If we are in merge mode without actual conflicts, this means
|
||||
"there are not conflicts and the user can be prompted to enter a
|
||||
"merge message.
|
||||
Gstatus
|
||||
call merginal#closeMerginalBuffer()
|
||||
endif
|
||||
endif
|
||||
call merginal#reloadBuffers()
|
||||
endfunction
|
||||
call s:f.addCommand('mergeBranchUnderCursor', [], 'MerginalMerge', ['mm', 'M'], 'Merge the branch under the cursor')
|
||||
call s:f.addCommand('mergeBranchUnderCursor', ['--no-ff'], 'MerginalMergeNoFF', ['mn'], 'Merge the branch under the cursor using --no-ff')
|
||||
|
||||
function! s:f.mergeBranchUnderCursorUsingFugitive() dict abort
|
||||
let l:branch = self.branchDetails('.')
|
||||
execute ':Gmerge '.l:branch.handle
|
||||
endfunction
|
||||
call s:f.addCommand('mergeBranchUnderCursorUsingFugitive', [], 'MerginalMergeUsingFugitive', ['mf'], 'Merge the branch under the cursor using fugitive')
|
||||
|
||||
function! s:f.rebaseBranchUnderCursor() dict abort
|
||||
let l:branch = self.branchDetails('.')
|
||||
call self.gitEcho('rebase', l:branch.handle)
|
||||
call merginal#reloadBuffers()
|
||||
call self.gotoSpecialModeBuffer()
|
||||
endfunction
|
||||
call s:f.addCommand('rebaseBranchUnderCursor', [], 'MerginalRebase', 'rb', 'Rebase the branch under the cursor')
|
||||
|
||||
function! s:f.remoteActionForBranchUnderCursor(action, ...) dict abort
|
||||
let l:branch = self.branchDetails('.')
|
||||
if l:branch.isLocal
|
||||
let l:remotes = self.gitLines('remote')
|
||||
if empty(l:remotes)
|
||||
throw 'Can not '.a:action.' - no remotes defined'
|
||||
endif
|
||||
|
||||
let l:chosenRemoteIndex=0
|
||||
if 1 < len(l:remotes)
|
||||
""Choose the correct text accoring to the action:
|
||||
let l:prompt = 'Choose remote to '.a:action.' `'.l:branch.handle.'`'
|
||||
if 'push' == a:action
|
||||
let l:prompt .= ' to:'
|
||||
else
|
||||
let l:prompt .= ' from:'
|
||||
endif
|
||||
let l:chosenRemoteIndex = merginal#util#inputList(l:prompt, l:remotes, 'MORE')
|
||||
"Check that the chosen index is in range
|
||||
if l:chosenRemoteIndex <= 0 || len(l:remotes) < l:chosenRemoteIndex
|
||||
return
|
||||
endif
|
||||
endif
|
||||
|
||||
let l:localBranchName = l:branch.name
|
||||
let l:chosenRemote = l:remotes[l:chosenRemoteIndex]
|
||||
|
||||
let l:remoteBranchNameCanadidate = self.getRemoteBranchTrackedByLocalBranch(l:branch.name)
|
||||
if !empty(l:remoteBranchNameCanadidate)
|
||||
"Check that this is the same remote:
|
||||
if l:remoteBranchNameCanadidate =~ '\V\^'.escape(l:chosenRemote, '\').'/'
|
||||
"Remove the remote repository name
|
||||
let l:remoteBranchName = l:remoteBranchNameCanadidate[len(l:chosenRemote) + 1:(-1)]
|
||||
endif
|
||||
endif
|
||||
elseif l:branch.isRemote
|
||||
let l:chosenRemote = l:branch.remote
|
||||
if 'push' == a:action
|
||||
"For push, we want to specify the remote branch name
|
||||
let l:remoteBranchName = l:branch.name
|
||||
|
||||
let l:locals = self.getLocalBranchNamesThatTrackARemoteBranch(l:branch.handle)
|
||||
|
||||
if empty(l:locals)
|
||||
let l:localBranchName = l:branch.name
|
||||
elseif 1 == len(l:locals)
|
||||
let l:localBranchName = l:locals[0]
|
||||
else
|
||||
let l:chosenLocalIndex = merginal#util#inputList('Choose local branch to push `'.l:branch.handle.'` from:', l:locals, 'MORE')
|
||||
|
||||
"Check that the chosen index is in range
|
||||
if l:chosenLocalIndex <= 0 || len(l:locals) < l:chosenLocalIndex
|
||||
return
|
||||
endif
|
||||
|
||||
let l:localBranchName = l:locals[l:chosenLocalIndex]
|
||||
endif
|
||||
else
|
||||
"For pull and fetch, git automatically resolves the tracking
|
||||
"branch based on the remote branch.
|
||||
let l:localBranchName = l:branch.name
|
||||
endif
|
||||
endif
|
||||
|
||||
if exists('l:remoteBranchName') && empty(l:remoteBranchName)
|
||||
unlet l:remoteBranchName
|
||||
endif
|
||||
|
||||
let l:gitCommandWithArgs = [a:action]
|
||||
for l:flag in a:000
|
||||
call add(l:gitCommandWithArgs, l:flag)
|
||||
endfor
|
||||
|
||||
let l:reloadBuffers = 0
|
||||
|
||||
"Pulling requires the --no-commit flag
|
||||
if 'pull' == a:action
|
||||
if exists('l:remoteBranchName')
|
||||
let l:remoteBranchNameAsPrefix = l:remoteBranchName
|
||||
else
|
||||
let l:remoteBranchNameAsPrefix = ''
|
||||
endif
|
||||
let l:remoteBranchEscapedName = l:remoteBranchNameAsPrefix.l:localBranchName
|
||||
call add(l:gitCommandWithArgs, '--no-commit')
|
||||
let l:reloadBuffers = 1
|
||||
|
||||
elseif 'push' == a:action
|
||||
if exists('l:remoteBranchName')
|
||||
let l:remoteBranchNameAsSuffix = ':'.l:remoteBranchName
|
||||
else
|
||||
let l:remoteBranchNameAsSuffix = ''
|
||||
endif
|
||||
let l:remoteBranchEscapedName = l:localBranchName.l:remoteBranchNameAsSuffix
|
||||
|
||||
elseif 'fetch' == a:action
|
||||
if exists('l:remoteBranchName')
|
||||
let l:targetBranchName = l:remoteBranchName
|
||||
else
|
||||
let l:targetBranchName = l:localBranchName
|
||||
endif
|
||||
let l:remoteBranchEscapedName = l:targetBranchName
|
||||
endif
|
||||
|
||||
call add(l:gitCommandWithArgs, l:chosenRemote)
|
||||
call add(l:gitCommandWithArgs, l:remoteBranchEscapedName)
|
||||
|
||||
call call(self.gitBang, l:gitCommandWithArgs, self)
|
||||
"if l:reloadBuffers
|
||||
"call merginal#reloadBuffers()
|
||||
"endif
|
||||
"call self.refresh()
|
||||
endfunction
|
||||
call s:f.addCommand('remoteActionForBranchUnderCursor', ['push'], 'MerginalPush', ['ps'], 'Prompt to choose a remote to push the branch under the cursor.')
|
||||
call s:f.addCommand('remoteActionForBranchUnderCursor', ['push', '--force'], 'MerginalPushForce', ['pS'], 'Prompt to choose a remote to force push the branch under the cursor.')
|
||||
call s:f.addCommand('remoteActionForBranchUnderCursor', ['pull'], 'MerginalPull', ['pl'], 'Prompt to choose a remote to pull the branch under the cursor.')
|
||||
call s:f.addCommand('remoteActionForBranchUnderCursor', ['pull', '--rebase'], 'MerginalPullRebase', ['pr'], 'Prompt to choose a remote to pull-rebase the branch under the cursor.')
|
||||
call s:f.addCommand('remoteActionForBranchUnderCursor', ['fetch'], 'MerginalFetch', ['pf'], 'Prompt to choose a remote to fetch the branch under the cursor.')
|
||||
|
||||
function! s:f.renameBranchUnderCursor() dict abort
|
||||
let l:branch = self.branchDetails('.')
|
||||
if !l:branch.isLocal
|
||||
throw 'Can not rename - not a local branch'
|
||||
endif
|
||||
let l:newName = input('Rename `'.l:branch.handle.'` to: ', l:branch.name)
|
||||
echo ' '
|
||||
if empty(l:newName)
|
||||
echom 'Branch rename canceled by user.'
|
||||
return
|
||||
elseif l:newName==l:branch.name
|
||||
echom 'Branch name was not modified.'
|
||||
return
|
||||
endif
|
||||
|
||||
call self.gitEcho('branch', '-m', l:branch.name, l:newName)
|
||||
call self.refresh()
|
||||
endfunction
|
||||
call s:f.addCommand('renameBranchUnderCursor', [], 'MerginalRenameBranch', 'rn', 'Prompt to rename the branch under the cursor.')
|
||||
|
33
vimfiles/autoload/merginal/buffers/cherryPickConflicts.vim
Normal file
33
vimfiles/autoload/merginal/buffers/cherryPickConflicts.vim
Normal file
@ -0,0 +1,33 @@
|
||||
call merginal#modulelib#makeModule(s:, 'cherryPickConflicts', 'conflictsBase')
|
||||
|
||||
function! s:f.generateHeader() dict abort
|
||||
let l:currentCommit = readfile(self.repo.dir('ORIG_HEAD'))[0]
|
||||
let l:currentCommitMessageLines = self.gitLines('log', '--format=%s', '-n1', l:currentCommit)
|
||||
call insert(l:currentCommitMessageLines, '=== Reapplying: ===')
|
||||
call add(l:currentCommitMessageLines, '===================')
|
||||
call add(l:currentCommitMessageLines, '')
|
||||
return l:currentCommitMessageLines
|
||||
endfunction
|
||||
|
||||
function! s:f.lastFileAdded() dict abort
|
||||
let l:cherryPickConflictsBuffer = bufnr('')
|
||||
Gstatus
|
||||
let l:gitStatusBuffer = bufnr('')
|
||||
execute bufwinnr(l:cherryPickConflictsBuffer).'wincmd w'
|
||||
wincmd q
|
||||
execute bufwinnr(l:gitStatusBuffer).'wincmd w'
|
||||
endfunction
|
||||
|
||||
|
||||
function! s:f.cherryPickAction(action) dict abort
|
||||
call self.gitEcho('cherry-pick', '--'.a:action)
|
||||
call merginal#reloadBuffers()
|
||||
if self._getSpecialMode() == self.name
|
||||
call self.refresh()
|
||||
else
|
||||
""If we finished cherry-picking - close the cherry-pick conflicts buffer
|
||||
wincmd q
|
||||
endif
|
||||
endfunction
|
||||
call s:f.addCommand('cherryPickAction', ['abort'], 'MerginalAbort', 'ca', 'Abort the cherry-pick.')
|
||||
call s:f.addCommand('cherryPickAction', ['continue'], 'MerginalContinue', 'cc', 'Continue to the next patch.')
|
61
vimfiles/autoload/merginal/buffers/conflictsBase.vim
Normal file
61
vimfiles/autoload/merginal/buffers/conflictsBase.vim
Normal file
@ -0,0 +1,61 @@
|
||||
call merginal#modulelib#makeModule(s:, 'conflictsBase', 'base')
|
||||
|
||||
function! s:f.generateBody() dict abort
|
||||
"Get the list of unmerged files:
|
||||
let l:conflicts = self.gitLines('ls-files', '--unmerged')
|
||||
|
||||
"Split by tab - the first part is info, the second is the file name
|
||||
let l:conflicts = map(l:conflicts, 'split(v:val, "\t")')
|
||||
|
||||
"Only take the stage 1 files - stage 2 and 3 are the same files with
|
||||
"different hash, and we don't care about the hash here
|
||||
let l:conflicts = filter(l:conflicts, 'v:val[0] =~ "\\v 1$"')
|
||||
|
||||
"Take the file name - we no longer care about the info
|
||||
let l:conflicts = map(l:conflicts, 'v:val[1]')
|
||||
|
||||
"If the working copy is not the current dir, we can get wrong paths.
|
||||
"We need to resolve that:
|
||||
let l:conflicts = map(l:conflicts, 'self.repo.tree(v:val)')
|
||||
|
||||
"Make the paths as short as possible:
|
||||
let l:conflicts = map(l:conflicts, 'fnamemodify(v:val, ":~:.")')
|
||||
|
||||
return l:conflicts
|
||||
endfunction
|
||||
|
||||
function! s:f.fileDetails(lineNumber) dict abort
|
||||
call self.verifyLineInBody(a:lineNumber)
|
||||
|
||||
let l:line = getline(a:lineNumber)
|
||||
let l:result = {}
|
||||
|
||||
let l:result.name = l:line
|
||||
|
||||
return l:result
|
||||
endfunction
|
||||
|
||||
|
||||
function! s:f.openConflictedFileUnderCursor() dict abort
|
||||
let l:file = self.fileDetails('.')
|
||||
if empty(l:file.name)
|
||||
return
|
||||
endif
|
||||
call merginal#openFileDecidedWindow(self.repo, l:file.name)
|
||||
endfunction
|
||||
call s:f.addCommand('openConflictedFileUnderCursor', [], 'MerginalOpen', '<Cr>', 'Open the conflicted file under the cursor.')
|
||||
|
||||
function! s:f.addConflictedFileToStagingArea() dict abort
|
||||
let l:file = self.fileDetails('.')
|
||||
if empty(l:file.name)
|
||||
return
|
||||
endif
|
||||
|
||||
call self.gitEcho('add', fnamemodify(l:file.name, ':p'))
|
||||
call self.refresh()
|
||||
|
||||
if empty(self.body) "This means that was the last file
|
||||
call self.lastFileAdded()
|
||||
endif
|
||||
endfunction
|
||||
call s:f.addCommand('addConflictedFileToStagingArea', [], 'MerginalAddConflictedFileToStagingArea', ['aa' ,'A'], 'Add the conflicted file under the cursor to the staging area.')
|
116
vimfiles/autoload/merginal/buffers/diffFiles.vim
Normal file
116
vimfiles/autoload/merginal/buffers/diffFiles.vim
Normal file
@ -0,0 +1,116 @@
|
||||
call merginal#modulelib#makeModule(s:, 'diffFiles', 'base')
|
||||
|
||||
function! s:f.init(diffTarget) dict abort
|
||||
let self.diffTarget = a:diffTarget
|
||||
endfunction
|
||||
|
||||
function! s:f.generateHeader() dict abort
|
||||
return [
|
||||
\ '=== Diffing With: ===',
|
||||
\ self.diffTarget,
|
||||
\ '=====================',
|
||||
\ '']
|
||||
endfunction
|
||||
|
||||
function! s:f.generateBody() dict abort
|
||||
let l:diffFiles = self.gitLines('diff', '--name-status', self.diffTarget)
|
||||
return l:diffFiles
|
||||
endfunction
|
||||
|
||||
function! s:f.diffFileDetails(lineNumber) dict abort
|
||||
call self.verifyLineInBody(a:lineNumber)
|
||||
|
||||
let l:line = getline(a:lineNumber)
|
||||
let l:result = {}
|
||||
|
||||
let l:matches = matchlist(l:line, '\v([ADM])\t(.*)$')
|
||||
|
||||
if empty(l:matches)
|
||||
throw 'Unable to get diff files details for `'.l:line.'`'
|
||||
endif
|
||||
|
||||
let l:result.isAdded = 0
|
||||
let l:result.isDeleted = 0
|
||||
let l:result.isModified = 0
|
||||
if 'A' == l:matches[1]
|
||||
let l:result.type = 'added'
|
||||
let l:result.isAdded = 1
|
||||
elseif 'D' == l:matches[1]
|
||||
let l:result.type = 'deleted'
|
||||
let l:result.isDeleted = 1
|
||||
else
|
||||
let l:result.type = 'modified'
|
||||
let l:result.isModified = 1
|
||||
endif
|
||||
|
||||
let l:result.fileInTree = l:matches[2]
|
||||
let l:result.fileFullPath = self.repo.tree(l:matches[2])
|
||||
|
||||
return l:result
|
||||
endfunction
|
||||
|
||||
|
||||
function! s:f.openDiffFileUnderCursor() dict abort
|
||||
let l:diffFile = self.diffFileDetails('.')
|
||||
|
||||
if l:diffFile.isDeleted
|
||||
throw 'File does not exist in current buffer'
|
||||
endif
|
||||
|
||||
call merginal#openFileDecidedWindow(self.repo, l:diffFile.fileFullPath)
|
||||
endfunction
|
||||
call s:f.addCommand('openDiffFileUnderCursor', [], 'MerginalOpen', '<Cr>', 'Open the file under the cursor (if it exists in the currently checked out branch).')
|
||||
|
||||
|
||||
function! s:f.openDiffFileUnderCursorAndDiff(diffType) dict abort
|
||||
if a:diffType!='s' && a:diffType!='v'
|
||||
throw 'Bad diff type'
|
||||
endif
|
||||
|
||||
let l:diffFile = self.diffFileDetails('.')
|
||||
|
||||
if l:diffFile.isAdded
|
||||
throw 'File does not exist in other buffer'
|
||||
endif
|
||||
|
||||
"Close currently open git diffs
|
||||
let l:currentWindowBuffer = winbufnr('.')
|
||||
try
|
||||
windo if 'blob' == get(b:,'fugitive_type','') && exists('w:fugitive_diff_restore')
|
||||
\| bdelete
|
||||
\| endif
|
||||
catch
|
||||
"do nothing
|
||||
finally
|
||||
execute bufwinnr(l:currentWindowBuffer).'wincmd w'
|
||||
endtry
|
||||
|
||||
call merginal#openFileDecidedWindow(self.repo, l:diffFile.fileFullPath)
|
||||
|
||||
execute ':G'.a:diffType.'diff '.fnameescape(self.diffTarget)
|
||||
endfunction
|
||||
call s:f.addCommand('openDiffFileUnderCursorAndDiff', ['s'], 'MerginalDiff', 'ds', 'Split-diff against the file under the cursor (if it exists in the other branch)')
|
||||
call s:f.addCommand('openDiffFileUnderCursorAndDiff', ['v'], 'MerginalVDiff', 'dv', 'VSplit-diff against the file under the cursor (if it exists in the other branch)')
|
||||
|
||||
|
||||
function! s:f.checkoutDiffFileUnderCursor() dict abort
|
||||
let l:diffFile = self.diffFileDetails('.')
|
||||
|
||||
if l:diffFile.isAdded
|
||||
throw 'File does not exist in diffed buffer'
|
||||
endif
|
||||
|
||||
let l:answer = 1
|
||||
if !empty(glob(l:diffFile.fileFullPath))
|
||||
let l:answer = 'yes' == input('Override `'.l:diffFile.fileInTree.'`? (type "yes" to confirm) ')
|
||||
endif
|
||||
if l:answer
|
||||
call self.gitEcho('checkout', self.diffTarget, '--', l:diffFile.fileFullPath)
|
||||
call merginal#reloadBuffers()
|
||||
call self.refresh()
|
||||
else
|
||||
echo
|
||||
echom 'File checkout canceled by user.'
|
||||
endif
|
||||
endfunction
|
||||
call s:f.addCommand('checkoutDiffFileUnderCursor', [], 'MerginalCheckoutDiffFile', 'co', 'Check out the file under the cursor (if it exists in the other branch) into the current branch.')
|
128
vimfiles/autoload/merginal/buffers/historyLog.vim
Normal file
128
vimfiles/autoload/merginal/buffers/historyLog.vim
Normal file
@ -0,0 +1,128 @@
|
||||
call merginal#modulelib#makeModule(s:, 'historyLog', 'base')
|
||||
|
||||
function! s:f.init(branch) dict abort
|
||||
let self.branch = a:branch
|
||||
endfunction
|
||||
|
||||
function! s:f.generateHeader() dict abort
|
||||
return [
|
||||
\ '=== Showing History For: ===',
|
||||
\ self.branch,
|
||||
\ '============================',
|
||||
\ '']
|
||||
endfunction
|
||||
|
||||
function! s:f.generateBody() dict abort
|
||||
let l:logLines = self.gitLines('log', '--format=%h %aN%n%ai%n%s%n', self.branch)
|
||||
if empty(l:logLines[len(l:logLines) - 1])
|
||||
call remove(l:logLines, len(l:logLines) - 1)
|
||||
endif
|
||||
return l:logLines
|
||||
endfunction
|
||||
|
||||
function! s:f.getFilteredBody() dict abort
|
||||
if empty(self.filter)
|
||||
return copy(self.body)
|
||||
endif
|
||||
let l:result = []
|
||||
let l:lastBunch = []
|
||||
for l:line in self.body
|
||||
if empty(l:line)
|
||||
if 0 <= match(l:lastBunch, self.filter)
|
||||
call extend(l:result, l:lastBunch)
|
||||
endif
|
||||
let l:lastBunch = []
|
||||
endif
|
||||
call add(l:lastBunch, l:line)
|
||||
endfor
|
||||
if 0 <= match(l:lastBunch, self.filter)
|
||||
call extend(l:result, l:lastBunch)
|
||||
endif
|
||||
if !empty(l:result) && l:result[0] == ''
|
||||
call remove(l:result, 0)
|
||||
endif
|
||||
return l:result
|
||||
endfunction
|
||||
|
||||
function! s:f.commitHash(lineNumber) dict abort
|
||||
call self.verifyLineInBody(a:lineNumber)
|
||||
if type(0) == type(a:lineNumber)
|
||||
let l:lineNumber = a:lineNumber
|
||||
else
|
||||
let l:lineNumber = line(a:lineNumber)
|
||||
endif
|
||||
while self.isLineInBody(l:lineNumber) && !empty(getline(l:lineNumber))
|
||||
let l:lineNumber -= 1
|
||||
endwhile
|
||||
let l:lineNumber += 1
|
||||
return split(getline(l:lineNumber))[0]
|
||||
endfunction
|
||||
|
||||
|
||||
function! s:f.moveToNextOrPreviousCommit(direction) dict abort
|
||||
let l:line = line('.')
|
||||
|
||||
"Find the first line of the current commit
|
||||
while !empty(getline(l:line - 1))
|
||||
let l:line -= 1
|
||||
endwhile
|
||||
|
||||
"Find the first line of the next/prev commit
|
||||
let l:line += a:direction
|
||||
while !empty(getline(l:line - 1))
|
||||
let l:line += a:direction
|
||||
endwhile
|
||||
|
||||
if l:line <= 0 || line('$') <= l:line
|
||||
"We reached past the first/last commit - go back!
|
||||
let l:line -= a:direction
|
||||
while !empty(getline(l:line - 1))
|
||||
let l:line -= a:direction
|
||||
endwhile
|
||||
endif
|
||||
if self.isLineInBody(l:line)
|
||||
execute l:line
|
||||
endif
|
||||
endfunction
|
||||
call s:f.addCommand('moveToNextOrPreviousCommit', [-1], '', '<C-p>', 'Move the cursor to the previous commit.')
|
||||
call s:f.addCommand('moveToNextOrPreviousCommit', [1], '', '<C-n>', 'Move the cursor to the next commit.')
|
||||
|
||||
function! s:f.printCommitUnderCurosr(format) dict abort
|
||||
let l:commitHash = self.commitHash('.')
|
||||
"Not using self.gitEcho() because we are insterested in the result as more
|
||||
"than just git command output. Also - using git-log with -1 instead of
|
||||
"git-show because for some reason git-show ignores the --format flag...
|
||||
echo join(self.gitLines('log', '-1', '--format='.a:format, l:commitHash), "\n")
|
||||
endfunction
|
||||
call s:f.addCommand('printCommitUnderCurosr', ['fuller'], 'MerginalShow', ['ss', 'S'], "Echo the commit details(using git's --format=fuller)")
|
||||
|
||||
function! s:f.checkoutCommitUnderCurosr() dict abort
|
||||
let l:commitHash = self.commitHash('.')
|
||||
call self.gitEcho('checkout', l:commitHash)
|
||||
call merginal#reloadBuffers()
|
||||
endfunction
|
||||
call s:f.addCommand('checkoutCommitUnderCurosr', [], 'MerginalCheckout', ['cc', 'C'], 'Checkout the commit under the cursor.')
|
||||
|
||||
function! s:f.diffWithCommitUnderCursor() dict abort
|
||||
let l:commitHash = self.commitHash('.')
|
||||
call self.gotoBuffer('diffFiles', l:commitHash)
|
||||
endfunction
|
||||
call s:f.addCommand('diffWithCommitUnderCursor', [], 'MerginalDiff', 'gd', 'Open diff files buffer to diff against the commit under the cursor.')
|
||||
|
||||
function! s:f.cherryPickCommitUnderCursor() dict abort
|
||||
let l:commitHash = self.commitHash('.')
|
||||
call self.gitEcho('cherry-pick', l:commitHash)
|
||||
let l:confilctsBuffer = self.gotoSpecialModeBuffer()
|
||||
if empty(l:confilctsBuffer)
|
||||
call self.refresh()
|
||||
else
|
||||
if empty(l:confilctsBuffer.body)
|
||||
"If we are in cherry-pick mode without actual conflicts, this
|
||||
"means there are not conflicts and the user can be prompted to
|
||||
"enter a cherry-pick message.
|
||||
Gstatus
|
||||
call merginal#closeMerginalBuffer()
|
||||
endif
|
||||
endif
|
||||
endfunction
|
||||
call s:f.addCommand('cherryPickCommitUnderCursor', [], 'MerginalCherryPick', 'cp', 'Cherry-pick the commit under the cursor')
|
110
vimfiles/autoload/merginal/buffers/immutableBranchList.vim
Normal file
110
vimfiles/autoload/merginal/buffers/immutableBranchList.vim
Normal file
@ -0,0 +1,110 @@
|
||||
call merginal#modulelib#makeModule(s:, 'immutableBranchList', 'base')
|
||||
|
||||
function! s:f.generateBody() dict abort
|
||||
return self.gitLines('branch', '--all')
|
||||
endfunction
|
||||
|
||||
function! s:f.branchDetails(lineNumber) dict abort
|
||||
call self.verifyLineInBody(a:lineNumber)
|
||||
|
||||
let l:line = getline(a:lineNumber)
|
||||
let l:result = {}
|
||||
|
||||
"Check if this branch is the currently selected one
|
||||
let l:result.isCurrent = ('*' == l:line[0])
|
||||
let l:line = l:line[2:]
|
||||
|
||||
let l:detachedMatch = matchlist(l:line, '\v^\(detached from ([^/]+)%(/(.*))?\)$')
|
||||
if !empty(l:detachedMatch)
|
||||
let l:result.type = 'detached'
|
||||
let l:result.isLocal = 0
|
||||
let l:result.isRemote = 0
|
||||
let l:result.isDetached = 1
|
||||
let l:result.remote = l:detachedMatch[1]
|
||||
let l:result.name = l:detachedMatch[2]
|
||||
if empty(l:detachedMatch[2])
|
||||
let l:result.handle = l:detachedMatch[1]
|
||||
else
|
||||
let l:result.handle = l:detachedMatch[1].'/'.l:detachedMatch[2]
|
||||
endif
|
||||
return l:result
|
||||
endif
|
||||
|
||||
let l:remoteMatch = matchlist(l:line,'\v^remotes/([^/]+)%(/(\S*))%( \-\> (\S+))?$')
|
||||
if !empty(l:remoteMatch)
|
||||
let l:result.type = 'remote'
|
||||
let l:result.isLocal = 0
|
||||
let l:result.isRemote = 1
|
||||
let l:result.isDetached = 0
|
||||
let l:result.remote = l:remoteMatch[1]
|
||||
let l:result.name = l:remoteMatch[2]
|
||||
if empty(l:remoteMatch[2])
|
||||
let l:result.handle = l:remoteMatch[1]
|
||||
else
|
||||
let l:result.handle = l:remoteMatch[1].'/'.l:remoteMatch[2]
|
||||
endif
|
||||
return l:result
|
||||
endif
|
||||
|
||||
let l:result.type = 'local'
|
||||
let l:result.isLocal = 1
|
||||
let l:result.isRemote = 0
|
||||
let l:result.isDetached = 0
|
||||
let l:result.remote = ''
|
||||
let l:result.name = l:line
|
||||
let l:result.handle = l:line
|
||||
|
||||
return l:result
|
||||
endfunction
|
||||
|
||||
function! s:f.jumpToCurrentItem() dict abort
|
||||
"Find the current branch's index
|
||||
let l:currentBranchIndex = -1
|
||||
for l:i in range(len(self.body))
|
||||
if '*' == self.body[i][0]
|
||||
let l:currentBranchIndex = l:i
|
||||
break
|
||||
endif
|
||||
endfor
|
||||
if -1 < l:currentBranchIndex
|
||||
"Jump to the current branch's line
|
||||
call self.jumpToIndexInBody(l:currentBranchIndex)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:f.getRemoteBranchTrackedByLocalBranch(localBranchName) dict abort
|
||||
let l:result = self.gitLines('branch','--list',a:localBranchName,'-vv')
|
||||
return matchstr(l:result, '\v\[\zs[^\[\]:]*\ze[\]:]')
|
||||
endfunction
|
||||
|
||||
function! s:f.getLocalBranchNamesThatTrackARemoteBranch(remoteBranchName) dict abort
|
||||
"Get verbose list of branches
|
||||
let l:branchList = self.gitLines('branch', '-vv')
|
||||
|
||||
"Filter for branches that track our remote
|
||||
let l:checkIfTrackingRegex = '\V['.escape(a:remoteBranchName, '\').'\[\]:]'
|
||||
let l:branchList = filter(l:branchList, 'v:val =~ l:checkIfTrackingRegex')
|
||||
|
||||
"Extract the branch name from the matching lines
|
||||
let l:extractBranchNameRegex = '\v^\*?\s*\zs\S+'
|
||||
let l:branchList = map(l:branchList, 'matchstr(v:val, l:extractBranchNameRegex)')
|
||||
|
||||
return l:branchList
|
||||
endfunction
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function! s:f.diffWithBranchUnderCursor() dict abort
|
||||
let l:branch = self.branchDetails('.')
|
||||
call self.gotoBuffer('diffFiles', l:branch.handle)
|
||||
endfunction
|
||||
call s:f.addCommand('diffWithBranchUnderCursor', [], 'MerginalDiff', 'gd', 'Open diff files buffer to diff against the branch under the cursor.')
|
||||
|
||||
function! s:f.historyLogForBranchUnderCursor() dict abort
|
||||
let l:branch = self.branchDetails('.')
|
||||
call self.gotoBuffer('historyLog', l:branch.handle)
|
||||
endfunction
|
||||
call s:f.addCommand('historyLogForBranchUnderCursor', [], 'MerginalHistoryLog', 'gl', 'Open history log buffer to view the history of the branch under the cursor.')
|
||||
|
10
vimfiles/autoload/merginal/buffers/mergeConflicts.vim
Normal file
10
vimfiles/autoload/merginal/buffers/mergeConflicts.vim
Normal file
@ -0,0 +1,10 @@
|
||||
call merginal#modulelib#makeModule(s:, 'mergeConflicts', 'conflictsBase')
|
||||
|
||||
function! s:f.lastFileAdded() dict abort
|
||||
let l:mergeConflictsBuffer = bufnr('')
|
||||
Gstatus
|
||||
let l:gitStatusBuffer = bufnr('')
|
||||
execute bufwinnr(l:mergeConflictsBuffer).'wincmd w'
|
||||
wincmd q
|
||||
execute bufwinnr(l:gitStatusBuffer).'wincmd w'
|
||||
endfunction
|
34
vimfiles/autoload/merginal/buffers/rebaseAmend.vim
Normal file
34
vimfiles/autoload/merginal/buffers/rebaseAmend.vim
Normal file
@ -0,0 +1,34 @@
|
||||
call merginal#modulelib#makeModule(s:, 'rebaseAmend', 'immutableBranchList')
|
||||
|
||||
function! s:f.generateHeader() dict abort
|
||||
let l:amendedCommit = readfile(self.repo.dir('rebase-merge', 'amend'))
|
||||
let l:amendedCommitShort = self.gitRun('rev-parse', '--short', l:amendedCommit[0])
|
||||
let l:amendedCommitShort = substitute(l:amendedCommitShort,'\v[\r\n]','','g')
|
||||
let l:header = ['=== Amending '.l:amendedCommitShort.' ===']
|
||||
|
||||
let l:amendedCommitMessage=readfile(self.repo.dir('rebase-merge', 'message'))
|
||||
let l:header += l:amendedCommitMessage
|
||||
|
||||
call add(l:header,repeat('=', len(l:header[0])))
|
||||
call add(l:header, '')
|
||||
|
||||
return l:header
|
||||
endfunction
|
||||
|
||||
|
||||
function! s:f.rebaseAction(action) dict abort
|
||||
call self.gitEcho('rebase', '--'.a:action)
|
||||
call merginal#reloadBuffers()
|
||||
let l:mode = self._getSpecialMode()
|
||||
if l:mode == self.name
|
||||
call self.refresh()
|
||||
elseif empty(l:mode)
|
||||
"If we finished rebasing - close the rebase amend buffer
|
||||
wincmd q
|
||||
else
|
||||
call self.gotoBuffer(l:mode)
|
||||
endif
|
||||
endfunction
|
||||
call s:f.addCommand('rebaseAction', ['abort'], 'MerginalAbort', 'ra', 'Abort the rebase.')
|
||||
call s:f.addCommand('rebaseAction', ['skip'], 'MerginalSkip', 'rs', 'Continue to the next patch.')
|
||||
call s:f.addCommand('rebaseAction', ['continue'], 'MerginalContinue', 'rc', 'Skip the current patch')
|
37
vimfiles/autoload/merginal/buffers/rebaseConflicts.vim
Normal file
37
vimfiles/autoload/merginal/buffers/rebaseConflicts.vim
Normal file
@ -0,0 +1,37 @@
|
||||
call merginal#modulelib#makeModule(s:, 'rebaseConflicts', 'conflictsBase')
|
||||
|
||||
function! s:f.generateHeader() dict abort
|
||||
let l:currentCommit = readfile(self.repo.dir('ORIG_HEAD'))[0]
|
||||
let l:currentCommitMessageLines = self.gitLines('log', '--format=%s', '-n1', l:currentCommit)
|
||||
call insert(l:currentCommitMessageLines, '=== Reapplying: ===')
|
||||
call add(l:currentCommitMessageLines, '===================')
|
||||
call add(l:currentCommitMessageLines, '')
|
||||
return l:currentCommitMessageLines
|
||||
endfunction
|
||||
|
||||
function! s:f.lastFileAdded() dict abort
|
||||
echo 'Added the last file of this patch.'
|
||||
echo 'Continue to the next patch (y/N)?'
|
||||
let l:answer = getchar()
|
||||
if char2nr('y') == l:answer || char2nr('Y') == l:answer
|
||||
call self.rebaseAction('continue')
|
||||
endif
|
||||
endfunction
|
||||
|
||||
|
||||
function! s:f.rebaseAction(action) dict abort
|
||||
call self.gitEcho('rebase', '--'.a:action)
|
||||
call merginal#reloadBuffers()
|
||||
let l:mode = self._getSpecialMode()
|
||||
if l:mode == self.name
|
||||
call self.refresh()
|
||||
elseif empty(l:mode)
|
||||
"If we finished rebasing - close the rebase conflicts buffer
|
||||
wincmd q
|
||||
else
|
||||
call self.gotoBuffer(l:mode)
|
||||
endif
|
||||
endfunction
|
||||
call s:f.addCommand('rebaseAction', ['abort'], 'MerginalAbort', 'ra', 'Abort the rebase.')
|
||||
call s:f.addCommand('rebaseAction', ['skip'], 'MerginalSkip', 'rs', 'Continue to the next patch.')
|
||||
call s:f.addCommand('rebaseAction', ['continue'], 'MerginalContinue', 'rc', 'Skip the current patch')
|
87
vimfiles/autoload/merginal/modulelib.vim
Normal file
87
vimfiles/autoload/merginal/modulelib.vim
Normal file
@ -0,0 +1,87 @@
|
||||
|
||||
let s:f = {}
|
||||
let s:modules = {}
|
||||
|
||||
function! merginal#modulelib#makeModule(namespace, name, parent)
|
||||
let s:modules[a:name] = a:namespace
|
||||
let a:namespace.f = merginal#modulelib#prototype()
|
||||
let a:namespace.moduleName = a:name
|
||||
let a:namespace.parent = a:parent
|
||||
endfunction
|
||||
|
||||
function! s:populate(object, moduleName)
|
||||
try
|
||||
let l:module = s:modules[a:moduleName]
|
||||
catch /Key not present in Dictionary/
|
||||
execute 'runtime autoload/merginal/buffers/'.a:moduleName.'.vim'
|
||||
let l:module = s:modules[a:moduleName]
|
||||
endtry
|
||||
|
||||
if !empty(l:module.parent)
|
||||
call s:populate(a:object, l:module.parent)
|
||||
endif
|
||||
|
||||
let l:f = l:module.f
|
||||
|
||||
for l:k in keys(l:f)
|
||||
if l:k != '_meta' && !has_key(s:f, l:k)
|
||||
let a:object[l:k] = l:f[l:k]
|
||||
endif
|
||||
endfor
|
||||
|
||||
call extend(a:object._meta, l:f._meta)
|
||||
endfunction
|
||||
|
||||
function! merginal#modulelib#createObject(moduleName)
|
||||
let l:obj = {}
|
||||
let l:obj.name = a:moduleName
|
||||
let l:obj._meta = []
|
||||
call s:populate(l:obj, a:moduleName)
|
||||
return l:obj
|
||||
endfunction
|
||||
|
||||
function! merginal#modulelib#prototype()
|
||||
let l:prototype = copy(s:f)
|
||||
let l:prototype._meta = []
|
||||
return l:prototype
|
||||
endfunction
|
||||
|
||||
function! s:f.new() dict abort
|
||||
let l:obj = {}
|
||||
for l:k in keys(self)
|
||||
if !has_key(s:f, l:k)
|
||||
let l:obj[l:k] = self[l:k]
|
||||
endif
|
||||
endfor
|
||||
|
||||
return l:obj
|
||||
endfunction
|
||||
|
||||
function! s:f.addCommand(functionName, args, command, keymaps, doc) dict abort
|
||||
let l:meta = {}
|
||||
|
||||
let l:args = []
|
||||
for l:arg in a:args
|
||||
call add(l:args, string(l:arg))
|
||||
endfor
|
||||
let l:meta.execute = 'call b:merginal.'.a:functionName.'('.join(l:args, ', ').')'
|
||||
|
||||
if !empty(a:command)
|
||||
let l:meta.command = a:command
|
||||
endif
|
||||
|
||||
if empty(a:keymaps)
|
||||
elseif type(a:keymaps) == type([])
|
||||
let l:meta.keymaps = a:keymaps
|
||||
else
|
||||
let l:meta.keymaps = [a:keymaps]
|
||||
endif
|
||||
|
||||
if !empty(a:doc)
|
||||
let l:meta.doc = a:doc
|
||||
endif
|
||||
|
||||
"let self._meta[a:functionName] = l:meta
|
||||
call add(self._meta, l:meta)
|
||||
endfunction
|
||||
|
89
vimfiles/autoload/merginal/util.vim
Normal file
89
vimfiles/autoload/merginal/util.vim
Normal file
@ -0,0 +1,89 @@
|
||||
"Similar to Vim's inputlist, but adds numbers and a 'more' option for huge
|
||||
"lists. If no options selected, returns -1(not 0 like inputlist!)
|
||||
function! merginal#util#inputList(prompt, options, morePrompt) abort
|
||||
let l:takeFrom = 0
|
||||
while l:takeFrom < len(a:options)
|
||||
let l:takeThisTime = &lines - 2
|
||||
if l:takeFrom + l:takeThisTime < len(a:options)
|
||||
let l:more = l:takeThisTime
|
||||
let l:takeThisTime -= 1
|
||||
else
|
||||
let l:more = 0
|
||||
endif
|
||||
|
||||
let l:options = [a:prompt]
|
||||
|
||||
for l:i in range(min([l:takeThisTime, len(a:options) - l:takeFrom]))
|
||||
call add(l:options, printf('%i) %s', 1 + l:i, a:options[l:takeFrom + l:i]))
|
||||
endfor
|
||||
if l:more
|
||||
call add(l:options, printf('%i) %s', l:more, a:morePrompt))
|
||||
endif
|
||||
let l:selected = inputlist(l:options)
|
||||
if l:selected <= 0 || len(l:options) <= l:selected
|
||||
return -1
|
||||
elseif l:more && l:selected < l:more
|
||||
return l:takeFrom + l:selected - 1
|
||||
elseif !l:more && l:selected < len(l:options)
|
||||
return l:takeFrom + l:selected - 1
|
||||
endif
|
||||
|
||||
"Create a new line for the next inputlist's prompt
|
||||
echo ' '
|
||||
|
||||
let l:takeFrom += l:takeThisTime
|
||||
endwhile
|
||||
endfunction
|
||||
|
||||
function! merginal#util#makeColumns(widths, texts) abort
|
||||
let l:brokenToLines = []
|
||||
for l:i in range(len(a:texts))
|
||||
let l:text = a:texts[l:i]
|
||||
let l:width = a:widths[l:i]
|
||||
let l:lines = []
|
||||
let l:line = ''
|
||||
let l:words = split(l:text, ' ')
|
||||
for l:word in l:words
|
||||
if l:width < len(l:line) + 1 + len(l:word)
|
||||
if !empty(l:line)
|
||||
call add(l:lines, l:line)
|
||||
endif
|
||||
while l:width < len(l:word)
|
||||
call add(l:lines, l:word[:l:width - 1])
|
||||
let l:word = l:word[l:width :]
|
||||
endwhile
|
||||
let l:line = ''
|
||||
endif
|
||||
if !empty(l:line)
|
||||
let l:line .= ' '
|
||||
endif
|
||||
let l:line .= l:word
|
||||
endfor
|
||||
if !empty(l:line)
|
||||
call add(l:lines, l:line)
|
||||
endif
|
||||
call add(l:brokenToLines, l:lines)
|
||||
endfor
|
||||
|
||||
let l:maxLength = max(map(copy(l:brokenToLines), 'len(v:val)'))
|
||||
for l:lines in l:brokenToLines
|
||||
while len(l:lines) < l:maxLength
|
||||
call add(l:lines, '')
|
||||
endwhile
|
||||
endfor
|
||||
|
||||
let l:result = []
|
||||
for l:i in range(l:maxLength)
|
||||
let l:resultLine = ''
|
||||
for l:j in range(len(l:brokenToLines))
|
||||
let l:width = a:widths[l:j]
|
||||
let l:line = l:brokenToLines[l:j][l:i]
|
||||
let l:resultLine .= l:line.repeat(' ', l:width - len(l:line))
|
||||
let l:resultLine .= ' '
|
||||
endfor
|
||||
let l:resultLine = substitute(l:resultLine, '\v\s*$', '', '')
|
||||
call add(l:result, l:resultLine)
|
||||
endfor
|
||||
|
||||
return l:result
|
||||
endfunction
|
@ -2,8 +2,8 @@
|
||||
" @Website: http://www.vim.org/account/profile.php?user_id=4037
|
||||
" @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
|
||||
" @Created: 2007-09-17.
|
||||
" @Last Change: 2014-06-25.
|
||||
" @Revision: 1656
|
||||
" @Last Change: 2015-09-30.
|
||||
" @Revision: 1781
|
||||
|
||||
" call tlog#Log('Load: '. expand('<sfile>')) " vimtlib-sfile
|
||||
|
||||
@ -40,10 +40,14 @@ endif
|
||||
if !exists('g:tcommentOptions')
|
||||
" Other key-value options used by |tcomment#Comment()|.
|
||||
"
|
||||
" Example: If you want to put the opening comment marker always in
|
||||
" the first column regardless of the block's indentation, put this
|
||||
" into your |vimrc| file: >
|
||||
" Examples:
|
||||
" Put the opening comment marker always in the first column
|
||||
" regardless of the block's indentation, put this into your |vimrc|
|
||||
" file: >
|
||||
" let g:tcommentOptions = {'col': 1}
|
||||
"
|
||||
" Indent uncommented lines: >
|
||||
" let g:tcommentOptions = {'postprocess_uncomment': 'norm! %sgg=%sgg'}
|
||||
let g:tcommentOptions = {} "{{{2
|
||||
endif
|
||||
|
||||
@ -111,9 +115,15 @@ endif
|
||||
if !exists("g:tcommentGuessFileType_eruby")
|
||||
let g:tcommentGuessFileType_eruby = 1 "{{{2
|
||||
endif
|
||||
if !exists("g:tcommentGuessFileType_jinja")
|
||||
let g:tcommentGuessFileType_jinja = 'html' "{{{2
|
||||
endif
|
||||
if !exists("g:tcommentGuessFileType_smarty")
|
||||
let g:tcommentGuessFileType_smarty = 1 "{{{2
|
||||
endif
|
||||
if !exists("g:tcommentGuessFileType_rnoweb")
|
||||
let g:tcommentGuessFileType_rnoweb = 'r' "{{{2
|
||||
endif
|
||||
|
||||
if !exists("g:tcommentIgnoreTypes_php")
|
||||
" In php files, some syntax regions are wrongly highlighted as sql
|
||||
@ -181,10 +191,10 @@ if !exists('g:tcomment#replacements_c')
|
||||
\ }
|
||||
endif
|
||||
|
||||
if !exists("g:tcommentInlineC")
|
||||
" Generic c-like comments.
|
||||
" :read: let g:tcommentInlineC = {...} "{{{2
|
||||
let g:tcommentInlineC = {
|
||||
if !exists("g:tcommentLineC_fmt")
|
||||
" Generic c-like block comments.
|
||||
let g:tcommentLineC_fmt = {
|
||||
\ 'commentstring_rx': '\%%(// %s\|/* %s */\)',
|
||||
\ 'commentstring': '/* %s */',
|
||||
\ 'rxbeg': '\*\+',
|
||||
\ 'rxend': '',
|
||||
@ -192,10 +202,24 @@ if !exists("g:tcommentInlineC")
|
||||
\ 'replacements': g:tcomment#replacements_c
|
||||
\ }
|
||||
endif
|
||||
if !exists("g:tcommentLineC")
|
||||
" Generic c-like block comments.
|
||||
let g:tcommentLineC = g:tcommentInlineC
|
||||
|
||||
|
||||
function! tcomment#GetLineC(...)
|
||||
let cmt = deepcopy(g:tcommentLineC_fmt)
|
||||
if a:0 >= 1
|
||||
let cmt.commentstring = a:1
|
||||
endif
|
||||
return cmt
|
||||
endf
|
||||
|
||||
|
||||
if !exists("g:tcommentInlineC")
|
||||
" Generic c-like comments.
|
||||
" :read: let g:tcommentInlineC = {...} "{{{2
|
||||
let g:tcommentInlineC = tcomment#GetLineC()
|
||||
endif
|
||||
|
||||
|
||||
if !exists("g:tcommentBlockC")
|
||||
let g:tcommentBlockC = {
|
||||
\ 'commentstring': '/*%s */',
|
||||
@ -345,14 +369,18 @@ endf
|
||||
|
||||
call tcomment#DefineType('aap', '# %s' )
|
||||
call tcomment#DefineType('ada', '-- %s' )
|
||||
call tcomment#DefineType('autohotkey', '; %s' )
|
||||
call tcomment#DefineType('apache', '# %s' )
|
||||
call tcomment#DefineType('applescript', '(* %s *)' )
|
||||
call tcomment#DefineType('applescript_block',"(*%s*)\n" )
|
||||
call tcomment#DefineType('applescript_inline','(* %s *)' )
|
||||
call tcomment#DefineType('asciidoc', '// %s' )
|
||||
call tcomment#DefineType('asm', '; %s' )
|
||||
call tcomment#DefineType('asterisk', '; %s' )
|
||||
call tcomment#DefineType('blade', '{{-- %s --}}' )
|
||||
call tcomment#DefineType('blade_block', '{{-- %s --}}' )
|
||||
call tcomment#DefineType('blade_inline', '{{-- %s --}}' )
|
||||
call tcomment#DefineType('c', g:tcommentLineC )
|
||||
call tcomment#DefineType('c', tcomment#GetLineC())
|
||||
call tcomment#DefineType('c_block', g:tcommentBlockC )
|
||||
call tcomment#DefineType('c_inline', g:tcommentInlineC )
|
||||
call tcomment#DefineType('catalog', '-- %s --' )
|
||||
@ -368,9 +396,10 @@ call tcomment#DefineType('coffee', '# %s' )
|
||||
call tcomment#DefineType('conf', '# %s' )
|
||||
call tcomment#DefineType('context', '%% %s' )
|
||||
call tcomment#DefineType('conkyrc', '# %s' )
|
||||
call tcomment#DefineType('cpp', '// %s' )
|
||||
call tcomment#DefineType('cpp', tcomment#GetLineC('// %s'))
|
||||
call tcomment#DefineType('cpp_block', g:tcommentBlockC )
|
||||
call tcomment#DefineType('cpp_inline', g:tcommentInlineC )
|
||||
call tcomment#DefineType('cram', {'col': 1, 'commentstring': '# %s' })
|
||||
call tcomment#DefineType('crontab', '# %s' )
|
||||
call tcomment#DefineType('cs', '// %s' )
|
||||
call tcomment#DefineType('cs_block', g:tcommentBlockC )
|
||||
@ -396,15 +425,17 @@ call tcomment#DefineType('erlang', '%%%% %s' )
|
||||
call tcomment#DefineType('eruby', '<%%# %s' )
|
||||
call tcomment#DefineType('esmtprc', '# %s' )
|
||||
call tcomment#DefineType('expect', '# %s' )
|
||||
call tcomment#DefineType('fish', '# %s' )
|
||||
call tcomment#DefineType('form', {'commentstring': '* %s', 'col': 1})
|
||||
call tcomment#DefineType('fstab', '# %s' )
|
||||
call tcomment#DefineType('gitconfig', '# %s' )
|
||||
call tcomment#DefineType('gitcommit', '# %s' )
|
||||
call tcomment#DefineType('gitignore', '# %s' )
|
||||
call tcomment#DefineType('gnuplot', '# %s' )
|
||||
call tcomment#DefineType('go', '// %s' )
|
||||
call tcomment#DefineType('go_block', g:tcommentBlockC )
|
||||
call tcomment#DefineType('go_inline', g:tcommentInlineC )
|
||||
call tcomment#DefineType('groovy', '// %s' )
|
||||
call tcomment#DefineType('groovy', tcomment#GetLineC('// %s'))
|
||||
call tcomment#DefineType('groovy_block', g:tcommentBlockC )
|
||||
call tcomment#DefineType('groovy_doc_block', g:tcommentBlockC2 )
|
||||
call tcomment#DefineType('groovy_inline', g:tcommentInlineC )
|
||||
@ -425,24 +456,34 @@ call tcomment#DefineType('ini', '; %s' ) " php ini (/et
|
||||
call tcomment#DefineType('io', '// %s' )
|
||||
call tcomment#DefineType('jade', '// %s' )
|
||||
call tcomment#DefineType('jasmine', '# %s' )
|
||||
call tcomment#DefineType('java', '/* %s */' )
|
||||
call tcomment#DefineType('java', tcomment#GetLineC('// %s'))
|
||||
call tcomment#DefineType('java_block', g:tcommentBlockC )
|
||||
call tcomment#DefineType('java_doc_block', g:tcommentBlockC2 )
|
||||
call tcomment#DefineType('java_inline', g:tcommentInlineC )
|
||||
" call tcomment#DefineType('javaScript', '// %s' )
|
||||
" call tcomment#DefineType('javaScript_block', g:tcommentBlockC )
|
||||
" call tcomment#DefineType('javaScript_inline', g:tcommentInlineC )
|
||||
call tcomment#DefineType('javascript', '// %s' )
|
||||
call tcomment#DefineType('javascript', tcomment#GetLineC('// %s'))
|
||||
call tcomment#DefineType('javascript_block', g:tcommentBlockC )
|
||||
call tcomment#DefineType('javascript_inline', g:tcommentInlineC )
|
||||
call tcomment#DefineType('jsx', '{/* %s */}')
|
||||
call tcomment#DefineType('jsx_block', '{/* %s */}')
|
||||
call tcomment#DefineType('jsx_inline', '{/* %s */}')
|
||||
call tcomment#DefineType('jinja', '{# %s #}' )
|
||||
call tcomment#DefineType('jinja_block', "{%% comment %%}%s{%% endcomment %%}\n ")
|
||||
call tcomment#DefineType('jproperties', '# %s' )
|
||||
call tcomment#DefineType('lilypond', '%% %s' )
|
||||
call tcomment#DefineType('lisp', '; %s' )
|
||||
call tcomment#DefineType('liquid', g:tcommentInlineXML)
|
||||
call tcomment#DefineType('liquid_block', g:tcommentBlockXML )
|
||||
call tcomment#DefineType('liquid_inline', g:tcommentInlineXML)
|
||||
call tcomment#DefineType('lua', '-- %s' )
|
||||
call tcomment#DefineType('lua_block', "--[[%s--]]\n" )
|
||||
call tcomment#DefineType('lua_inline', '--[[%s --]]' )
|
||||
call tcomment#DefineType('lynx', '# %s' )
|
||||
call tcomment#DefineType('m4', 'dnl %s' )
|
||||
call tcomment#DefineType('mail', '> %s' )
|
||||
call tcomment#DefineType('make', '# %s' )
|
||||
call tcomment#DefineType('markdown_block', "<!---%s--->\n " )
|
||||
call tcomment#DefineType('markdown.pandoc', '<!--- %s --->' )
|
||||
call tcomment#DefineType('markdown.pandoc_block', "<!---%s--->\n ")
|
||||
call tcomment#DefineType('matlab', '%% %s' )
|
||||
call tcomment#DefineType('monkey', ''' %s' )
|
||||
call tcomment#DefineType('msidl', '// %s' )
|
||||
@ -484,7 +525,10 @@ call tcomment#DefineType('rc', '// %s' )
|
||||
call tcomment#DefineType('readline', '# %s' )
|
||||
call tcomment#DefineType('remind', {'commentstring_rx': '\[;#] %s', 'commentstring': '# %s'})
|
||||
call tcomment#DefineType('resolv', '# %s' )
|
||||
call tcomment#DefineType('robot', {'col': 1, 'commentstring': '# %s'})
|
||||
call tcomment#DefineType('robots', '# %s' )
|
||||
call tcomment#DefineType('rust', tcomment#GetLineC('// %s'))
|
||||
call tcomment#DefineType('rust_block', g:tcommentBlockC )
|
||||
call tcomment#DefineType('ruby', '# %s' )
|
||||
call tcomment#DefineType('ruby_3', '### %s' )
|
||||
call tcomment#DefineType('ruby_block', "=begin rdoc%s=end")
|
||||
@ -519,9 +563,12 @@ call tcomment#DefineType('sshdconfig', '# %s' )
|
||||
call tcomment#DefineType('st', '" %s "' )
|
||||
call tcomment#DefineType('tcl', '# %s' )
|
||||
call tcomment#DefineType('tex', '%% %s' )
|
||||
call tcomment#DefineType('toml', '# %s' )
|
||||
call tcomment#DefineType('tpl', '<!-- %s -->' )
|
||||
call tcomment#DefineType('tup', '# %s' )
|
||||
call tcomment#DefineType('typoscript', '# %s' )
|
||||
call tcomment#DefineType('upstart', '# %s' )
|
||||
call tcomment#DefineType('vader', {'col': 1, 'commentstring': '" %s' })
|
||||
call tcomment#DefineType('vhdl', '-- %s' )
|
||||
call tcomment#DefineType('verilog', '// %s' )
|
||||
call tcomment#DefineType('verilog_inline', g:tcommentInlineC )
|
||||
@ -569,6 +616,21 @@ function! s:DefaultValue(option)
|
||||
endf
|
||||
|
||||
|
||||
function! s:Count(string, rx)
|
||||
return len(split(a:string, a:rx, 1)) - 1
|
||||
endf
|
||||
|
||||
|
||||
function! s:Printf1(fmt, expr)
|
||||
let n = s:Count(a:fmt, '%\@<!\%(%%\)*%s')
|
||||
let exprs = repeat([a:expr], n)
|
||||
" TLogVAR a:fmt, a:expr, exprs
|
||||
let rv = call(function('printf'), [a:fmt] + exprs)
|
||||
" TLogVAR rv
|
||||
return rv
|
||||
endf
|
||||
|
||||
|
||||
let s:default_comments = s:DefaultValue('comments')
|
||||
let s:default_comment_string = s:DefaultValue('commentstring')
|
||||
let s:null_comment_string = '%s'
|
||||
@ -608,6 +670,9 @@ let s:null_comment_string = '%s'
|
||||
" (default), strip from empty lines only,
|
||||
" if 2, always strip whitespace; if 0,
|
||||
" don't strip any whitespace
|
||||
" postprocess_uncomment .. Run a |printf()| expression with 2
|
||||
" placeholders on uncommented lines, e.g.
|
||||
" 'norm! %sgg=%sgg'.
|
||||
" 2. 1-2 values for: ?commentPrefix, ?commentPostfix
|
||||
" 3. a dictionary (internal use only)
|
||||
"
|
||||
@ -621,6 +686,7 @@ let s:null_comment_string = '%s'
|
||||
" v ... visual
|
||||
" o ... operator
|
||||
" C ... force comment
|
||||
" K ... comment only uncommented lines
|
||||
" U ... force uncomment (if U and C are present, U wins)
|
||||
" By default, each line in range will be commented by adding the comment
|
||||
" prefix and postfix.
|
||||
@ -628,7 +694,7 @@ function! tcomment#Comment(beg, end, ...)
|
||||
let comment_mode0 = s:AddModeExtra((a:0 >= 1 ? a:1 : 'G'), g:tcommentModeExtra, a:beg, a:end)
|
||||
let comment_mode = comment_mode0
|
||||
let comment_anyway = a:0 >= 2 ? (a:2 == '!') : 0
|
||||
" TLogVAR a:beg, a:end, comment_mode, comment_anyway
|
||||
" TLogVAR a:beg, a:end, comment_mode, comment_anyway, a:000
|
||||
" save the cursor position
|
||||
if exists('w:tcomment_pos')
|
||||
let s:current_pos = copy(w:tcomment_pos)
|
||||
@ -656,11 +722,7 @@ function! tcomment#Comment(beg, end, ...)
|
||||
let [lbeg, cbeg, lend, cend] = s:GetStartEnd(a:beg, a:end, comment_mode)
|
||||
" TLogVAR lbeg, cbeg, lend, cend, virtcol('$')
|
||||
if comment_mode ==? 'I' && comment_mode0 =~# 'i' && lbeg == lend && cend >= virtcol('$') - 1
|
||||
if cbeg <= 1
|
||||
let comment_mode = 'G'
|
||||
else
|
||||
let comment_mode = 'R'
|
||||
endif
|
||||
let comment_mode = substitute(comment_mode, '\CI', cbeg <= 1 ? 'G' : 'R', 'g')
|
||||
" TLogVAR comment_mode
|
||||
endif
|
||||
let mode_extra = s:GetTempOption('mode_extra', '')
|
||||
@ -696,7 +758,8 @@ function! tcomment#Comment(beg, end, ...)
|
||||
endif
|
||||
" TLogVAR ax, a:0, a:000
|
||||
if a:0 >= ax
|
||||
let cdef = extend(cdef, s:ParseArgs(lbeg, lend, comment_mode, a:000[ax - 1 : -1]))
|
||||
" let cdef = extend(cdef, s:ParseArgs(lbeg, lend, comment_mode, a:000[ax - 1 : -1]))
|
||||
let cdef = s:ExtendCDef(lbeg, lend, comment_mode, cdef, s:ParseArgs(lbeg, lend, comment_mode, a:000[ax - 1 : -1]))
|
||||
" TLogVAR 5, cdef
|
||||
endif
|
||||
if !empty(get(cdef, 'begin', '')) || !empty(get(cdef, 'end', ''))
|
||||
@ -734,26 +797,39 @@ function! tcomment#Comment(beg, end, ...)
|
||||
let cmt_check = substitute(cms0, '\([ ]\)', '\1\\?', 'g')
|
||||
"" turn commentstring into a search pattern
|
||||
" TLogVAR cmt_check
|
||||
let cmt_check = printf(cmt_check, '\(\_.\{-}\)')
|
||||
let cmt_check = s:Printf1(cmt_check, '\(\_.\{-}\)')
|
||||
" TLogVAR cdef, cmt_check
|
||||
let s:cdef = cdef
|
||||
" set comment_mode
|
||||
" TLogVAR comment_mode
|
||||
let [lbeg, lend, uncomment] = s:CommentDef(lbeg, lend, cmt_check, comment_mode, cbeg, cend)
|
||||
" TLogVAR lbeg, lend, cbeg, cend, uncomment
|
||||
" echom "DBG" string(s:cdef)
|
||||
let cbeg = get(s:cdef, 'col', cbeg)
|
||||
" TLogVAR cbeg
|
||||
if mode_extra =~# 'U'
|
||||
let uncomment = 1
|
||||
elseif mode_extra =~# 'C' || comment_anyway
|
||||
let uncomment = 0
|
||||
" TLogVAR lbeg, lend, cbeg, cend, uncomment, comment_mode, comment_anyway
|
||||
if uncomment
|
||||
if comment_mode =~# 'C' || comment_anyway
|
||||
let comment_do = 'c'
|
||||
else
|
||||
let comment_do = 'u'
|
||||
endif
|
||||
else
|
||||
if comment_mode =~# 'U'
|
||||
let comment_do = 'u'
|
||||
elseif comment_mode =~# 'K'
|
||||
let comment_do = 'k'
|
||||
else
|
||||
let comment_do = 'c'
|
||||
endif
|
||||
endif
|
||||
" TLogVAR comment_anyway, mode_extra, uncomment
|
||||
" TLogVAR comment_anyway, comment_mode, mode_extra, comment_do
|
||||
" " echom "DBG" string(s:cdef)
|
||||
if comment_do ==# 'c'
|
||||
let cbeg = get(s:cdef, 'col', cbeg)
|
||||
endif
|
||||
" TLogVAR cbeg
|
||||
" go
|
||||
" TLogVAR comment_mode
|
||||
if comment_mode =~# 'B'
|
||||
" We want a comment block
|
||||
call s:CommentBlock(lbeg, lend, cbeg, cend, comment_mode, uncomment, cmt_check, s:cdef)
|
||||
call s:CommentBlock(lbeg, lend, cbeg, cend, comment_mode, comment_do, cmt_check, s:cdef)
|
||||
else
|
||||
" We want commented lines
|
||||
" final search pattern for uncommenting
|
||||
@ -791,18 +867,28 @@ function! tcomment#Comment(beg, end, ...)
|
||||
endif
|
||||
endif
|
||||
if !empty(lmatch)
|
||||
let part1 = s:ProcessLine(uncomment, lmatch[2], cmt_check, cmt_replace)
|
||||
" TLogVAR part1
|
||||
let line1 = lmatch[1] . part1 . lmatch[4]
|
||||
if uncomment && g:tcomment#rstrip_on_uncomment > 0
|
||||
if g:tcomment#rstrip_on_uncomment == 2 || line1 !~ '\S'
|
||||
let line1 = substitute(line1, '\s\+$', '', '')
|
||||
let [part1, ok] = s:ProcessLine(comment_do, lmatch[2], cmt_check, cmt_replace)
|
||||
" TLogVAR part1, ok
|
||||
if ok
|
||||
let line1 = lmatch[1] . part1 . lmatch[4]
|
||||
if comment_do ==# 'u'
|
||||
if g:tcomment#rstrip_on_uncomment > 0
|
||||
if g:tcomment#rstrip_on_uncomment == 2 || line1 !~ '\S'
|
||||
let line1 = substitute(line1, '\s\+$', '', '')
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
" TLogVAR line1
|
||||
call setline(lnum, line1)
|
||||
endif
|
||||
" TLogVAR line1
|
||||
call setline(lnum, line1)
|
||||
endif
|
||||
endfor
|
||||
if comment_do ==# 'u'
|
||||
let postprocess_uncomment = get(cdef, 'postprocess_uncomment', '')
|
||||
if !empty(postprocess_uncomment)
|
||||
exec printf(postprocess_uncomment, lbeg, lend)
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
" reposition cursor
|
||||
" TLogVAR 3, comment_mode
|
||||
@ -839,6 +925,20 @@ else
|
||||
endif
|
||||
|
||||
|
||||
function! tcomment#MaybeReuseOptions(name) "{{{3
|
||||
if exists('s:options_cache') && get(s:options_cache, 'name', '') == a:name
|
||||
if exists('s:temp_options')
|
||||
let s:temp_options = extend(deepcopy(s:options_cache.options), s:temp_options)
|
||||
let s:options_cache = {'name': a:name, 'options': s:temp_options}
|
||||
else
|
||||
let s:temp_options = deepcopy(s:options_cache.options)
|
||||
endif
|
||||
elseif exists('s:temp_options')
|
||||
let s:options_cache = {'name': a:name, 'options': s:temp_options}
|
||||
endif
|
||||
endf
|
||||
|
||||
|
||||
function! s:GetTempOption(name, default) "{{{3
|
||||
if exists('s:temp_options') && has_key(s:temp_options, a:name)
|
||||
return s:temp_options[a:name]
|
||||
@ -848,6 +948,11 @@ function! s:GetTempOption(name, default) "{{{3
|
||||
endf
|
||||
|
||||
|
||||
function! tcomment#ResetOption() "{{{3
|
||||
unlet! s:temp_options s:options_cache
|
||||
endf
|
||||
|
||||
|
||||
function! tcomment#SetOption(name, arg) "{{{3
|
||||
" TLogVAR a:name, a:arg
|
||||
if !exists('s:temp_options')
|
||||
@ -1012,15 +1117,27 @@ endf
|
||||
|
||||
function! s:ExtendCDef(beg, end, comment_mode, cdef, args)
|
||||
for [key, value] in items(a:args)
|
||||
" TLogVAR key, value
|
||||
if key == 'as'
|
||||
call extend(a:cdef, s:GetCommentDefinitionForType(a:beg, a:end, a:comment_mode, value))
|
||||
elseif key == 'mode'
|
||||
let a:cdef[key] = a:comment_mode . value
|
||||
" let a:cdef[key] = a:comment_mode . value
|
||||
let a:cdef.mode = s:AddModeExtra(a:comment_mode, value, a:beg, a:end)
|
||||
elseif key == 'mode_extra'
|
||||
if has_key(a:cdef, 'mode')
|
||||
let mode = s:AddModeExtra(a:comment_mode, a:cdef.mode, a:beg, a:end)
|
||||
" TLogVAR 'mode', mode
|
||||
else
|
||||
let mode = a:comment_mode
|
||||
" TLogVAR 'mode == comment_mode', mode
|
||||
endif
|
||||
let a:cdef.mode = s:AddModeExtra(mode, value, a:beg, a:end)
|
||||
elseif key == 'count'
|
||||
let a:cdef[key] = str2nr(value)
|
||||
else
|
||||
let a:cdef[key] = value
|
||||
endif
|
||||
" TLogVAR get(a:cdef, 'comment_mode', '')
|
||||
endfor
|
||||
return a:cdef
|
||||
endf
|
||||
@ -1228,7 +1345,7 @@ endf
|
||||
" s:GetCommentDefinition(beg, end, comment_mode, ?filetype="")
|
||||
function! s:GetCommentDefinition(beg, end, comment_mode, ...)
|
||||
let ft = a:0 >= 1 ? a:1 : ''
|
||||
" TLogVAR ft
|
||||
" TLogVAR a:comment_mode, ft
|
||||
if ft != ''
|
||||
let cdef = s:GuessCustomCommentString(ft, a:comment_mode)
|
||||
else
|
||||
@ -1342,75 +1459,97 @@ function! s:CommentDef(beg, end, checkRx, comment_mode, cbeg, cend)
|
||||
" TLogVAR a:beg, a:end, a:checkRx, a:comment_mode, a:cbeg, a:cend
|
||||
let beg = a:beg
|
||||
let end = a:end
|
||||
if get(s:cdef, 'mixedindent', 1)
|
||||
let mdrx = '\V'. s:StartColRx(a:comment_mode, a:cbeg) .'\s\*'
|
||||
let mdrx .= s:StartColRx(a:comment_mode, a:cbeg + 1, 0) .'\s\*'
|
||||
if a:comment_mode =~# 'U'
|
||||
let uncomment = 1
|
||||
elseif a:comment_mode =~# '[CK]'
|
||||
let uncomment = 0
|
||||
else
|
||||
let mdrx = '\V'. s:StartColRx(a:comment_mode, a:cbeg) .'\s\*'
|
||||
endif
|
||||
let mdrx .= a:checkRx .'\s\*'. s:EndColRx(a:comment_mode, a:end, 0)
|
||||
" let mdrx = '\V'. s:StartPosRx(a:comment_mode, beg, a:cbeg) .'\s\*'. a:checkRx .'\s\*'. s:EndPosRx(a:comment_mode, end, 0)
|
||||
" TLogVAR mdrx
|
||||
let line = getline(beg)
|
||||
if a:cbeg != 0 && a:cend != 0
|
||||
let line = strpart(line, 0, a:cend - 1)
|
||||
endif
|
||||
let uncomment = (line =~ mdrx)
|
||||
" TLogVAR 1, uncomment, line
|
||||
let n = beg + 1
|
||||
if a:comment_mode =~# 'G'
|
||||
if uncomment
|
||||
while n <= end
|
||||
if getline(n) =~ '\S'
|
||||
if !(getline(n) =~ mdrx)
|
||||
let uncomment = 0
|
||||
" TLogVAR 2, uncomment
|
||||
break
|
||||
if get(s:cdef, 'mixedindent', 1)
|
||||
let mdrx = '\V'. s:StartColRx(a:comment_mode, a:cbeg) .'\s\*'
|
||||
let mdrx .= s:StartColRx(a:comment_mode, a:cbeg + 1, 0) .'\s\*'
|
||||
else
|
||||
let mdrx = '\V'. s:StartColRx(a:comment_mode, a:cbeg) .'\s\*'
|
||||
endif
|
||||
let mdrx .= a:checkRx .'\s\*'. s:EndColRx(a:comment_mode, a:end, 0)
|
||||
" let mdrx = '\V'. s:StartPosRx(a:comment_mode, beg, a:cbeg) .'\s\*'. a:checkRx .'\s\*'. s:EndPosRx(a:comment_mode, end, 0)
|
||||
" TLogVAR mdrx
|
||||
let line = getline(beg)
|
||||
if a:cbeg != 0 && a:cend != 0
|
||||
let line = strpart(line, 0, a:cend - 1)
|
||||
endif
|
||||
let uncomment = (line =~ mdrx)
|
||||
" TLogVAR 1, uncomment, line
|
||||
let n = beg + 1
|
||||
if a:comment_mode =~# 'G'
|
||||
if uncomment
|
||||
while n <= end
|
||||
if getline(n) =~ '\S'
|
||||
if !(getline(n) =~ mdrx)
|
||||
let uncomment = 0
|
||||
" TLogVAR 2, uncomment
|
||||
break
|
||||
endif
|
||||
endif
|
||||
let n = n + 1
|
||||
endwh
|
||||
endif
|
||||
elseif a:comment_mode =~# 'B'
|
||||
let t = @t
|
||||
try
|
||||
silent exec 'norm! '. beg.'G1|v'.end.'G$"ty'
|
||||
if &selection == 'inclusive' && @t =~ '\n$' && len(@t) > 1
|
||||
let @t = @t[0 : -2]
|
||||
endif
|
||||
" TLogVAR @t, mdrx
|
||||
let uncomment = (@t =~ mdrx)
|
||||
" TLogVAR 3, uncomment
|
||||
if !uncomment && a:comment_mode =~ 'o'
|
||||
let mdrx1 = substitute(mdrx, '\\$$', '\\n\\$', '')
|
||||
" TLogVAR mdrx1
|
||||
if @t =~ mdrx1
|
||||
let uncomment = 1
|
||||
" TLogVAR 4, uncomment
|
||||
endif
|
||||
endif
|
||||
let n = n + 1
|
||||
endwh
|
||||
finally
|
||||
let @t = t
|
||||
endtry
|
||||
endif
|
||||
elseif a:comment_mode =~# 'B'
|
||||
let t = @t
|
||||
try
|
||||
silent exec 'norm! '. beg.'G1|v'.end.'G$"ty'
|
||||
if &selection == 'inclusive' && @t =~ '\n$' && len(@t) > 1
|
||||
let @t = @t[0 : -2]
|
||||
endif
|
||||
" TLogVAR @t, mdrx
|
||||
let uncomment = (@t =~ mdrx)
|
||||
" TLogVAR 3, uncomment
|
||||
if !uncomment && a:comment_mode =~ 'o'
|
||||
let mdrx1 = substitute(mdrx, '\\$$', '\\n\\$', '')
|
||||
" TLogVAR mdrx1
|
||||
if @t =~ mdrx1
|
||||
let uncomment = 1
|
||||
" TLogVAR 4, uncomment
|
||||
endif
|
||||
endif
|
||||
finally
|
||||
let @t = t
|
||||
endtry
|
||||
endif
|
||||
" TLogVAR 5, uncomment
|
||||
" TLogVAR 5, beg, end, uncomment
|
||||
return [beg, end, uncomment]
|
||||
endf
|
||||
|
||||
|
||||
function! s:ProcessLine(uncomment, match, checkRx, replace)
|
||||
" TLogVAR a:uncomment, a:match, a:checkRx, a:replace
|
||||
function! s:ProcessLine(comment_do, match, checkRx, replace)
|
||||
" TLogVAR a:comment_do, a:match, a:checkRx, a:replace
|
||||
try
|
||||
if !(g:tcomment#blank_lines > 0 || a:match =~ '\S')
|
||||
return a:match
|
||||
endif
|
||||
if a:uncomment
|
||||
let rv = substitute(a:match, a:checkRx, '\1\2', '')
|
||||
if a:comment_do ==# 'k'
|
||||
if a:match =~ a:checkRx
|
||||
return ['', 0]
|
||||
endif
|
||||
endif
|
||||
if a:comment_do ==# 'u'
|
||||
let m = matchlist(a:match, a:checkRx)
|
||||
if !empty(m)
|
||||
for irx in range(2, s:Count(a:checkRx, '\\\@<!\\('))
|
||||
if !empty(m[irx])
|
||||
break
|
||||
endif
|
||||
endfor
|
||||
" TLogVAR irx
|
||||
else
|
||||
let irx = 2
|
||||
endif
|
||||
let rv = substitute(a:match, a:checkRx, '\1\'. irx, '')
|
||||
let rv = s:UnreplaceInLine(rv)
|
||||
else
|
||||
let ml = len(a:match)
|
||||
let rv = s:ReplaceInLine(a:match)
|
||||
let rv = printf(a:replace, rv)
|
||||
let rv = s:Printf1(a:replace, rv)
|
||||
let strip_whitespace = get(s:cdef, 'strip_whitespace', 1)
|
||||
if strip_whitespace == 2 || (strip_whitespace == 1 && ml == 0)
|
||||
let rv = substitute(rv, '\s\+$', '', '')
|
||||
@ -1429,7 +1568,7 @@ function! s:ProcessLine(uncomment, match, checkRx, replace)
|
||||
" TLogVAR a:replace, prefix_len
|
||||
if prefix_len != -1
|
||||
let s:cursor_pos = copy(s:current_pos)
|
||||
if a:uncomment
|
||||
if a:comment_do ==# 'u'
|
||||
let s:cursor_pos[2] -= prefix_len
|
||||
if s:cursor_pos[2] < 1
|
||||
let s:cursor_pos[2] = 1
|
||||
@ -1450,7 +1589,7 @@ function! s:ProcessLine(uncomment, match, checkRx, replace)
|
||||
" TLogVAR rv
|
||||
" let rv = substitute(rv, '\n', '\\\n', 'g')
|
||||
" TLogVAR rv
|
||||
return rv
|
||||
return [rv, 1]
|
||||
finally
|
||||
let s:processline_lnum += 1
|
||||
endtry
|
||||
@ -1510,8 +1649,8 @@ function! s:InlineReplacement(text, rx, tokens, replacements) "{{{3
|
||||
endf
|
||||
|
||||
|
||||
function! s:CommentBlock(beg, end, cbeg, cend, comment_mode, uncomment, checkRx, cdef)
|
||||
" TLogVAR a:beg, a:end, a:cbeg, a:cend, a:uncomment, a:checkRx, a:cdef
|
||||
function! s:CommentBlock(beg, end, cbeg, cend, comment_mode, comment_do, checkRx, cdef)
|
||||
" TLogVAR a:beg, a:end, a:cbeg, a:cend, a:comment_do, a:checkRx, a:cdef
|
||||
let indentStr = repeat(' ', a:cbeg)
|
||||
let t = @t
|
||||
let sel_save = &selection
|
||||
@ -1525,7 +1664,7 @@ function! s:CommentBlock(beg, end, cbeg, cend, comment_mode, uncomment, checkRx,
|
||||
let prefix = substitute(matchstr(cs, '^.*%\@<!\ze%s'), '%\(.\)', '\1', 'g')
|
||||
let postfix = substitute(matchstr(cs, '%\@<!%s\zs.*$'), '%\(.\)', '\1', 'g')
|
||||
" TLogVAR ms, mx, cs, prefix, postfix
|
||||
if a:uncomment
|
||||
if a:comment_do == 'u'
|
||||
let @t = substitute(@t, '\V\^\s\*'. a:checkRx .'\$', '\1', '')
|
||||
let tt = []
|
||||
" TODO: Correctly handle foreign comments with inconsistent
|
||||
@ -1591,7 +1730,7 @@ function! s:CommentBlock(beg, end, cbeg, cend, comment_mode, uncomment, checkRx,
|
||||
let @t = join(lines, "\n")
|
||||
" TLogVAR 3, @t
|
||||
endif
|
||||
let @t = printf(cs, "\n". @t ."\n")
|
||||
let @t = s:Printf1(cs, "\n". @t ."\n")
|
||||
" TLogVAR 4, cs, @t, a:comment_mode
|
||||
if a:comment_mode =~ '#'
|
||||
let s:cursor_pos = copy(s:current_pos)
|
||||
@ -1695,7 +1834,6 @@ endf
|
||||
" s:GuessFileType(beg, end, comment_mode, filetype, ?fallbackFiletype)
|
||||
function! s:GuessFileType(beg, end, comment_mode, filetype, ...)
|
||||
" TLogVAR a:beg, a:end, a:comment_mode, a:filetype, a:000
|
||||
" TLogVAR cdef
|
||||
let cdef0 = s:GuessCustomCommentString(a:filetype, a:comment_mode)
|
||||
if a:0 >= 1 && a:1 != ''
|
||||
let cdef = s:GuessCustomCommentString(a:1, a:comment_mode)
|
||||
@ -1727,10 +1865,12 @@ function! s:GuessFileType(beg, end, comment_mode, filetype, ...)
|
||||
let n = beg
|
||||
" TLogVAR n, beg, end
|
||||
while n <= end
|
||||
let m = indent(n) + 1
|
||||
let text = getline(n)
|
||||
let le = len(text)
|
||||
" TLogVAR m, le
|
||||
let indentstring = matchstr(text, '^\s*')
|
||||
let m = strwidth(indentstring)
|
||||
" let m = indent(n) + 1
|
||||
let le = strwidth(text)
|
||||
" TLogVAR n, m, le
|
||||
while m <= le
|
||||
let syntax_name = s:GetSyntaxName(n, m)
|
||||
" TLogVAR syntax_name, n, m
|
||||
@ -1805,6 +1945,7 @@ endf
|
||||
|
||||
|
||||
function! s:AddModeExtra(comment_mode, extra, beg, end) "{{{3
|
||||
" TLogVAR a:comment_mode, a:extra
|
||||
if a:beg == a:end
|
||||
let extra = substitute(a:extra, '\C[B]', '', 'g')
|
||||
else
|
||||
@ -1817,6 +1958,9 @@ function! s:AddModeExtra(comment_mode, extra, beg, end) "{{{3
|
||||
if extra =~# '[IR]'
|
||||
let comment_mode = substitute(comment_mode, '\c[gb]', '', 'g')
|
||||
endif
|
||||
if extra =~# '[BLIRK]' && comment_mode =~# 'G'
|
||||
let comment_mode = substitute(comment_mode, '\c[G]', '', 'g')
|
||||
endif
|
||||
let rv = comment_mode . extra
|
||||
" TLogVAR a:comment_mode, a:extra, comment_mode, extra, rv
|
||||
return rv
|
||||
@ -1825,20 +1969,20 @@ endf
|
||||
|
||||
function! s:GuessCommentMode(comment_mode, supported_comment_modes) "{{{3
|
||||
" TLogVAR a:comment_mode, a:supported_comment_modes
|
||||
let special = substitute(a:comment_mode, '\c[^ukc]', '', 'g')
|
||||
let cmode = tolower(a:comment_mode)
|
||||
let ccmodes = split(tolower(a:supported_comment_modes), '\zs')
|
||||
let ccmodes = filter(ccmodes, 'stridx(cmode, v:val) != -1')
|
||||
let guess = substitute(a:comment_mode, '\w\+', 'G', 'g')
|
||||
" TLogVAR ccmodes, guess
|
||||
if a:comment_mode =~# '[BR]'
|
||||
return !empty(ccmodes) ? a:comment_mode : guess
|
||||
let rv = !empty(ccmodes) ? a:comment_mode : guess
|
||||
elseif a:comment_mode =~# '[I]'
|
||||
return !empty(ccmodes) ? a:comment_mode : ''
|
||||
" elseif a:comment_mode =~# '[R]' && !empty(ccmodes)
|
||||
" return a:comment_mode
|
||||
let rv = !empty(ccmodes) ? a:comment_mode : ''
|
||||
else
|
||||
return guess
|
||||
let rv = guess
|
||||
endif
|
||||
return s:AddModeExtra(rv, special, 0, 1)
|
||||
endf
|
||||
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
*SrchRplcHiGrp.txt* Search and Replace Restricted to a Highlighting Group
|
||||
|
||||
Author: David Fishburn January 1, 2011
|
||||
Author: David Fishburn August 25, 2015
|
||||
|
||||
|
||||
==============================================================================
|
||||
@ -13,6 +13,7 @@ Author: David Fishburn January 1, 2011
|
||||
SRChooseHiGrp.................: |SRChooseHiGrp|
|
||||
SRHiGrp.......................: |SRHiGrp|
|
||||
3. Examples......................: |srchrplchigrp-examples|
|
||||
4. History.......................: |srchrplchigrp-history|
|
||||
|
||||
|
||||
==============================================================================
|
||||
@ -24,7 +25,7 @@ Author: David Fishburn January 1, 2011
|
||||
Displays the syntax id and name the of the syntax group
|
||||
which has been chosen.
|
||||
|
||||
SRChooseHiGrp[!] *SRChooseHiGrp*
|
||||
SRChooseHiGrp[!][id] *SRChooseHiGrp*
|
||||
Before you can run the search and replace command (:SRHiGrp),
|
||||
you must choose which syntax group id you want to operate on.
|
||||
The top level syntax id of the current cursor position is
|
||||
@ -33,61 +34,74 @@ Author: David Fishburn January 1, 2011
|
||||
The optional bang lets SRChooseHiGrp use the translated
|
||||
syntax ID. This is final one versus the top-level one.
|
||||
|
||||
Assuming we were using a SQL file and placed the cursor on the
|
||||
FROM word, then using the SyntaxAttr plugin
|
||||
(http://vim.sourceforge.net/script.php?script_id=383)
|
||||
it displays both the top-level and translated
|
||||
(or final) highlight group as follows: >
|
||||
group: sqlKeyword->Statement guifg=#ffff00(#ffff00)
|
||||
<
|
||||
Assuming we were using a SQL file and placed the cursor on any
|
||||
word in a Comment section. Typically SQL comments can use any
|
||||
of these formats:
|
||||
-- This is a comment
|
||||
|
||||
// This is also a comment
|
||||
|
||||
/*
|
||||
* This is a multi
|
||||
* line comment
|
||||
*/
|
||||
|
||||
|
||||
Examples: >
|
||||
:SRChooseHiGrp
|
||||
< Will operate on only sqlKeyword syntax groups
|
||||
< SRHiGrp - Group ID: 497 Name: sqlDashComment
|
||||
|
||||
Will operate on only sqlDashComment syntax groups
|
||||
>
|
||||
:SRChooseHiGrp!
|
||||
< Will operate on all Statement syntax groups. Based on
|
||||
|group-name|, the Statement group will highlight the
|
||||
same color for the following highlight groups:
|
||||
Conditional
|
||||
Repeat
|
||||
Label
|
||||
Operator
|
||||
Keyword
|
||||
Exception
|
||||
Therefore SRChooseHiGrp! will operate over all of the
|
||||
above syntax groups.
|
||||
< SRHiGrp - Group ID: 46 Name: Comment
|
||||
|
||||
SRSearch *SRSearch*
|
||||
This command will perform a forward search starting at the current
|
||||
cursor position for a specified highlight group name. The range defaults
|
||||
to the entire file. It supports all visual modes, characterwise (v),
|
||||
linewise (V) and blockwise (<C-V>).
|
||||
|
||||
It optionally takes takes one parameter. You can supply a hightlight
|
||||
group name: >
|
||||
:SRSearch Statement
|
||||
Will operate on all Comment syntax groups. Looking
|
||||
at the syntax file for this we see: >
|
||||
hi def link sqlDashComment Comment
|
||||
hi def link sqlSlashComment Comment
|
||||
hi def link sqlMultiComment Comment
|
||||
<
|
||||
The command supports highlight group name completion. >
|
||||
:SRSearch C<Tab>
|
||||
< Depending on which syntax groups are defined (given your filetype and
|
||||
various plugins) this will cycle through all highlight group names
|
||||
beginning with the letter 'C'.
|
||||
Therefore SRChooseHiGrp! will operate over all of the
|
||||
above syntax groups: >
|
||||
sqlDashComment
|
||||
sqlSlashComment
|
||||
sqlMultiComment
|
||||
>
|
||||
:SRChooseHiGrp 46
|
||||
< SRHiGrp - Group ID: 46 Name: Comment
|
||||
|
||||
Alternatively, you can use the SRChooseHiGrp or SRChooseHiGrp!
|
||||
command to select the highlight group. Running SRSearch
|
||||
without a parameter will check if a valid group name was
|
||||
selected via SRChooseHiGrp and begin the search. If no valid
|
||||
group name was specified, an error message will be reported.
|
||||
Instead of choosing the syntax group the cursor is on
|
||||
this allows you to programmatically choose the exact
|
||||
group id you want.
|
||||
|
||||
SRSearch[!] *SRSearch*
|
||||
This command will perform a forward search starting at the current
|
||||
cursor position for text in the specified highlight group
|
||||
name. The range defaults to the entire file. It supports all
|
||||
visual modes, characterwise (v), linewise (V) and blockwise
|
||||
(<C-V>). First choose a highlight group using SRChooseHiGrp.
|
||||
Providing no arguments will search until it finds text
|
||||
highlighted in that syntax. >
|
||||
:SRSearch
|
||||
<
|
||||
Using the bang (!) it will search for the next text that is
|
||||
not using the syntax group: >
|
||||
:SRSearch!
|
||||
<
|
||||
It optionally takes takes a regex parameter. You can supply a hightlight
|
||||
group name: >
|
||||
:SRSearch some text
|
||||
:SRSearch \(first\|second\|word\)
|
||||
<
|
||||
Running SRSearch a second time will ensure the cursor is
|
||||
positioned on the next separate highlight matched text.
|
||||
There must be a gap between the two groups.
|
||||
|
||||
SRHiGrp[!] *SRHiGrp*
|
||||
This command will perform a search and replace over a visual
|
||||
range. It works in all visual modes, characterwise (v),
|
||||
linewise (V) and blockwise (<C-V>).
|
||||
This command will perform a search and replace over a range.
|
||||
The range defaults to the entire file. It works in all visual
|
||||
modes, characterwise (v), linewise (V) and blockwise (<C-V>).
|
||||
|
||||
It optionally takes takes 2 parameters.
|
||||
|
||||
@ -184,26 +198,57 @@ Author: David Fishburn January 1, 2011
|
||||
--------
|
||||
|
||||
SRSearch simply does a forward search for the specified highlight
|
||||
group. A few examples: >
|
||||
:SRSearch sqlKeyword
|
||||
:1,5SRSearch sqlKeyword
|
||||
:'<,'>SRSearch sqlKeyword
|
||||
<
|
||||
Optionally, you can first choose the hightlight group by placing your
|
||||
cursor on the highlight you want and: >
|
||||
:SRChooseHiGrp
|
||||
group. You must first use SRChooseHiGrp to choose a highlight group.
|
||||
Find the next item highlighted as that syntax group: >
|
||||
:SRSearch
|
||||
:1,5SRSearch
|
||||
:'<,'>SRSearch
|
||||
<
|
||||
Using Vim's tab completion you can also: >
|
||||
:SRSearch s<Tab>
|
||||
Find the next item highlighted that is NOT that syntax group: >
|
||||
:SRSearch!
|
||||
:1,5SRSearch!
|
||||
:'<,'>SRSearch!
|
||||
<
|
||||
Find the next item highlighted as that syntax group and matches
|
||||
the regular expression supplied: >
|
||||
:SRSearch something
|
||||
:SRSearch \(first\|second\|word\)
|
||||
<
|
||||
Find the next item highlighted that is NOT that syntax group and
|
||||
matches the regular expression supplied: >
|
||||
:SRSearch! \(first\|second\|word\)
|
||||
<
|
||||
Each time you press tab, it will cycle through the currently defined
|
||||
syntax highlight groups beginning with the letter 's'.
|
||||
|
||||
The results of the search is displayed in the command line and is
|
||||
highlighted in the color of the syntax group. This will remind you
|
||||
which group was searched for. >
|
||||
SRSearch - Match found - Group ID: 171 Name: sqlKeyword
|
||||
SRSearch - Match NOT found - Group ID: 171 Name: sqlKeyword
|
||||
SRSearch - Match found - Group ID: 171 Name: sqlKeyword Regex: \(first\|second\|word\)
|
||||
SRSearch - Match NOT found - Group ID: 171 Name: sqlKeyword Regex \(first\|second\|word\)
|
||||
<
|
||||
==============================================================================
|
||||
4. History *srchrplchigrp-history*
|
||||
|
||||
Version 7 (August 25, 2015)
|
||||
- Changed SRSeach. It will first look for the next item that has
|
||||
the syntax group chosen via SRChooseHiGrp.
|
||||
It will also take an optional regular expression and not only find
|
||||
that syntax group, but also match the regular expression.
|
||||
Added SRSearch!, which will find the next item that is NOT what
|
||||
was chosen via SRChooseHiGrp. Same applied with the regular
|
||||
expression, so if I put my cursor on a comment and :SRChooseHiGrp.
|
||||
Then ran :SRSearch! something, it will find the word "something"
|
||||
that is NOT in a comment.
|
||||
|
||||
|
||||
|
||||
Version 6 (July 27, 2015)
|
||||
- Changed to save and restore cp options on load
|
||||
- Changed to use Vim's autoload mechanism to load only when
|
||||
required (speeds Vim's load time and memory usage)
|
||||
- When using SRHiGrp! (operate over non-matching areas) the plugin
|
||||
always reported "Did not find highlight group" (Mathieu Westphal)
|
||||
- SRHiGrp now defaults the range to the entire file, instead of the
|
||||
current row
|
||||
|
||||
vim:tw=78:ts=8:ft=help:norl:
|
||||
|
392
vimfiles/doc/diffchar.txt
Normal file
392
vimfiles/doc/diffchar.txt
Normal file
@ -0,0 +1,392 @@
|
||||
*diffchar.txt* Highlight the exact differences, based on characters and words
|
||||
>
|
||||
____ _ ____ ____ _____ _ _ _____ ____
|
||||
| | | || || || || | | || _ || _ |
|
||||
| _ || || __|| __|| || | | || | | || | ||
|
||||
| | | || || |__ | |__ | __|| |_| || |_| || |_||_
|
||||
| |_| || || __|| __|| | | || || __ |
|
||||
| || || | | | | |__ | _ || _ || | | |
|
||||
|____| |_||_| |_| |_____||_| |_||_| |_||_| |_|
|
||||
<
|
||||
Last Change: 2016/03/09
|
||||
Version: 6.1
|
||||
Author: Rick Howe <rdcxy754@ybb.ne.jp>
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
INTRODUCTION *diffchar*
|
||||
|
||||
This plugin has been developed in order to make diff mode more useful. Vim
|
||||
highlights all the text in between the first and last different characters on
|
||||
a changed line. But this plugin will find the exact differences between them,
|
||||
character by character - so called DiffChar.
|
||||
|
||||
For example, in diff mode: ( [DiffText], <DiffAdd> )
|
||||
>
|
||||
(window A) The [quick brown fox jumps over the lazy] dog.
|
||||
(window B) The [lazy fox jumps over the quick brown] dog.
|
||||
<
|
||||
this plugin will exactly show the changed and added units:
|
||||
>
|
||||
(window A) The [quick] <brown >fox jumps over the [lazy] dog.
|
||||
(window B) The [lazy] fox jumps over the [quick] <brown >dog.
|
||||
<
|
||||
This plugin will synchronously show/reset the highlights of the exact
|
||||
differences as soon as the diff mode starts/ends since a |g:DiffModeSync| is
|
||||
enabled as a default. It synchronously works as well on your custom diff tool
|
||||
(e.g. git-diff) when you have specified it to the 'diffexpr' option.
|
||||
|
||||
In non-diff mode or when the |g:DiffModeSync| is disabled, you can toggle to
|
||||
show/reset the diff highlights by pressing <F7> or <F8> or using |:TDChar|
|
||||
command. To show or reset them, use |:SDChar| or |:RDChar| command.
|
||||
|
||||
In diff mode, the corresponding changed lines are compared between two
|
||||
windows. In non-diff mode, the same lines are compared among them. You can
|
||||
set a matching color to a |g:DiffColors| to make it easy to recognize the
|
||||
corresponding changed units between two windows. As a default, all the
|
||||
changed units are highlighted with DiffText. In addition, DiffAdd is always
|
||||
used for the added units and both the previous and next character of the
|
||||
deleted units are underlined.
|
||||
|
||||
This plugin traces the differences based on a |g:DiffUnit|. Its default is
|
||||
'Word1' and it handles a \w\+ word and a \W character as a difference unit.
|
||||
There are other types of word provided and you can also set 'Char' to compare
|
||||
character by character.
|
||||
|
||||
While showing the exact differences, you can use ]b or ]e to jump cursor to
|
||||
the start or end position of the next difference unit, and [b or [e to the
|
||||
start or end position of the previous unit. Then this plugin echoes the
|
||||
corresponding difference unit with the assigned color as a message. Those
|
||||
keymaps, <F7> and <F8> are configurable in your vimrc and so on.
|
||||
|
||||
This plugin attempts to keep the exact differences updated while editing since
|
||||
a |g:DiffUpdate| is enabled as a default. However, a total number of lines are
|
||||
changed (after some lines are added/deleted), all the diff highlights will
|
||||
be cleared and you will need to manually show them again to update.
|
||||
|
||||
This plugin has been using "An O(NP) Sequence Comparison Algorithm" developed
|
||||
by S.Wu, et al., which always finds an optimum sequence quickly. But for
|
||||
longer lines and less-similar files, it takes time to complete the diff
|
||||
tracing. To make it more efficient, this plugin splits the tracing with the
|
||||
external diff command. Firstly applies the internal O(NP) algorithm. If not
|
||||
completed within the time specified by a |g:DiffSplitTime|, continuously
|
||||
switches to the diff command at that point, and then joins both results. This
|
||||
approach provides a stable performance and reasonable accuracy, because the
|
||||
diff command effectively optimizes between them. Its default is 100 ms, which
|
||||
would be useful for smaller files. If prefer to always apply the internal
|
||||
algorithm for accuracy (or the diff command for performance), set some large
|
||||
value (or 0) to it.
|
||||
|
||||
This plugin sets the DiffCharExpr() to the 'diffexpr' option, if it is empty.
|
||||
It also uses the |g:DiffSplitTime| and splits the tracing between the
|
||||
internal algorithm and the external diff command. If prefer to leave the
|
||||
'diffexpr' option as empty, set 0 to a |g:DiffExpr|.
|
||||
|
||||
This plugin works on each tab page individually. You can use a tab page
|
||||
variable (t:), instead of a global one (g:), to specify different options on
|
||||
each tab page.
|
||||
|
||||
This plugin has been always positively supporting mulltibyte characters.
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
COMMANDS *diffchar-commands*
|
||||
|
||||
:[range]SDChar - Show the highlights of difference units for [range]
|
||||
:[range]RDChar - Reset the highlights of difference units for [range]
|
||||
:[range]TDChar - Toggle to show/reset the highlights for [range]
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
KEYMAPS *diffchar-keymaps*
|
||||
|
||||
<Plug>ToggleDiffCharAllLines (default: <F7>)
|
||||
Toggle to show/reset the highlights for all/selected lines
|
||||
|
||||
<Plug>ToggleDiffCharCurrentLine (default: <F8>)
|
||||
Toggle to show/reset the highlights for current/selected lines
|
||||
|
||||
<Plug>JumpDiffCharPrevStart (default: [b)
|
||||
Jump cursor to the start position of the previous difference unit
|
||||
|
||||
<Plug>JumpDiffCharNextStart (default: ]b)
|
||||
Jump cursor to the start position of the next difference unit
|
||||
|
||||
<Plug>JumpDiffCharPrevEnd (default: [e)
|
||||
Jump cursor to the end position of the previous difference unit
|
||||
|
||||
<Plug>JumpDiffCharNextEnd (default: ]e)
|
||||
Jump cursor to the end position of the next difference unit
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
OPTIONS *diffchar-options*
|
||||
|
||||
|g:DiffUnit|, |t:DiffUnit|
|
||||
Type of difference unit
|
||||
'Word1' : \w\+ word and any \W single character (default)
|
||||
'Word2' : non-space and space words
|
||||
'Word3' : \< or \> character class boundaries
|
||||
'Char' : any single character
|
||||
'CSV(,)' : separated by characters such as ',', ';', and '\t'
|
||||
|
||||
|g:DiffColors|, |t:DiffColors|
|
||||
Matching colors for changed unit pairs (always DiffAdd for added units)
|
||||
0 : always DiffText (default)
|
||||
1 : 4 colors in fixed order
|
||||
2 : 8 colors in fixed order
|
||||
3 : 16 colors in fixed order
|
||||
100 : all available colors in dynamic random order
|
||||
|
||||
|g:DiffUpdate|, |t:DiffUpdate| (available on vim 7.4)
|
||||
Interactively updating the diff highlights while editing
|
||||
1 : enable (default)
|
||||
0 : disable
|
||||
|
||||
|g:DiffSplitTime|, |t:DiffSplitTime|
|
||||
A time length (ms) to apply the internal algorithm first
|
||||
0 ~ : (100 as default)
|
||||
|
||||
|g:DiffModeSync|, |t:DiffModeSync|
|
||||
Synchronously show/reset with diff mode
|
||||
1 : enable (default)
|
||||
0 : disable
|
||||
|
||||
|g:DiffExpr|
|
||||
Set DiffCharExpr() to the 'diffexpr' option
|
||||
1 : enable (default)
|
||||
0 : disable
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
CHANGE HISTORY *diffchar-history*
|
||||
|
||||
Update : 6.1
|
||||
* Improved a workaround for vim 7.4.682 (at update 5.1) not to disappear vim's
|
||||
DiffChange/DiffText highlights in other tab pages.
|
||||
* Improved to handle diff tracing only once in one diff session when more than
|
||||
2 buffers become diff mode and DiffModeSync is enabled.
|
||||
* Fixed to correctly reset diffchar highlights on a split window when the
|
||||
window is closed.
|
||||
|
||||
Update : 6.0
|
||||
* Defined a new :TDChar command to toggle the highlights for specified range,
|
||||
and make it possible to select a block of lines in visual mode and toggle
|
||||
them by using <F8>.
|
||||
* Changed the default value of g:DiffUnit from 'Char' to 'Word1', where \w\+
|
||||
is handled as a single difference unit, to make more sense to usual case.
|
||||
* Changed the default value of g:DiffSplitTime from 500 to 100 to switch more
|
||||
quickly and changed to check the time more often (unit-by-unit, not
|
||||
line-by-line) to detect the time limit earlier.
|
||||
* Changed to use the g:DiffSplitTime, instead of the number of lines as an
|
||||
argument, in the DiffCharExpr() to switch to the diff command as accurately
|
||||
as specified.
|
||||
* Improved the way to analyze the output of the diff command quickly.
|
||||
* Enhanced to interactively update the highlights faster while editing when
|
||||
g:DiffUpdate is enabled.
|
||||
* Changed the position of a pair cursor for a deleted unit on either its
|
||||
previous or next character instead of both.
|
||||
* Fixed to ignore white spaces at line end when iwhite is specified in the
|
||||
'diffopt' option.
|
||||
* Fixed to enable to use a t:DiffModeSync tab page variable as well as its
|
||||
global one.
|
||||
|
||||
Update : 5.5
|
||||
* Introduced g:DiffModeSync to synchronously show/reset the highlights as the
|
||||
diff mode starts/ends, which also works on your custom diff tool.
|
||||
* Changed to enable g:DiffUpdate as a default and then interactively update
|
||||
the highlights while editing.
|
||||
* Enhanced to draw and delete the highlights faster by specifying as many
|
||||
position parameters as possible in one matchaddpos() and matchadd() call.
|
||||
* Changed to select current window and next diff mode window (if present)
|
||||
whose buffer is different at initialize.
|
||||
* Fixed:
|
||||
- caused an error on getwinvar() in vim 7.3.
|
||||
- in non-gVim, did not show a matching pair cursor when jumping the cursor
|
||||
by using [e or ]b, depending on a color scheme.
|
||||
- sometimes failed to toggle the highlights when using <F7> or <F8> in diff
|
||||
mode windows.
|
||||
- did not interactively update the highlight of all the lines when multiple
|
||||
lines were changed at once if g:DiffUpdate = 1.
|
||||
|
||||
Update : 5.4
|
||||
* Enhanced to show a position of a deleted unit with underline on its
|
||||
previous and next characters. This position is where a unit is added
|
||||
between those characters in another diffchar window.
|
||||
* Improved to be able to change this plugin's global variables anytime.
|
||||
* Changed to select current window and then the next (wincmd w) window whose
|
||||
buffer is different.
|
||||
|
||||
Update : 5.3
|
||||
* Performance improved for long lines and some defects fixed when the diff
|
||||
command is used for the diff tracing.
|
||||
|
||||
Update : 5.2
|
||||
* Enhanced to provide a stable performance even for less-similar long files.
|
||||
The new approach applies this plugin's algorithm first, and if not
|
||||
completed within the specified time, continuously splits the tracing with
|
||||
the diff command, and join both results.
|
||||
* Fixed: when diff command does not choose minimal algorithm and it shows the
|
||||
equivalent lines as "changed", this plugin sometimes makes an error.
|
||||
* Fixed: if file encoding is not same as buffer encoding, a difference may
|
||||
not be correctly detected in DiffCharExpr().
|
||||
|
||||
Update : 5.1
|
||||
* Since vim 7.4.682, it has become impossible to overwrite the vim's diff
|
||||
highlights with this plugin. Then, for example, DiffText bold typeface will
|
||||
be left in all the diff highlighted lines (for more info, see
|
||||
https://groups.google.com/forum/?hl=en_US#!topic/vim_use/1jQnbTva2fY). This
|
||||
update provides a workaround to reduce its effect and to show the
|
||||
differences mostly same as before.
|
||||
|
||||
Update : 5.0
|
||||
* Significantly improved the way to trace and show the differences and make
|
||||
them 1.5 ~ 2.0 times faster.
|
||||
* Introduced g:DiffMaxRatio (and t:DiffMaxRatio), a maximum difference ratio
|
||||
to trace (100% as default). Once exceeds, the diff tracing is recursively
|
||||
split and helps to keep performance instead of diff accuracy.
|
||||
* Discontinued other difference algorithms (OND and Basic) than the ONP, then
|
||||
g:DiffAlgorithm no longer supported.
|
||||
* Improved to allow to specify one or more characters for 'CSV(c)' in
|
||||
g:DiffUnit (and t:DiffUnit). For example, 'CSV(,:\t)' will split the units
|
||||
by a comma, colon, and tab. Use '\\' for a backslash.
|
||||
|
||||
Update : 4.9
|
||||
* Fixed DiffCharExpr() to check the number of total lines, not different
|
||||
lines only, of both windows and apply either internal algorithm or external
|
||||
diff command, in order to keep the appropriate performance for large files.
|
||||
|
||||
Update : 4.81
|
||||
* Enhanced to make DiffCharExpr() a bit faster by using uniq() or so.
|
||||
|
||||
Update : 4.8
|
||||
* Enhanced to set the threshold value on DiffCharExpr() to check how many
|
||||
differences and then apply either of internal algorithm or external diff
|
||||
command. The default for 'diffexpr' option using DiffCharExpr() is changed to
|
||||
use this threshold, 200 - apply internal if less than 200 differences,
|
||||
apply external if more.
|
||||
* Changed the way to select windows when more than 2 windows in the page.
|
||||
- automatically select the diff mode's next (wincmd w) window, if any, in
|
||||
addition to the current window
|
||||
- can select any of split windows as vim can do for diff
|
||||
|
||||
Update : 4.7
|
||||
* Enhanced to set DiffCharExpr() to the 'diffexpr' option, if it is empty. When
|
||||
diff mode begins, vim calls this function which finds differences by this
|
||||
plugin's internal diff algorithm (default) and then initially shows the
|
||||
exact differences (default). You can also explicitly set this function to
|
||||
the option with different arguments.
|
||||
* Enhanced to make the key mappings configurable.
|
||||
For example, the default <F7> can be modified by:
|
||||
nmap <silent> your_favorite_key <Plug>ToggleDiffCharAllLines
|
||||
* Fixed to correctly adjust the position of difference units when 'diffopt'
|
||||
iwhite option is enabled.
|
||||
|
||||
Update : 4.6
|
||||
* Fixed to correctly show the colors of changed units in one-by-one defined
|
||||
order of g:DiffColors. Since an added unit was improperly counted as
|
||||
changed one, some colors were skipped and not shown. The first changed unit
|
||||
is now always highlighted with DiffText in any color mode.
|
||||
|
||||
Update : 4.5
|
||||
* Fixed to trace the differences until the end of the units. Previously the
|
||||
last same units were skipped, so last added units were sometimes shown as
|
||||
changed ones (eg: the last "swift brown" on above were shown as changed
|
||||
units but now shows "brown" as added ones).
|
||||
* Enhanced to use your global variables if defined in vimrc.
|
||||
|
||||
Update : 4.4
|
||||
* Enhanced to follow 'diffopt' icase and iwhite options for both diff and
|
||||
non-diff modes (ignorecase option is not used). Previously, it has been
|
||||
always case and space/tab sensitive.
|
||||
* Implemented to highlight the difference units using a new matchaddpos()
|
||||
function, introduced in 7.4.330, when available to draw faster.
|
||||
|
||||
Update : 4.3
|
||||
* Enhanced to differently show added/deleted/changed difference units with
|
||||
original diff highlightings.
|
||||
- added units will be always highlighted with DiffAdd.
|
||||
- changed units will be highlighted based on the g:DiffColors (and
|
||||
t:DiffColors) variable, but DiffText is always used for the first changed
|
||||
unit.
|
||||
- when jumping cursor by [b/]b or [e/]e on the added unit, it highlights
|
||||
around the corresponding deleted units with a cursor-type color in
|
||||
another window, and echoes a diff-delete filler with DiffDelete, along
|
||||
with common characters on both sides (e.g. a-----b).
|
||||
|
||||
Update : 4.2
|
||||
* Enhanced to update the highlighted DiffChar units while editing. A
|
||||
g:DiffUpdate (and t:DiffUpdate) variable enables and disables (default)
|
||||
this update behavior. If a text line was added/deleted, reset all the
|
||||
highlightings. This feature is available on vim 7.4.
|
||||
|
||||
Update : 4.1
|
||||
* Implemented to echo a matching difference unit with its color when jumping
|
||||
cursor by [b/]b or [e/]e.
|
||||
* Fixed defects: not using the new uniq() function introduced in vim 7.4.
|
||||
|
||||
Update : 4.0
|
||||
* Enhanced to easily find a corresponding pair of each difference unit.
|
||||
- each unit pair will be shown in individual same color on both windows. A
|
||||
g:DiffColors (and t:DiffColors) variable is a type of matching colors, 0
|
||||
(default) for always 1 color as before, 1/2/3 for 4/8/16 colors in fixed
|
||||
order, and 100 for all available colors in dynamic random order.
|
||||
- when jumping cursor by [b/]b or [e/]e in either window, the start or end
|
||||
position of a matching unit will be highlighted with a cursor-type color
|
||||
in another window.
|
||||
|
||||
Update : 3.6
|
||||
* Added two g:DiffUnit (and t:DiffUnit) types. 'Word3' will split at the \<
|
||||
or \> boundaries, which can separate based on the character class like CJK,
|
||||
Hiragana, Katakana, Hangul, full width symbols and so on. And 'CSV(c)' will
|
||||
split the units by a specified character 'c'. For example, 'CSV(,)' and
|
||||
'CSV(\t)' can be used for comma and tab separated text.
|
||||
|
||||
Update : 3.5
|
||||
* Fixed defects: DiffChar highlighting units do not override/hide hlsearch.
|
||||
|
||||
Update : 3.4
|
||||
* Enhanced to support individual DiffChar handling on each tab page.
|
||||
Difference unit and algorithm can also be set page by page using tab page
|
||||
local variables, t:DiffUnit and t:DiffAlgorithm.
|
||||
|
||||
Update : 3.3
|
||||
* Enhanced to jump cursor to the DiffChar highlighting units. Sample keymaps
|
||||
]b and [b will move cursor forwards to the next and backwards to the
|
||||
previous start positions. And ]e and [e will move to the end positions.
|
||||
|
||||
Update : 3.2
|
||||
* Enhanced to follow diff mode without any limitations. Compare between the
|
||||
corresponding DiffChange lines on both windows and properly handle DiffAdd
|
||||
and DiffDelete lines.
|
||||
|
||||
Update : 3.1
|
||||
* Enhanced to show/reset/toggle DiffChar highlightings on individual line by
|
||||
line.
|
||||
* Implemented the window layout handling.
|
||||
- the DiffChar'ed windows will remain the highlightings even if the window
|
||||
position is rotated/replaced/moved and another new window opens.
|
||||
- if either DiffChar'ed window is closed, reset all the DiffChar
|
||||
highlightings on another window.
|
||||
* Removed limitations:
|
||||
- when more than 2 windows exist, current and next (wincmd w) windows will
|
||||
be selected.
|
||||
- if the specified numbers of lines are different in both windows, ignore
|
||||
the redundant lines and continue to compare the text on the same lines.
|
||||
- RDChar sample command has a range attribute (e.g. %RDChar).
|
||||
* Fixed defects:
|
||||
- reset just DiffChar highlightings only and remain others.
|
||||
|
||||
Update : 3.0
|
||||
* Implemented word by word differences. A g:DiffUnit variable is a type of a
|
||||
difference unit. Its default is 'Char', which will trace character by
|
||||
character as before. 'Word1' will split into \w\+ words and any \W single
|
||||
characters. And 'Word2' will separate the units at the \s\+ space
|
||||
boundaries.
|
||||
* Improved the performance around 10%.
|
||||
|
||||
Update : 2.1
|
||||
* Coding changes in the O(NP) function for readability.
|
||||
|
||||
Update : 2.0
|
||||
* Implemented the O(NP) and O(ND) Difference algorithms to improve the
|
||||
performance. This update uses the O(NP) by default, and can be changed to
|
||||
the O(ND) if necessary, or to the basic algorithm implemented in the
|
||||
initial version.
|
||||
|
||||
vim:tw=78:ts=8:ft=help:norl:
|
32
vimfiles/doc/merginal.txt
Executable file → Normal file
32
vimfiles/doc/merginal.txt
Executable file → Normal file
@ -4,7 +4,7 @@
|
||||
Author: Idan Arye <https://github.com/idanarye/>
|
||||
License: Same terms as Vim itself (see |license|)
|
||||
|
||||
Version: 1.5.0
|
||||
Version: 2.0.1
|
||||
|
||||
INTRODUCTION *merginal*
|
||||
|
||||
@ -54,6 +54,7 @@ following keymaps to interact with the branches:
|
||||
|
||||
q Close the branch list.
|
||||
R Refresh the branch list.
|
||||
& Filter the branch list.
|
||||
cc Checkout the branch under the cursor.
|
||||
ct Track the remote branch under the cursor.
|
||||
cT Track the remote branch under the cursor, prompting for a name.
|
||||
@ -69,6 +70,9 @@ mm Merge the branch under the cursor into the currently checked out
|
||||
M Same as mm.
|
||||
mf Merge the branch under the cursor into the currently checked out branch
|
||||
using Fugitive's |:Gmerge| command.
|
||||
mn Merge the branch under the cursor using the --no-ff flag, forcing the
|
||||
creation of a merge commit even when the merge resolves as a
|
||||
fast-forward.
|
||||
rb Rebase the currently checked out branch against the branch under the
|
||||
cursor. If there are rebase conflicts, the |merginal-rebase-conflicts|
|
||||
buffer will open in place of
|
||||
@ -92,6 +96,7 @@ files that have merge conflicts and offers the following keymaps:
|
||||
|
||||
q Close the merge conflicts list.
|
||||
R Refresh the merge conflicts list.
|
||||
& Filter the merge conflicts list.
|
||||
<Cr> Open the conflicted file under the cursor.
|
||||
aa Add the conflicted file under the cursor to the staging area. If that
|
||||
was the last conflicted file, the merge conflicts buffer will close and
|
||||
@ -106,6 +111,7 @@ currently applied commit message and all the files that have rebase conflicts,
|
||||
and offers the following keymaps:
|
||||
|
||||
R Refresh the rebase conflicts list.
|
||||
& Filter the rebase conflicts list.
|
||||
<Cr> Open the conflicted file under the cursor.
|
||||
aa Add the conflicted file under the cursor to the staging area. If that
|
||||
was the last conflicted file, prompt the user to continue to the next
|
||||
@ -125,6 +131,7 @@ keymaps:
|
||||
|
||||
q Close the rebase amend buffer.
|
||||
R Refresh the rebase amend buffer.
|
||||
& Filter the rebase amend buffer.
|
||||
gd Open |merginal-diff-files| buffer to diff against the branch under the
|
||||
cursor.
|
||||
gl Open |merginal-history-log| buffer to view the history of the branch
|
||||
@ -142,6 +149,7 @@ opened against, and offers the following keymaps:
|
||||
|
||||
q Close the diff files list.
|
||||
R Refresh the diff files list.
|
||||
& Filter the diff files list.
|
||||
<Cr> Open the file under the cursor (if it exists in the currently checked
|
||||
out branch).
|
||||
ds Split-diff against the file under the cursor (if it exists in the other
|
||||
@ -160,6 +168,7 @@ offers the following keymaps:
|
||||
|
||||
q Close the history log buffer.
|
||||
R Refresh the history log buffer.
|
||||
& Filter the history log buffer.
|
||||
<C-p> Move the cursor to the previous commit.
|
||||
<C-n> Move the cursor to the next commit.
|
||||
ss Echo the commit details(using git's --format=fuller).
|
||||
@ -168,3 +177,24 @@ cc Checkout the commit under the cursor.
|
||||
C Same as cc.
|
||||
gd Open |merginal-diff-files| buffer to diff against the commit under the
|
||||
cursor.
|
||||
cp Cherry-pick the commit under the cursor into the currently checked out
|
||||
branch. If there are cherry-pick conflicts, the
|
||||
|merginal-cherry-pick-conflicts| buffer will open in place of the
|
||||
history log buffer.
|
||||
|
||||
|
||||
CHERRY-PICK CONFLICTS *merginal-cherry-pick-conflicts*
|
||||
|
||||
The cherry-pick conflicts buffer is used to solve cherry-pick conflicts. It
|
||||
shows the cherry-picked commit message and all the files that have cherry-pick
|
||||
conflicts, and offers the following keymaps:
|
||||
|
||||
R Refresh the cherry-pick conflicts list.
|
||||
& Filter the cherry-pick conflicts list.
|
||||
<Cr> Open the conflicted file under the cursor.
|
||||
aa Add the conflicted file under the cursor to the staging area. If that
|
||||
was the last conflicted file, prompt the user to continue to the next
|
||||
patch.
|
||||
A Same as aa.
|
||||
ra Abort the cherry-pick.
|
||||
rc Continue to the next patch.
|
||||
|
@ -13,7 +13,7 @@
|
||||
:CSVHeader ft-csv.txt /*:CSVHeader*
|
||||
:CSVHeaderToggle ft-csv.txt /*:CSVHeaderToggle*
|
||||
:CSVHiColumn ft-csv.txt /*:CSVHiColumn*
|
||||
:CSVInitCSV ft-csv.txt /*:CSVInitCSV*
|
||||
:CSVInit ft-csv.txt /*:CSVInit*
|
||||
:CSVMoveCol ft-csv.txt /*:CSVMoveCol*
|
||||
:CSVNewDelimiter ft-csv.txt /*:CSVNewDelimiter*
|
||||
:CSVNewRecord ft-csv.txt /*:CSVNewRecord*
|
||||
@ -115,26 +115,26 @@
|
||||
:VCSVimDiff vcscommand.txt /*:VCSVimDiff*
|
||||
:Vexplore pi_netrw.txt /*:Vexplore*
|
||||
:VimballList pi_vimball.txt /*:VimballList*
|
||||
<Plug>TComment-<Leader>_<space> tcomment.txt /*<Plug>TComment-<Leader>_<space>*
|
||||
<Plug>TComment-<Leader>__ tcomment.txt /*<Plug>TComment-<Leader>__*
|
||||
<Plug>TComment-<Leader>_a tcomment.txt /*<Plug>TComment-<Leader>_a*
|
||||
<Plug>TComment-<Leader>_b tcomment.txt /*<Plug>TComment-<Leader>_b*
|
||||
<Plug>TComment-<Leader>_n tcomment.txt /*<Plug>TComment-<Leader>_n*
|
||||
<Plug>TComment-<Leader>_p tcomment.txt /*<Plug>TComment-<Leader>_p*
|
||||
<Plug>TComment-<Leader>_r tcomment.txt /*<Plug>TComment-<Leader>_r*
|
||||
<Plug>TComment-<Leader>_s tcomment.txt /*<Plug>TComment-<Leader>_s*
|
||||
<Plug>TComment-<c-_><c-_> tcomment.txt /*<Plug>TComment-<c-_><c-_>*
|
||||
<Plug>TComment-<c-_><space> tcomment.txt /*<Plug>TComment-<c-_><space>*
|
||||
<Plug>TComment-<c-_>a tcomment.txt /*<Plug>TComment-<c-_>a*
|
||||
<Plug>TComment-<c-_>b tcomment.txt /*<Plug>TComment-<c-_>b*
|
||||
<Plug>TComment-<c-_>ca tcomment.txt /*<Plug>TComment-<c-_>ca*
|
||||
<Plug>TComment-<c-_>cc tcomment.txt /*<Plug>TComment-<c-_>cc*
|
||||
<Plug>TComment-<c-_>i tcomment.txt /*<Plug>TComment-<c-_>i*
|
||||
<Plug>TComment-<c-_>n tcomment.txt /*<Plug>TComment-<c-_>n*
|
||||
<Plug>TComment-<c-_>p tcomment.txt /*<Plug>TComment-<c-_>p*
|
||||
<Plug>TComment-<c-_>r tcomment.txt /*<Plug>TComment-<c-_>r*
|
||||
<Plug>TComment-<c-_>s tcomment.txt /*<Plug>TComment-<c-_>s*
|
||||
<Plug>TComment-ic tcomment.txt /*<Plug>TComment-ic*
|
||||
<Plug>TComment_<Leader>_<space> tcomment.txt /*<Plug>TComment_<Leader>_<space>*
|
||||
<Plug>TComment_<Leader>__ tcomment.txt /*<Plug>TComment_<Leader>__*
|
||||
<Plug>TComment_<Leader>_a tcomment.txt /*<Plug>TComment_<Leader>_a*
|
||||
<Plug>TComment_<Leader>_b tcomment.txt /*<Plug>TComment_<Leader>_b*
|
||||
<Plug>TComment_<Leader>_n tcomment.txt /*<Plug>TComment_<Leader>_n*
|
||||
<Plug>TComment_<Leader>_p tcomment.txt /*<Plug>TComment_<Leader>_p*
|
||||
<Plug>TComment_<Leader>_r tcomment.txt /*<Plug>TComment_<Leader>_r*
|
||||
<Plug>TComment_<Leader>_s tcomment.txt /*<Plug>TComment_<Leader>_s*
|
||||
<Plug>TComment_<c-_><c-_> tcomment.txt /*<Plug>TComment_<c-_><c-_>*
|
||||
<Plug>TComment_<c-_><space> tcomment.txt /*<Plug>TComment_<c-_><space>*
|
||||
<Plug>TComment_<c-_>a tcomment.txt /*<Plug>TComment_<c-_>a*
|
||||
<Plug>TComment_<c-_>b tcomment.txt /*<Plug>TComment_<c-_>b*
|
||||
<Plug>TComment_<c-_>ca tcomment.txt /*<Plug>TComment_<c-_>ca*
|
||||
<Plug>TComment_<c-_>cc tcomment.txt /*<Plug>TComment_<c-_>cc*
|
||||
<Plug>TComment_<c-_>i tcomment.txt /*<Plug>TComment_<c-_>i*
|
||||
<Plug>TComment_<c-_>n tcomment.txt /*<Plug>TComment_<c-_>n*
|
||||
<Plug>TComment_<c-_>p tcomment.txt /*<Plug>TComment_<c-_>p*
|
||||
<Plug>TComment_<c-_>r tcomment.txt /*<Plug>TComment_<c-_>r*
|
||||
<Plug>TComment_<c-_>s tcomment.txt /*<Plug>TComment_<c-_>s*
|
||||
<Plug>TComment_ic tcomment.txt /*<Plug>TComment_ic*
|
||||
AddColumn_CSV ft-csv.txt /*AddColumn_CSV*
|
||||
Align-copyright Align.txt /*Align-copyright*
|
||||
Analyze_CSV ft-csv.txt /*Analyze_CSV*
|
||||
@ -142,13 +142,17 @@ ArrangeColumn_CSV ft-csv.txt /*ArrangeColumn_CSV*
|
||||
C-Reference crefvim.txt /*C-Reference*
|
||||
CSV-Functions ft-csv.txt /*CSV-Functions*
|
||||
CSVCol() ft-csv.txt /*CSVCol()*
|
||||
CSVCount() ft-csv.txt /*CSVCount()*
|
||||
CSVField() ft-csv.txt /*CSVField()*
|
||||
CSVFixed ft-csv.txt /*CSVFixed*
|
||||
CSVMax() ft-csv.txt /*CSVMax()*
|
||||
CSVMin() ft-csv.txt /*CSVMin()*
|
||||
CSVPat() ft-csv.txt /*CSVPat()*
|
||||
CSVSum() ft-csv.txt /*CSVSum()*
|
||||
CSV_WCol() ft-csv.txt /*CSV_WCol()*
|
||||
ConvertData_CSV ft-csv.txt /*ConvertData_CSV*
|
||||
Copy_CSV ft-csv.txt /*Copy_CSV*
|
||||
CountCol_CSV ft-csv.txt /*CountCol_CSV*
|
||||
DeleteColumn_CSV ft-csv.txt /*DeleteColumn_CSV*
|
||||
DirDiff dirdiff.txt /*DirDiff*
|
||||
Duplicate_CSV ft-csv.txt /*Duplicate_CSV*
|
||||
@ -171,10 +175,11 @@ HiColumn_CSV ft-csv.txt /*HiColumn_CSV*
|
||||
IDMY visincr.txt /*IDMY*
|
||||
IMDY visincr.txt /*IMDY*
|
||||
IYMD visincr.txt /*IYMD*
|
||||
InitCSV ft-csv.txt /*InitCSV*
|
||||
LogiPat() LogiPat.txt /*LogiPat()*
|
||||
LogiPat-flags LogiPat.txt /*LogiPat-flags*
|
||||
MatchError matchit.txt /*MatchError*
|
||||
MaxCol_CSV ft-csv.txt /*MaxCol_CSV*
|
||||
MinCol_CSV ft-csv.txt /*MinCol_CSV*
|
||||
MoveCol_CSV ft-csv.txt /*MoveCol_CSV*
|
||||
MultipleSearch MultipleSearch.txt /*MultipleSearch*
|
||||
MultipleSearch-commands MultipleSearch.txt /*MultipleSearch-commands*
|
||||
@ -1607,6 +1612,7 @@ csv-strict ft-csv.txt /*csv-strict*
|
||||
csv-syntax ft-csv.txt /*csv-syntax*
|
||||
csv-syntax-error ft-csv.txt /*csv-syntax-error*
|
||||
csv-tabularize ft-csv.txt /*csv-tabularize*
|
||||
csv-textobjects ft-csv.txt /*csv-textobjects*
|
||||
csv-tips ft-csv.txt /*csv-tips*
|
||||
csv-toc ft-csv.txt /*csv-toc*
|
||||
csv-transpose ft-csv.txt /*csv-transpose*
|
||||
@ -1614,6 +1620,12 @@ csv-vertfold ft-csv.txt /*csv-vertfold*
|
||||
cvscommand-changes vcscommand.txt /*cvscommand-changes*
|
||||
dav pi_netrw.txt /*dav*
|
||||
davs pi_netrw.txt /*davs*
|
||||
diffchar diffchar.txt /*diffchar*
|
||||
diffchar-commands diffchar.txt /*diffchar-commands*
|
||||
diffchar-history diffchar.txt /*diffchar-history*
|
||||
diffchar-keymaps diffchar.txt /*diffchar-keymaps*
|
||||
diffchar-options diffchar.txt /*diffchar-options*
|
||||
diffchar.txt diffchar.txt /*diffchar.txt*
|
||||
dirdiff dirdiff.txt /*dirdiff*
|
||||
dirdiff-a dirdiff.txt /*dirdiff-a*
|
||||
dirdiff-enter dirdiff.txt /*dirdiff-enter*
|
||||
@ -1823,7 +1835,9 @@ g:tcommentGuessFileType_django tcomment.txt /*g:tcommentGuessFileType_django*
|
||||
g:tcommentGuessFileType_dsl tcomment.txt /*g:tcommentGuessFileType_dsl*
|
||||
g:tcommentGuessFileType_eruby tcomment.txt /*g:tcommentGuessFileType_eruby*
|
||||
g:tcommentGuessFileType_html tcomment.txt /*g:tcommentGuessFileType_html*
|
||||
g:tcommentGuessFileType_jinja tcomment.txt /*g:tcommentGuessFileType_jinja*
|
||||
g:tcommentGuessFileType_php tcomment.txt /*g:tcommentGuessFileType_php*
|
||||
g:tcommentGuessFileType_rnoweb tcomment.txt /*g:tcommentGuessFileType_rnoweb*
|
||||
g:tcommentGuessFileType_smarty tcomment.txt /*g:tcommentGuessFileType_smarty*
|
||||
g:tcommentGuessFileType_tskeleton tcomment.txt /*g:tcommentGuessFileType_tskeleton*
|
||||
g:tcommentGuessFileType_vim tcomment.txt /*g:tcommentGuessFileType_vim*
|
||||
@ -1890,15 +1904,15 @@ gundo_right gundo.txt /*gundo_right*
|
||||
gundo_tree_statusline gundo.txt /*gundo_tree_statusline*
|
||||
gundo_width gundo.txt /*gundo_width*
|
||||
http pi_netrw.txt /*http*
|
||||
i_<Plug>TComment-<c-_><c-_> tcomment.txt /*i_<Plug>TComment-<c-_><c-_>*
|
||||
i_<Plug>TComment-<c-_><space> tcomment.txt /*i_<Plug>TComment-<c-_><space>*
|
||||
i_<Plug>TComment-<c-_>a tcomment.txt /*i_<Plug>TComment-<c-_>a*
|
||||
i_<Plug>TComment-<c-_>b tcomment.txt /*i_<Plug>TComment-<c-_>b*
|
||||
i_<Plug>TComment-<c-_>i tcomment.txt /*i_<Plug>TComment-<c-_>i*
|
||||
i_<Plug>TComment-<c-_>n tcomment.txt /*i_<Plug>TComment-<c-_>n*
|
||||
i_<Plug>TComment-<c-_>p tcomment.txt /*i_<Plug>TComment-<c-_>p*
|
||||
i_<Plug>TComment-<c-_>r tcomment.txt /*i_<Plug>TComment-<c-_>r*
|
||||
i_<Plug>TComment-<c-_>s tcomment.txt /*i_<Plug>TComment-<c-_>s*
|
||||
i_<Plug>TComment_<c-_><c-_> tcomment.txt /*i_<Plug>TComment_<c-_><c-_>*
|
||||
i_<Plug>TComment_<c-_><space> tcomment.txt /*i_<Plug>TComment_<c-_><space>*
|
||||
i_<Plug>TComment_<c-_>a tcomment.txt /*i_<Plug>TComment_<c-_>a*
|
||||
i_<Plug>TComment_<c-_>b tcomment.txt /*i_<Plug>TComment_<c-_>b*
|
||||
i_<Plug>TComment_<c-_>i tcomment.txt /*i_<Plug>TComment_<c-_>i*
|
||||
i_<Plug>TComment_<c-_>n tcomment.txt /*i_<Plug>TComment_<c-_>n*
|
||||
i_<Plug>TComment_<c-_>p tcomment.txt /*i_<Plug>TComment_<c-_>p*
|
||||
i_<Plug>TComment_<c-_>r tcomment.txt /*i_<Plug>TComment_<c-_>r*
|
||||
i_<Plug>TComment_<c-_>s tcomment.txt /*i_<Plug>TComment_<c-_>s*
|
||||
linediff linediff.txt /*linediff*
|
||||
linediff-commands linediff.txt /*linediff-commands*
|
||||
linediff-contents linediff.txt /*linediff-contents*
|
||||
@ -1950,6 +1964,7 @@ matchit.txt matchit.txt /*matchit.txt*
|
||||
matchit.vim matchit.txt /*matchit.vim*
|
||||
merginal merginal.txt /*merginal*
|
||||
merginal-branch-list merginal.txt /*merginal-branch-list*
|
||||
merginal-cherry-pick-conflicts merginal.txt /*merginal-cherry-pick-conflicts*
|
||||
merginal-diff-files merginal.txt /*merginal-diff-files*
|
||||
merginal-history-log merginal.txt /*merginal-history-log*
|
||||
merginal-merge-conflicts merginal.txt /*merginal-merge-conflicts*
|
||||
@ -1958,15 +1973,6 @@ merginal-rebase-conflicts merginal.txt /*merginal-rebase-conflicts*
|
||||
merginal-requirements merginal.txt /*merginal-requirements*
|
||||
merginal-usage merginal.txt /*merginal-usage*
|
||||
merginal.txt merginal.txt /*merginal.txt*
|
||||
n_<Plug>TComment-Comment tcomment.txt /*n_<Plug>TComment-Comment*
|
||||
n_<Plug>TComment-Commentb tcomment.txt /*n_<Plug>TComment-Commentb*
|
||||
n_<Plug>TComment-Commentc tcomment.txt /*n_<Plug>TComment-Commentc*
|
||||
n_<Plug>TComment-Uncomment tcomment.txt /*n_<Plug>TComment-Uncomment*
|
||||
n_<Plug>TComment-Uncommentb tcomment.txt /*n_<Plug>TComment-Uncommentb*
|
||||
n_<Plug>TComment-Uncommentc tcomment.txt /*n_<Plug>TComment-Uncommentc*
|
||||
n_<Plug>TComment-gc tcomment.txt /*n_<Plug>TComment-gc*
|
||||
n_<Plug>TComment-gcb tcomment.txt /*n_<Plug>TComment-gcb*
|
||||
n_<Plug>TComment-gcc tcomment.txt /*n_<Plug>TComment-gcc*
|
||||
netreadfixup pi_netrw.txt /*netreadfixup*
|
||||
netrw pi_netrw.txt /*netrw*
|
||||
netrw-% pi_netrw.txt /*netrw-%*
|
||||
@ -2174,23 +2180,27 @@ srchrplchigrp SrchRplcHiGrp.txt /*srchrplchigrp*
|
||||
srchrplchigrp-commands SrchRplcHiGrp.txt /*srchrplchigrp-commands*
|
||||
srchrplchigrp-contents SrchRplcHiGrp.txt /*srchrplchigrp-contents*
|
||||
srchrplchigrp-examples SrchRplcHiGrp.txt /*srchrplchigrp-examples*
|
||||
srchrplchigrp-history SrchRplcHiGrp.txt /*srchrplchigrp-history*
|
||||
tcomment#Comment() tcomment.txt /*tcomment#Comment()*
|
||||
tcomment#CommentAs() tcomment.txt /*tcomment#CommentAs()*
|
||||
tcomment#DefineType() tcomment.txt /*tcomment#DefineType()*
|
||||
tcomment#GetCommentDef() tcomment.txt /*tcomment#GetCommentDef()*
|
||||
tcomment#GetLineC() tcomment.txt /*tcomment#GetLineC()*
|
||||
tcomment#GuessCommentType() tcomment.txt /*tcomment#GuessCommentType()*
|
||||
tcomment#MaybeReuseOptions() tcomment.txt /*tcomment#MaybeReuseOptions()*
|
||||
tcomment#Operator() tcomment.txt /*tcomment#Operator()*
|
||||
tcomment#OperatorAnyway() tcomment.txt /*tcomment#OperatorAnyway()*
|
||||
tcomment#OperatorLine() tcomment.txt /*tcomment#OperatorLine()*
|
||||
tcomment#OperatorLineAnyway() tcomment.txt /*tcomment#OperatorLineAnyway()*
|
||||
tcomment#ResetOption() tcomment.txt /*tcomment#ResetOption()*
|
||||
tcomment#SetOption() tcomment.txt /*tcomment#SetOption()*
|
||||
tcomment#TextObjectInlineComment() tcomment.txt /*tcomment#TextObjectInlineComment()*
|
||||
tcomment-maps tcomment.txt /*tcomment-maps*
|
||||
tcomment-operator tcomment.txt /*tcomment-operator*
|
||||
tcomment.txt tcomment.txt /*tcomment.txt*
|
||||
v_<Plug>TComment-<c-_><c-_> tcomment.txt /*v_<Plug>TComment-<c-_><c-_>*
|
||||
v_<Plug>TComment-<c-_>i tcomment.txt /*v_<Plug>TComment-<c-_>i*
|
||||
v_<Plug>TComment-ic tcomment.txt /*v_<Plug>TComment-ic*
|
||||
v_<Plug>TComment_<c-_><c-_> tcomment.txt /*v_<Plug>TComment_<c-_><c-_>*
|
||||
v_<Plug>TComment_<c-_>i tcomment.txt /*v_<Plug>TComment_<c-_>i*
|
||||
v_<Plug>TComment_ic tcomment.txt /*v_<Plug>TComment_ic*
|
||||
v_[% matchit.txt /*v_[%*
|
||||
v_]% matchit.txt /*v_]%*
|
||||
v_a% matchit.txt /*v_a%*
|
||||
@ -2269,11 +2279,11 @@ visincr-raggedright visincr.txt /*visincr-raggedright*
|
||||
visincr-restrict visincr.txt /*visincr-restrict*
|
||||
visincr-usage visincr.txt /*visincr-usage*
|
||||
visincr.txt visincr.txt /*visincr.txt*
|
||||
x_<Plug>TComment-<Leader>__ tcomment.txt /*x_<Plug>TComment-<Leader>__*
|
||||
x_<Plug>TComment-<Leader>_i tcomment.txt /*x_<Plug>TComment-<Leader>_i*
|
||||
x_<Plug>TComment-Comment tcomment.txt /*x_<Plug>TComment-Comment*
|
||||
x_<Plug>TComment-Uncomment tcomment.txt /*x_<Plug>TComment-Uncomment*
|
||||
x_<Plug>TComment-gc tcomment.txt /*x_<Plug>TComment-gc*
|
||||
x_<Plug>TComment_<Leader>__ tcomment.txt /*x_<Plug>TComment_<Leader>__*
|
||||
x_<Plug>TComment_<Leader>_i tcomment.txt /*x_<Plug>TComment_<Leader>_i*
|
||||
x_<Plug>TComment_Comment tcomment.txt /*x_<Plug>TComment_Comment*
|
||||
x_<Plug>TComment_Uncomment tcomment.txt /*x_<Plug>TComment_Uncomment*
|
||||
x_<Plug>TComment_gc tcomment.txt /*x_<Plug>TComment_gc*
|
||||
xml-plugin-callbacks xml-plugin.txt /*xml-plugin-callbacks*
|
||||
xml-plugin-html xml-plugin.txt /*xml-plugin-html*
|
||||
xml-plugin-mappings xml-plugin.txt /*xml-plugin-mappings*
|
||||
|
@ -54,7 +54,7 @@ Explicit commenting/uncommenting:
|
||||
In visual mode:
|
||||
|
||||
gc :: Toggle comments
|
||||
gC :: Comment selected text
|
||||
g> :: Comment selected text
|
||||
|
||||
CAVEAT: If you visually select text within a line, the visual mode map will
|
||||
comment out the selected text. If you selected text across several lines, the
|
||||
@ -145,52 +145,43 @@ Contents~
|
||||
:TCommentBlock ................................ |:TCommentBlock|
|
||||
:TCommentInline ............................... |:TCommentInline|
|
||||
:TCommentMaybeInline .......................... |:TCommentMaybeInline|
|
||||
<Plug>TComment-<c-_><c-_> ..................... |<Plug>TComment-<c-_><c-_>|
|
||||
v_<Plug>TComment-<c-_><c-_> ................... |v_<Plug>TComment-<c-_><c-_>|
|
||||
i_<Plug>TComment-<c-_><c-_> ................... |i_<Plug>TComment-<c-_><c-_>|
|
||||
<Plug>TComment-<c-_>p ......................... |<Plug>TComment-<c-_>p|
|
||||
i_<Plug>TComment-<c-_>p ....................... |i_<Plug>TComment-<c-_>p|
|
||||
<Plug>TComment-<c-_><space> ................... |<Plug>TComment-<c-_><space>|
|
||||
i_<Plug>TComment-<c-_><space> ................. |i_<Plug>TComment-<c-_><space>|
|
||||
i_<Plug>TComment-<c-_>r ....................... |i_<Plug>TComment-<c-_>r|
|
||||
<Plug>TComment-<c-_>r ......................... |<Plug>TComment-<c-_>r|
|
||||
v_<Plug>TComment-<c-_>i ....................... |v_<Plug>TComment-<c-_>i|
|
||||
<Plug>TComment-<c-_>i ......................... |<Plug>TComment-<c-_>i|
|
||||
i_<Plug>TComment-<c-_>i ....................... |i_<Plug>TComment-<c-_>i|
|
||||
<Plug>TComment-<c-_>b ......................... |<Plug>TComment-<c-_>b|
|
||||
i_<Plug>TComment-<c-_>b ....................... |i_<Plug>TComment-<c-_>b|
|
||||
<Plug>TComment-<c-_>a ......................... |<Plug>TComment-<c-_>a|
|
||||
i_<Plug>TComment-<c-_>a ....................... |i_<Plug>TComment-<c-_>a|
|
||||
<Plug>TComment-<c-_>n ......................... |<Plug>TComment-<c-_>n|
|
||||
i_<Plug>TComment-<c-_>n ....................... |i_<Plug>TComment-<c-_>n|
|
||||
<Plug>TComment-<c-_>s ......................... |<Plug>TComment-<c-_>s|
|
||||
i_<Plug>TComment-<c-_>s ....................... |i_<Plug>TComment-<c-_>s|
|
||||
<Plug>TComment-<c-_>cc ........................ |<Plug>TComment-<c-_>cc|
|
||||
<Plug>TComment-<c-_>ca ........................ |<Plug>TComment-<c-_>ca|
|
||||
<Plug>TComment-<Leader>__ ..................... |<Plug>TComment-<Leader>__|
|
||||
x_<Plug>TComment-<Leader>__ ................... |x_<Plug>TComment-<Leader>__|
|
||||
<Plug>TComment-<Leader>_p ..................... |<Plug>TComment-<Leader>_p|
|
||||
<Plug>TComment-<Leader>_<space> ............... |<Plug>TComment-<Leader>_<space>|
|
||||
x_<Plug>TComment-<Leader>_i ................... |x_<Plug>TComment-<Leader>_i|
|
||||
<Plug>TComment-<Leader>_r ..................... |<Plug>TComment-<Leader>_r|
|
||||
<Plug>TComment-<Leader>_b ..................... |<Plug>TComment-<Leader>_b|
|
||||
<Plug>TComment-<Leader>_a ..................... |<Plug>TComment-<Leader>_a|
|
||||
<Plug>TComment-<Leader>_n ..................... |<Plug>TComment-<Leader>_n|
|
||||
<Plug>TComment-<Leader>_s ..................... |<Plug>TComment-<Leader>_s|
|
||||
n_<Plug>TComment-Uncomment .................... |n_<Plug>TComment-Uncomment|
|
||||
n_<Plug>TComment-Uncommentc ................... |n_<Plug>TComment-Uncommentc|
|
||||
n_<Plug>TComment-Uncommentb ................... |n_<Plug>TComment-Uncommentb|
|
||||
x_<Plug>TComment-Uncomment .................... |x_<Plug>TComment-Uncomment|
|
||||
n_<Plug>TComment-Comment ...................... |n_<Plug>TComment-Comment|
|
||||
n_<Plug>TComment-Commentc ..................... |n_<Plug>TComment-Commentc|
|
||||
n_<Plug>TComment-Commentb ..................... |n_<Plug>TComment-Commentb|
|
||||
x_<Plug>TComment-Comment ...................... |x_<Plug>TComment-Comment|
|
||||
v_<Plug>TComment-ic ........................... |v_<Plug>TComment-ic|
|
||||
<Plug>TComment-ic ............................. |<Plug>TComment-ic|
|
||||
n_<Plug>TComment-gcc .......................... |n_<Plug>TComment-gcc|
|
||||
n_<Plug>TComment-gcb .......................... |n_<Plug>TComment-gcb|
|
||||
x_<Plug>TComment-gc ........................... |x_<Plug>TComment-gc|
|
||||
n_<Plug>TComment-gc ........................... |n_<Plug>TComment-gc|
|
||||
<Plug>TComment_<c-_><c-_> ..................... |<Plug>TComment_<c-_><c-_>|
|
||||
v_<Plug>TComment_<c-_><c-_> ................... |v_<Plug>TComment_<c-_><c-_>|
|
||||
i_<Plug>TComment_<c-_><c-_> ................... |i_<Plug>TComment_<c-_><c-_>|
|
||||
<Plug>TComment_<c-_>p ......................... |<Plug>TComment_<c-_>p|
|
||||
i_<Plug>TComment_<c-_>p ....................... |i_<Plug>TComment_<c-_>p|
|
||||
<Plug>TComment_<c-_><space> ................... |<Plug>TComment_<c-_><space>|
|
||||
i_<Plug>TComment_<c-_><space> ................. |i_<Plug>TComment_<c-_><space>|
|
||||
i_<Plug>TComment_<c-_>r ....................... |i_<Plug>TComment_<c-_>r|
|
||||
<Plug>TComment_<c-_>r ......................... |<Plug>TComment_<c-_>r|
|
||||
v_<Plug>TComment_<c-_>i ....................... |v_<Plug>TComment_<c-_>i|
|
||||
<Plug>TComment_<c-_>i ......................... |<Plug>TComment_<c-_>i|
|
||||
i_<Plug>TComment_<c-_>i ....................... |i_<Plug>TComment_<c-_>i|
|
||||
<Plug>TComment_<c-_>b ......................... |<Plug>TComment_<c-_>b|
|
||||
i_<Plug>TComment_<c-_>b ....................... |i_<Plug>TComment_<c-_>b|
|
||||
<Plug>TComment_<c-_>a ......................... |<Plug>TComment_<c-_>a|
|
||||
i_<Plug>TComment_<c-_>a ....................... |i_<Plug>TComment_<c-_>a|
|
||||
<Plug>TComment_<c-_>n ......................... |<Plug>TComment_<c-_>n|
|
||||
i_<Plug>TComment_<c-_>n ....................... |i_<Plug>TComment_<c-_>n|
|
||||
<Plug>TComment_<c-_>s ......................... |<Plug>TComment_<c-_>s|
|
||||
i_<Plug>TComment_<c-_>s ....................... |i_<Plug>TComment_<c-_>s|
|
||||
<Plug>TComment_<c-_>cc ........................ |<Plug>TComment_<c-_>cc|
|
||||
<Plug>TComment_<c-_>ca ........................ |<Plug>TComment_<c-_>ca|
|
||||
<Plug>TComment_<Leader>__ ..................... |<Plug>TComment_<Leader>__|
|
||||
x_<Plug>TComment_<Leader>__ ................... |x_<Plug>TComment_<Leader>__|
|
||||
<Plug>TComment_<Leader>_p ..................... |<Plug>TComment_<Leader>_p|
|
||||
<Plug>TComment_<Leader>_<space> ............... |<Plug>TComment_<Leader>_<space>|
|
||||
x_<Plug>TComment_<Leader>_i ................... |x_<Plug>TComment_<Leader>_i|
|
||||
<Plug>TComment_<Leader>_r ..................... |<Plug>TComment_<Leader>_r|
|
||||
<Plug>TComment_<Leader>_b ..................... |<Plug>TComment_<Leader>_b|
|
||||
<Plug>TComment_<Leader>_a ..................... |<Plug>TComment_<Leader>_a|
|
||||
<Plug>TComment_<Leader>_n ..................... |<Plug>TComment_<Leader>_n|
|
||||
<Plug>TComment_<Leader>_s ..................... |<Plug>TComment_<Leader>_s|
|
||||
x_<Plug>TComment_Uncomment .................... |x_<Plug>TComment_Uncomment|
|
||||
x_<Plug>TComment_Comment ...................... |x_<Plug>TComment_Comment|
|
||||
v_<Plug>TComment_ic ........................... |v_<Plug>TComment_ic|
|
||||
<Plug>TComment_ic ............................. |<Plug>TComment_ic|
|
||||
x_<Plug>TComment_gc ........................... |x_<Plug>TComment_gc|
|
||||
g:tcomment#blank_lines ........................ |g:tcomment#blank_lines|
|
||||
g:tcomment#rstrip_on_uncomment ................ |g:tcomment#rstrip_on_uncomment|
|
||||
g:tcommentModeExtra ........................... |g:tcommentModeExtra|
|
||||
@ -208,11 +199,14 @@ Contents~
|
||||
g:tcommentGuessFileType_vim ................... |g:tcommentGuessFileType_vim|
|
||||
g:tcommentGuessFileType_django ................ |g:tcommentGuessFileType_django|
|
||||
g:tcommentGuessFileType_eruby ................. |g:tcommentGuessFileType_eruby|
|
||||
g:tcommentGuessFileType_jinja ................. |g:tcommentGuessFileType_jinja|
|
||||
g:tcommentGuessFileType_smarty ................ |g:tcommentGuessFileType_smarty|
|
||||
g:tcommentGuessFileType_rnoweb ................ |g:tcommentGuessFileType_rnoweb|
|
||||
g:tcommentIgnoreTypes_php ..................... |g:tcommentIgnoreTypes_php|
|
||||
g:tcomment#syntax_substitute .................. |g:tcomment#syntax_substitute|
|
||||
g:tcommentSyntaxMap ........................... |g:tcommentSyntaxMap|
|
||||
g:tcomment#replacements_c ..................... |g:tcomment#replacements_c|
|
||||
tcomment#GetLineC ............................. |tcomment#GetLineC()|
|
||||
g:tcommentInlineC ............................. |g:tcommentInlineC|
|
||||
g:tcommentBlockC2 ............................. |g:tcommentBlockC2|
|
||||
g:tcomment#replacements_xml ................... |g:tcomment#replacements_xml|
|
||||
@ -224,6 +218,8 @@ Contents~
|
||||
tcomment#GetCommentDef ........................ |tcomment#GetCommentDef()|
|
||||
g:tcomment_types .............................. |g:tcomment_types|
|
||||
tcomment#Comment .............................. |tcomment#Comment()|
|
||||
tcomment#MaybeReuseOptions .................... |tcomment#MaybeReuseOptions()|
|
||||
tcomment#ResetOption .......................... |tcomment#ResetOption()|
|
||||
tcomment#SetOption ............................ |tcomment#SetOption()|
|
||||
tcomment#Operator ............................. |tcomment#Operator()|
|
||||
tcomment#OperatorLine ......................... |tcomment#OperatorLine()|
|
||||
@ -324,143 +320,116 @@ g:tcommentTextObjectInlineComment (default: 'ic')
|
||||
1. a list of key=value pairs
|
||||
2. 1-2 values for: ?commentBegin, ?commentEnd
|
||||
|
||||
*<Plug>TComment-<c-_><c-_>*
|
||||
<Plug>TComment-<c-_><c-_> ... :TComment<cr>
|
||||
*<Plug>TComment_<c-_><c-_>*
|
||||
<Plug>TComment_<c-_><c-_> ... :TComment<cr>
|
||||
|
||||
*v_<Plug>TComment-<c-_><c-_>*
|
||||
v_<Plug>TComment-<c-_><c-_> ... :TCommentMaybeInline<cr>
|
||||
*v_<Plug>TComment_<c-_><c-_>*
|
||||
v_<Plug>TComment_<c-_><c-_> ... :TCommentMaybeInline<cr>
|
||||
|
||||
*i_<Plug>TComment-<c-_><c-_>*
|
||||
i_<Plug>TComment-<c-_><c-_> ... <c-o>:TComment<cr>
|
||||
*i_<Plug>TComment_<c-_><c-_>*
|
||||
i_<Plug>TComment_<c-_><c-_> ... <c-o>:TComment<cr>
|
||||
|
||||
*<Plug>TComment-<c-_>p*
|
||||
<Plug>TComment-<c-_>p ... m`vip:TComment<cr>``
|
||||
*<Plug>TComment_<c-_>p*
|
||||
<Plug>TComment_<c-_>p ... m`vip:TComment<cr>``
|
||||
|
||||
*i_<Plug>TComment-<c-_>p*
|
||||
i_<Plug>TComment-<c-_>p ... <c-o>:norm! m`vip<cr>:TComment<cr><c-o>``
|
||||
*i_<Plug>TComment_<c-_>p*
|
||||
i_<Plug>TComment_<c-_>p ... <c-o>:norm! m`vip<cr>:TComment<cr><c-o>``
|
||||
|
||||
*<Plug>TComment-<c-_><space>*
|
||||
<Plug>TComment-<c-_><space> ... :TComment
|
||||
*<Plug>TComment_<c-_><space>*
|
||||
<Plug>TComment_<c-_><space> ... :TComment
|
||||
|
||||
*i_<Plug>TComment-<c-_><space>*
|
||||
i_<Plug>TComment-<c-_><space> ... <c-o>:TComment
|
||||
*i_<Plug>TComment_<c-_><space>*
|
||||
i_<Plug>TComment_<c-_><space> ... <c-o>:TComment
|
||||
|
||||
*i_<Plug>TComment-<c-_>r*
|
||||
i_<Plug>TComment-<c-_>r ... <c-o>:TCommentRight<cr>
|
||||
*i_<Plug>TComment_<c-_>r*
|
||||
i_<Plug>TComment_<c-_>r ... <c-o>:TCommentRight<cr>
|
||||
|
||||
*<Plug>TComment-<c-_>r*
|
||||
<Plug>TComment-<c-_>r ... :TCommentRight<cr>
|
||||
*<Plug>TComment_<c-_>r*
|
||||
<Plug>TComment_<c-_>r ... :TCommentRight<cr>
|
||||
|
||||
*v_<Plug>TComment-<c-_>i*
|
||||
v_<Plug>TComment-<c-_>i ... :TCommentInline<cr>
|
||||
*v_<Plug>TComment_<c-_>i*
|
||||
v_<Plug>TComment_<c-_>i ... :TCommentInline<cr>
|
||||
|
||||
*<Plug>TComment-<c-_>i*
|
||||
<Plug>TComment-<c-_>i ... v:TCommentInline mode=I#<cr>
|
||||
*<Plug>TComment_<c-_>i*
|
||||
<Plug>TComment_<c-_>i ... v:TCommentInline mode=I#<cr>
|
||||
|
||||
*i_<Plug>TComment-<c-_>i*
|
||||
i_<Plug>TComment-<c-_>i ... <c-\><c-o>v:TCommentInline mode=#<cr>
|
||||
*i_<Plug>TComment_<c-_>i*
|
||||
i_<Plug>TComment_<c-_>i ... <c-\><c-o>v:TCommentInline mode=#<cr>
|
||||
|
||||
*<Plug>TComment-<c-_>b*
|
||||
<Plug>TComment-<c-_>b ... :TCommentBlock<cr>
|
||||
*<Plug>TComment_<c-_>b*
|
||||
<Plug>TComment_<c-_>b ... :TCommentBlock<cr>
|
||||
|
||||
*i_<Plug>TComment-<c-_>b*
|
||||
i_<Plug>TComment-<c-_>b ... <c-\><c-o>:TCommentBlock mode=#<cr>
|
||||
*i_<Plug>TComment_<c-_>b*
|
||||
i_<Plug>TComment_<c-_>b ... <c-\><c-o>:TCommentBlock mode=#<cr>
|
||||
|
||||
*<Plug>TComment-<c-_>a*
|
||||
<Plug>TComment-<c-_>a ... :TCommentAs
|
||||
*<Plug>TComment_<c-_>a*
|
||||
<Plug>TComment_<c-_>a ... :TCommentAs
|
||||
|
||||
*i_<Plug>TComment-<c-_>a*
|
||||
i_<Plug>TComment-<c-_>a ... <c-o>:TCommentAs
|
||||
*i_<Plug>TComment_<c-_>a*
|
||||
i_<Plug>TComment_<c-_>a ... <c-o>:TCommentAs
|
||||
|
||||
*<Plug>TComment-<c-_>n*
|
||||
<Plug>TComment-<c-_>n ... :TCommentAs <c-r>=&ft<cr>
|
||||
*<Plug>TComment_<c-_>n*
|
||||
<Plug>TComment_<c-_>n ... :TCommentAs <c-r>=&ft<cr>
|
||||
|
||||
*i_<Plug>TComment-<c-_>n*
|
||||
i_<Plug>TComment-<c-_>n ... <c-o>:TCommentAs <c-r>=&ft<cr>
|
||||
*i_<Plug>TComment_<c-_>n*
|
||||
i_<Plug>TComment_<c-_>n ... <c-o>:TCommentAs <c-r>=&ft<cr>
|
||||
|
||||
*<Plug>TComment-<c-_>s*
|
||||
<Plug>TComment-<c-_>s ... :TCommentAs <c-r>=&ft<cr>_
|
||||
*<Plug>TComment_<c-_>s*
|
||||
<Plug>TComment_<c-_>s ... :TCommentAs <c-r>=&ft<cr>_
|
||||
|
||||
*i_<Plug>TComment-<c-_>s*
|
||||
i_<Plug>TComment-<c-_>s ... <c-o>:TCommentAs <c-r>=&ft<cr>_
|
||||
*i_<Plug>TComment_<c-_>s*
|
||||
i_<Plug>TComment_<c-_>s ... <c-o>:TCommentAs <c-r>=&ft<cr>_
|
||||
|
||||
*<Plug>TComment-<c-_>cc*
|
||||
<Plug>TComment-<c-_>cc ... :<c-u>call tcomment#SetOption("count", v:count1)<cr>
|
||||
*<Plug>TComment_<c-_>cc*
|
||||
<Plug>TComment_<c-_>cc ... :<c-u>call tcomment#SetOption("count", v:count1)<cr>
|
||||
|
||||
*<Plug>TComment-<c-_>ca*
|
||||
<Plug>TComment-<c-_>ca ... :<c-u>call tcomment#SetOption("as", input("Comment as: ", &filetype, "customlist,tcomment#Complete"))<cr>
|
||||
*<Plug>TComment_<c-_>ca*
|
||||
<Plug>TComment_<c-_>ca ... :<c-u>call tcomment#SetOption("as", input("Comment as: ", &filetype, "customlist,tcomment#Complete"))<cr>
|
||||
|
||||
*<Plug>TComment-<Leader>__*
|
||||
<Plug>TComment-<Leader>__ ... :TComment<cr>
|
||||
*<Plug>TComment_<Leader>__*
|
||||
<Plug>TComment_<Leader>__ ... :TComment<cr>
|
||||
|
||||
*x_<Plug>TComment-<Leader>__*
|
||||
x_<Plug>TComment-<Leader>__ ... :TCommentMaybeInline<cr>
|
||||
*x_<Plug>TComment_<Leader>__*
|
||||
x_<Plug>TComment_<Leader>__ ... :TCommentMaybeInline<cr>
|
||||
|
||||
*<Plug>TComment-<Leader>_p*
|
||||
<Plug>TComment-<Leader>_p ... vip:TComment<cr>
|
||||
*<Plug>TComment_<Leader>_p*
|
||||
<Plug>TComment_<Leader>_p ... vip:TComment<cr>
|
||||
|
||||
*<Plug>TComment-<Leader>_<space>*
|
||||
<Plug>TComment-<Leader>_<space> ... :TComment
|
||||
*<Plug>TComment_<Leader>_<space>*
|
||||
<Plug>TComment_<Leader>_<space> ... :TComment
|
||||
|
||||
*x_<Plug>TComment-<Leader>_i*
|
||||
x_<Plug>TComment-<Leader>_i ... :TCommentInline<cr>
|
||||
*x_<Plug>TComment_<Leader>_i*
|
||||
x_<Plug>TComment_<Leader>_i ... :TCommentInline<cr>
|
||||
|
||||
*<Plug>TComment-<Leader>_r*
|
||||
<Plug>TComment-<Leader>_r ... :TCommentRight<cr>
|
||||
*<Plug>TComment_<Leader>_r*
|
||||
<Plug>TComment_<Leader>_r ... :TCommentRight<cr>
|
||||
|
||||
*<Plug>TComment-<Leader>_b*
|
||||
<Plug>TComment-<Leader>_b ... :TCommentBlock<cr>
|
||||
*<Plug>TComment_<Leader>_b*
|
||||
<Plug>TComment_<Leader>_b ... :TCommentBlock<cr>
|
||||
|
||||
*<Plug>TComment-<Leader>_a*
|
||||
<Plug>TComment-<Leader>_a ... :TCommentAs
|
||||
*<Plug>TComment_<Leader>_a*
|
||||
<Plug>TComment_<Leader>_a ... :TCommentAs
|
||||
|
||||
*<Plug>TComment-<Leader>_n*
|
||||
<Plug>TComment-<Leader>_n ... :TCommentAs <c-r>=&ft<cr>
|
||||
*<Plug>TComment_<Leader>_n*
|
||||
<Plug>TComment_<Leader>_n ... :TCommentAs <c-r>=&ft<cr>
|
||||
|
||||
*<Plug>TComment-<Leader>_s*
|
||||
<Plug>TComment-<Leader>_s ... :TCommentAs <c-r>=&ft<cr>_
|
||||
*<Plug>TComment_<Leader>_s*
|
||||
<Plug>TComment_<Leader>_s ... :TCommentAs <c-r>=&ft<cr>_
|
||||
|
||||
*n_<Plug>TComment-Uncomment*
|
||||
n_<Plug>TComment-Uncomment ... :<c-u>if v:count > 0 \| call tcomment#SetOption("count", v:count) \| endif \| call tcomment#SetOption("mode_extra", "U") \| let w:tcommentPos = getpos(".") \| set opfunc=tcomment#OperatorAnyway<cr>g@
|
||||
*x_<Plug>TComment_Uncomment*
|
||||
x_<Plug>TComment_Uncomment ... :<c-u>if v:count > 0 \| call tcomment#SetOption("count", v:count) \| endif \| call tcomment#SetOption("mode_extra", "U") \| '<,'>TCommentMaybeInline<cr>
|
||||
|
||||
*n_<Plug>TComment-Uncommentc*
|
||||
n_<Plug>TComment-Uncommentc ... :<c-u>if v:count > 0 \| call tcomment#SetOption("count", v:count) \| endif \| call tcomment#SetOption("mode_extra", "U") \| let w:tcommentPos = getpos(".") \| set opfunc=tcomment#OperatorLineAnyway<cr>g@$
|
||||
*x_<Plug>TComment_Comment*
|
||||
x_<Plug>TComment_Comment ... :<c-u>if v:count > 0 \| call tcomment#SetOption("count", v:count) \| endif \| '<,'>TCommentMaybeInline!<cr>
|
||||
|
||||
*n_<Plug>TComment-Uncommentb*
|
||||
n_<Plug>TComment-Uncommentb ... :<c-u>if v:count > 0 \| call tcomment#SetOption("count", v:count) \| endif \| call tcomment#SetOption("mode_extra", "UB") \| let w:tcommentPos = getpos(".") \| set opfunc=tcomment#OperatorLine<cr>g@
|
||||
*v_<Plug>TComment_ic*
|
||||
v_<Plug>TComment_ic ... :<c-U>call tcomment#TextObjectInlineComment()<cr>
|
||||
|
||||
*x_<Plug>TComment-Uncomment*
|
||||
x_<Plug>TComment-Uncomment ... :<c-u>if v:count > 0 \| call tcomment#SetOption("count", v:count) \| endif \| call tcomment#SetOption("mode_extra", "U") \| '<,'>TCommentMaybeInline<cr>
|
||||
*<Plug>TComment_ic*
|
||||
<Plug>TComment_ic ... :<c-U>call tcomment#TextObjectInlineComment()<cr>
|
||||
|
||||
*n_<Plug>TComment-Comment*
|
||||
n_<Plug>TComment-Comment ... :<c-u>if v:count > 0 \| call tcomment#SetOption("count", v:count) \| endif \| let w:tcommentPos = getpos(".") \| set opfunc=tcomment#OperatorAnyway<cr>g@
|
||||
|
||||
*n_<Plug>TComment-Commentc*
|
||||
n_<Plug>TComment-Commentc ... :<c-u>if v:count > 0 \| call tcomment#SetOption("count", v:count) \| endif \| let w:tcommentPos = getpos(".") \| set opfunc=tcomment#OperatorLineAnyway<cr>g@$
|
||||
|
||||
*n_<Plug>TComment-Commentb*
|
||||
n_<Plug>TComment-Commentb ... :<c-u>if v:count > 0 \| call tcomment#SetOption("count", v:count) \| endif \| call tcomment#SetOption("mode_extra", "B") \| let w:tcommentPos = getpos(".") \| set opfunc=tcomment#OperatorLine<cr>g@
|
||||
|
||||
*x_<Plug>TComment-Comment*
|
||||
x_<Plug>TComment-Comment ... :<c-u>if v:count > 0 \| call tcomment#SetOption("count", v:count) \| endif \| '<,'>TCommentMaybeInline!<cr>
|
||||
|
||||
*v_<Plug>TComment-ic*
|
||||
v_<Plug>TComment-ic ... :<c-U>call tcomment#TextObjectInlineComment()<cr>
|
||||
|
||||
*<Plug>TComment-ic*
|
||||
<Plug>TComment-ic ... :<c-U>call tcomment#TextObjectInlineComment()<cr>
|
||||
|
||||
*n_<Plug>TComment-gcc*
|
||||
n_<Plug>TComment-gcc ... :<c-u>if v:count > 0 \| call tcomment#SetOption("count", v:count) \| endif \| let w:tcommentPos = getpos(".") \| set opfunc=tcomment#OperatorLine<cr>g@$
|
||||
|
||||
*n_<Plug>TComment-gcb*
|
||||
n_<Plug>TComment-gcb ... :<c-u>if v:count > 0 \| call tcomment#SetOption("count", v:count) \| endif \| let w:tcommentPos = getpos(".") \| call tcomment#SetOption("mode_extra", "B") \| set opfunc=tcomment#OperatorLine<cr>g@
|
||||
|
||||
*x_<Plug>TComment-gc*
|
||||
x_<Plug>TComment-gc ... :TCommentMaybeInline<cr>
|
||||
|
||||
*n_<Plug>TComment-gc*
|
||||
n_<Plug>TComment-gc ... :<c-u>if v:count > 0 \| call tcomment#SetOption("count", v:count) \| endif \| let w:tcommentPos = getpos(".") \| set opfunc=tcomment#Operator<cr>g@
|
||||
*x_<Plug>TComment_gc*
|
||||
x_<Plug>TComment_gc ... :TCommentMaybeInline<cr>
|
||||
|
||||
|
||||
========================================================================
|
||||
@ -496,10 +465,14 @@ g:tcommentOpModeExtra (default: '')
|
||||
g:tcommentOptions (default: {})
|
||||
Other key-value options used by |tcomment#Comment()|.
|
||||
|
||||
Example: If you want to put the opening comment marker always in
|
||||
the first column regardless of the block's indentation, put this
|
||||
into your |vimrc| file: >
|
||||
Examples:
|
||||
Put the opening comment marker always in the first column
|
||||
regardless of the block's indentation, put this into your |vimrc|
|
||||
file: >
|
||||
let g:tcommentOptions = {'col': 1}
|
||||
|
||||
< Indent uncommented lines: >
|
||||
let g:tcommentOptions = {'postprocess_uncomment': 'norm! %sgg=%sgg'}
|
||||
<
|
||||
|
||||
*g:tcomment#options_comments*
|
||||
@ -563,9 +536,15 @@ g:tcommentGuessFileType_django (default: 1)
|
||||
*g:tcommentGuessFileType_eruby*
|
||||
g:tcommentGuessFileType_eruby (default: 1)
|
||||
|
||||
*g:tcommentGuessFileType_jinja*
|
||||
g:tcommentGuessFileType_jinja (default: 'html')
|
||||
|
||||
*g:tcommentGuessFileType_smarty*
|
||||
g:tcommentGuessFileType_smarty (default: 1)
|
||||
|
||||
*g:tcommentGuessFileType_rnoweb*
|
||||
g:tcommentGuessFileType_rnoweb (default: 'r')
|
||||
|
||||
*g:tcommentIgnoreTypes_php*
|
||||
g:tcommentIgnoreTypes_php (default: 'sql')
|
||||
In php files, some syntax regions are wrongly highlighted as sql
|
||||
@ -586,6 +565,9 @@ g:tcommentSyntaxMap (default: {...})
|
||||
g:tcomment#replacements_c (default: {...})
|
||||
Replacements for c filetype.
|
||||
|
||||
*tcomment#GetLineC()*
|
||||
tcomment#GetLineC(...)
|
||||
|
||||
*g:tcommentInlineC*
|
||||
g:tcommentInlineC (default: {...})
|
||||
Generic c-like comments.
|
||||
@ -710,6 +692,9 @@ tcomment#Comment(beg, end, ...)
|
||||
(default), strip from empty lines only,
|
||||
if 2, always strip whitespace; if 0,
|
||||
don't strip any whitespace
|
||||
postprocess_uncomment .. Run a |printf()| expression with 2
|
||||
placeholders on uncommented lines, e.g.
|
||||
'norm! %sgg=%sgg'.
|
||||
2. 1-2 values for: ?commentPrefix, ?commentPostfix
|
||||
3. a dictionary (internal use only)
|
||||
|
||||
@ -723,10 +708,17 @@ tcomment#Comment(beg, end, ...)
|
||||
v ... visual
|
||||
o ... operator
|
||||
C ... force comment
|
||||
K ... comment only uncommented lines
|
||||
U ... force uncomment (if U and C are present, U wins)
|
||||
By default, each line in range will be commented by adding the comment
|
||||
prefix and postfix.
|
||||
|
||||
*tcomment#MaybeReuseOptions()*
|
||||
tcomment#MaybeReuseOptions(name)
|
||||
|
||||
*tcomment#ResetOption()*
|
||||
tcomment#ResetOption()
|
||||
|
||||
*tcomment#SetOption()*
|
||||
tcomment#SetOption(name, arg)
|
||||
|
||||
|
@ -1,8 +1,8 @@
|
||||
" SrchRplcHiGrp.vim - Search and Replace based on a highlight group
|
||||
"
|
||||
" Version: 5.0
|
||||
" Version: 7.0
|
||||
" Author: David Fishburn <dfishburn dot vim at gmail dot com>
|
||||
" Last Changed: 2011 Jan 01
|
||||
" Last Changed: 2015 Aug 25
|
||||
" Created: Tue Dec 02 2003 10:11:07 PM
|
||||
" Description: Search and Replace based on a syntax highlight group
|
||||
" Script: http://www.vim.org/script.php?script_id=848
|
||||
@ -17,476 +17,23 @@
|
||||
" }}}
|
||||
|
||||
" If syntax is not enabled, do not bother loading this plugin
|
||||
if exists('g:loaded_srhg') || &cp || !exists("syntax_on")
|
||||
if exists('g:loaded_srhg') || !exists("syntax_on")
|
||||
finish
|
||||
endif
|
||||
let g:loaded_srhg = 5
|
||||
let g:loaded_srhg = 7
|
||||
|
||||
" Default the highlight group to 0
|
||||
let s:srhg_group_id = 0
|
||||
let s:srhg_firstline = 0
|
||||
let s:srhg_lastline = 0
|
||||
|
||||
" Functions: "{{{
|
||||
|
||||
" SRWarningMsg:
|
||||
function! <SID>SRWarningMsg(msg) "{{{
|
||||
echohl WarningMsg
|
||||
echomsg a:msg
|
||||
echohl None
|
||||
endfunction "}}}
|
||||
|
||||
" SRDispHiGrp:
|
||||
" Echos the currently selected highlight group name to the screen.
|
||||
" If a parameter is supplied, it will display the message in the
|
||||
" colour of the group name.
|
||||
function! <SID>SRDispHiGrp(...) "{{{
|
||||
if s:srhg_group_id != 0
|
||||
if s:srhg_group_id < 0
|
||||
let gid = -s:srhg_group_id
|
||||
else
|
||||
let gid = s:srhg_group_id
|
||||
endif
|
||||
|
||||
if a:0 > 0 && strlen(a:1) > 0
|
||||
let msg = a:1
|
||||
else
|
||||
let msg = "SRHiGrp - Group ID: " .gid . " Name: " . synIDattr(gid,"name")
|
||||
endif
|
||||
|
||||
exec 'echohl ' . synIDattr(gid, "name")
|
||||
exec "echomsg '" . msg . "'"
|
||||
echohl None
|
||||
else
|
||||
echo "No highlight group has been choosen yet"
|
||||
endif
|
||||
endfunction "}}}
|
||||
|
||||
" SRChooseHiGrp:
|
||||
" Sets the script variable s:srhg_group_id to the value
|
||||
" of the highlight group underneath the current cursor
|
||||
" position.
|
||||
function! <SID>SRChooseHiGrp(use_top_level) "{{{
|
||||
if(a:use_top_level == 1)
|
||||
let cursynid = -synID(line("."),col("."),1)
|
||||
else
|
||||
let cursynid = synIDtrans(synID(line("."),col("."),1))
|
||||
endif
|
||||
|
||||
if cursynid == 0
|
||||
call s:SRWarningMsg(
|
||||
\ 'There is no syntax group specified ' .
|
||||
\ 'under the cursor'
|
||||
\ )
|
||||
else
|
||||
let s:srhg_group_id = cursynid
|
||||
call s:SRDispHiGrp()
|
||||
endif
|
||||
endfunction "}}}
|
||||
|
||||
" SRSetVisualRange:
|
||||
" Redefines the visual range if the user called the functions
|
||||
" with 1,5SR*
|
||||
function! <SID>SRSetVisualRange() "{{{
|
||||
" If the current line position is not at the beginning
|
||||
" or the end of the visual region
|
||||
if line(".") != line("'<") && line(".") != line("'>")
|
||||
" Visually select the rows to ensure the correct
|
||||
" range is operated on.
|
||||
" This handles the case that SRHiGrp was run as:
|
||||
" :SRHiGrp
|
||||
" :1,5SRHiGrp
|
||||
" instead of:
|
||||
" :'<,'>SRHiGrp
|
||||
|
||||
exec 'normal! '.s:srhg_firstline."GV"
|
||||
if s:srhg_lastline > s:srhg_firstline
|
||||
exec "normal! " .
|
||||
\ (s:srhg_lastline - s:srhg_firstline) .
|
||||
\ "j"
|
||||
endif
|
||||
exec "normal! \<Esc>"
|
||||
endif
|
||||
return 1
|
||||
endfunction "}}}
|
||||
|
||||
" SRPositionWord:
|
||||
" Places the cursor on the next match following the
|
||||
" previous line and column passed in.
|
||||
function! <SID>SRPositionWord(prvline, prvcol, bfirsttime) "{{{
|
||||
let prvline = a:prvline
|
||||
let prvcol = a:prvcol
|
||||
|
||||
" echo 'L:'. col("'<") . ' R:' . col("'>")
|
||||
" echo 'Visual Mode:'. visualmode()
|
||||
|
||||
if (prvline == 0) && (prvcol == 0)
|
||||
call s:SRSetVisualRange()
|
||||
let leftcol = col("'<") - 1
|
||||
" exe 'norm! '.s:srhg_firstline."G\<bar>".leftcol.(leftcol>0 ? 'l' : '' )
|
||||
call cursor(s:srhg_firstline,leftcol)
|
||||
return 1
|
||||
endif
|
||||
|
||||
while 1==1
|
||||
if visualmode() ==# 'v'
|
||||
if line(".") == s:srhg_firstline
|
||||
" let leftcol = col("'<") - 1
|
||||
let leftcol = col("'<")
|
||||
else
|
||||
let leftcol = 1
|
||||
endif
|
||||
if line(".") == s:srhg_lastline
|
||||
let rightcol = col("'>")
|
||||
else
|
||||
let rightcol = col("$")
|
||||
endif
|
||||
elseif visualmode() ==# 'V'
|
||||
let leftcol = 1
|
||||
let rightcol = col("$")
|
||||
elseif visualmode() ==# "\<C-V>"
|
||||
let leftcol = col("'<") - 1
|
||||
let leftcol = col("'<")
|
||||
let rightcol = col("'>")
|
||||
endif
|
||||
|
||||
" echo 'PrvLine:'.prvline.' prvcol:'.prvcol.
|
||||
" \' L:'.leftcol.' R:'.rightcol.
|
||||
" \' VL:'.leftcol.' VR:'.rightcol
|
||||
|
||||
" Position cursor on leftcol
|
||||
" on each new line based on visual mode
|
||||
if col(".") == leftcol && a:bfirsttime == 1
|
||||
" The cursor is already at it starting position,
|
||||
" do not move the cursor
|
||||
elseif col(".") < leftcol
|
||||
" exe 'norm! '.line(".")."G\<bar>".leftcol.(leftcol>0 ? 'l' : '' )
|
||||
call cursor(line("."),leftcol)
|
||||
else
|
||||
normal! w
|
||||
endif
|
||||
|
||||
" Add additional check to see if the cursor has
|
||||
" moved after the above, if not, exit.
|
||||
if (col(".") == prvcol) && (line(".") == prvline && a:bfirsttime != 1)
|
||||
return -1
|
||||
endif
|
||||
|
||||
|
||||
if col(".") >= leftcol &&
|
||||
\ col(".") <= rightcol &&
|
||||
\ line(".") <= s:srhg_lastline
|
||||
return 1
|
||||
elseif col(".") > rightcol && line(".") < s:srhg_lastline
|
||||
let prvline = prvline + 1
|
||||
" Position the cursor on the next line and move
|
||||
" to the start of the visual region
|
||||
" exe 'norm! '.prvline."G\<bar>".leftcol.(leftcol>0 ? 'l' : '' )
|
||||
call cursor(prvline,leftcol)
|
||||
break
|
||||
elseif col(".") < leftcol && line(".") <= s:srhg_lastline
|
||||
" outside of visual area, move to next word
|
||||
continue
|
||||
else
|
||||
return -1
|
||||
endif
|
||||
endwhile
|
||||
|
||||
return 1
|
||||
endfunction "}}}
|
||||
|
||||
" SRHiGrp:
|
||||
" Traverses the region selected and performs all search and
|
||||
" replaces over the region for the selected highlight group.
|
||||
function! <SID>SRHiGrp(...) range "{{{
|
||||
|
||||
let s:srhg_firstline = a:firstline
|
||||
let s:srhg_lastline = a:lastline
|
||||
|
||||
if s:srhg_group_id == 0
|
||||
call s:SRWarningMsg(
|
||||
\ 'You must specify a syntax group name ' .
|
||||
\ 'by placing the cursor on a character ' .
|
||||
\ 'that is highlighted the way you want ' .
|
||||
\ 'and execute :SRChooseHiGrp or ' .
|
||||
\ ':SRChooseHiGrp!'
|
||||
\ )
|
||||
return
|
||||
endif
|
||||
|
||||
let group_name = synIDattr(s:srhg_group_id, 'name')
|
||||
if group_name == ''
|
||||
let group_name = synIDattr(-s:srhg_group_id, 'name')
|
||||
endif
|
||||
|
||||
if(a:0 > 0)
|
||||
if( a:1 == 0 || a:1 == 1)
|
||||
let match_group = a:1
|
||||
endif
|
||||
else
|
||||
" Default to operate on syntax groups that match
|
||||
let match_group = 1
|
||||
endif
|
||||
|
||||
if(a:0 > 1)
|
||||
let match_exp = a:2
|
||||
else
|
||||
let match_exp = '\(\w\+\>\)'
|
||||
let dialog_msg = "Enter match expression (default word at cursor - " .
|
||||
\ match_exp .
|
||||
\ "): "
|
||||
let l:var_val = inputdialog(dialog_msg, match_exp)
|
||||
let response = 1
|
||||
" Ok or Cancel result in an empty string
|
||||
if l:var_val == ""
|
||||
call s:SRWarningMsg(
|
||||
\ 'You must provide a match expression which ' .
|
||||
\ 'includes a submatch'
|
||||
\ )
|
||||
return
|
||||
endif
|
||||
let match_exp = l:var_val
|
||||
endif
|
||||
|
||||
if(a:0 > 2)
|
||||
let replace_exp = a:3
|
||||
else
|
||||
let replace_exp = '\U\1'
|
||||
let dialog_msg = "Enter replacement expression for the submatch " .
|
||||
\ "(ie capitalize word - \\U\\1): "
|
||||
let l:var_val = inputdialog(dialog_msg, replace_exp)
|
||||
let response = 1
|
||||
" Ok or Cancel result in an empty string
|
||||
if l:var_val == ""
|
||||
" If empty, check if they want to leave it empty
|
||||
" of skip this variable
|
||||
let response = confirm("Your value is empty!"
|
||||
\ , "&Use blank\n&Cancel", response)
|
||||
endif
|
||||
if response == 1
|
||||
" Replace the variable with what was entered
|
||||
let replace_exp = l:var_val
|
||||
else
|
||||
" Cancel
|
||||
return
|
||||
endif
|
||||
endif
|
||||
|
||||
" let higrpid = synIDtrans(hlID(s:srhg_group_id))
|
||||
let found = 0
|
||||
let firsttime = 1
|
||||
let lastline = line("$")
|
||||
let orgline = line(".")
|
||||
let orgcol = col(".")
|
||||
let curline = line(".")
|
||||
let curcol = col(".")
|
||||
let fenkeep = &fen
|
||||
let saveSearch = @/
|
||||
let saveFoldEnable = &foldenable
|
||||
setlocal nofoldenable
|
||||
|
||||
" Reset visual range if necessary
|
||||
call s:SRSetVisualRange()
|
||||
|
||||
" Restore the cursor position since resetting
|
||||
" the visual area could have moved the cursor
|
||||
call cursor(orgline, orgcol)
|
||||
|
||||
if s:SRPositionWord(orgline,(orgcol-1), firsttime) == -1
|
||||
call s:SRWarningMsg(
|
||||
\ 'Please reselect the visual area (ie gv)'
|
||||
\ )
|
||||
return
|
||||
endif
|
||||
let firsttime = 0
|
||||
|
||||
let gid = s:srhg_group_id
|
||||
if(gid < 0)
|
||||
let gid = -s:srhg_group_id
|
||||
endif
|
||||
|
||||
while line(".") <= a:lastline
|
||||
let curcol = col(".")
|
||||
let curline = line(".")
|
||||
let cursynid = (s:srhg_group_id < 0) ?
|
||||
\ -synID(line("."),col("."),1) :
|
||||
\ synIDtrans(synID(line("."),col("."),1))
|
||||
let cursynid = (s:srhg_group_id < 0) ? synID(line("."),col("."),1) : synIDtrans(synID(line("."),col("."),1))
|
||||
" Useful debugging statement:
|
||||
" echo col(".").':'.getline(".")[col(".")-1].':'.cursynid.':'.getline(".")
|
||||
|
||||
if line(".") == curline
|
||||
if match_group == 1 && cursynid == gid
|
||||
" Perform the subtitution, but do not report an error
|
||||
" if the match fails
|
||||
exec 's/\%#'.match_exp.'/'.replace_exp.'/e'
|
||||
" Since this command can move the cursor, put the cursor
|
||||
" back to its original position
|
||||
" exe 'norm! '.curline."G\<bar>".(curcol-1)."l"
|
||||
call cursor(curline,curcol)
|
||||
let found = 1
|
||||
elseif match_group == 0 && cursynid != gid
|
||||
" Perform the subtitution, but do not report an error
|
||||
" if the match fails
|
||||
exec 's/\%#'.match_exp.'/'.replace_exp.'/e'
|
||||
" Since this command can move the cursor, put the cursor
|
||||
" back to its original position
|
||||
exe 'norm! '.curline."G\<bar>".(curcol-1)."l"
|
||||
endif
|
||||
endif
|
||||
|
||||
let prvcol = curcol
|
||||
let prvline = curline
|
||||
if s:SRPositionWord(prvline, prvcol, firsttime) == -1
|
||||
break
|
||||
endif
|
||||
|
||||
endwhile
|
||||
|
||||
if found == 0
|
||||
call s:SRWarningMsg('Did not find highlight group: "'.group_name.'"')
|
||||
endif
|
||||
|
||||
" cleanup
|
||||
let &fen = fenkeep
|
||||
if foldlevel(".") > 0
|
||||
norm! zO
|
||||
endif
|
||||
let &foldenable = saveFoldEnable
|
||||
unlet curcol
|
||||
" unlet higrpid
|
||||
unlet lastline
|
||||
let @/ = saveSearch
|
||||
if exists("prvcol")
|
||||
unlet prvcol
|
||||
endif
|
||||
endfunction "}}}
|
||||
|
||||
"}}}
|
||||
|
||||
" SRSearch:
|
||||
" Finds the next occurrence of the highlight group within
|
||||
" the range selected from the current cursor position.
|
||||
function! <SID>SRSearch(fline, lline, ...) "{{{
|
||||
|
||||
let s:srhg_firstline = a:fline
|
||||
let s:srhg_lastline = a:lline
|
||||
|
||||
if a:0 > 0 && strlen(a:1) > 0
|
||||
let s:srhg_group_id = -hlID(a:1)
|
||||
let group_name = a:1
|
||||
else
|
||||
let group_name = synIDattr(-s:srhg_group_id, 'name')
|
||||
endif
|
||||
|
||||
if s:srhg_group_id == 0
|
||||
call s:SRWarningMsg(
|
||||
\ 'You must specify a syntax group name ' .
|
||||
\ 'on the command line (<Tab> to complete) ' .
|
||||
\ 'or by placing the cursor on a character ' .
|
||||
\ 'that is highlighted the way you want ' .
|
||||
\ 'and execute :SRChooseHiGrp or ' .
|
||||
\ ':SRChooseHiGrp!'
|
||||
\ )
|
||||
return
|
||||
endif
|
||||
|
||||
" let higrpid = synIDtrans(hlID(s:srhg_group_id))
|
||||
let found = 0
|
||||
let lastline = line("$")
|
||||
let orgline = line(".")
|
||||
let orgcol = col(".")
|
||||
let curline = line(".")
|
||||
let curcol = col(".")
|
||||
let fenkeep = &fen
|
||||
let saveSearch = @/
|
||||
let saveFoldEnable = &foldenable
|
||||
setlocal nofoldenable
|
||||
" Set this to false, to force the search to move the cursor
|
||||
" this prevents the user from having to manually move the
|
||||
" cursor between recursive calls.
|
||||
let firsttime = 0
|
||||
|
||||
" Reset visual range if necessary
|
||||
call s:SRSetVisualRange()
|
||||
|
||||
" Restore the cursor position since resetting
|
||||
" the visual area could have moved the cursor
|
||||
call cursor(orgline, orgcol)
|
||||
|
||||
if s:SRPositionWord(orgline,orgcol,firsttime) == -1
|
||||
call s:SRWarningMsg(
|
||||
\ 'Please reselect the visual area (ie gv)'
|
||||
\ )
|
||||
return
|
||||
endif
|
||||
|
||||
let gid = s:srhg_group_id
|
||||
if(gid < 0)
|
||||
let gid = -s:srhg_group_id
|
||||
endif
|
||||
|
||||
while line(".") <= s:srhg_lastline
|
||||
let curcol = col(".")
|
||||
let curline = line(".")
|
||||
let cursynid = (s:srhg_group_id < 0) ? synID(line("."),col("."),1) : synIDtrans(synID(line("."),col("."),1))
|
||||
let prevsynid = (s:srhg_group_id < 0) ? synID(line("."),(col(".")-1),1) : synIDtrans(synID(line("."),(col(".")-1),1))
|
||||
" Useful debugging statement:
|
||||
" echo col(".").':'.getline(".")[col(".")-1].':'.cursynid.':'.getline(".")
|
||||
|
||||
" if line(".") == curline
|
||||
" Check the current syn id against the previous columns syn id.
|
||||
" If they are the same, assume we are still part of the same "string"
|
||||
" and we need to continue searching until we find a gap between the
|
||||
" highlight groups indicating we are actually on our next match
|
||||
" (Sergio).
|
||||
if line(".") == curline && (cursynid != prevsynid)
|
||||
if cursynid == gid
|
||||
call s:SRDispHiGrp( "SRSearch - Match found - Group ID: " .
|
||||
\ gid . " Name: " . synIDattr(gid,"name")
|
||||
\ )
|
||||
let found = 1
|
||||
break
|
||||
endif
|
||||
endif
|
||||
|
||||
let prvcol = curcol
|
||||
let prvline = curline
|
||||
if s:SRPositionWord(prvline, prvcol, firsttime) == -1
|
||||
break
|
||||
endif
|
||||
|
||||
endwhile
|
||||
|
||||
if found == 0
|
||||
call s:SRDispHiGrp( "SRSearch - Match NOT found - Group ID: " .
|
||||
\ gid . " Name: " . synIDattr(gid,"name")
|
||||
\ )
|
||||
call cursor(orgline, orgcol)
|
||||
endif
|
||||
|
||||
" cleanup
|
||||
let &fen = fenkeep
|
||||
if foldlevel(".") > 0
|
||||
norm! zO
|
||||
endif
|
||||
let &foldenable = saveFoldEnable
|
||||
unlet curcol
|
||||
" unlet higrpid
|
||||
unlet lastline
|
||||
let @/ = saveSearch
|
||||
if exists("prvcol")
|
||||
unlet prvcol
|
||||
endif
|
||||
endfunction "}}}
|
||||
|
||||
"}}}
|
||||
" Turn on support for line continuations when creating the script
|
||||
let s:cpo_save = &cpo
|
||||
set cpo&vim
|
||||
|
||||
" Commands: {{{
|
||||
command! -range -bang -nargs=* SRHiGrp <line1>,<line2>call s:SRHiGrp(<bang>1,<args>)
|
||||
command! -bang -nargs=0 SRChooseHiGrp :call s:SRChooseHiGrp(<bang>1)
|
||||
command! -nargs=0 SRDispHiGrp :call s:SRDispHiGrp()
|
||||
command! -range=% -nargs=? -complete=highlight SRSearch call s:SRSearch(<line1>,<line2>,<q-args>)
|
||||
command! -range=% -nargs=* -bang SRHiGrp <line1>,<line2>call SrchRplcHiGrp#SRHiGrp(<bang>1,<args>)
|
||||
command! -nargs=* -bang SRChooseHiGrp :call SrchRplcHiGrp#SRChooseHiGrp(<bang>1,<args>)
|
||||
command! -nargs=* SRDispHiGrp :call SrchRplcHiGrp#SRDispHiGrp(<args>)
|
||||
command! -range=% -nargs=? -bang SRSearch call SrchRplcHiGrp#SRSearch(<bang>1,<line1>,<line2>,<q-args>)
|
||||
"}}}
|
||||
|
||||
let &cpo = s:cpo_save
|
||||
unlet s:cpo_save
|
||||
|
||||
" vim:fdm=marker:nowrap:ts=4:
|
||||
|
File diff suppressed because it is too large
Load Diff
60
vimfiles/plugin/merginal.vim
Executable file → Normal file
60
vimfiles/plugin/merginal.vim
Executable file → Normal file
@ -1,51 +1,23 @@
|
||||
function! s:openBasedOnMergeMode() abort
|
||||
if merginal#isRebaseMode()
|
||||
call merginal#openRebaseConflictsBuffer()
|
||||
elseif merginal#isRebaseAmendMode()
|
||||
call merginal#openRebaseAmendBuffer()
|
||||
elseif merginal#isMergeMode()
|
||||
call merginal#openMergeConflictsBuffer()
|
||||
else
|
||||
call merginal#openBranchListBuffer()
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:toggleBasedOnMergeMode() abort
|
||||
let l:repo=fugitive#repo()
|
||||
let l:merginalWindowNumber=bufwinnr('Merginal:')
|
||||
if 0<=l:merginalWindowNumber
|
||||
let l:merginalBufferNumber=winbufnr(l:merginalWindowNumber)
|
||||
let l:merginalBufferName=bufname(l:merginalBufferNumber)
|
||||
|
||||
"If we are not on the same dir we need to reload the merginal buffer
|
||||
"anyways:
|
||||
if getbufvar(l:merginalBufferNumber,'merginal_repo').dir()==l:repo.dir()
|
||||
if merginal#isRebaseMode()
|
||||
if 'Merginal:Rebase'==l:merginalBufferName
|
||||
call merginal#closeMerginalBuffer()
|
||||
return
|
||||
endif
|
||||
elseif merginal#isRebaseAmendMode()
|
||||
if 'Merginal:RebaseAmend'==l:merginalBufferName
|
||||
call merginal#closeMerginalBuffer()
|
||||
return
|
||||
endif
|
||||
elseif merginal#isMergeMode()
|
||||
if 'Merginal:Conflicts'==l:merginalBufferName
|
||||
call merginal#closeMerginalBuffer()
|
||||
return
|
||||
endif
|
||||
else
|
||||
if 'Merginal:Branches'==l:merginalBufferName
|
||||
call merginal#closeMerginalBuffer()
|
||||
return
|
||||
endif
|
||||
end
|
||||
let l:merginalWindowNumber = bufwinnr('Merginal:')
|
||||
if 0 <= l:merginalWindowNumber
|
||||
let l:merginalBufferNumber = winbufnr(l:merginalWindowNumber)
|
||||
let l:bufferObject = getbufvar(l:merginalBufferNumber, 'merginal')
|
||||
let l:mode = l:bufferObject._getSpecialMode()
|
||||
if l:mode == ''
|
||||
let l:mode = 'branchList'
|
||||
endif
|
||||
if l:bufferObject.name == l:mode
|
||||
call merginal#closeMerginalBuffer()
|
||||
return
|
||||
else
|
||||
call l:bufferObject.gotoBuffer(l:mode)
|
||||
endif
|
||||
else
|
||||
call merginal#openMerginalBuffer()
|
||||
endif
|
||||
call s:openBasedOnMergeMode()
|
||||
endfunction
|
||||
|
||||
autocmd User Fugitive command! -buffer -nargs=0 Merginal call s:openBasedOnMergeMode()
|
||||
autocmd User Fugitive command! -buffer -nargs=0 Merginal call merginal#openMerginalBuffer()
|
||||
autocmd User Fugitive command! -buffer -nargs=0 MerginalToggle call s:toggleBasedOnMergeMode()
|
||||
autocmd User Fugitive command! -buffer -nargs=0 MerginalClose call merginal#closeMerginalBuffer()
|
||||
|
@ -2,14 +2,14 @@
|
||||
" @Author: Tom Link (micathom AT gmail com)
|
||||
" @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
|
||||
" @Created: 27-Dez-2004.
|
||||
" @Last Change: 2014-06-30.
|
||||
" @Revision: 840
|
||||
" @Last Change: 2015-04-26.
|
||||
" @Revision: 964
|
||||
" GetLatestVimScripts: 1173 1 tcomment.vim
|
||||
|
||||
if &cp || exists('loaded_tcomment')
|
||||
finish
|
||||
endif
|
||||
let loaded_tcomment = 304
|
||||
let loaded_tcomment = 307
|
||||
|
||||
let s:save_cpo = &cpo
|
||||
set cpo&vim
|
||||
@ -117,138 +117,169 @@ command! -bar -bang -range -nargs=* -complete=customlist,tcomment#CompleteArgs T
|
||||
\ keepjumps call tcomment#Comment(<line1>, <line2>, 'i', "<bang>", <f-args>)
|
||||
|
||||
|
||||
noremap <Plug>TComment-<c-_><c-_> :TComment<cr>
|
||||
vnoremap <Plug>TComment-<c-_><c-_> :TCommentMaybeInline<cr>
|
||||
inoremap <Plug>TComment-<c-_><c-_> <c-o>:TComment<cr>
|
||||
noremap <Plug>TComment-<c-_>p m`vip:TComment<cr>``
|
||||
inoremap <Plug>TComment-<c-_>p <c-o>:norm! m`vip<cr>:TComment<cr><c-o>``
|
||||
noremap <Plug>TComment-<c-_><space> :TComment
|
||||
inoremap <Plug>TComment-<c-_><space> <c-o>:TComment
|
||||
inoremap <Plug>TComment-<c-_>r <c-o>:TCommentRight<cr>
|
||||
noremap <Plug>TComment-<c-_>r :TCommentRight<cr>
|
||||
vnoremap <Plug>TComment-<c-_>i :TCommentInline<cr>
|
||||
noremap <Plug>TComment-<c-_>i v:TCommentInline mode=I#<cr>
|
||||
inoremap <Plug>TComment-<c-_>i <c-\><c-o>v:TCommentInline mode=#<cr>
|
||||
noremap <Plug>TComment-<c-_>b :TCommentBlock<cr>
|
||||
inoremap <Plug>TComment-<c-_>b <c-\><c-o>:TCommentBlock mode=#<cr>
|
||||
noremap <Plug>TComment-<c-_>a :TCommentAs
|
||||
inoremap <Plug>TComment-<c-_>a <c-o>:TCommentAs
|
||||
noremap <Plug>TComment-<c-_>n :TCommentAs <c-r>=&ft<cr>
|
||||
inoremap <Plug>TComment-<c-_>n <c-o>:TCommentAs <c-r>=&ft<cr>
|
||||
noremap <Plug>TComment-<c-_>s :TCommentAs <c-r>=&ft<cr>_
|
||||
inoremap <Plug>TComment-<c-_>s <c-o>:TCommentAs <c-r>=&ft<cr>_
|
||||
noremap <Plug>TComment-<c-_>cc :<c-u>call tcomment#SetOption("count", v:count1)<cr>
|
||||
noremap <Plug>TComment-<c-_>ca :<c-u>call tcomment#SetOption("as", input("Comment as: ", &filetype, "customlist,tcomment#Complete"))<cr>
|
||||
" command! -range TCommentMap call tcomment#ResetOption() | <args>
|
||||
|
||||
noremap <Plug>TComment-<Leader>__ :TComment<cr>
|
||||
xnoremap <Plug>TComment-<Leader>__ :TCommentMaybeInline<cr>
|
||||
noremap <Plug>TComment-<Leader>_p vip:TComment<cr>
|
||||
noremap <Plug>TComment-<Leader>_<space> :TComment
|
||||
xnoremap <Plug>TComment-<Leader>_i :TCommentInline<cr>
|
||||
noremap <Plug>TComment-<Leader>_r :TCommentRight<cr>
|
||||
noremap <Plug>TComment-<Leader>_b :TCommentBlock<cr>
|
||||
noremap <Plug>TComment-<Leader>_a :TCommentAs
|
||||
noremap <Plug>TComment-<Leader>_n :TCommentAs <c-r>=&ft<cr>
|
||||
noremap <Plug>TComment-<Leader>_s :TCommentAs <c-r>=&ft<cr>_
|
||||
noremap <Plug>TComment_<c-_><c-_> :TComment<cr>
|
||||
vnoremap <Plug>TComment_<c-_><c-_> :TCommentMaybeInline<cr>
|
||||
inoremap <Plug>TComment_<c-_><c-_> <c-o>:TComment<cr>
|
||||
noremap <Plug>TComment_<c-_>p m`vip:TComment<cr>``
|
||||
inoremap <Plug>TComment_<c-_>p <c-o>:norm! m`vip<cr>:TComment<cr><c-o>``
|
||||
noremap <Plug>TComment_<c-_><space> :TComment
|
||||
inoremap <Plug>TComment_<c-_><space> <c-o>:TComment
|
||||
inoremap <Plug>TComment_<c-_>r <c-o>:TCommentRight<cr>
|
||||
noremap <Plug>TComment_<c-_>r :TCommentRight<cr>
|
||||
vnoremap <Plug>TComment_<c-_>i :TCommentInline<cr>
|
||||
noremap <Plug>TComment_<c-_>i v:TCommentInline mode=I#<cr>
|
||||
inoremap <Plug>TComment_<c-_>i <c-\><c-o>v:TCommentInline mode=#<cr>
|
||||
noremap <Plug>TComment_<c-_>b :TCommentBlock<cr>
|
||||
inoremap <Plug>TComment_<c-_>b <c-\><c-o>:TCommentBlock mode=#<cr>
|
||||
noremap <Plug>TComment_<c-_>a :TCommentAs
|
||||
inoremap <Plug>TComment_<c-_>a <c-o>:TCommentAs
|
||||
noremap <Plug>TComment_<c-_>n :TCommentAs <c-r>=&ft<cr>
|
||||
inoremap <Plug>TComment_<c-_>n <c-o>:TCommentAs <c-r>=&ft<cr>
|
||||
noremap <Plug>TComment_<c-_>s :TCommentAs <c-r>=&ft<cr>_
|
||||
inoremap <Plug>TComment_<c-_>s <c-o>:TCommentAs <c-r>=&ft<cr>_
|
||||
noremap <Plug>TComment_<c-_>cc :<c-u>call tcomment#SetOption("count", v:count1)<cr>
|
||||
noremap <Plug>TComment_<c-_>ca :<c-u>call tcomment#SetOption("as", input("Comment as: ", &filetype, "customlist,tcomment#Complete"))<cr>
|
||||
|
||||
nnoremap <silent> <Plug>TComment-Uncomment :<c-u>if v:count > 0 \| call tcomment#SetOption("count", v:count) \| endif \| call tcomment#SetOption("mode_extra", "U") \| let w:tcommentPos = getpos(".") \| set opfunc=tcomment#OperatorAnyway<cr>g@
|
||||
nnoremap <silent> <Plug>TComment-Uncommentc :<c-u>if v:count > 0 \| call tcomment#SetOption("count", v:count) \| endif \| call tcomment#SetOption("mode_extra", "U") \| let w:tcommentPos = getpos(".") \| set opfunc=tcomment#OperatorLineAnyway<cr>g@$
|
||||
nnoremap <silent> <Plug>TComment-Uncommentb :<c-u>if v:count > 0 \| call tcomment#SetOption("count", v:count) \| endif \| call tcomment#SetOption("mode_extra", "UB") \| let w:tcommentPos = getpos(".") \| set opfunc=tcomment#OperatorLine<cr>g@
|
||||
xnoremap <silent> <Plug>TComment-Uncomment :<c-u>if v:count > 0 \| call tcomment#SetOption("count", v:count) \| endif \| call tcomment#SetOption("mode_extra", "U") \| '<,'>TCommentMaybeInline<cr>
|
||||
noremap <Plug>TComment_<Leader>__ :TComment<cr>
|
||||
xnoremap <Plug>TComment_<Leader>__ :TCommentMaybeInline<cr>
|
||||
noremap <Plug>TComment_<Leader>_p vip:TComment<cr>
|
||||
noremap <Plug>TComment_<Leader>_<space> :TComment
|
||||
xnoremap <Plug>TComment_<Leader>_i :TCommentInline<cr>
|
||||
noremap <Plug>TComment_<Leader>_r :TCommentRight<cr>
|
||||
noremap <Plug>TComment_<Leader>_b :TCommentBlock<cr>
|
||||
noremap <Plug>TComment_<Leader>_a :TCommentAs
|
||||
noremap <Plug>TComment_<Leader>_n :TCommentAs <c-r>=&ft<cr>
|
||||
noremap <Plug>TComment_<Leader>_s :TCommentAs <c-r>=&ft<cr>_
|
||||
|
||||
nnoremap <silent> <Plug>TComment-Comment :<c-u>if v:count > 0 \| call tcomment#SetOption("count", v:count) \| endif \| let w:tcommentPos = getpos(".") \| set opfunc=tcomment#OperatorAnyway<cr>g@
|
||||
nnoremap <silent> <Plug>TComment-Commentc :<c-u>if v:count > 0 \| call tcomment#SetOption("count", v:count) \| endif \| let w:tcommentPos = getpos(".") \| set opfunc=tcomment#OperatorLineAnyway<cr>g@$
|
||||
nnoremap <silent> <Plug>TComment-Commentb :<c-u>if v:count > 0 \| call tcomment#SetOption("count", v:count) \| endif \| call tcomment#SetOption("mode_extra", "B") \| let w:tcommentPos = getpos(".") \| set opfunc=tcomment#OperatorLine<cr>g@
|
||||
xnoremap <silent> <Plug>TComment-Comment :<c-u>if v:count > 0 \| call tcomment#SetOption("count", v:count) \| endif \| '<,'>TCommentMaybeInline!<cr>
|
||||
|
||||
vnoremap <Plug>TComment-ic :<c-U>call tcomment#TextObjectInlineComment()<cr>
|
||||
noremap <Plug>TComment-ic :<c-U>call tcomment#TextObjectInlineComment()<cr>
|
||||
" function! TCommentOp(type) "{{{3
|
||||
" " TLogVAR a:type, v:count
|
||||
" " echom "DBG TCommentOp" g:tcomment_ex
|
||||
" " echom "DBG TCommentOp" g:tcomment_op
|
||||
" exec g:tcomment_ex
|
||||
" call call(g:tcomment_op, [a:type])
|
||||
" endf
|
||||
|
||||
nnoremap <silent> <Plug>TComment-gcc :<c-u>if v:count > 0 \| call tcomment#SetOption("count", v:count) \| endif \| let w:tcommentPos = getpos(".") \| set opfunc=tcomment#OperatorLine<cr>g@$
|
||||
nnoremap <silent> <Plug>TComment-gcb :<c-u>if v:count > 0 \| call tcomment#SetOption("count", v:count) \| endif \| let w:tcommentPos = getpos(".") \| call tcomment#SetOption("mode_extra", "B") \| set opfunc=tcomment#OperatorLine<cr>g@
|
||||
xnoremap <Plug>TComment-gc :TCommentMaybeInline<cr>
|
||||
function! s:MapOp(name, extra, op, invoke) "{{{3
|
||||
let opfunc = 'TCommentOpFunc_'. substitute(a:name, '[^a-zA-Z0-9_]', '_', 'G')
|
||||
let fn = [
|
||||
\ 'function! '. opfunc .'(...)',
|
||||
\ 'call tcomment#MaybeReuseOptions('. string(opfunc) .')',
|
||||
\ a:extra,
|
||||
\ 'return call('. string(a:op) .', a:000)',
|
||||
\ 'endf'
|
||||
\ ]
|
||||
exec join(fn, "\n")
|
||||
exec printf('nnoremap <silent> <Plug>TComment_%s '.
|
||||
\ ':<c-u>call tcomment#ResetOption() \| if v:count > 0 \| call tcomment#SetOption("count", v:count) \| endif \| let w:tcommentPos = getpos(".") \|'.
|
||||
\ 'set opfunc=%s<cr>%s',
|
||||
\ a:name, opfunc, a:invoke)
|
||||
endf
|
||||
|
||||
nnoremap <silent> <Plug>TComment-gc :<c-u>if v:count > 0 \| call tcomment#SetOption("count", v:count) \| endif \| let w:tcommentPos = getpos(".") \| set opfunc=tcomment#Operator<cr>g@
|
||||
|
||||
call s:MapOp('Uncomment', 'call tcomment#SetOption("mode_extra", "U")', 'tcomment#Operator', 'g@')
|
||||
call s:MapOp('Uncommentc', 'call tcomment#SetOption("mode_extra", "U")', 'tcomment#OperatorLine', 'g@$')
|
||||
call s:MapOp('Uncommentb', 'call tcomment#SetOption("mode_extra", "UB")', 'tcomment#OperatorLine', 'g@')
|
||||
xnoremap <silent> <Plug>TComment_Uncomment :<c-u>if v:count > 0 \| call tcomment#SetOption("count", v:count) \| endif \| call tcomment#SetOption("mode_extra", "U") \| '<,'>TCommentMaybeInline<cr>
|
||||
|
||||
call s:MapOp('Comment', '', 'tcomment#OperatorAnyway', 'g@')
|
||||
call s:MapOp('Commentc', '', 'tcomment#OperatorLineAnyway', 'g@$')
|
||||
call s:MapOp('Commentb', 'call tcomment#SetOption("mode_extra", "B")', 'tcomment#OperatorLine', 'g@')
|
||||
xnoremap <silent> <Plug>TComment_Comment :<c-u>if v:count > 0 \| call tcomment#SetOption("count", v:count) \| endif \| '<,'>TCommentMaybeInline!<cr>
|
||||
|
||||
vnoremap <Plug>TComment_ic :<c-U>call tcomment#TextObjectInlineComment()<cr>
|
||||
noremap <Plug>TComment_ic :<c-U>call tcomment#TextObjectInlineComment()<cr>
|
||||
|
||||
call s:MapOp('gcc', '', 'tcomment#OperatorLine', 'g@$')
|
||||
call s:MapOp('gcb', 'call tcomment#SetOption("mode_extra", "B")', 'tcomment#OperatorLine', 'g@')
|
||||
xnoremap <Plug>TComment_gc :TCommentMaybeInline<cr>
|
||||
|
||||
call s:MapOp('gc', '', 'tcomment#Operator', 'g@')
|
||||
|
||||
for s:i in range(1, 9)
|
||||
exec 'noremap <Plug>TComment-<c-_>' . s:i . ' :call tcomment#SetOption("count", '. s:i .')<cr>'
|
||||
exec 'inoremap <Plug>TComment-<c-_>' . s:i . ' <c-\><c-o>:call tcomment#SetOption("count", '. s:i .')<cr>'
|
||||
exec 'vnoremap <Plug>TComment-<c-_>' . s:i . ' :call tcomment#SetOption("count", '. s:i .')<cr>'
|
||||
exec 'noremap <Plug>TComment_<c-_>' . s:i . ' :call tcomment#SetOption("count", '. s:i .')<cr>'
|
||||
exec 'inoremap <Plug>TComment_<c-_>' . s:i . ' <c-\><c-o>:call tcomment#SetOption("count", '. s:i .')<cr>'
|
||||
exec 'vnoremap <Plug>TComment_<c-_>' . s:i . ' :call tcomment#SetOption("count", '. s:i .')<cr>'
|
||||
endfor
|
||||
for s:i in range(1, 9)
|
||||
exec 'nnoremap <silent> <Plug>TComment-gc' . s:i .'c :let w:tcommentPos = getpos(".") \| call tcomment#SetOption("count", '. s:i .') \| set opfunc=tcomment#Operator<cr>g@'
|
||||
call s:MapOp('gc' . s:i .'c', 'call tcomment#SetOption("count", '. s:i .')', 'tcomment#Operator', 'g@')
|
||||
endfor
|
||||
unlet s:i
|
||||
|
||||
delfun s:MapOp
|
||||
|
||||
|
||||
if g:tcommentMaps
|
||||
if g:tcommentMapLeader1 != ''
|
||||
exec 'map '. g:tcommentMapLeader1 . g:tcommentMapLeader1 .' <Plug>TComment-<c-_><c-_>'
|
||||
exec 'vmap '. g:tcommentMapLeader1 . g:tcommentMapLeader1 .' <Plug>TComment-<c-_><c-_>'
|
||||
exec 'imap '. g:tcommentMapLeader1 . g:tcommentMapLeader1 .' <Plug>TComment-<c-_><c-_>'
|
||||
exec 'map '. g:tcommentMapLeader1 .'p <Plug>TComment-<c-_>p'
|
||||
exec 'imap '. g:tcommentMapLeader1 .'p <Plug>TComment-<c-_>p'
|
||||
exec 'map '. g:tcommentMapLeader1 .'<space> <Plug>TComment-<c-_><space>'
|
||||
exec 'imap '. g:tcommentMapLeader1 .'<space> <Plug>TComment-<c-_><space>'
|
||||
exec 'imap '. g:tcommentMapLeader1 .'r <Plug>TComment-<c-_>r'
|
||||
exec 'map '. g:tcommentMapLeader1 .'r <Plug>TComment-<c-_>r'
|
||||
exec 'vmap '. g:tcommentMapLeader1 .'i <Plug>TComment-<c-_>i'
|
||||
exec 'map '. g:tcommentMapLeader1 .'i <Plug>TComment-<c-_>i'
|
||||
exec 'imap '. g:tcommentMapLeader1 .'i <Plug>TComment-<c-_>i'
|
||||
exec 'map '. g:tcommentMapLeader1 .'b <Plug>TComment-<c-_>b'
|
||||
exec 'imap '. g:tcommentMapLeader1 .'b <Plug>TComment-<c-_>b'
|
||||
exec 'map '. g:tcommentMapLeader1 .'a <Plug>TComment-<c-_>a'
|
||||
exec 'imap '. g:tcommentMapLeader1 .'a <Plug>TComment-<c-_>a'
|
||||
exec 'map '. g:tcommentMapLeader1 .'n <Plug>TComment-<c-_>n'
|
||||
exec 'imap '. g:tcommentMapLeader1 .'n <Plug>TComment-<c-_>n'
|
||||
exec 'map '. g:tcommentMapLeader1 .'s <Plug>TComment-<c-_>s'
|
||||
exec 'imap '. g:tcommentMapLeader1 .'s <Plug>TComment-<c-_>s'
|
||||
exec 'map '. g:tcommentMapLeader1 .'cc <Plug>TComment-<c-_>cc'
|
||||
exec 'map '. g:tcommentMapLeader1 .'ca <Plug>TComment-<c-_>ca'
|
||||
exec 'map '. g:tcommentMapLeader1 . g:tcommentMapLeader1 .' <Plug>TComment_<c-_><c-_>'
|
||||
exec 'vmap '. g:tcommentMapLeader1 . g:tcommentMapLeader1 .' <Plug>TComment_<c-_><c-_>'
|
||||
exec 'imap '. g:tcommentMapLeader1 . g:tcommentMapLeader1 .' <Plug>TComment_<c-_><c-_>'
|
||||
exec 'map '. g:tcommentMapLeader1 .'p <Plug>TComment_<c-_>p'
|
||||
exec 'imap '. g:tcommentMapLeader1 .'p <Plug>TComment_<c-_>p'
|
||||
exec 'map '. g:tcommentMapLeader1 .'<space> <Plug>TComment_<c-_><space>'
|
||||
exec 'imap '. g:tcommentMapLeader1 .'<space> <Plug>TComment_<c-_><space>'
|
||||
exec 'imap '. g:tcommentMapLeader1 .'r <Plug>TComment_<c-_>r'
|
||||
exec 'map '. g:tcommentMapLeader1 .'r <Plug>TComment_<c-_>r'
|
||||
exec 'vmap '. g:tcommentMapLeader1 .'i <Plug>TComment_<c-_>i'
|
||||
exec 'map '. g:tcommentMapLeader1 .'i <Plug>TComment_<c-_>i'
|
||||
exec 'imap '. g:tcommentMapLeader1 .'i <Plug>TComment_<c-_>i'
|
||||
exec 'map '. g:tcommentMapLeader1 .'b <Plug>TComment_<c-_>b'
|
||||
exec 'imap '. g:tcommentMapLeader1 .'b <Plug>TComment_<c-_>b'
|
||||
exec 'map '. g:tcommentMapLeader1 .'a <Plug>TComment_<c-_>a'
|
||||
exec 'imap '. g:tcommentMapLeader1 .'a <Plug>TComment_<c-_>a'
|
||||
exec 'map '. g:tcommentMapLeader1 .'n <Plug>TComment_<c-_>n'
|
||||
exec 'imap '. g:tcommentMapLeader1 .'n <Plug>TComment_<c-_>n'
|
||||
exec 'map '. g:tcommentMapLeader1 .'s <Plug>TComment_<c-_>s'
|
||||
exec 'imap '. g:tcommentMapLeader1 .'s <Plug>TComment_<c-_>s'
|
||||
exec 'map '. g:tcommentMapLeader1 .'cc <Plug>TComment_<c-_>cc'
|
||||
exec 'map '. g:tcommentMapLeader1 .'ca <Plug>TComment_<c-_>ca'
|
||||
for s:i in range(1, 9)
|
||||
exec 'map '. g:tcommentMapLeader1 . s:i .' <Plug>TComment-<c-_>'.s:i
|
||||
exec 'imap '. g:tcommentMapLeader1 . s:i .' <Plug>TComment-<c-_>'.s:i
|
||||
exec 'vmap '. g:tcommentMapLeader1 . s:i .' <Plug>TComment-<c-_>'.s:i
|
||||
exec 'map '. g:tcommentMapLeader1 . s:i .' <Plug>TComment_<c-_>'.s:i
|
||||
exec 'imap '. g:tcommentMapLeader1 . s:i .' <Plug>TComment_<c-_>'.s:i
|
||||
exec 'vmap '. g:tcommentMapLeader1 . s:i .' <Plug>TComment_<c-_>'.s:i
|
||||
endfor
|
||||
unlet s:i
|
||||
endif
|
||||
if g:tcommentMapLeader2 != ''
|
||||
exec 'map '. g:tcommentMapLeader2 .'_ <Plug>TComment-<Leader>__'
|
||||
exec 'xmap '. g:tcommentMapLeader2 .'_ <Plug>TComment-<Leader>__'
|
||||
exec 'map '. g:tcommentMapLeader2 .'p <Plug>TComment-<Leader>_p'
|
||||
exec 'map '. g:tcommentMapLeader2 .'<space> <Plug>TComment-<Leader>_<space>'
|
||||
exec 'xmap '. g:tcommentMapLeader2 .'i <Plug>TComment-<Leader>_i'
|
||||
exec 'map '. g:tcommentMapLeader2 .'r <Plug>TComment-<Leader>_r'
|
||||
exec 'map '. g:tcommentMapLeader2 .'b <Plug>TComment-<Leader>_b'
|
||||
exec 'map '. g:tcommentMapLeader2 .'a <Plug>TComment-<Leader>_a'
|
||||
exec 'map '. g:tcommentMapLeader2 .'n <Plug>TComment-<Leader>_n'
|
||||
exec 'map '. g:tcommentMapLeader2 .'s <Plug>TComment-<Leader>_s'
|
||||
exec 'map '. g:tcommentMapLeader2 .'_ <Plug>TComment_<Leader>__'
|
||||
exec 'xmap '. g:tcommentMapLeader2 .'_ <Plug>TComment_<Leader>__'
|
||||
exec 'map '. g:tcommentMapLeader2 .'p <Plug>TComment_<Leader>_p'
|
||||
exec 'map '. g:tcommentMapLeader2 .'<space> <Plug>TComment_<Leader>_<space>'
|
||||
exec 'xmap '. g:tcommentMapLeader2 .'i <Plug>TComment_<Leader>_i'
|
||||
exec 'map '. g:tcommentMapLeader2 .'r <Plug>TComment_<Leader>_r'
|
||||
exec 'map '. g:tcommentMapLeader2 .'b <Plug>TComment_<Leader>_b'
|
||||
exec 'map '. g:tcommentMapLeader2 .'a <Plug>TComment_<Leader>_a'
|
||||
exec 'map '. g:tcommentMapLeader2 .'n <Plug>TComment_<Leader>_n'
|
||||
exec 'map '. g:tcommentMapLeader2 .'s <Plug>TComment_<Leader>_s'
|
||||
endif
|
||||
if g:tcommentMapLeaderOp1 != ''
|
||||
exec 'nmap <silent> '. g:tcommentMapLeaderOp1 .' <Plug>TComment-gc'
|
||||
exec 'nmap <silent> '. g:tcommentMapLeaderOp1 .' <Plug>TComment_gc'
|
||||
for s:i in range(1, 9)
|
||||
exec 'nmap <silent> '. g:tcommentMapLeaderOp1 . s:i .' <Plug>TComment-gc'.s:i
|
||||
exec 'nmap <silent> '. g:tcommentMapLeaderOp1 . s:i .' <Plug>TComment_gc'.s:i
|
||||
exec 'nmap <silent> '. g:tcommentMapLeaderOp1 . s:i .'c <Plug>TComment_gc'.s:i.'c'
|
||||
endfor
|
||||
unlet s:i
|
||||
exec 'nmap <silent> '. g:tcommentMapLeaderOp1 .'c <Plug>TComment-gcc'
|
||||
exec 'nmap <silent> '. g:tcommentMapLeaderOp1 .'b <Plug>TComment-gcb'
|
||||
exec 'xmap '. g:tcommentMapLeaderOp1 .' <Plug>TComment-gc'
|
||||
exec 'nmap <silent> '. g:tcommentMapLeaderOp1 .'c <Plug>TComment_gcc'
|
||||
exec 'nmap <silent> '. g:tcommentMapLeaderOp1 .'b <Plug>TComment_gcb'
|
||||
exec 'xmap '. g:tcommentMapLeaderOp1 .' <Plug>TComment_gc'
|
||||
endif
|
||||
if g:tcommentMapLeaderUncommentAnyway != ''
|
||||
exec 'nmap <silent> '. g:tcommentMapLeaderUncommentAnyway .' <Plug>TComment-Uncomment'
|
||||
exec 'nmap <silent> '. g:tcommentMapLeaderUncommentAnyway .'c <Plug>TComment-Uncommentc'
|
||||
exec 'nmap <silent> '. g:tcommentMapLeaderUncommentAnyway .'b <Plug>TComment-Uncommentb'
|
||||
exec 'xmap '. g:tcommentMapLeaderUncommentAnyway .' <Plug>TComment-Uncomment'
|
||||
exec 'nmap <silent> '. g:tcommentMapLeaderUncommentAnyway .' <Plug>TComment_Uncomment'
|
||||
exec 'nmap <silent> '. g:tcommentMapLeaderUncommentAnyway .'c <Plug>TComment_Uncommentc'
|
||||
exec 'nmap <silent> '. g:tcommentMapLeaderUncommentAnyway .'b <Plug>TComment_Uncommentb'
|
||||
exec 'xmap '. g:tcommentMapLeaderUncommentAnyway .' <Plug>TComment_Uncomment'
|
||||
endif
|
||||
if g:tcommentMapLeaderCommentAnyway != ''
|
||||
exec 'nmap <silent> '. g:tcommentMapLeaderCommentAnyway .' <Plug>TComment-Comment'
|
||||
exec 'nmap <silent> '. g:tcommentMapLeaderCommentAnyway .'c <Plug>TComment-Commentc'
|
||||
exec 'nmap <silent> '. g:tcommentMapLeaderCommentAnyway .'b <Plug>TComment-Commentb'
|
||||
exec 'xmap '. g:tcommentMapLeaderCommentAnyway .' <Plug>TComment-Comment'
|
||||
exec 'nmap <silent> '. g:tcommentMapLeaderCommentAnyway .' <Plug>TComment_Comment'
|
||||
exec 'nmap <silent> '. g:tcommentMapLeaderCommentAnyway .'c <Plug>TComment_Commentc'
|
||||
exec 'nmap <silent> '. g:tcommentMapLeaderCommentAnyway .'b <Plug>TComment_Commentb'
|
||||
exec 'xmap '. g:tcommentMapLeaderCommentAnyway .' <Plug>TComment_Comment'
|
||||
endif
|
||||
if g:tcommentTextObjectInlineComment != ''
|
||||
exec 'vmap' g:tcommentTextObjectInlineComment ' <Plug>TComment-ic'
|
||||
exec 'omap' g:tcommentTextObjectInlineComment ' <Plug>TComment-ic'
|
||||
exec 'vmap' g:tcommentTextObjectInlineComment ' <Plug>TComment_ic'
|
||||
exec 'omap' g:tcommentTextObjectInlineComment ' <Plug>TComment_ic'
|
||||
endif
|
||||
endif
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user