summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSven-Hendrik Haase <svenstaro@gmail.com>2017-12-01 18:36:44 +0100
committerw0rp <w0rp@users.noreply.github.com>2017-12-01 17:36:44 +0000
commit51b127a4fd8e581ab0592874db584facb70e9f79 (patch)
treece44fd01ca3448d911a52c31164b20f93bf28158
parent6053f764bd6f7707af0be0f0520a691571de5705 (diff)
downloadale-51b127a4fd8e581ab0592874db584facb70e9f79.zip
Add glslls (#1179)
* Add glslls-based LSP linter * Make logfile configureable
-rw-r--r--README.md2
-rw-r--r--ale_linters/glsl/glslls.vim38
-rw-r--r--doc/ale-glsl.txt20
-rw-r--r--doc/ale.txt3
-rw-r--r--test/command_callback/test_glslls_command_callback.vader37
5 files changed, 98 insertions, 2 deletions
diff --git a/README.md b/README.md
index 0cc5206a..89bcc255 100644
--- a/README.md
+++ b/README.md
@@ -100,7 +100,7 @@ formatting.
| Erlang | [erlc](http://erlang.org/doc/man/erlc.html), [SyntaxErl](https://github.com/ten0s/syntaxerl) |
| Fortran | [gcc](https://gcc.gnu.org/) |
| FusionScript | [fusion-lint](https://github.com/RyanSquared/fusionscript) |
-| GLSL | [glslang](https://github.com/KhronosGroup/glslang) |
+| GLSL | [glslang](https://github.com/KhronosGroup/glslang), [glslls](https://github.com/svenstaro/glsl-language-server) |
| Go | [gofmt](https://golang.org/cmd/gofmt/), [goimports](https://godoc.org/golang.org/x/tools/cmd/goimports), [go vet](https://golang.org/cmd/vet/), [golint](https://godoc.org/github.com/golang/lint), [gometalinter](https://github.com/alecthomas/gometalinter) !!, [go build](https://golang.org/cmd/go/) !!, [gosimple](https://github.com/dominikh/go-tools/tree/master/cmd/gosimple) !!, [staticcheck](https://github.com/dominikh/go-tools/tree/master/cmd/staticcheck) !! |
| GraphQL | [eslint](http://eslint.org/), [gqlint](https://github.com/happylinks/gqlint) |
| Haml | [haml-lint](https://github.com/brigade/haml-lint) |
diff --git a/ale_linters/glsl/glslls.vim b/ale_linters/glsl/glslls.vim
new file mode 100644
index 00000000..67ea379c
--- /dev/null
+++ b/ale_linters/glsl/glslls.vim
@@ -0,0 +1,38 @@
+" Author: Sven-Hendrik Haase <svenstaro@gmail.com>
+" Description: A language server for glsl
+
+call ale#Set('glsl_glslls_executable', 'glslls')
+call ale#Set('glsl_glslls_logfile', '')
+
+function! ale_linters#glsl#glslls#GetExecutable(buffer) abort
+ return ale#Var(a:buffer, 'glsl_glslls_executable')
+endfunction
+
+function! ale_linters#glsl#glslls#GetCommand(buffer) abort
+ let l:executable = ale_linters#glsl#glslls#GetExecutable(a:buffer)
+ let l:logfile = ale#Var(a:buffer, 'glsl_glslls_logfile')
+ let l:logfile_args = ''
+ if l:logfile isnot# ''
+ let l:logfile_args = ' --verbose -l ' . l:logfile
+ endif
+ return ale#Escape(l:executable) . l:logfile_args . ' --stdin'
+endfunction
+
+function! ale_linters#glsl#glslls#GetLanguage(buffer) abort
+ return 'glsl'
+endfunction
+
+function! ale_linters#glsl#glslls#GetProjectRoot(buffer) abort
+ let l:project_root = ale#c#FindProjectRoot(a:buffer)
+
+ return !empty(l:project_root) ? fnamemodify(l:project_root, ':h:h') : ''
+endfunction
+
+call ale#linter#Define('glsl', {
+\ 'name': 'glslls',
+\ 'lsp': 'stdio',
+\ 'executable_callback': 'ale_linters#glsl#glslls#GetExecutable',
+\ 'command_callback': 'ale_linters#glsl#glslls#GetCommand',
+\ 'language_callback': 'ale_linters#glsl#glslls#GetLanguage',
+\ 'project_root_callback': 'ale_linters#glsl#glslls#GetProjectRoot',
+\})
diff --git a/doc/ale-glsl.txt b/doc/ale-glsl.txt
index fbadf03c..257de751 100644
--- a/doc/ale-glsl.txt
+++ b/doc/ale-glsl.txt
@@ -33,4 +33,24 @@ g:ale_glsl_glslang_options *g:ale_glsl_glslang_options*
===============================================================================
+glslls *ale-glsl-glslls*
+
+g:ale_glsl_glslls_executable *g:ale_glsl_glslls_executable*
+ *b:ale_glsl_glslls_executable*
+ Type: |String|
+ Default: `'glslls'`
+
+ This variable can be changed to change the path to glslls.
+ See |ale-integrations-local-executables|
+
+g:ale_glsl_glslls_logfile *g:ale_glsl_glslls_logfile*
+ *b:ale_glsl_glslls_logfile*
+ Type: |String|
+ Default: `''`
+
+ Setting this variable to a writeable file path will enable logging to that
+ file.
+
+
+===============================================================================
vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl:
diff --git a/doc/ale.txt b/doc/ale.txt
index d39a5c65..1106946b 100644
--- a/doc/ale.txt
+++ b/doc/ale.txt
@@ -70,6 +70,7 @@ CONTENTS *ale-contents*
fusion-lint.........................|ale-fuse-fusionlint|
glsl..................................|ale-glsl-options|
glslang.............................|ale-glsl-glslang|
+ glslls..............................|ale-glsl-glslls|
go....................................|ale-go-options|
gofmt...............................|ale-go-gofmt|
gometalinter........................|ale-go-gometalinter|
@@ -295,7 +296,7 @@ Notes:
* Erlang: `erlc`, `SyntaxErl`
* Fortran: `gcc`
* FusionScript: `fusion-lint`
-* GLSL: glslang
+* GLSL: glslang, `glslls`
* Go: `gofmt`, `goimports`, `go vet`, `golint`, `gometalinter`!!, `go build`!!, `gosimple`!!, `staticcheck`!!
* GraphQL: `eslint`, `gqlint`
* Haml: `haml-lint`
diff --git a/test/command_callback/test_glslls_command_callback.vader b/test/command_callback/test_glslls_command_callback.vader
new file mode 100644
index 00000000..e64c2352
--- /dev/null
+++ b/test/command_callback/test_glslls_command_callback.vader
@@ -0,0 +1,37 @@
+Before:
+ Save g:ale_glsl_glslls_executable
+ Save g:ale_glsl_glslls_logfile
+
+ unlet! g:ale_glsl_glslls_executable
+ unlet! g:ale_glsl_glslls_logfile
+
+ runtime ale_linters/glsl/glslls.vim
+ call ale#test#SetDirectory('/testplugin/test/command_callback')
+
+After:
+ Restore
+ call ale#linter#Reset()
+
+Execute(Executable should default to 'glslls'):
+ AssertEqual
+ \ 'glslls',
+ \ ale_linters#glsl#glslls#GetExecutable(bufnr(''))
+
+Execute(Executable should be configurable):
+ let g:ale_glsl_glslls_executable = 'foobar'
+ AssertEqual
+ \ 'foobar',
+ \ ale_linters#glsl#glslls#GetExecutable(bufnr(''))
+
+Execute(Command should use executable):
+ let command1 = ale_linters#glsl#glslls#GetCommand(bufnr(''))
+ AssertEqual command1, ale#Escape('glslls') . ' --stdin'
+
+ let g:ale_glsl_glslls_executable = 'foobar'
+ let command2 = ale_linters#glsl#glslls#GetCommand(bufnr(''))
+ AssertEqual command2, ale#Escape('foobar') . ' --stdin'
+
+Execute(Setting logfile should work):
+ let g:ale_glsl_glslls_logfile = '/tmp/test.log'
+ let command = ale_linters#glsl#glslls#GetCommand(bufnr(''))
+ AssertEqual command, ale#Escape('glslls') . ' --verbose -l /tmp/test.log --stdin'