]> git.madduck.net Git - etc/vim.git/blob - .vim/bundle/ale/ale_linters/cmake/cmake_lint.vim

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

Merge commit 'a39f715c13be3352193ffd9c5b7536b8786eff64' as '.vim/bundle/vim-lsp'
[etc/vim.git] / .vim / bundle / ale / ale_linters / cmake / cmake_lint.vim
1 " Author: Carl Smedstad <carl.smedstad at protonmail dot com>
2 " Description: cmake-lint for cmake files
3
4 let g:ale_cmake_cmake_lint_executable =
5 \   get(g:, 'ale_cmake_cmake_lint_executable', 'cmake-lint')
6
7 let g:ale_cmake_cmake_lint_options =
8 \   get(g:, 'ale_cmake_cmake_lint_options', '')
9
10 function! ale_linters#cmake#cmake_lint#Executable(buffer) abort
11     return ale#Var(a:buffer, 'cmake_cmake_lint_executable')
12 endfunction
13
14 function! ale_linters#cmake#cmake_lint#Command(buffer) abort
15     let l:executable = ale_linters#cmake#cmake_lint#Executable(a:buffer)
16     let l:options = ale#Var(a:buffer, 'cmake_cmake_lint_options')
17
18     return ale#Escape(l:executable) . ' ' . l:options . ' %s'
19 endfunction
20
21 function! ale_linters#cmake#cmake_lint#Handle(buffer, lines) abort
22     let l:pattern = '\v^[^:]+:(\d+),?(\d+)?:\s\[([A-Z]\d+)\]\s(.+)$'
23     let l:output = []
24
25     for l:match in ale#util#GetMatches(a:lines, l:pattern)
26         call add(l:output, {
27         \   'lnum': l:match[1] + 0,
28         \   'col': l:match[2] + 0,
29         \   'type': 'W',
30         \   'code': l:match[3],
31         \   'text': l:match[4],
32         \})
33     endfor
34
35     return l:output
36 endfunction
37
38 call ale#linter#Define('cmake', {
39 \   'name': 'cmake_lint',
40 \   'executable': function('ale_linters#cmake#cmake_lint#Executable'),
41 \   'command': function('ale_linters#cmake#cmake_lint#Command'),
42 \   'callback': 'ale_linters#cmake#cmake_lint#Handle',
43 \})