1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
local function run_sonar()
local exe = vim.fn.exepath("sonar-scanner")
if exe == "" then
vim.notify("sonar-scanner nicht im PATH gefunden", vim.log.levels.ERROR)
return
end
if vim.fn.executable(exe) == 0 then
vim.notify("sonar-scanner ist nicht ausführbar", vim.log.levels.ERROR)
return
end
-- Suche nach *.properties im aktuellen Verzeichnis
local files = vim.fn.glob("*.properties", false, true)
local cmd = exe
if #files > 0 then
-- Optional: gezielt sonar-project.properties bevorzugen
local selected = nil
for _, f in ipairs(files) do
if f == "sonar-project.properties" then
selected = f
break
end
end
-- Falls keine Standarddatei, nimm die erste
if not selected then selected = files[1] end
cmd = cmd .. " -Dproject.settings=" .. selected
vim.notify("Verwende Properties: " .. selected, vim.log.levels.INFO)
else
vim.notify("Keine .properties Datei gefunden, nutze Default-Verhalten", vim.log.levels.WARN)
end
vim.cmd("botright split | terminal " .. cmd)
vim.cmd("norm G")
end
local function load_sonar_issues()
local cmd = vim.fn.stdpath("config") .. "/scripts/sonarqube.sh"
vim.fn.setqflist({}, " ", {
title = "SonarQube Issues",
lines = vim.fn.systemlist(cmd),
})
vim.cmd("copen")
end
vim.api.nvim_create_user_command("SonarScan", run_sonar, {})
vim.api.nvim_create_user_command("SonarIssues", load_sonar_issues, {})
|