File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -276,4 +276,12 @@ M.get_cpu_thread_count = function()
276276 end
277277end
278278
279+ M .java_bin = function ()
280+ local java_home = vim .env [" JAVA_HOME" ]
281+ if java_home then
282+ return java_home .. " /bin/java"
283+ end
284+ return " java"
285+ end
286+
279287return M
Original file line number Diff line number Diff line change 11local M = {}
2- M .setup = function (opt )
3- if not (" Y" == vim .env [" SONARLINT_ENABLE" ]) then
4- return
5- end
6- local vscode = require (" kide.core.vscode" )
7- local sonarlint_ls = vscode .find_one (" /sonarsource.sonarlint-vscode*/server/sonarlint-ls.jar" )
8- local analyzer_java = vscode .find_one (" /sonarsource.sonarlint-vscode*/analyzers/sonarjava.jar" )
9- if not sonarlint_ls then
10- vim .notify (" sonarlint-ls.jar not found" , vim .log .levels .WARN )
11- return
12- end
13- if not analyzer_java then
14- vim .notify (" sonarjava.jar not found" , vim .log .levels .WARN )
15- return
16- end
172
18- local cmd = {
19- " java" ,
20- " -jar" ,
21- sonarlint_ls ,
22- " -stdio" ,
23- " -analyzers" ,
24- analyzer_java ,
25- }
26- require (" sonarlint" ).setup ({
27- server = {
28- cmd = cmd ,
29- },
30- filetypes = {
31- " java" ,
32- },
33- })
3+ if " Y" == vim .env [" SONARLINT_ENABLE" ] then
4+ M .setup = function ()
5+ local vscode = require (" kide.core.vscode" )
6+ local utils = require (" kide.core.utils" )
7+ local sonarlint_ls = vscode .find_one (" /sonarsource.sonarlint-vscode*/server/sonarlint-ls.jar" )
8+ if not sonarlint_ls then
9+ vim .notify (" sonarlint not found" , vim .log .levels .WARN )
10+ return
11+ end
12+ local analyzer_path = vscode .find_one (" /sonarsource.sonarlint-vscode*/analyzers" )
13+
14+ local analyzer_jar = vim .split (vim .fn .glob (analyzer_path .. " /*.jar" ), " \n " )
15+
16+ local cmd = {
17+ utils .java_bin (),
18+ " -jar" ,
19+ sonarlint_ls ,
20+ " -stdio" ,
21+ " -analyzers" ,
22+ }
23+ vim .list_extend (cmd , analyzer_jar )
24+ require (" sonarlint" ).setup ({
25+ server = {
26+ cmd = cmd ,
27+ },
28+ filetypes = {
29+ " java" ,
30+ },
31+ })
32+ end
3433end
3534return M
You can’t perform that action at this time.
0 commit comments