aboutsummaryrefslogtreecommitdiff
path: root/nvim/lua/config/usercmds.lua
blob: e7dd220bddd1a6d97275103d9b7c64466b11d689 (plain)
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
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

  -- vim.cmd("!" .. exe)
  vim.cmd("botright split | terminal " .. exe)
  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, {})