From 192f211a0ee63c716d0d5887755d1e139a82ace8 Mon Sep 17 00:00:00 2001 From: Tim Byrne Date: Mon, 27 Aug 2018 12:59:38 -0500 Subject: [PATCH 1/3] Support options for puppet parser validate It can be necessary to pass options to the puppet parser validation. The most glaring example of this is when using Puppet 3, with the `parser = future` option enabled. This update allows adding `--parser=future` to the options passed to Puppet. --- ale_linters/puppet/puppet.vim | 13 +++++++++++-- doc/ale-puppet.txt | 20 ++++++++++++++++++++ 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/ale_linters/puppet/puppet.vim b/ale_linters/puppet/puppet.vim index 4ca0dd55..1ed268d1 100644 --- a/ale_linters/puppet/puppet.vim +++ b/ale_linters/puppet/puppet.vim @@ -1,5 +1,8 @@ " Author: Alexander Olofsson +call ale#Set('puppet_puppet_executable', 'puppet') +call ale#Set('puppet_puppet_options', '--color=false') + function! ale_linters#puppet#puppet#Handle(buffer, lines) abort " Matches patterns like the following: " Error: Could not parse for environment production: Syntax error at ':' at /root/puppetcode/modules/nginx/manifests/init.pp:43:12 @@ -20,10 +23,16 @@ function! ale_linters#puppet#puppet#Handle(buffer, lines) abort return l:output endfunction +function! ale_linters#puppet#puppet#GetCommand(buffer) abort + return '%e parser validate ' + \ . ale#Pad(ale#Var(a:buffer, 'puppet_puppet_options')) + \ . ' %t' +endfunction + call ale#linter#Define('puppet', { \ 'name': 'puppet', -\ 'executable': 'puppet', +\ 'executable_callback': ale#VarFunc('puppet_puppet_executable'), \ 'output_stream': 'stderr', -\ 'command': 'puppet parser validate --color=false %t', +\ 'command_callback': 'ale_linters#puppet#puppet#GetCommand', \ 'callback': 'ale_linters#puppet#puppet#Handle', \}) diff --git a/doc/ale-puppet.txt b/doc/ale-puppet.txt index 7c67484e..b37a19a1 100644 --- a/doc/ale-puppet.txt +++ b/doc/ale-puppet.txt @@ -2,6 +2,26 @@ ALE Puppet Integration *ale-puppet-options* +=============================================================================== +puppet *ale-puppet-puppet* + +g:ale_puppet_puppet_executable *g:ale_puppet_puppet_executable* + *b:ale_puppet_puppet_executable* + Type: |String| + Default: `'puppet'` + + This variable can be changed to specify the executable used for puppet. + + +g:ale_puppet_puppet_options *g:ale_puppet_puppet_options* + *b:ale_puppet_puppet_options* + Type: |String| + Default: `'--color=false'` + + This variable can be changed to add command-line arguments to the + puppet parser validate invocation. + + =============================================================================== puppetlint *ale-puppet-puppetlint* From 6212d9a515a54866995c82eb88ed8b9469232e44 Mon Sep 17 00:00:00 2001 From: Tim Byrne Date: Mon, 27 Aug 2018 13:12:56 -0500 Subject: [PATCH 2/3] Update TOC for ale-puppet-puppet --- doc/ale.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/ale.txt b/doc/ale.txt index 8e38f92a..7059f76d 100644 --- a/doc/ale.txt +++ b/doc/ale.txt @@ -202,6 +202,7 @@ CONTENTS *ale-contents* pug...................................|ale-pug-options| puglint.............................|ale-pug-puglint| puppet................................|ale-puppet-options| + puppet..............................|ale-puppet-puppet| puppetlint..........................|ale-puppet-puppetlint| puppet-languageserver...............|ale-puppet-languageserver| pyrex (cython)........................|ale-pyrex-options| From ed26ddc09cfa6374c460822ae30ab8a34619210a Mon Sep 17 00:00:00 2001 From: Tim Byrne Date: Wed, 29 Aug 2018 07:11:51 -0500 Subject: [PATCH 3/3] Always use --color=false when validating puppet Colorized output is difficult for ALE to parse. --- ale_linters/puppet/puppet.vim | 4 ++-- doc/ale-puppet.txt | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ale_linters/puppet/puppet.vim b/ale_linters/puppet/puppet.vim index 1ed268d1..d44bb517 100644 --- a/ale_linters/puppet/puppet.vim +++ b/ale_linters/puppet/puppet.vim @@ -1,7 +1,7 @@ " Author: Alexander Olofsson call ale#Set('puppet_puppet_executable', 'puppet') -call ale#Set('puppet_puppet_options', '--color=false') +call ale#Set('puppet_puppet_options', '') function! ale_linters#puppet#puppet#Handle(buffer, lines) abort " Matches patterns like the following: @@ -24,7 +24,7 @@ function! ale_linters#puppet#puppet#Handle(buffer, lines) abort endfunction function! ale_linters#puppet#puppet#GetCommand(buffer) abort - return '%e parser validate ' + return '%e parser validate --color=false ' \ . ale#Pad(ale#Var(a:buffer, 'puppet_puppet_options')) \ . ' %t' endfunction diff --git a/doc/ale-puppet.txt b/doc/ale-puppet.txt index b37a19a1..daa8c10f 100644 --- a/doc/ale-puppet.txt +++ b/doc/ale-puppet.txt @@ -16,7 +16,7 @@ g:ale_puppet_puppet_executable *g:ale_puppet_puppet_executable* g:ale_puppet_puppet_options *g:ale_puppet_puppet_options* *b:ale_puppet_puppet_options* Type: |String| - Default: `'--color=false'` + Default: `''` This variable can be changed to add command-line arguments to the puppet parser validate invocation.