Skip to content

Commit ad041dc

Browse files
authored
Merge branch 'main' into feat/luarocks-tagged-releases
2 parents c7f2ddb + 3c206df commit ad041dc

19 files changed

Lines changed: 349 additions & 50 deletions

File tree

.github/pull_request_template.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
## What does this PR do?
2+
3+
<!-- Please describe what changes you're making and why -->
4+
5+
## Checklist
6+
7+
- [ ] If I'm adding a new builtin (linter, formatter, code action, etc.), I
8+
understand it should be contributed to
9+
[nvimtools/none-ls-extras.nvim](https://github.com/nvimtools/none-ls-extras.nvim)
10+
instead
11+
- [ ] I've written tests for these changes

.github/workflows/build.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ jobs:
1313
- stable
1414
- nightly
1515
steps:
16-
- uses: actions/checkout@v4
16+
- uses: actions/checkout@v5
1717
with:
1818
path: none-ls.nvim
19-
- uses: actions/checkout@v4
19+
- uses: actions/checkout@v5
2020
with:
2121
repository: nvim-lua/plenary.nvim
2222
path: none-ls.nvim/.tests/site/pack/deps/start/plenary.nvim

.github/workflows/docs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
runs-on: ubuntu-latest
1818
steps:
1919
- name: Checkout
20-
uses: actions/checkout@v4
20+
uses: actions/checkout@v5
2121
with:
2222
ref: ${{ github.head_ref }}
2323

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
repos:
22
- repo: https://github.com/johnnymorganz/stylua
3-
rev: v2.1.0
3+
rev: v2.3.1
44
hooks:
55
- id: stylua-github
66
- repo: https://github.com/pre-commit/mirrors-prettier
@@ -9,7 +9,7 @@ repos:
99
- id: prettier
1010
exclude: "^test/"
1111
- repo: https://github.com/rhysd/actionlint
12-
rev: v1.7.7
12+
rev: v1.7.10
1313
hooks:
1414
- id: actionlint
1515
- repo: https://github.com/Kampfkarren/selene

doc/BUILTINS.md

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ local sources = { null_ls.builtins.code_actions.proselint }
113113
- Filetypes: `{ "markdown", "tex" }`
114114
- Method: `code_action`
115115
- Command: `proselint`
116-
- Args: `{ "--json" }`
116+
- Args: `{ "check", "--output-format=json" }`
117117

118118
### [refactoring](https://github.com/ThePrimeagen/refactoring.nvim)
119119

@@ -775,6 +775,23 @@ local sources = { null_ls.builtins.diagnostics.gdlint }
775775
- Command: `gdlint`
776776
- Args: `{ "$FILENAME" }`
777777

778+
### [gitleaks](https://github.com/gitleaks/gitleaks)
779+
780+
Gitleaks is a SAST tool for detecting and preventing hardcoded secrets like passwords, API keys, and tokens in git repos.
781+
782+
#### Usage
783+
784+
```lua
785+
local sources = { null_ls.builtins.diagnostics.gitleaks }
786+
```
787+
788+
#### Defaults
789+
790+
- Filetypes: `{}`
791+
- Method: `diagnostics`
792+
- Command: `gitleaks`
793+
- Args: `{ "stdin", "--report-format", "json", "--report-path", "-", "--exit-code", "0", "--no-banner" }`
794+
778795
### [gitlint](https://jorisroovers.com/gitlint/)
779796

780797
Linter for Git commit messages.
@@ -1205,7 +1222,7 @@ local sources = { null_ls.builtins.diagnostics.proselint }
12051222
- Filetypes: `{ "markdown", "tex" }`
12061223
- Method: `diagnostics`
12071224
- Command: `proselint`
1208-
- Args: `{ "--json" }`
1225+
- Args: `{ "check", "--output-format=json" }`
12091226

12101227
### [protolint](https://github.com/yoheimuta/protolint)
12111228

@@ -2026,6 +2043,7 @@ local sources = { null_ls.builtins.formatting.bean_format }
20262043
- Filetypes: `{ "beancount" }`
20272044
- Method: `formatting`
20282045
- Command: `bean-format`
2046+
- Args: `{ "-" }`
20292047

20302048
#### Notes
20312049

@@ -3111,7 +3129,7 @@ local sources = { null_ls.builtins.formatting.meson_format }
31113129
- Filetypes: `{ "meson" }`
31123130
- Method: `formatting`
31133131
- Command: `meson`
3114-
- Args: `{ "format", "--", "$FILENAME" }`
3132+
- Args: `{ "format", "--source-file-path", "$FILENAME", "--", "-" }`
31153133

31163134
### [mix](https://hexdocs.pm/mix/1.12/Mix.html)
31173135

doc/builtins.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,9 @@
202202
"gdscript"
203203
]
204204
},
205+
"gitleaks": {
206+
"filetypes": []
207+
},
205208
"gitlint": {
206209
"filetypes": [
207210
"gitcommit"

doc/null-ls.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
*null-ls.txt* Last change: 2025 August 06
1+
*null-ls.txt* Last change: 2026 January 14
22

33
==============================================================================
44
Table of Contents *null-ls-table-of-contents*

lua/null-ls/builtins/_meta/diagnostics.lua

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@ return {
7979
gdlint = {
8080
filetypes = { "gdscript" }
8181
},
82+
gitleaks = {
83+
filetypes = {}
84+
},
8285
gitlint = {
8386
filetypes = { "gitcommit" }
8487
},

lua/null-ls/builtins/code_actions/proselint.lua

Lines changed: 51 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,27 +13,66 @@ return h.make_builtin({
1313
filetypes = { "markdown", "tex" },
1414
generator_opts = {
1515
command = "proselint",
16-
args = { "--json" },
16+
args = { "check", "--output-format=json" },
1717
format = "json",
1818
to_stdin = true,
1919
check_exit_code = function(c)
2020
return c <= 1
2121
end,
2222
on_output = function(params)
2323
local actions = {}
24-
for _, d in ipairs(params.output.data.errors) do
25-
if d.replacements ~= vim.NIL and params.row == d.line then
26-
local row = d.line - 1
27-
local col_beg = d.column - 1
28-
local col_end = d.column + d.extent - 2
29-
table.insert(actions, {
30-
title = d.message,
31-
action = function()
32-
vim.api.nvim_buf_set_text(params.bufnr, row, col_beg, row, col_end, { d.replacements })
33-
end,
34-
})
24+
25+
local output = params.output
26+
if not output or output.error then
27+
return actions
28+
end
29+
30+
local result = output.result
31+
if not result then
32+
return actions
33+
end
34+
35+
local buf = params.bufnr
36+
local text = table.concat(vim.api.nvim_buf_get_lines(buf, 0, -1, false), "\n")
37+
38+
for _, file_output in pairs(result) do
39+
if file_output.diagnostics then
40+
for _, d in ipairs(file_output.diagnostics) do
41+
if d.replacements and d.replacements ~= vim.NIL then
42+
-- byte offsets (1-based)
43+
local byte_start = d.span[1]
44+
local byte_end = d.span[2]
45+
46+
-- turn into 0-based Lua string indices
47+
local sub = text:sub(byte_start, byte_end)
48+
49+
-- find the (line, col) from byte indices
50+
local before = text:sub(1, byte_start - 1)
51+
local line = select(2, before:gsub("\n", "")) + 1
52+
local col = #before:match("[^\n]*$") + 1
53+
54+
-- end col
55+
local length = #sub
56+
local end_col = col + length - 1
57+
58+
table.insert(actions, {
59+
title = d.message,
60+
action = function()
61+
vim.api.nvim_buf_set_text(
62+
buf,
63+
line - 1,
64+
col - 1,
65+
line - 1,
66+
end_col,
67+
{ d.replacements }
68+
)
69+
end,
70+
})
71+
end
72+
end
3573
end
3674
end
75+
3776
return actions
3877
end,
3978
},
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
local h = require("null-ls.helpers")
2+
local methods = require("null-ls.methods")
3+
4+
local DIAGNOSTICS = methods.internal.DIAGNOSTICS
5+
6+
local handle_gitleaks_output = function(params)
7+
local parser = h.diagnostics.from_json({
8+
attributes = {
9+
code = "code",
10+
},
11+
diagnostic = {
12+
source = "gitleaks",
13+
},
14+
})
15+
16+
local offenses = {}
17+
for _, finding in ipairs(params.output or {}) do
18+
table.insert(offenses, {
19+
message = finding.Description,
20+
ruleId = finding.RuleID,
21+
code = finding.RuleID,
22+
line = finding.StartLine,
23+
column = finding.StartColumn,
24+
endLine = finding.EndLine,
25+
endColumn = finding.EndColumn,
26+
})
27+
end
28+
29+
return parser({ output = offenses })
30+
end
31+
32+
return h.make_builtin({
33+
name = "gitleaks",
34+
meta = {
35+
url = "https://github.com/gitleaks/gitleaks",
36+
description = "Gitleaks is a SAST tool for detecting and preventing hardcoded secrets like passwords, API keys, and tokens in git repos.",
37+
},
38+
method = DIAGNOSTICS,
39+
filetypes = {},
40+
generator_opts = {
41+
command = "gitleaks",
42+
args = {
43+
"stdin",
44+
"--report-format",
45+
"json",
46+
"--report-path",
47+
"-",
48+
"--exit-code",
49+
"0",
50+
"--no-banner",
51+
},
52+
format = "json",
53+
to_stdin = true,
54+
from_stderr = true,
55+
ignore_stderr = true,
56+
check_exit_code = function(code)
57+
return code == 0
58+
end,
59+
on_output = handle_gitleaks_output,
60+
},
61+
factory = h.generator_factory,
62+
})

0 commit comments

Comments
 (0)