aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2018-07-04 13:08:30 +1200
committerTom Ryder <tom@sanctum.geek.nz>2018-07-04 13:08:30 +1200
commitd91e4c77ebe9a7dcc3336b25e0570551a933f974 (patch)
tree49d819767dd6517bf4059986de1ea5b094ce0a1a
parentcd28ccec63f7c1cb00b5f35aca6a8bff2a750581 (diff)
downloaddotfiles-d91e4c77ebe9a7dcc3336b25e0570551a933f974.tar.gz
dotfiles-d91e4c77ebe9a7dcc3336b25e0570551a933f974.zip
Spin off Vim Perl version bump into ftplugin
-rw-r--r--.gitmodules3
-rw-r--r--vim/after/ftplugin/perl.vim8
-rw-r--r--vim/autoload/perl.vim45
m---------vim/bundle/perl_version_bump0
4 files changed, 7 insertions, 49 deletions
diff --git a/.gitmodules b/.gitmodules
index 6f4c3e62..390e7400 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -52,6 +52,9 @@
[submodule "vim/bundle/markdown_autoformat"]
path = vim/bundle/markdown_autoformat
url = https://sanctum.geek.nz/code/vim-markdown-autoformat.git
+[submodule "vim/bundle/perl_version_bump"]
+ path = vim/bundle/perl_version_bump
+ url = https://sanctum.geek.nz/code/vim-perl-version-bump.git
# My Vim colorschemes
[submodule "vim/bundle/juvenile"]
diff --git a/vim/after/ftplugin/perl.vim b/vim/after/ftplugin/perl.vim
index acfb72c4..1a7df559 100644
--- a/vim/after/ftplugin/perl.vim
+++ b/vim/after/ftplugin/perl.vim
@@ -30,10 +30,10 @@ let b:undo_ftplugin = b:undo_ftplugin
\ . '|nunmap <buffer> <LocalLeader>t'
" Bump version numbers
-nnoremap <buffer> <LocalLeader>v
- \ :<C-U>call perl#BumpVersionMinor()<CR>
-nnoremap <buffer> <LocalLeader>V
- \ :<C-U>call perl#BumpVersionMajor()<CR>
+nmap <buffer> <LocalLeader>v
+ \ <Plug>PerlVersionBumpMinor
+nmap <buffer> <LocalLeader>V
+ \ <Plug>PerlVersionBumpMajor
let b:undo_ftplugin = b:undo_ftplugin
\ . '|nunmap <buffer> <LocalLeader>v'
\ . '|nunmap <buffer> <LocalLeader>V'
diff --git a/vim/autoload/perl.vim b/vim/autoload/perl.vim
deleted file mode 100644
index a4c8724a..00000000
--- a/vim/autoload/perl.vim
+++ /dev/null
@@ -1,45 +0,0 @@
-" Version number specifier format
-let g:perl#verpat = '\m\C^'
- \ . '\(our\s\+\$VERSION\s*=\D*\)'
- \ . '\(\d\+\)\.\(\d\+\)'
- \ . '\(.*\)'
-
-" Version number bumper
-function! perl#BumpVersion(major) abort
- let l:view = winsaveview()
- let l:li = search(g:perl#verpat)
- if !l:li
- echomsg 'No version number declaration found'
- return
- endif
- let l:matches = matchlist(getline(l:li), g:perl#verpat)
- let [l:lvalue, l:major, l:minor, l:rest]
- \ = matchlist(getline(l:li), g:perl#verpat)[1:4]
- if a:major
- let l:major = perl#Setf(l:major, l:major + 1)
- let l:minor = perl#Setf(l:minor, 0)
- else
- let l:minor = perl#Setf(l:minor, l:minor + 1)
- endif
- let l:version = l:major.'.'.l:minor
- call setline(l:li, l:lvalue.l:version.l:rest)
- if a:major
- echomsg 'Bumped major $VERSION: '.l:version
- else
- echomsg 'Bumped minor $VERSION: '.l:version
- endif
- call winrestview(l:view)
-endfunction
-
-" Explanatory wrappers
-function! perl#BumpVersionMinor() abort
- call perl#BumpVersion(0)
-endfunction
-function! perl#BumpVersionMajor() abort
- call perl#BumpVersion(1)
-endfunction
-
-" Helper function to format a number without decreasing its digit count
-function! perl#Setf(old, new) abort
- return repeat('0', strlen(a:old) - strlen(a:new)).a:new
-endfunction
diff --git a/vim/bundle/perl_version_bump b/vim/bundle/perl_version_bump
new file mode 160000
+Subproject 80c98e8b11832cf78f2fc3ee43599749be8ee6a