aboutsummaryrefslogtreecommitdiff
path: root/vim/after/ftplugin/perl.vim
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2018-08-15 10:12:38 +1200
committerTom Ryder <tom@sanctum.geek.nz>2018-08-15 10:12:38 +1200
commit4dd8d125cd401137d18d196e4125aa8fe789d2a0 (patch)
tree273810b45b6cd15d57402340da7978834cd27b55 /vim/after/ftplugin/perl.vim
parentMerge branch 'release/v1.52.0' (diff)
parentBump VERSION (diff)
downloaddotfiles-4dd8d125cd401137d18d196e4125aa8fe789d2a0.tar.gz
dotfiles-4dd8d125cd401137d18d196e4125aa8fe789d2a0.zip
Merge branch 'release/v1.53.0'v1.53.0
* release/v1.53.0: Bump VERSION Unset g:is_posix when no longer needed Move Perl boilerplate generation to autoload Use consistent format for local leader mappings Rearrange local mappings for mail Add `abort` attribute to autoloaded mail function Move Vim mail functions to autoload Delete multiple blank lines after skipped greeting Add "hey" to generic mail quote greetings
Diffstat (limited to 'vim/after/ftplugin/perl.vim')
-rw-r--r--vim/after/ftplugin/perl.vim61
1 files changed, 1 insertions, 60 deletions
diff --git a/vim/after/ftplugin/perl.vim b/vim/after/ftplugin/perl.vim
index 9c3ce6f6..ee8da2a7 100644
--- a/vim/after/ftplugin/perl.vim
+++ b/vim/after/ftplugin/perl.vim
@@ -13,65 +13,6 @@ let b:undo_ftplugin .= '|unlet b:current_compiler'
setlocal matchpairs+=<:>
let b:undo_ftplugin .= '|setlocal matchpairs<'
-" Function to add boilerplate intelligently
-function! s:Boilerplate() abort
-
- " Flag whether the buffer started blank
- let l:blank = line2byte(line('$') + 1) <= 2
-
- " This is a .pm file, guess its package name from path
- if expand('%:e') ==# 'pm'
-
- let l:match = matchlist(expand('%:p'), '.*/lib/\(.\+\).pm$')
- if len(l:match)
- let l:package = substitute(l:match[1], '/', '::', 'g')
- else
- let l:package = expand('%:t:r')
- endif
-
- " Otherwise, just use 'main'
- else
- let l:package = 'main'
- endif
-
- " Lines always to add
- let l:lines = [
- \ 'package '.l:package.';',
- \ '',
- \ 'use strict;',
- \ 'use warnings;',
- \ 'use utf8;',
- \ '',
- \ 'use 5.006;',
- \ '',
- \ 'our $VERSION = ''0.01'';',
- \ ''
- \ ]
-
- " Conditional lines depending on package
- if l:package ==# 'main'
- let l:lines = ['#!perl'] + l:lines
- else
- let l:lines = l:lines + ['', '1;']
- endif
-
- " Add all the lines in the array
- for l:line in l:lines
- call append(line('.') - 1, l:line)
- endfor
-
- " If we started in a completely empty buffer, delete the current blank line
- if l:blank
- delete
- endif
-
- " If we added a trailing '1' for a package, move the cursor up two lines
- if l:package !=# 'main'
- -2
- endif
-
-endfunction
-
" Stop here if the user doesn't want ftplugin mappings
if exists('g:no_plugin_maps') || exists('g:no_perl_maps')
finish
@@ -79,7 +20,7 @@ endif
" Add boilerplate intelligently
nnoremap <buffer> <silent> <LocalLeader>b
- \ :<C-U>call <SID>Boilerplate()<CR>
+ \ :<C-U>call perl#Boilerplate()<CR>
let b:undo_ftplugin .= '|nunmap <buffer> <LocalLeader>b'
" Mappings to choose compiler