aboutsummaryrefslogtreecommitdiff
path: root/vim/ftplugin
diff options
context:
space:
mode:
Diffstat (limited to 'vim/ftplugin')
-rw-r--r--vim/ftplugin/html.vim24
-rw-r--r--vim/ftplugin/perl.vim17
-rw-r--r--vim/ftplugin/sh.vim22
-rw-r--r--vim/ftplugin/vim.vim5
4 files changed, 57 insertions, 11 deletions
diff --git a/vim/ftplugin/html.vim b/vim/ftplugin/html.vim
index 3f28e9ea..c756eb80 100644
--- a/vim/ftplugin/html.vim
+++ b/vim/ftplugin/html.vim
@@ -1,11 +1,25 @@
-" Run tidy -eq -utf8 on file for the current buffer
-nnoremap <leader>v :exe "!tidy -eq -utf8 " . shellescape(expand("%"))<CR>
+" Run `tidy -errors -quiet` over buffer
+nnoremap <buffer> <silent> <LocalLeader>c
+ \ :write !tidy -errors -quiet<CR>
+
+" Filter buffer through `tidy`
+nnoremap <buffer> <silent> <LocalLeader>t
+ \ :%!tidy -quiet<CR>
" Make a bare URL into a link to itself
function! s:UrlLink()
+
+ " Yank this whole whitespace-separated word
normal! yiW
- execute "normal! i<a href=\"\<C-R>0\">\<Esc>"
+ " Open a link tag
+ normal! i<a href="">
+ " Paste the URL into the quotes
+ normal! hP
+ " Move to the end of the link text URL
normal! E
- execute "normal! a</a>\<Esc>"
+ " Close the link tag
+ normal! a</a>
+
endfunction
-nnoremap <silent> <leader>r :<C-U>call <SID>UrlLink()<CR>
+nnoremap <buffer> <silent> <LocalLeader>r
+ \ :<C-U>call <SID>UrlLink()<CR>
diff --git a/vim/ftplugin/perl.vim b/vim/ftplugin/perl.vim
index dad2ce35..2ea4676b 100644
--- a/vim/ftplugin/perl.vim
+++ b/vim/ftplugin/perl.vim
@@ -1,6 +1,11 @@
-" Run perl -c on file for the current buffer
-nnoremap <leader>pc :exe "!perl -c " . shellescape(expand("%"))<CR>
-" Run perlcritic on the file for the current buffer
-nnoremap <leader>pl :exe "!perlcritic " . shellescape(expand("%"))<CR>
-" Run the current buffer through perltidy
-nnoremap <leader>pt :%!perltidy<CR>
+" Run `perl -c` over buffer
+nnoremap <buffer> <silent> <LocalLeader>c
+ \ :write !perl -c<CR>
+
+" Run `perlcritic` over buffer
+nnoremap <buffer> <silent> <LocalLeader>l
+ \ :write !perlcritic<CR>
+
+" Filter buffer through `perltidy`
+nnoremap <buffer> <silent> <LocalLeader>t
+ \ :%!perltidy<CR>
diff --git a/vim/ftplugin/sh.vim b/vim/ftplugin/sh.vim
index a6dd62eb..c09e4fe8 100644
--- a/vim/ftplugin/sh.vim
+++ b/vim/ftplugin/sh.vim
@@ -24,3 +24,25 @@ endif
if exists('b:is_bash') && executable('han')
setlocal keywordprg=han
endif
+
+" Map checker based on shell family
+if exists('b:is_bash') && b:is_bash
+ let b:check = 'bash -n'
+elseif exists('b:is_ksh') && b:is_ksh
+ let b:check = 'ksh -n'
+else
+ let b:check = 'sh -n'
+endif
+nnoremap <buffer> <silent> <LocalLeader>c
+ \ :<C-U>execute ':write !' . b:check<CR>
+
+" Map linter based on shell family
+if exists('b:is_bash') && b:is_bash
+ let b:lint = 'shellcheck -s bash -'
+elseif exists('b:is_ksh') && b:is_ksh
+ let b:lint = 'shellcheck -s ksh -'
+else
+ let b:lint = 'shellcheck -s sh -'
+endif
+nnoremap <buffer> <silent> <LocalLeader>l
+ \ :<C-U>execute ':write !' . b:lint<CR>
diff --git a/vim/ftplugin/vim.vim b/vim/ftplugin/vim.vim
new file mode 100644
index 00000000..e023553e
--- /dev/null
+++ b/vim/ftplugin/vim.vim
@@ -0,0 +1,5 @@
+" Run `vint` over buffer
+" /dev/stdin is not optimal here; it's widely implemented, but not POSIX.
+" `vint` does not seem to have another way to parse standard input.
+nnoremap <buffer> <silent> <LocalLeader>l
+ \ :write !vint -s /dev/stdin<CR>