add cmake-format fixer support (#2244)

This commit is contained in:
Attila Maczak
2019-01-27 06:45:57 -05:00
committed by w0rp
parent e46c17e8ef
commit d7ced31fe2
6 changed files with 84 additions and 2 deletions

View File

@@ -145,6 +145,11 @@ let s:default_registry = {
\ 'suggested_filetypes': ['c', 'cpp'],
\ 'description': 'Fix C/C++ files with clang-format.',
\ },
\ 'cmakeformat': {
\ 'function': 'ale#fixers#cmakeformat#Fix',
\ 'suggested_filetypes': ['cmake'],
\ 'description': 'Fix CMake files with cmake-format.',
\ },
\ 'gofmt': {
\ 'function': 'ale#fixers#gofmt#Fix',
\ 'suggested_filetypes': ['go'],

View File

@@ -0,0 +1,18 @@
" Author: Attila Maczak <attila@maczak.hu>
" Description: Integration of cmakeformat with ALE.
call ale#Set('cmake_cmakeformat_executable', 'cmake-format')
call ale#Set('cmake_cmakeformat_options', '')
function! ale#fixers#cmakeformat#Fix(buffer) abort
let l:executable = ale#Var(a:buffer, 'cmake_cmakeformat_executable')
let l:options = ale#Var(a:buffer, 'cmake_cmakeformat_options')
return {
\ 'command': ale#Escape(l:executable)
\ . ' -i '
\ . (empty(l:options) ? '' : ' ' . l:options)
\ . ' %t',
\ 'read_temporary_file': 1,
\}
endfunction