summaryrefslogtreecommitdiff
path: root/autoload
diff options
context:
space:
mode:
authorAttila Maczak <attila@maczak.hu>2019-01-27 06:45:57 -0500
committerw0rp <w0rp@users.noreply.github.com>2019-01-27 11:45:57 +0000
commitd7ced31fe20b218320046eea46ea2f8558d1ee4b (patch)
tree752d3542f3aad574e95bd1cb4b1a9f8e9c8d4ad5 /autoload
parente46c17e8ef85c3108f93bd3f19d6f1775b2fbf63 (diff)
downloadale-d7ced31fe20b218320046eea46ea2f8558d1ee4b.zip
add cmake-format fixer support (#2244)
Diffstat (limited to 'autoload')
-rw-r--r--autoload/ale/fix/registry.vim5
-rw-r--r--autoload/ale/fixers/cmakeformat.vim18
2 files changed, 23 insertions, 0 deletions
diff --git a/autoload/ale/fix/registry.vim b/autoload/ale/fix/registry.vim
index 98a35b7e..90450b34 100644
--- a/autoload/ale/fix/registry.vim
+++ b/autoload/ale/fix/registry.vim
@@ -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'],
diff --git a/autoload/ale/fixers/cmakeformat.vim b/autoload/ale/fixers/cmakeformat.vim
new file mode 100644
index 00000000..f40ed6ed
--- /dev/null
+++ b/autoload/ale/fixers/cmakeformat.vim
@@ -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