summaryrefslogtreecommitdiff
path: root/ale_linters/cmake
diff options
context:
space:
mode:
Diffstat (limited to 'ale_linters/cmake')
-rw-r--r--ale_linters/cmake/cmake_lint.vim43
1 files changed, 43 insertions, 0 deletions
diff --git a/ale_linters/cmake/cmake_lint.vim b/ale_linters/cmake/cmake_lint.vim
new file mode 100644
index 00000000..3c44c92f
--- /dev/null
+++ b/ale_linters/cmake/cmake_lint.vim
@@ -0,0 +1,43 @@
+" Author: Carl Smedstad <carl.smedstad at protonmail dot com>
+" Description: cmake-lint for cmake files
+
+let g:ale_cmake_cmake_lint_executable =
+\ get(g:, 'ale_cmake_cmake_lint_executable', 'cmake-lint')
+
+let g:ale_cmake_cmake_lint_options =
+\ get(g:, 'ale_cmake_cmake_lint_options', '')
+
+function! ale_linters#cmake#cmake_lint#Executable(buffer) abort
+ return ale#Var(a:buffer, 'cmake_cmake_lint_executable')
+endfunction
+
+function! ale_linters#cmake#cmake_lint#Command(buffer) abort
+ let l:executable = ale_linters#cmake#cmake_lint#Executable(a:buffer)
+ let l:options = ale#Var(a:buffer, 'cmake_cmake_lint_options')
+
+ return ale#Escape(l:executable) . ' ' . l:options . ' %t'
+endfunction
+
+function! ale_linters#cmake#cmake_lint#Handle(buffer, lines) abort
+ let l:pattern = '\v^[^:]+:(\d+),?(\d+)?:\s\[([A-Z]\d+)\]\s(.+)$'
+ let l:output = []
+
+ for l:match in ale#util#GetMatches(a:lines, l:pattern)
+ call add(l:output, {
+ \ 'lnum': l:match[1] + 0,
+ \ 'col': l:match[2] + 0,
+ \ 'type': 'W',
+ \ 'code': l:match[3],
+ \ 'text': l:match[4],
+ \})
+ endfor
+
+ return l:output
+endfunction
+
+call ale#linter#Define('cmake', {
+\ 'name': 'cmake_lint',
+\ 'executable': function('ale_linters#cmake#cmake_lint#Executable'),
+\ 'command': function('ale_linters#cmake#cmake_lint#Command'),
+\ 'callback': 'ale_linters#cmake#cmake_lint#Handle',
+\})