aboutsummaryrefslogtreecommitdiff
path: root/vim/after/ftplugin
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2018-06-17 11:53:31 +1200
committerTom Ryder <tom@sanctum.geek.nz>2018-06-17 11:53:31 +1200
commit670c735799879ae066b9a5249356a4d872514951 (patch)
tree994ec8145503f6515e83cd6284e1f4bca85b6ad6 /vim/after/ftplugin
parentAdd local copy of php.vim compiler (diff)
downloaddotfiles-670c735799879ae066b9a5249356a4d872514951.tar.gz
dotfiles-670c735799879ae066b9a5249356a4d872514951.zip
Use autoload function for temp-makeprg :lmake
Diffstat (limited to 'vim/after/ftplugin')
-rw-r--r--vim/after/ftplugin/html/lint.vim25
-rw-r--r--vim/after/ftplugin/perl/check.vim25
-rw-r--r--vim/after/ftplugin/perl/lint.vim25
-rw-r--r--vim/after/ftplugin/php/check.vim34
-rw-r--r--vim/after/ftplugin/sh/check.vim36
-rw-r--r--vim/after/ftplugin/sh/lint.vim25
-rw-r--r--vim/after/ftplugin/vim/lint.vim25
-rw-r--r--vim/after/ftplugin/zsh/check.vim25
8 files changed, 55 insertions, 165 deletions
diff --git a/vim/after/ftplugin/html/lint.vim b/vim/after/ftplugin/html/lint.vim
index a3776d60..0b56e73c 100644
--- a/vim/after/ftplugin/html/lint.vim
+++ b/vim/after/ftplugin/html/lint.vim
@@ -15,33 +15,20 @@ if &filetype !=# 'html'
finish
endif
+" Don't load if the user doesn't want ftplugin mappings
+if exists('g:no_plugin_maps') || exists('g:no_html_maps')
+ finish
+endif
+
" Flag as loaded
let b:did_ftplugin_html_lint = 1
let b:undo_ftplugin = b:undo_ftplugin
\ . '|unlet b:did_ftplugin_html_lint'
-" Build function for linter
-function! s:HtmlLint()
- if exists('b:current_compiler')
- let l:save_compiler = b:current_compiler
- endif
- compiler tidy
- lmake!
- lwindow
- if exists('l:save_compiler')
- execute 'compiler ' . l:save_compiler
- endif
-endfunction
-
-" Stop here if the user doesn't want ftplugin mappings
-if exists('g:no_plugin_maps') || exists('g:no_html_maps')
- finish
-endif
-
" Define a mapping target
nnoremap <buffer> <silent> <unique>
\ <Plug>HtmlLint
- \ :<C-U>call <SID>HtmlLint()<CR>
+ \ :<C-U>call compiler#Make('tidy')<CR>
let b:undo_ftplugin = b:undo_ftplugin
\ . '|nunmap <buffer> <Plug>HtmlLint'
diff --git a/vim/after/ftplugin/perl/check.vim b/vim/after/ftplugin/perl/check.vim
index e115b37f..f6f99f08 100644
--- a/vim/after/ftplugin/perl/check.vim
+++ b/vim/after/ftplugin/perl/check.vim
@@ -10,33 +10,20 @@ if exists('b:did_ftplugin_perl_check')
finish
endif
+" Don't load if the user doesn't want ftplugin mappings
+if exists('g:no_plugin_maps') || exists('g:no_perl_maps')
+ finish
+endif
+
" Flag as loaded
let b:did_ftplugin_perl_check = 1
let b:undo_ftplugin = b:undo_ftplugin
\ . '|unlet b:did_ftplugin_perl_check'
-" Build function for checker
-function! s:PerlCheck()
- if exists('b:current_compiler')
- let l:save_compiler = b:current_compiler
- endif
- compiler perl
- lmake!
- lwindow
- if exists('l:save_compiler')
- execute 'compiler ' . l:save_compiler
- endif
-endfunction
-
-" Stop here if the user doesn't want ftplugin mappings
-if exists('g:no_plugin_maps') || exists('g:no_perl_maps')
- finish
-endif
-
" Define a mapping target
nnoremap <buffer> <silent> <unique>
\ <Plug>PerlCheck
- \ :<C-U>call <SID>PerlCheck()<CR>
+ \ :<C-U>call compiler#Make('perl')<CR>
let b:undo_ftplugin = b:undo_ftplugin
\ . '|nunmap <buffer> <Plug>PerlCheck'
diff --git a/vim/after/ftplugin/perl/lint.vim b/vim/after/ftplugin/perl/lint.vim
index 3e73ac9a..eaa6684c 100644
--- a/vim/after/ftplugin/perl/lint.vim
+++ b/vim/after/ftplugin/perl/lint.vim
@@ -10,33 +10,20 @@ if exists('b:did_ftplugin_perl_lint')
finish
endif
+" Don't load if the user doesn't want ftplugin mappings
+if exists('g:no_plugin_maps') || exists('g:no_html_maps')
+ finish
+endif
+
" Flag as loaded
let b:did_ftplugin_perl_lint = 1
let b:undo_ftplugin = b:undo_ftplugin
\ . '|unlet b:did_ftplugin_perl_lint'
-" Build function for linter
-function! s:PerlLint()
- if exists('b:current_compiler')
- let l:save_compiler = b:current_compiler
- endif
- compiler perlcritic
- lmake!
- lwindow
- if exists('l:save_compiler')
- execute 'compiler ' . l:save_compiler
- endif
-endfunction
-
-" Stop here if the user doesn't want ftplugin mappings
-if exists('g:no_plugin_maps') || exists('g:no_perl_maps')
- finish
-endif
-
" Define a mapping target
nnoremap <buffer> <silent> <unique>
\ <Plug>PerlLint
- \ :<C-U>call <SID>PerlLint()<CR>
+ \ :<C-U>call compiler#Make('perlcritic')<CR>
let b:undo_ftplugin = b:undo_ftplugin
\ . '|nunmap <buffer> <Plug>PerlLint'
diff --git a/vim/after/ftplugin/php/check.vim b/vim/after/ftplugin/php/check.vim
index f211a642..9dc4c6a8 100644
--- a/vim/after/ftplugin/php/check.vim
+++ b/vim/after/ftplugin/php/check.vim
@@ -10,42 +10,20 @@ if exists('b:did_ftplugin_php_check')
finish
endif
+" Don't load if the user doesn't want ftplugin mappings
+if exists('g:no_plugin_maps') || exists('g:no_php_maps')
+ finish
+endif
+
" Flag as loaded
let b:did_ftplugin_php_check = 1
let b:undo_ftplugin = b:undo_ftplugin
\ . '|unlet b:did_ftplugin_php_check'
-" Build function for checker
-function! s:PhpCheck()
- if exists('b:current_compiler')
- let l:save_compiler = b:current_compiler
- endif
- compiler php
-
- " The PHP compiler is unusual: it gets us to provide the filename argument
- " ourselves. 7.4.191 is the earliest version with the :S file name modifier,
- " which we really should use if we can
- if v:version >= 704 || v:version == 704 && has('patch191')
- lmake! %:S
- else
- lmake! %
- endif
- lwindow
-
- if exists('l:save_compiler')
- execute 'compiler ' . l:save_compiler
- endif
-endfunction
-
-" Stop here if the user doesn't want ftplugin mappings
-if exists('g:no_plugin_maps') || exists('g:no_php_maps')
- finish
-endif
-
" Define a mapping target
nnoremap <buffer> <silent> <unique>
\ <Plug>PhpCheck
- \ :<C-U>call <SID>PhpCheck()<CR>
+ \ :<C-U>call compiler#Make('php')<CR>
let b:undo_ftplugin = b:undo_ftplugin
\ . '|nunmap <buffer> <Plug>PhpCheck'
diff --git a/vim/after/ftplugin/sh/check.vim b/vim/after/ftplugin/sh/check.vim
index e92409cf..499926f3 100644
--- a/vim/after/ftplugin/sh/check.vim
+++ b/vim/after/ftplugin/sh/check.vim
@@ -10,39 +10,29 @@ if exists('b:did_ftplugin_sh_check')
finish
endif
+" Stop here if the user doesn't want ftplugin mappings
+if exists('g:no_plugin_maps') || exists('g:no_sh_maps')
+ finish
+endif
+
" Flag as loaded
let b:did_ftplugin_sh_check = 1
let b:undo_ftplugin = b:undo_ftplugin
\ . '|unlet b:did_ftplugin_sh_check'
-" Build function for checker
-function! s:ShCheck()
- if exists('b:current_compiler')
- let l:save_compiler = b:current_compiler
- endif
- if exists('b:is_bash')
- compiler bash
- elseif exists('b:is_kornshell')
- compiler ksh
- else
- compiler sh
- endif
- lmake!
- lwindow
- if exists('l:save_compiler')
- execute 'compiler ' . l:save_compiler
- endif
-endfunction
-
-" Stop here if the user doesn't want ftplugin mappings
-if exists('g:no_plugin_maps') || exists('g:no_sh_maps')
- finish
+" Choose compiler based on file subtype
+if exists('b:is_bash')
+ let b:sh_check_compiler = 'bash'
+elseif exists('b:is_kornshell')
+ let b:sh_check_compiler = 'ksh'
+else
+ let b:sh_check_compiler = 'sh'
endif
" Define a mapping target
nnoremap <buffer> <silent> <unique>
\ <Plug>ShCheck
- \ :<C-U>call <SID>ShCheck()<CR>
+ \ :<C-U>call compiler#Make(b:sh_check_compiler)<CR>
let b:undo_ftplugin = b:undo_ftplugin
\ . '|nunmap <buffer> <Plug>ShCheck'
diff --git a/vim/after/ftplugin/sh/lint.vim b/vim/after/ftplugin/sh/lint.vim
index 87f1c07e..65fe003d 100644
--- a/vim/after/ftplugin/sh/lint.vim
+++ b/vim/after/ftplugin/sh/lint.vim
@@ -10,33 +10,20 @@ if exists('b:did_ftplugin_sh_lint')
finish
endif
+" Don't load if the user doesn't want ftplugin mappings
+if exists('g:no_plugin_maps') || exists('g:no_sh_maps')
+ finish
+endif
+
" Flag as loaded
let b:did_ftplugin_sh_lint = 1
let b:undo_ftplugin = b:undo_ftplugin
\ . '|unlet b:did_ftplugin_sh_lint'
-" Build function for linter
-function! s:ShLint()
- if exists('b:current_compiler')
- let l:save_compiler = b:current_compiler
- endif
- compiler shellcheck
- lmake!
- lwindow
- if exists('l:save_compiler')
- execute 'compiler ' . l:save_compiler
- endif
-endfunction
-
-" Stop here if the user doesn't want ftplugin mappings
-if exists('g:no_plugin_maps') || exists('g:no_sh_maps')
- finish
-endif
-
" Define a mapping target
nnoremap <buffer> <silent> <unique>
\ <Plug>ShLint
- \ :<C-U>call <SID>ShLint()<CR>
+ \ :<C-U>call compiler#Make('shellcheck')<CR>
let b:undo_ftplugin = b:undo_ftplugin
\ . '|nunmap <buffer> <Plug>ShLint'
diff --git a/vim/after/ftplugin/vim/lint.vim b/vim/after/ftplugin/vim/lint.vim
index 1e4f7d39..bd8c1da4 100644
--- a/vim/after/ftplugin/vim/lint.vim
+++ b/vim/after/ftplugin/vim/lint.vim
@@ -10,33 +10,20 @@ if exists('b:did_ftplugin_vim_lint')
finish
endif
+" Don't load if the user doesn't want ftplugin mappings
+if exists('g:no_plugin_maps') || exists('g:no_vim_maps')
+ finish
+endif
+
" Flag as loaded
let b:did_ftplugin_vim_lint = 1
let b:undo_ftplugin = b:undo_ftplugin
\ . '|unlet b:did_ftplugin_vim_lint'
-" Build function for linter
-function! s:VimLint()
- if exists('b:current_compiler')
- let l:save_compiler = b:current_compiler
- endif
- compiler vint
- lmake!
- lwindow
- if exists('l:save_compiler')
- execute 'compiler ' . l:save_compiler
- endif
-endfunction
-
-" Stop here if the user doesn't want ftplugin mappings
-if exists('g:no_plugin_maps') || exists('g:no_vim_maps')
- finish
-endif
-
" Define a mapping target
nnoremap <buffer> <silent> <unique>
\ <Plug>VimLint
- \ :<C-U>call <SID>VimLint()<CR>
+ \ :<C-U>call compiler#Make('vint')<CR>
let b:undo_ftplugin = b:undo_ftplugin
\ . '|nunmap <buffer> <Plug>VimLint'
diff --git a/vim/after/ftplugin/zsh/check.vim b/vim/after/ftplugin/zsh/check.vim
index 1d327a62..3e5ad7c6 100644
--- a/vim/after/ftplugin/zsh/check.vim
+++ b/vim/after/ftplugin/zsh/check.vim
@@ -10,33 +10,20 @@ if exists('b:did_ftplugin_zsh_check')
finish
endif
+" Don't load if the user doesn't want ftplugin mappings
+if exists('g:no_plugin_maps') || exists('g:no_zsh_maps')
+ finish
+endif
+
" Flag as loaded
let b:did_ftplugin_zsh_check = 1
let b:undo_ftplugin = b:undo_ftplugin
\ . '|unlet b:did_ftplugin_zsh_check'
-" Build function for checker
-function! s:ZshCheck()
- if exists('b:current_compiler')
- let l:save_compiler = b:current_compiler
- endif
- compiler zsh
- lmake!
- lwindow
- if exists('l:save_compiler')
- execute 'compiler ' . l:save_compiler
- endif
-endfunction
-
-" Set up a mapping for the checker, if we're allowed
-if exists('g:no_plugin_maps') || exists('g:no_zsh_maps')
- finish
-endif
-
" Define a mapping target
nnoremap <buffer> <silent> <unique>
\ <Plug>ZshCheck
- \ :<C-U>call <SID>ZshCheck()<CR>
+ \ :<C-U>call compiler#Make('zsh')<CR>
let b:undo_ftplugin = b:undo_ftplugin
\ . '|nunmap <buffer> <Plug>ZshCheck'