Fix vint warning and errors in functions.vim
This commit is contained in:
parent
384a4dc236
commit
c953ae7dbf
@ -1,61 +1,62 @@
|
|||||||
" Fold Text
|
" Fold Text
|
||||||
set foldtext=FoldText()
|
set foldtext=FoldText()
|
||||||
function! FoldText()
|
function! FoldText()
|
||||||
let line = getline(v:foldstart)
|
let l:line = getline(v:foldstart)
|
||||||
return line.' '.string(v:foldend - v:foldstart + 1).' lines '
|
return l:line.' '.string(v:foldend - v:foldstart + 1).' lines '
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" Derived from http://stackoverflow.com/a/1333025
|
" Derived from http://stackoverflow.com/a/1333025
|
||||||
function! CloneHighlightGroupWithAttributes(group, new_group, attributes)
|
function! CloneHighlightGroupWithAttributes(group, new_group, attributes)
|
||||||
" Get group details, resolving group links.
|
" Get group details, resolving group links.
|
||||||
redir => group
|
redir => l:group
|
||||||
exe "silent hi " . a:group
|
exe 'silent hi ' . a:group
|
||||||
redir END
|
redir END
|
||||||
while group =~ "links to"
|
while l:group =~? 'links to'
|
||||||
let index = stridx(group, "links to") + len("links to")
|
let l:index = stridx(l:group, 'links to') + len('links to')
|
||||||
let linked_group = strpart(group, index + 1)
|
let l:linked_group = strpart(l:group, l:index + 1)
|
||||||
redir => group
|
redir => l:group
|
||||||
exe "silent hi " . linked_group
|
exe 'silent hi ' . l:linked_group
|
||||||
redir END
|
redir END
|
||||||
endwhile
|
endwhile
|
||||||
|
|
||||||
" Get highlight parameters and existing remove attributes.
|
" Get highlight parameters and existing remove attributes.
|
||||||
let parameters = matchlist(group, '\<xxx\>\s\+\(.*\)')[1]
|
let l:parameters = matchlist(l:group, '\<xxx\>\s\+\(.*\)')[1]
|
||||||
let parameters = substitute(parameters, '\(c\?term\|gui\)=\w\+', '', 'g')
|
let l:parameters = substitute(l:parameters, '\(c\?term\|gui\)=\w\+', '', 'g')
|
||||||
|
|
||||||
" Create the cloned highlight group with new attributes.
|
" Create the cloned highlight group with new attributes.
|
||||||
exe 'hi '.a:new_group.' '.parameters.
|
exe 'hi '.a:new_group.' '.l:parameters.
|
||||||
\' term='.a:attributes.' cterm='.a:attributes.' gui='.a:attributes
|
\' term='.a:attributes.' cterm='.a:attributes.' gui='.a:attributes
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! <SID>Synstack()
|
function! s:Synstack()
|
||||||
for id in synstack(line('.'), col('.'))
|
for l:id in synstack(line('.'), col('.'))
|
||||||
let attributes = synIDattr(id, 'name')
|
let l:attributes = synIDattr(l:id, 'name')
|
||||||
let attr = synIDattr(id, 'fg')
|
let l:attr = synIDattr(l:id, 'fg')
|
||||||
if attr != ''
|
if l:attr !=? ''
|
||||||
let attributes = attributes.' fg='.attr
|
let l:attributes = l:attributes.' fg='.l:attr
|
||||||
endif
|
endif
|
||||||
endfor
|
endfor
|
||||||
endfunction
|
endfunction
|
||||||
command Synstack :call <SID>Synstack()
|
command Synstack :call s:Synstack()
|
||||||
|
|
||||||
" Strip trailing whitespace
|
" Strip trailing whitespace
|
||||||
function! <SID>StripWhitespace()
|
function! s:StripWhitespace()
|
||||||
let l = line(".")
|
let l:line = line('.')
|
||||||
let c = col(".")
|
let l:column = col('.')
|
||||||
%s/\s\+$//e
|
execute '%s/\s\+$//e'
|
||||||
call cursor(l, c)
|
nohlsearch
|
||||||
|
call cursor(l:line, l:column)
|
||||||
endfunction
|
endfunction
|
||||||
command! StripWhitespace :call <SID>StripWhitespace()
|
command! StripWhitespace :call s:StripWhitespace()
|
||||||
augroup strip_white_space
|
augroup strip_white_space
|
||||||
" Strip whitespace on buffer write
|
" Strip whitespace on buffer write
|
||||||
autocmd!
|
autocmd!
|
||||||
autocmd BufWritePre * :call <SID>StripWhitespace()
|
autocmd BufWritePre * :call s:StripWhitespace()
|
||||||
augroup END
|
augroup END
|
||||||
|
|
||||||
" Stringify
|
" Stringify
|
||||||
" Make a code block in to a C string literal
|
" Make a code block in to a C string literal
|
||||||
function! <SID>Stringify()
|
function! s:Stringify()
|
||||||
" Escape existing escape characters
|
" Escape existing escape characters
|
||||||
execute 's/\\/\\\\/ge'
|
execute 's/\\/\\\\/ge'
|
||||||
" Escape quotes
|
" Escape quotes
|
||||||
@ -66,9 +67,9 @@ function! <SID>Stringify()
|
|||||||
execute 's/$/\\n"/g'
|
execute 's/$/\\n"/g'
|
||||||
noh
|
noh
|
||||||
endfunction
|
endfunction
|
||||||
map <silent> <leader>s :call <SID>Stringify()<CR>
|
map <silent> <leader>s :call s:Stringify()<CR>
|
||||||
" Make a C string literal in to a code block
|
" Make a C string literal in to a code block
|
||||||
function! <SID>Destringify()
|
function! s:Destringify()
|
||||||
" Remove final quote and carriage return
|
" Remove final quote and carriage return
|
||||||
execute 's/\\n"\s*$//ge'
|
execute 's/\\n"\s*$//ge'
|
||||||
" Remove first quote
|
" Remove first quote
|
||||||
@ -79,22 +80,22 @@ function! <SID>Destringify()
|
|||||||
execute 's/\\\\/\\/ge'
|
execute 's/\\\\/\\/ge'
|
||||||
noh
|
noh
|
||||||
endfunction
|
endfunction
|
||||||
map <silent> <leader>S :call <SID>Destringify()<CR>
|
map <silent> <leader>S :call s:Destringify()<CR>
|
||||||
|
|
||||||
" Invoke terminal command without prompt and then redraw.
|
" Invoke terminal command without prompt and then redraw.
|
||||||
command! -nargs=+ Silent execute 'silent <args>' | redraw!
|
command! -nargs=+ Silent execute 'silent <args>' | redraw!
|
||||||
|
|
||||||
" Set the tab width for the current filetype
|
" Set the tab width for the current filetype
|
||||||
function! <SID>TabWidth(width)
|
function! s:TabWidth(width)
|
||||||
execute "setlocal tabstop=".a:width
|
execute 'setlocal tabstop='.a:width
|
||||||
execute "setlocal shiftwidth=".a:width
|
execute 'setlocal shiftwidth='.a:width
|
||||||
execute "setlocal softtabstop=".a:width
|
execute 'setlocal softtabstop='.a:width
|
||||||
echo "Tab width is now ".a:width
|
echo 'Tab width is now '.a:width
|
||||||
endfunction
|
endfunction
|
||||||
command! -nargs=1 TabWidth :call <SID>TabWidth(<f-args>)
|
command! -nargs=1 TabWidth :call s:TabWidth(<f-args>)
|
||||||
|
|
||||||
" Toggle GitHub style bullet checkbox
|
" Toggle GitHub style bullet checkbox
|
||||||
function! <SID>CheckboxToggle()
|
function! s:CheckboxToggle()
|
||||||
" Get current line
|
" Get current line
|
||||||
let l:line = getline('.')
|
let l:line = getline('.')
|
||||||
|
|
||||||
@ -103,7 +104,7 @@ function! <SID>CheckboxToggle()
|
|||||||
let l:char = matchstr(l:line, l:pattern)
|
let l:char = matchstr(l:line, l:pattern)
|
||||||
|
|
||||||
" Toggle the ' ' or 'x' character
|
" Toggle the ' ' or 'x' character
|
||||||
if l:char == 'x'
|
if l:char ==? 'x'
|
||||||
let l:char = ' '
|
let l:char = ' '
|
||||||
else
|
else
|
||||||
let l:char = 'x'
|
let l:char = 'x'
|
||||||
@ -112,7 +113,7 @@ function! <SID>CheckboxToggle()
|
|||||||
" Replace the current line with a new one
|
" Replace the current line with a new one
|
||||||
call setline(line('.'), substitute(l:line, l:pattern, l:char, ''))
|
call setline(line('.'), substitute(l:line, l:pattern, l:char, ''))
|
||||||
endfunction
|
endfunction
|
||||||
command! CheckboxToggle :call <SID>CheckboxToggle()
|
command! CheckboxToggle :call s:CheckboxToggle()
|
||||||
nnoremap <leader><CR> :CheckboxToggle<CR>
|
nnoremap <leader><CR> :CheckboxToggle<CR>
|
||||||
|
|
||||||
" Show highlight groups under the cursor
|
" Show highlight groups under the cursor
|
||||||
|
Loading…
x
Reference in New Issue
Block a user