vimchef-infravim-pluginneovimvim-ale

How to configure VIM ALE to use cookstyle linter


I am trying to configure VIM plugin ALE to use chef cookstyle linter for chef cookbooks projects. But ALE is not throwing any errors. On the documentation I found out ALE has options for chef-based cookstyle https://github.com/dense-analysis/ale/blob/master/doc/ale.txt, but it's not working.

I have defined the following configuration in my vimrc file ALE configuration for cookstyle


Solution

  • There are ale_linters for Chef distributed with ALE, so it would be a matter of setting your filetype=chef for these Ruby files matching a certain directory path. This can be done with something like (of course, adjust accordingly to your local directory structure):

    autocmd BufNewFile,BufRead */recipes/*.rb set ft=chef syntax=ruby
    

    Then when running :ALEInfo you will see output like:

     Current Filetype: chef                                                                                                                
    Available Linters: ['cookstyle', 'foodcritic']
      Enabled Linters: ['cookstyle', 'foodcritic']
      Ignored Linters: []
     Suggested Fixers:
      'remove_trailing_lines' - Remove all blank lines at the end of a file.
      'trim_whitespace' - Remove all trailing whitespace characters at the end of every line.
     Linter Variables:
    let g:ale_chef_cookstyle_executable = 'cookstyle'
    let g:ale_chef_cookstyle_options = ''
    let g:ale_chef_foodcritic_executable = 'foodcritic'
    let g:ale_chef_foodcritic_options = ''
     Global Variables:
    ...