From f0ba36cfe286566625c461534bac2721651af170 Mon Sep 17 00:00:00 2001
From: "Kenneth Benzie (Benie)" <k.benzie83@gmail.com>
Date: Thu, 4 May 2017 00:20:12 +0100
Subject: [PATCH] Fix vint warning and errors in functions.vim
---
plugin/functions.vim | 79 ++++++++++++++++++++++----------------------
1 file changed, 40 insertions(+), 39 deletions(-)
diff --git a/plugin/functions.vim b/plugin/functions.vim
index dfe4eb9..ae87d2e 100644
--- a/plugin/functions.vim
+++ b/plugin/functions.vim
@@ -1,61 +1,62 @@
" Fold Text
set foldtext=FoldText()
function! FoldText()
- let line = getline(v:foldstart)
- return line.' '.string(v:foldend - v:foldstart + 1).' lines '
+ let l:line = getline(v:foldstart)
+ return l:line.' '.string(v:foldend - v:foldstart + 1).' lines '
endfunction
" Derived from http://stackoverflow.com/a/1333025
function! CloneHighlightGroupWithAttributes(group, new_group, attributes)
" Get group details, resolving group links.
- redir => group
- exe "silent hi " . a:group
+ redir => l:group
+ exe 'silent hi ' . a:group
redir END
- while group =~ "links to"
- let index = stridx(group, "links to") + len("links to")
- let linked_group = strpart(group, index + 1)
- redir => group
- exe "silent hi " . linked_group
+ while l:group =~? 'links to'
+ let l:index = stridx(l:group, 'links to') + len('links to')
+ let l:linked_group = strpart(l:group, l:index + 1)
+ redir => l:group
+ exe 'silent hi ' . l:linked_group
redir END
endwhile
" Get highlight parameters and existing remove attributes.
- let parameters = matchlist(group, '\<xxx\>\s\+\(.*\)')[1]
- let parameters = substitute(parameters, '\(c\?term\|gui\)=\w\+', '', 'g')
+ let l:parameters = matchlist(l:group, '\<xxx\>\s\+\(.*\)')[1]
+ let l:parameters = substitute(l:parameters, '\(c\?term\|gui\)=\w\+', '', 'g')
" 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
endfunction
-function! <SID>Synstack()
- for id in synstack(line('.'), col('.'))
- let attributes = synIDattr(id, 'name')
- let attr = synIDattr(id, 'fg')
- if attr != ''
- let attributes = attributes.' fg='.attr
+function! s:Synstack()
+ for l:id in synstack(line('.'), col('.'))
+ let l:attributes = synIDattr(l:id, 'name')
+ let l:attr = synIDattr(l:id, 'fg')
+ if l:attr !=? ''
+ let l:attributes = l:attributes.' fg='.l:attr
endif
endfor
endfunction
-command Synstack :call <SID>Synstack()
+command Synstack :call s:Synstack()
" Strip trailing whitespace
-function! <SID>StripWhitespace()
- let l = line(".")
- let c = col(".")
- %s/\s\+$//e
- call cursor(l, c)
+function! s:StripWhitespace()
+ let l:line = line('.')
+ let l:column = col('.')
+ execute '%s/\s\+$//e'
+ nohlsearch
+ call cursor(l:line, l:column)
endfunction
-command! StripWhitespace :call <SID>StripWhitespace()
+command! StripWhitespace :call s:StripWhitespace()
augroup strip_white_space
" Strip whitespace on buffer write
autocmd!
- autocmd BufWritePre * :call <SID>StripWhitespace()
+ autocmd BufWritePre * :call s:StripWhitespace()
augroup END
" Stringify
" Make a code block in to a C string literal
-function! <SID>Stringify()
+function! s:Stringify()
" Escape existing escape characters
execute 's/\\/\\\\/ge'
" Escape quotes
@@ -66,9 +67,9 @@ function! <SID>Stringify()
execute 's/$/\\n"/g'
noh
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
-function! <SID>Destringify()
+function! s:Destringify()
" Remove final quote and carriage return
execute 's/\\n"\s*$//ge'
" Remove first quote
@@ -79,22 +80,22 @@ function! <SID>Destringify()
execute 's/\\\\/\\/ge'
noh
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.
command! -nargs=+ Silent execute 'silent <args>' | redraw!
" Set the tab width for the current filetype
-function! <SID>TabWidth(width)
- execute "setlocal tabstop=".a:width
- execute "setlocal shiftwidth=".a:width
- execute "setlocal softtabstop=".a:width
- echo "Tab width is now ".a:width
+function! s:TabWidth(width)
+ execute 'setlocal tabstop='.a:width
+ execute 'setlocal shiftwidth='.a:width
+ execute 'setlocal softtabstop='.a:width
+ echo 'Tab width is now '.a:width
endfunction
-command! -nargs=1 TabWidth :call <SID>TabWidth(<f-args>)
+command! -nargs=1 TabWidth :call s:TabWidth(<f-args>)
" Toggle GitHub style bullet checkbox
-function! <SID>CheckboxToggle()
+function! s:CheckboxToggle()
" Get current line
let l:line = getline('.')
@@ -103,7 +104,7 @@ function! <SID>CheckboxToggle()
let l:char = matchstr(l:line, l:pattern)
" Toggle the ' ' or 'x' character
- if l:char == 'x'
+ if l:char ==? 'x'
let l:char = ' '
else
let l:char = 'x'
@@ -112,7 +113,7 @@ function! <SID>CheckboxToggle()
" Replace the current line with a new one
call setline(line('.'), substitute(l:line, l:pattern, l:char, ''))
endfunction
-command! CheckboxToggle :call <SID>CheckboxToggle()
+command! CheckboxToggle :call s:CheckboxToggle()
nnoremap <leader><CR> :CheckboxToggle<CR>
" Show highlight groups under the cursor