From 217284360d35711b751859ed27a7a3c3da300e85 Mon Sep 17 00:00:00 2001 From: w0rp Date: Thu, 2 Aug 2018 23:44:12 +0100 Subject: Simplify the code for most linters and tests with closures --- ale_linters/scala/fsc.vim | 23 ++++------------------- ale_linters/scala/scalac.vim | 23 ++++------------------- 2 files changed, 8 insertions(+), 38 deletions(-) (limited to 'ale_linters/scala') diff --git a/ale_linters/scala/fsc.vim b/ale_linters/scala/fsc.vim index 17b26f0b..fbdce20e 100644 --- a/ale_linters/scala/fsc.vim +++ b/ale_linters/scala/fsc.vim @@ -1,29 +1,14 @@ " Author: Nils Leuzinger - https://github.com/PawkyPenguin " Description: Basic scala support using fsc -" -function! ale_linters#scala#fsc#GetExecutable(buffer) abort - if index(split(getbufvar(a:buffer, '&filetype'), '\.'), 'sbt') >= 0 - " Don't check sbt files - return '' - endif - return 'fsc' -endfunction - -function! ale_linters#scala#fsc#GetCommand(buffer) abort - let l:executable = ale_linters#scala#fsc#GetExecutable(a:buffer) - - if empty(l:executable) - return '' - endif - - return ale#Escape(l:executable) . ' -Ystop-after:parser %t' +function! s:IsSbt(buffer) abort + return index(split(getbufvar(a:buffer, '&filetype'), '\.'), 'sbt') >= 0 endfunction call ale#linter#Define('scala', { \ 'name': 'fsc', -\ 'executable_callback': 'ale_linters#scala#fsc#GetExecutable', -\ 'command_callback': 'ale_linters#scala#fsc#GetCommand', +\ 'executable_callback': {buf -> s:IsSbt(buf) ? '' : 'fsc'}, +\ 'command': '%e -Ystop-after:parser %t', \ 'callback': 'ale#handlers#scala#HandleScalacLintFormat', \ 'output_stream': 'stderr', \}) diff --git a/ale_linters/scala/scalac.vim b/ale_linters/scala/scalac.vim index 551284af..3dbdd925 100644 --- a/ale_linters/scala/scalac.vim +++ b/ale_linters/scala/scalac.vim @@ -2,29 +2,14 @@ " w0rp " Description: Basic scala support using scalac -function! ale_linters#scala#scalac#GetExecutable(buffer) abort - if index(split(getbufvar(a:buffer, '&filetype'), '\.'), 'sbt') >= 0 - " Don't check sbt files - return '' - endif - - return 'scalac' -endfunction - -function! ale_linters#scala#scalac#GetCommand(buffer) abort - let l:executable = ale_linters#scala#scalac#GetExecutable(a:buffer) - - if empty(l:executable) - return '' - endif - - return ale#Escape(l:executable) . ' -Ystop-after:parser %t' +function! s:IsSbt(buffer) abort + return index(split(getbufvar(a:buffer, '&filetype'), '\.'), 'sbt') >= 0 endfunction call ale#linter#Define('scala', { \ 'name': 'scalac', -\ 'executable_callback': 'ale_linters#scala#scalac#GetExecutable', -\ 'command_callback': 'ale_linters#scala#scalac#GetCommand', +\ 'executable_callback': {buf -> s:IsSbt(buf) ? '' : 'scalac'}, +\ 'command': '%e -Ystop-after:parser %t', \ 'callback': 'ale#handlers#scala#HandleScalacLintFormat', \ 'output_stream': 'stderr', \}) -- cgit v1.2.3 From 8e3bf10592b52ba96ce94c5819a19ee8de6f0899 Mon Sep 17 00:00:00 2001 From: Ty Coghlan Date: Mon, 27 Aug 2018 01:12:56 -0400 Subject: added sbtserver linter --- ale_linters/scala/sbtserver.vim | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 ale_linters/scala/sbtserver.vim (limited to 'ale_linters/scala') diff --git a/ale_linters/scala/sbtserver.vim b/ale_linters/scala/sbtserver.vim new file mode 100644 index 00000000..3092dc13 --- /dev/null +++ b/ale_linters/scala/sbtserver.vim @@ -0,0 +1,37 @@ +" Author: ophirr33 +" Description: TCP lsp client for sbt Server + +call ale#Set('scala_sbtserver_address', '') +call ale#Set('scala_sbtserver_project_root', '') + +function! ale_linters#scala#sbtserver#GetProjectRoot(buffer) abort + let l:project_root = ale#Var(a:buffer, 'scala_sbtserver_project_root') + if l:project_root is? '' + let l:project_root = ale#path#FindNearestFile(a:buffer, 'build.sbt') + return !empty(l:project_root) ? fnamemodify(l:project_root, ':h') : '' + endif + return l:project_root +endfunction + +function! ale_linters#scala#sbtserver#GetAddress(buffer) abort + let l:address = ale#Var(a:buffer, 'scala_sbtserver_address') + if l:address is? '' + let l:project_root = ale_linters#scala#sbtserver#GetProjectRoot(a:buffer) + let l:active_file = l:project_root . '/project/target/active.json' + if !empty(glob(l:active_file)) + let l:active = json_decode(join(readfile(l:project_root . '/project/target/active.json'))) + if has_key(l:active, 'uri') + return substitute(l:active.uri, 'tcp://', '', '') + endif + endif + endif + return l:address +endfunction + +call ale#linter#Define('scala', { +\ 'name': 'sbtserver', +\ 'lsp': 'socket', +\ 'address_callback': 'ale_linters#scala#sbtserver#GetAddress', +\ 'language': 'scala', +\ 'project_root_callback': 'ale_linters#scala#sbtserver#GetProjectRoot', +\}) -- cgit v1.2.3 From 3d016f1697dd25443852d18a29a20c42c753dee1 Mon Sep 17 00:00:00 2001 From: Ty Coghlan Date: Sat, 1 Sep 2018 20:59:36 -0400 Subject: Changed sbtserver to just work off of the address variable --- ale_linters/scala/sbtserver.vim | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) (limited to 'ale_linters/scala') diff --git a/ale_linters/scala/sbtserver.vim b/ale_linters/scala/sbtserver.vim index 3092dc13..d75c38ca 100644 --- a/ale_linters/scala/sbtserver.vim +++ b/ale_linters/scala/sbtserver.vim @@ -1,7 +1,7 @@ " Author: ophirr33 " Description: TCP lsp client for sbt Server -call ale#Set('scala_sbtserver_address', '') +call ale#Set('scala_sbtserver_address', '127.0.0.1:4273') call ale#Set('scala_sbtserver_project_root', '') function! ale_linters#scala#sbtserver#GetProjectRoot(buffer) abort @@ -15,16 +15,6 @@ endfunction function! ale_linters#scala#sbtserver#GetAddress(buffer) abort let l:address = ale#Var(a:buffer, 'scala_sbtserver_address') - if l:address is? '' - let l:project_root = ale_linters#scala#sbtserver#GetProjectRoot(a:buffer) - let l:active_file = l:project_root . '/project/target/active.json' - if !empty(glob(l:active_file)) - let l:active = json_decode(join(readfile(l:project_root . '/project/target/active.json'))) - if has_key(l:active, 'uri') - return substitute(l:active.uri, 'tcp://', '', '') - endif - endif - endif return l:address endfunction -- cgit v1.2.3 From d476578a402763f2c6e4e0ada2eb345d0ac938d7 Mon Sep 17 00:00:00 2001 From: w0rp Date: Tue, 4 Sep 2018 16:51:18 +0100 Subject: Improve ALE project style checking * The project style linter now runs while you type. * Now the scripts for checking the project require blank lines. * Many style issues have been found and fixed. --- ale_linters/scala/sbtserver.vim | 4 ++++ ale_linters/scala/scalastyle.vim | 2 ++ 2 files changed, 6 insertions(+) (limited to 'ale_linters/scala') diff --git a/ale_linters/scala/sbtserver.vim b/ale_linters/scala/sbtserver.vim index d75c38ca..694241d7 100644 --- a/ale_linters/scala/sbtserver.vim +++ b/ale_linters/scala/sbtserver.vim @@ -6,15 +6,19 @@ call ale#Set('scala_sbtserver_project_root', '') function! ale_linters#scala#sbtserver#GetProjectRoot(buffer) abort let l:project_root = ale#Var(a:buffer, 'scala_sbtserver_project_root') + if l:project_root is? '' let l:project_root = ale#path#FindNearestFile(a:buffer, 'build.sbt') + return !empty(l:project_root) ? fnamemodify(l:project_root, ':h') : '' endif + return l:project_root endfunction function! ale_linters#scala#sbtserver#GetAddress(buffer) abort let l:address = ale#Var(a:buffer, 'scala_sbtserver_address') + return l:address endfunction diff --git a/ale_linters/scala/scalastyle.vim b/ale_linters/scala/scalastyle.vim index 3232d70b..42228cf6 100644 --- a/ale_linters/scala/scalastyle.vim +++ b/ale_linters/scala/scalastyle.vim @@ -53,12 +53,14 @@ function! ale_linters#scala#scalastyle#GetCommand(buffer) abort \ 'scalastyle_config.xml', \ 'scalastyle-config.xml' \] + for l:config in l:potential_configs let l:scalastyle_config = ale#path#ResolveLocalPath( \ a:buffer, \ l:config, \ '' \) + if !empty(l:scalastyle_config) break endif -- cgit v1.2.3 From c25582076cba2b83da1608faac1e093443d866ff Mon Sep 17 00:00:00 2001 From: Zack Hsi Date: Fri, 16 Nov 2018 15:31:13 -0800 Subject: Continue scalac compilation until just before bytecode generation Previous behavior does not compile deep enough to surface errors. See compiler phases: https://docs.scala-lang.org/overviews/compiler-options/index.html#compilation-phases --- ale_linters/scala/scalac.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'ale_linters/scala') diff --git a/ale_linters/scala/scalac.vim b/ale_linters/scala/scalac.vim index 3dbdd925..ba105927 100644 --- a/ale_linters/scala/scalac.vim +++ b/ale_linters/scala/scalac.vim @@ -9,7 +9,7 @@ endfunction call ale#linter#Define('scala', { \ 'name': 'scalac', \ 'executable_callback': {buf -> s:IsSbt(buf) ? '' : 'scalac'}, -\ 'command': '%e -Ystop-after:parser %t', +\ 'command': '%e -Ystop-before:jvm %t', \ 'callback': 'ale#handlers#scala#HandleScalacLintFormat', \ 'output_stream': 'stderr', \}) -- cgit v1.2.3