parent
d999eb1f35
commit
be21aa5cda
7 changed files with 72 additions and 17 deletions
|
@ -113,7 +113,7 @@ formatting.
|
|||
| CSS | [csslint](http://csslint.net/), [prettier](https://github.com/prettier/prettier), [stylelint](https://github.com/stylelint/stylelint) |
|
||||
| Cucumber | [cucumber](https://cucumber.io/) |
|
||||
| Cython (pyrex filetype) | [cython](http://cython.org/) |
|
||||
| D | [dmd](https://dlang.org/dmd-linux.html), [uncrustify](https://github.com/uncrustify/uncrustify) |
|
||||
| D | [dls](https://github.com/d-language-server/dls), [dmd](https://dlang.org/dmd-linux.html), [uncrustify](https://github.com/uncrustify/uncrustify) |
|
||||
| Dafny | [dafny](https://rise4fun.com/Dafny) !! |
|
||||
| Dart | [dartanalyzer](https://github.com/dart-lang/sdk/tree/master/pkg/analyzer_cli) !!, [language_server](https://github.com/natebosch/dart_language_server), [dartfmt](https://github.com/dart-lang/sdk/tree/master/utils/dartfmt) |
|
||||
| Dockerfile | [hadolint](https://github.com/hadolint/hadolint) |
|
||||
|
|
22
ale_linters/d/dls.vim
Normal file
22
ale_linters/d/dls.vim
Normal file
|
@ -0,0 +1,22 @@
|
|||
" Author: aurieh <me@aurieh.me>
|
||||
" Description: A Language Server implementation for D
|
||||
|
||||
call ale#Set('d_dls_executable', 'dls')
|
||||
|
||||
function! ale_linters#d#dls#GetExecutable(buffer) abort
|
||||
return ale#Var(a:buffer, 'd_dls_executable')
|
||||
endfunction
|
||||
|
||||
function! ale_linters#d#dls#FindProjectRoot(buffer) abort
|
||||
" Note: this will return . if dub config is empty
|
||||
" dls can run outside DUB projects just fine
|
||||
return fnamemodify(ale#d#FindDUBConfig(a:buffer), ':h')
|
||||
endfunction
|
||||
|
||||
call ale#linter#Define('d', {
|
||||
\ 'name': 'dls',
|
||||
\ 'lsp': 'stdio',
|
||||
\ 'executable_callback': 'ale_linters#d#dls#GetExecutable',
|
||||
\ 'command_callback': 'ale_linters#d#dls#GetExecutable',
|
||||
\ 'project_root_callback': 'ale_linters#d#dls#FindProjectRoot',
|
||||
\})
|
|
@ -1,20 +1,6 @@
|
|||
" Author: w0rp <devw0rp@gmail.com>
|
||||
" Description: "dmd for D files"
|
||||
|
||||
function! s:FindDUBConfig(buffer) abort
|
||||
" Find a DUB configuration file in ancestor paths.
|
||||
" The most DUB-specific names will be tried first.
|
||||
for l:possible_filename in ['dub.sdl', 'dub.json', 'package.json']
|
||||
let l:dub_file = ale#path#FindNearestFile(a:buffer, l:possible_filename)
|
||||
|
||||
if !empty(l:dub_file)
|
||||
return l:dub_file
|
||||
endif
|
||||
endfor
|
||||
|
||||
return ''
|
||||
endfunction
|
||||
|
||||
function! ale_linters#d#dmd#DUBCommand(buffer) abort
|
||||
" If we can't run dub, then skip this command.
|
||||
if !executable('dub')
|
||||
|
@ -22,7 +8,7 @@ function! ale_linters#d#dmd#DUBCommand(buffer) abort
|
|||
return ''
|
||||
endif
|
||||
|
||||
let l:dub_file = s:FindDUBConfig(a:buffer)
|
||||
let l:dub_file = ale#d#FindDUBConfig(a:buffer)
|
||||
|
||||
if empty(l:dub_file)
|
||||
return ''
|
||||
|
|
16
autoload/ale/d.vim
Normal file
16
autoload/ale/d.vim
Normal file
|
@ -0,0 +1,16 @@
|
|||
" Author: Auri <me@aurieh.me>
|
||||
" Description: Functions for integrating with D linters.
|
||||
|
||||
function! ale#d#FindDUBConfig(buffer) abort
|
||||
" Find a DUB configuration file in ancestor paths.
|
||||
" The most DUB-specific names will be tried first.
|
||||
for l:possible_filename in ['dub.sdl', 'dub.json', 'package.json']
|
||||
let l:dub_file = ale#path#FindNearestFile(a:buffer, l:possible_filename)
|
||||
|
||||
if !empty(l:dub_file)
|
||||
return l:dub_file
|
||||
endif
|
||||
endfor
|
||||
|
||||
return ''
|
||||
endfunction
|
|
@ -2,6 +2,17 @@
|
|||
ALE D Integration *ale-d-options*
|
||||
|
||||
|
||||
===============================================================================
|
||||
dls *ale-d-dls*
|
||||
|
||||
g:ale_d_dls_executable *g:ale_d_dls_executable*
|
||||
*b:ale_d_dls_executable*
|
||||
Type: |String|
|
||||
Default: `dls`
|
||||
|
||||
See |ale-integrations-local-executables|
|
||||
|
||||
|
||||
===============================================================================
|
||||
uncrustify *ale-d-uncrustify*
|
||||
|
||||
|
|
|
@ -67,6 +67,7 @@ CONTENTS *ale-contents*
|
|||
cuda..................................|ale-cuda-options|
|
||||
nvcc................................|ale-cuda-nvcc|
|
||||
d.....................................|ale-d-options|
|
||||
dls.................................|ale-d-dls|
|
||||
uncrustify..........................|ale-d-uncrustify|
|
||||
dart..................................|ale-dart-options|
|
||||
dartanalyzer........................|ale-dart-dartanalyzer|
|
||||
|
@ -394,7 +395,7 @@ Notes:
|
|||
* CSS: `csslint`, `prettier`, `stylelint`
|
||||
* Cucumber: `cucumber`
|
||||
* Cython (pyrex filetype): `cython`
|
||||
* D: `dmd`, `uncrustify`
|
||||
* D: `dls`, `dmd`, `uncrustify`
|
||||
* Dafny: `dafny`!!
|
||||
* Dart: `dartanalyzer`!!, `language_server`, dartfmt!!
|
||||
* Dockerfile: `hadolint`
|
||||
|
|
19
test/command_callback/test_d_dls_callbacks.vader
Normal file
19
test/command_callback/test_d_dls_callbacks.vader
Normal file
|
@ -0,0 +1,19 @@
|
|||
Before:
|
||||
call ale#assert#SetUpLinterTest('d', 'dls')
|
||||
|
||||
Save &filetype
|
||||
let &filetype = 'd'
|
||||
|
||||
After:
|
||||
call ale#assert#TearDownLinterTest()
|
||||
|
||||
Execute(The language string should be correct):
|
||||
AssertLSPLanguage 'd'
|
||||
|
||||
Execute(The default executable should be correct):
|
||||
AssertLinter 'dls', 'dls'
|
||||
|
||||
Execute(The executable should be configurable):
|
||||
let g:ale_d_dls_executable = 'foobar'
|
||||
|
||||
AssertLinter 'foobar', 'foobar'
|
Reference in a new issue