summaryrefslogtreecommitdiff
path: root/autoload
diff options
context:
space:
mode:
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