summaryrefslogtreecommitdiff
path: root/ale_linters
diff options
context:
space:
mode:
authorBlahGeek <i@blahgeek.com>2017-09-08 02:23:58 +0800
committerw0rp <w0rp@users.noreply.github.com>2017-09-07 19:23:58 +0100
commit73d031d7eacba95c68287eddb52fb0b73947ba05 (patch)
tree6d12b5354686b3170637b93abb252f58eedf4697 /ale_linters
parent555d23c035cf032c5ed89d7d2b0d5b3c478b08c8 (diff)
downloadale-73d031d7eacba95c68287eddb52fb0b73947ba05.zip
Add cuda nvcc linter (#874)
* add cuda nvcc linter
Diffstat (limited to 'ale_linters')
-rw-r--r--ale_linters/cuda/nvcc.vim56
1 files changed, 56 insertions, 0 deletions
diff --git a/ale_linters/cuda/nvcc.vim b/ale_linters/cuda/nvcc.vim
new file mode 100644
index 00000000..7aaa5cc3
--- /dev/null
+++ b/ale_linters/cuda/nvcc.vim
@@ -0,0 +1,56 @@
+" Author: blahgeek <i@blahgeek.com>
+" Description: NVCC linter for cuda files
+
+call ale#Set('cuda_nvcc_executable', 'nvcc')
+call ale#Set('cuda_nvcc_options', '-std=c++11')
+
+function! ale_linters#cuda#nvcc#GetExecutable(buffer) abort
+ return ale#Var(a:buffer, 'cuda_nvcc_executable')
+endfunction
+
+function! ale_linters#cuda#nvcc#GetCommand(buffer) abort
+ " Unused: use ale#util#nul_file
+ " let l:output_file = tempname() . '.ii'
+ " call ale#engine#ManageFile(a:buffer, l:output_file)
+
+ return ale#Escape(ale_linters#cuda#nvcc#GetExecutable(a:buffer))
+ \ . ' -cuda '
+ \ . ale#c#IncludeOptions(ale#c#FindLocalHeaderPaths(a:buffer))
+ \ . ale#Var(a:buffer, 'cuda_nvcc_options') . ' %s'
+ \ . ' -o ' . g:ale#util#nul_file
+endfunction
+
+function! ale_linters#cuda#nvcc#HandleNVCCFormat(buffer, lines) abort
+ " Look for lines like the following.
+ "
+ " test.cu(8): error: argument of type "void *" is incompatible with parameter of type "int *"
+ let l:pattern = '\v^([^:\(\)]+):?\(?(\d+)\)?:(\d+)?:?\s*\w*\s*(error|warning): (.+)$'
+ let l:output = []
+
+ for l:match in ale#util#GetMatches(a:lines, l:pattern)
+
+ let l:item = {
+ \ 'lnum': str2nr(l:match[2]),
+ \ 'type': l:match[4] =~# 'error' ? 'E' : 'W',
+ \ 'text': l:match[5],
+ \ 'filename': fnamemodify(l:match[1], ':p'),
+ \}
+
+ if !empty(l:match[3])
+ let l:item.col = str2nr(l:match[3])
+ endif
+
+ call add(l:output, l:item)
+ endfor
+
+ return l:output
+endfunction
+
+call ale#linter#Define('cuda', {
+\ 'name': 'nvcc',
+\ 'output_stream': 'stderr',
+\ 'executable_callback': 'ale_linters#cuda#nvcc#GetExecutable',
+\ 'command_callback': 'ale_linters#cuda#nvcc#GetCommand',
+\ 'callback': 'ale_linters#cuda#nvcc#HandleNVCCFormat',
+\ 'lint_file': 1,
+\})