aboutsummaryrefslogtreecommitdiff
path: root/vim
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2017-10-30 19:11:22 +1300
committerTom Ryder <tom@sanctum.geek.nz>2017-10-30 19:11:22 +1300
commit1834c083aa436d59713b0054566e06648d67ac1e (patch)
treec49418442110da13aef79acfb7af29eee95ab4b1 /vim
parentMove viminfo conf from spell.vim into new subfile (diff)
downloaddotfiles-1834c083aa436d59713b0054566e06648d67ac1e.tar.gz
dotfiles-1834c083aa436d59713b0054566e06648d67ac1e.zip
Apply name conventions, scoping to Vim identifiers
The Google VimScript Style Guide says <https://google.github.io/styleguide/vimscriptguide.xml#Naming>: >In general, use plugin-names-like-this, FunctionNamesLikeThis, >CommandNamesLikeThis, augroup_names_like_this, >variable_names_like_this. Adjusted variable, function, and `augroup` names accordingly, including setting script scope for some of the functions and their calls (`s:` and `<SID>` prefixes). Initially I tried using `prefix#`, but it turns out that this is a namespacing contention for publically callable functions like `pathogen#infect`, and none of these functions need to be publically callable.
Diffstat (limited to 'vim')
-rw-r--r--vim/config/bigfile.vim10
-rw-r--r--vim/config/format.vim8
-rw-r--r--vim/config/linebreak.vim4
-rw-r--r--vim/config/search.vim2
-rw-r--r--vim/config/swapfile.vim2
-rw-r--r--vim/config/syntax.vim4
-rw-r--r--vim/config/undo.vim2
-rw-r--r--vim/config/viminfo.vim2
-rw-r--r--vim/config/whitespace.vim4
-rw-r--r--vim/ftdetect/csv.vim2
-rw-r--r--vim/ftdetect/muttrc.vim2
-rw-r--r--vim/ftdetect/sh.vim2
-rw-r--r--vim/ftdetect/tsv.vim2
-rw-r--r--vim/ftdetect/xdefaults.vim2
-rw-r--r--vim/ftplugin/html.vim4
15 files changed, 26 insertions, 26 deletions
diff --git a/vim/config/bigfile.vim b/vim/config/bigfile.vim
index f15c7e85..5c68b1a7 100644
--- a/vim/config/bigfile.vim
+++ b/vim/config/bigfile.vim
@@ -2,12 +2,12 @@
if has('eval') && has('autocmd')
" Threshold is 10 MiB
- let g:bigfilesize = 10 * 1024 * 1024
+ let g:big_file_size = 10 * 1024 * 1024
" Declare function for turning off slow options
- function! BigFileMeasures()
+ function! s:BigFileMeasures()
let l:file = expand('<afile>')
- if getfsize(l:file) > g:bigfilesize
+ if getfsize(l:file) > g:big_file_size
setlocal nobackup
setlocal nowritebackup
setlocal noswapfile
@@ -21,8 +21,8 @@ if has('eval') && has('autocmd')
endfunction
" Define autocmd for calling to check filesize
- augroup bigfilesize
+ augroup dotfiles_big_file_measures
autocmd!
- autocmd BufReadPre * call BigFileMeasures()
+ autocmd BufReadPre * call s:BigFileMeasures()
augroup end
endif
diff --git a/vim/config/format.vim b/vim/config/format.vim
index fadbd8f7..b307c4b6 100644
--- a/vim/config/format.vim
+++ b/vim/config/format.vim
@@ -20,12 +20,12 @@ endif
" very handy
"
if has('eval')
- function! ToggleFormatFlag(flag)
+ function! s:ToggleFormatFlag(flag)
let l:operation = (&formatoptions =~ a:flag) ? '-=' : '+='
silent! exec 'setlocal formatoptions' . l:operation . a:flag
setlocal formatoptions?
endfunction
- nnoremap <silent> <leader>a :<C-U>call ToggleFormatFlag('a')<CR>
- nnoremap <silent> <leader>c :<C-U>call ToggleFormatFlag('c')<CR>
- nnoremap <silent> <leader>t :<C-U>call ToggleFormatFlag('t')<CR>
+ nnoremap <silent> <leader>a :<C-U>call <SID>ToggleFormatFlag('a')<CR>
+ nnoremap <silent> <leader>c :<C-U>call <SID>ToggleFormatFlag('c')<CR>
+ nnoremap <silent> <leader>t :<C-U>call <SID>ToggleFormatFlag('t')<CR>
endif
diff --git a/vim/config/linebreak.vim b/vim/config/linebreak.vim
index 5abdabd1..0c358955 100644
--- a/vim/config/linebreak.vim
+++ b/vim/config/linebreak.vim
@@ -11,7 +11,7 @@ if has('linebreak')
" Bind \b to turn off linebreak and toggle the showbreak characters on and
" off for convenience of copypasting multiple lines from terminal emulators.
if has('eval')
- function! ToggleBreak()
+ function! s:ToggleBreak()
if &linebreak
set nolinebreak
set showbreak=
@@ -26,6 +26,6 @@ if has('linebreak')
endif
endif
endfunction
- nnoremap <silent> <leader>b :<C-U>call ToggleBreak()<CR>
+ nnoremap <silent> <leader>b :<C-U>call <SID>ToggleBreak()<CR>
endif
endif
diff --git a/vim/config/search.vim b/vim/config/search.vim
index ed71bff8..56a461b3 100644
--- a/vim/config/search.vim
+++ b/vim/config/search.vim
@@ -17,7 +17,7 @@ if has('extra_search')
" Clear search highlighting as soon as I enter insert mode, and restore it
" once I leave it
if has('autocmd')
- augroup highlight
+ augroup dotfiles_highlight
autocmd!
silent! autocmd InsertEnter * set nohlsearch
silent! autocmd InsertLeave * set hlsearch
diff --git a/vim/config/swapfile.vim b/vim/config/swapfile.vim
index d5534d92..f118eabd 100644
--- a/vim/config/swapfile.vim
+++ b/vim/config/swapfile.vim
@@ -18,7 +18,7 @@ if !strlen($SUDO_USER) && has('unix')
" filesystems; this is because they're used as scratch spaces for tools
" like sudoedit(8) and pass(1) and hence could present a security problem
if has('autocmd')
- augroup swapskip
+ augroup dotfiles_swap_skip
autocmd!
silent! autocmd BufNewFile,BufReadPre
\ /tmp/*,$TMPDIR/*,$TMP/*,$TEMP/*,*/shm/*
diff --git a/vim/config/syntax.vim b/vim/config/syntax.vim
index 08b908c8..e7d94b1b 100644
--- a/vim/config/syntax.vim
+++ b/vim/config/syntax.vim
@@ -10,7 +10,7 @@ if has('syntax')
if has('eval') && v:version >= 701
" Wrap all this logic in a function
- function! DetectBackground()
+ function! s:DetectBackground()
" Split up the value of $COLORFGBG (if any) by semicolons
let l:colorfgbg = split($COLORFGBG, ';')
@@ -28,7 +28,7 @@ if has('syntax')
endfunction
" Call the function just defined directly
- call DetectBackground()
+ call s:DetectBackground()
" Ancient or cut-down Vim? Just go dark
else
diff --git a/vim/config/undo.vim b/vim/config/undo.vim
index 68dde131..872578f7 100644
--- a/vim/config/undo.vim
+++ b/vim/config/undo.vim
@@ -22,7 +22,7 @@ if !strlen($SUDO_USER) && has('unix') && has('persistent_undo')
" Don't track changes to sensitive files
if has('autocmd')
- augroup undoskip
+ augroup dotfiles_undo_skip
autocmd!
silent! autocmd BufWritePre
\ /tmp/*,$TMPDIR/*,$TMP/*,$TEMP/*,*/shm/*
diff --git a/vim/config/viminfo.vim b/vim/config/viminfo.vim
index 49ff7582..ce5d539d 100644
--- a/vim/config/viminfo.vim
+++ b/vim/config/viminfo.vim
@@ -2,7 +2,7 @@
" memory filesystems; this is because they're used as scratch spaces for tools
" like sudoedit(8) and pass(1) and hence could present a security problem
if has('viminfo') && has('autocmd')
- augroup viminfoskip
+ augroup dotfiles_viminfo_skip
autocmd!
silent! autocmd BufNewFile,BufReadPre
\ /tmp/*,$TMPDIR/*,$TMP/*,$TEMP/*,*/shm/*
diff --git a/vim/config/whitespace.vim b/vim/config/whitespace.vim
index 119d2c48..4189d858 100644
--- a/vim/config/whitespace.vim
+++ b/vim/config/whitespace.vim
@@ -4,12 +4,12 @@ set nojoinspaces
" Strip trailing whitespace with \x
if has('eval')
- function! StripTrailingWhitespace()
+ function! s:StripTrailingWhitespace()
let l:li = 1
for l:line in getline(1,'$')
call setline(l:li, substitute(l:line, '\m\C\s\+$', '', 'g'))
let l:li = l:li + 1
endfor
endfunction
- nnoremap <silent> <leader>x :<C-U>call StripTrailingWhitespace()<CR>
+ nnoremap <silent> <leader>x :<C-U>call <SID>StripTrailingWhitespace()<CR>
endif
diff --git a/vim/ftdetect/csv.vim b/vim/ftdetect/csv.vim
index 727077a0..e5a38e10 100644
--- a/vim/ftdetect/csv.vim
+++ b/vim/ftdetect/csv.vim
@@ -1,5 +1,5 @@
" Add automatic commands to detect CSV files
-augroup dfcsv
+augroup dotfiles_ftdetect_csv
autocmd!
autocmd BufNewFile,BufRead
\ *.csv
diff --git a/vim/ftdetect/muttrc.vim b/vim/ftdetect/muttrc.vim
index 832d0c1f..0f625f2b 100644
--- a/vim/ftdetect/muttrc.vim
+++ b/vim/ftdetect/muttrc.vim
@@ -1,5 +1,5 @@
" Add automatic commands to detect .muttrc files
-augroup dfmuttrc
+augroup dotfiles_ftdetect_muttrc
autocmd!
autocmd BufNewFile,BufRead
\ **/.dotfiles/mutt/muttrc.d/*.rc,**/.muttrc.d/*.rc
diff --git a/vim/ftdetect/sh.vim b/vim/ftdetect/sh.vim
index 92aa2a0c..3df9c3ce 100644
--- a/vim/ftdetect/sh.vim
+++ b/vim/ftdetect/sh.vim
@@ -1,5 +1,5 @@
" Add automatic commands to choose shell flavours based on filename pattern
-augroup dfsh
+augroup dotfiles_ftdetect_sh
autocmd!
" Names/paths of things that are Bash shell script
diff --git a/vim/ftdetect/tsv.vim b/vim/ftdetect/tsv.vim
index af544a94..673721f5 100644
--- a/vim/ftdetect/tsv.vim
+++ b/vim/ftdetect/tsv.vim
@@ -1,5 +1,5 @@
" Add automatic commands to detect TSV files
-augroup dftsv
+augroup dotfiles_ftdetect_tsv
autocmd!
autocmd BufNewFile,BufRead
\ *.tsv
diff --git a/vim/ftdetect/xdefaults.vim b/vim/ftdetect/xdefaults.vim
index 098ded56..1529e5c9 100644
--- a/vim/ftdetect/xdefaults.vim
+++ b/vim/ftdetect/xdefaults.vim
@@ -1,5 +1,5 @@
" Add automatic commands to find Xresources subfiles
-augroup dfxdefaults
+augroup dotfiles_ftdetect_xdefaults
autocmd!
autocmd BufNewFile,BufRead
\ **/.Xresources.d/*
diff --git a/vim/ftplugin/html.vim b/vim/ftplugin/html.vim
index ca762422..3f28e9ea 100644
--- a/vim/ftplugin/html.vim
+++ b/vim/ftplugin/html.vim
@@ -2,10 +2,10 @@
nnoremap <leader>v :exe "!tidy -eq -utf8 " . shellescape(expand("%"))<CR>
" Make a bare URL into a link to itself
-function! UrlLink()
+function! s:UrlLink()
normal! yiW
execute "normal! i<a href=\"\<C-R>0\">\<Esc>"
normal! E
execute "normal! a</a>\<Esc>"
endfunction
-nnoremap <silent> <leader>r :<C-U>call UrlLink()<CR>
+nnoremap <silent> <leader>r :<C-U>call <SID>UrlLink()<CR>