From 12a9d4c30cb5f4b95c77ba2521b8fc9cdcc83f87 Mon Sep 17 00:00:00 2001 From: Abdurrahman Aborazmeh Date: Mon, 30 Nov 2015 06:19:22 +0200 Subject: [PATCH] Add perltidy --- README.md | 3 +++ plugin/defaults.vim | 15 +++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/README.md b/README.md index 3d943c3..1afbd5b 100644 --- a/README.md +++ b/README.md @@ -139,6 +139,9 @@ It can be installed using `cargo`, the Rust package manager. Up-to-date installa * `dartfmt` for __Dart__. Part of the Dart SDK (make sure it is on your PATH). See https://www.dartlang.org/tools/dartfmt/ for more info. +* `perltidy` for __Perl__. +It can be installed from CPAN `cpanm Perl::Tidy` . See https://metacpan.org/pod/Perl::Tidy and http://perltidy.sourceforge.net/ for more info. + How can I change the behaviour of formatters, or add one myself? ---------------------------------------------------------------- If you need a formatter that is not among the defaults, or if you are not satisfied with the default formatting behaviour that is provided by vim-autoformat, you can define it yourself. diff --git a/plugin/defaults.vim b/plugin/defaults.vim index 047b798..7cc49f4 100644 --- a/plugin/defaults.vim +++ b/plugin/defaults.vim @@ -211,3 +211,18 @@ endif if !exists('g:formatters_dart') let g:formatters_dart = ['dartfmt'] endif + +" Perl +if !exists('g:formatdef_perltidy') + " use perltidyrc file if readable + if (has("win32") && (filereadable("perltid.ini") || filereadable($HOMEPATH."/perltidy.ini"))) || + \ ((has("unix") || has("mac")) && (filereadable(".perltidyrc") || filereadable("~/.perltidyrc") || filereadable("/usr/local/etc/perltidyrc") || filereadable("/etc/perltidyrc"))) + let g:formatdef_perltidy = '"perltidy -q -st"' + else + let g:formatdef_perltidy = '"perltidy --perl-best-practices --format-skipping -q "' + endif +endif + +if !exists('g:formatters_perl') + let g:formatters_perl = ['perltidy'] +endif