Update generated neovim config
This commit is contained in:
@ -0,0 +1,21 @@
|
||||
local api = vim.api
|
||||
describe("codespell", function()
|
||||
it("provides end_col", function()
|
||||
local parser = require("lint.linters.codespell").parser
|
||||
local bufnr = api.nvim_create_buf(false, true)
|
||||
api.nvim_buf_set_lines(bufnr, 0, -1, true, {' error("hello crate test")'})
|
||||
local result = parser("1: crate ==> create", bufnr)
|
||||
local expected = {
|
||||
{
|
||||
col = 15,
|
||||
end_col = 20,
|
||||
end_lnum = 0,
|
||||
lnum = 0,
|
||||
message = 'crate ==> create',
|
||||
severity = vim.diagnostic.severity.INFO,
|
||||
source = 'codespell',
|
||||
}
|
||||
}
|
||||
assert.are.same(expected, result)
|
||||
end)
|
||||
end)
|
||||
@ -0,0 +1,59 @@
|
||||
describe("hledger", function()
|
||||
local parser = require("lint.linters.hledger").parser
|
||||
it("no diagnostics on empty output", function()
|
||||
assert.are.same({}, parser(""))
|
||||
end)
|
||||
|
||||
it("returns error diagnostic on error output", function()
|
||||
-- editorconfig-checker-disable
|
||||
local msg = [[
|
||||
| 2024-08-10 * payment
|
||||
| revenue:dev:customer -1.234,00 EUR
|
||||
14 | assets:receivable:customer 1.234,00 EUR
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
Strict account checking is enabled, and
|
||||
account "assets:receivable:customer" has not been declared.
|
||||
Consider adding an account directive. Examples:
|
||||
|
||||
account assets:receivable:customer
|
||||
account assets:receivable:customer ; type:A ; (L,E,R,X,C,V)
|
||||
]]
|
||||
-- editorconfig-checker-enable
|
||||
local output = "hledger: Error: -:14:" .. msg
|
||||
local expected = {
|
||||
{
|
||||
message = msg,
|
||||
col = 0,
|
||||
lnum = 13,
|
||||
severity = vim.diagnostic.severity.ERROR,
|
||||
source = "hledger"
|
||||
},
|
||||
}
|
||||
assert.are.same(expected, parser(output))
|
||||
end)
|
||||
it("supports column-ranges", function()
|
||||
-- editorconfig-checker-disable
|
||||
local msg = [[
|
||||
109 | 2024-08-16 assert balance
|
||||
| assets:checking 4 EUR = 68,59 EUR
|
||||
|
||||
This transaction is unbalanced.
|
||||
The real postings' sum should be 0 but is: 4 EUR
|
||||
Consider adjusting this entry's amounts, or adding missing postings.
|
||||
]]
|
||||
-- editorconfig-checker-enable
|
||||
local output = "hledger: Error: -:109-110:" .. msg
|
||||
local expected = {
|
||||
{
|
||||
message = msg,
|
||||
col = 0,
|
||||
lnum = 108,
|
||||
end_lnum = 109,
|
||||
severity = vim.diagnostic.severity.ERROR,
|
||||
source = "hledger"
|
||||
},
|
||||
}
|
||||
assert.are.same(expected, parser(output))
|
||||
end)
|
||||
end)
|
||||
@ -73,4 +73,58 @@ bar:209:14 Bigger mistake
|
||||
}
|
||||
assert.are.same(expected, result)
|
||||
end)
|
||||
|
||||
it("supports lpeg pattern", function()
|
||||
if not vim.re then
|
||||
return
|
||||
end
|
||||
local pattern = vim.re.compile("{[0-9]+} ':' { (.*) }")
|
||||
local groups = { 'lnum', 'message' }
|
||||
local parser = require('lint.parser').from_pattern(pattern, groups)
|
||||
local output = [[
|
||||
10:Big mistake
|
||||
14:Bigger mistake
|
||||
]]
|
||||
local result = parser(output, 0)
|
||||
local expected = {
|
||||
{
|
||||
message = 'Big mistake',
|
||||
lnum = 9,
|
||||
end_lnum = 9,
|
||||
col = 0,
|
||||
end_col = 0,
|
||||
severity = vim.diagnostic.severity.ERROR,
|
||||
},
|
||||
{
|
||||
message = 'Bigger mistake',
|
||||
lnum = 13,
|
||||
col = 0,
|
||||
end_lnum = 13,
|
||||
end_col = 0,
|
||||
severity = vim.diagnostic.severity.ERROR,
|
||||
},
|
||||
}
|
||||
assert.are.same(expected, result)
|
||||
assert.are.same({}, parser("no-match", 0))
|
||||
end)
|
||||
|
||||
it("supports match function", function()
|
||||
local pattern = function(_)
|
||||
return { 10, "hello" }
|
||||
end
|
||||
local groups = { 'lnum', 'message' }
|
||||
local parser = require('lint.parser').from_pattern(pattern, groups)
|
||||
local result = parser("foo", 0)
|
||||
local expected = {
|
||||
{
|
||||
message = "hello",
|
||||
lnum = 9,
|
||||
col = 0,
|
||||
end_lnum = 9,
|
||||
end_col = 0,
|
||||
severity = vim.diagnostic.severity.ERROR
|
||||
},
|
||||
}
|
||||
assert.are.same(expected, result)
|
||||
end)
|
||||
end)
|
||||
|
||||
@ -3,6 +3,7 @@ describe('linter.sqlfluff', function()
|
||||
local parser = require('lint.linters.sqlfluff').parser
|
||||
local bufnr = vim.uri_to_bufnr('file:///non-existent.sql')
|
||||
-- actual output I got from running sqlfluff
|
||||
-- NB: These tests do not address parsing failures
|
||||
local result = parser([[
|
||||
[{"filepath": "stdin", "violations": [{"start_line_no": 68, "start_line_pos": 1, "code": "L003", "description": "Expected 1 indentation, found 0 [compared to line 52]"}, {"start_line_no": 68, "start_line_pos": 1, "code": "L013", "description": "Column expression without alias. Use explicit `AS` clause."}]}]
|
||||
|
||||
@ -15,7 +16,7 @@ describe('linter.sqlfluff', function()
|
||||
message = 'Expected 1 indentation, found 0 [compared to line 52]',
|
||||
lnum = 67, -- mind the line indexing
|
||||
col = 0, -- mind the column indexing
|
||||
severity = vim.diagnostic.severity.ERROR,
|
||||
severity = vim.diagnostic.severity.WARN,
|
||||
user_data = {lsp = {code = 'L003'}},
|
||||
}
|
||||
assert.are.same(expected[1], result[1])
|
||||
@ -25,7 +26,7 @@ describe('linter.sqlfluff', function()
|
||||
message = 'Column expression without alias. Use explicit `AS` clause.',
|
||||
lnum = 67,
|
||||
col = 0,
|
||||
severity = vim.diagnostic.severity.ERROR,
|
||||
severity = vim.diagnostic.severity.WARN,
|
||||
user_data = {lsp = {code = 'L013'}},
|
||||
}
|
||||
assert.are.same(expected[2], result[2])
|
||||
@ -47,7 +48,7 @@ describe('linter.sqlfluff', function()
|
||||
message = 'Expected 1 indentation, found 0 [compared to line 52]',
|
||||
lnum = 67, -- mind the line indexing
|
||||
col = 0, -- mind the column indexing
|
||||
severity = vim.diagnostic.severity.ERROR,
|
||||
severity = vim.diagnostic.severity.WARN,
|
||||
user_data = {lsp = {code = 'L003'}},
|
||||
}
|
||||
assert.are.same(expected[1], result[1])
|
||||
@ -57,7 +58,7 @@ describe('linter.sqlfluff', function()
|
||||
message = 'Column expression without alias. Use explicit `AS` clause.',
|
||||
lnum = 67,
|
||||
col = 0,
|
||||
severity = vim.diagnostic.severity.ERROR,
|
||||
severity = vim.diagnostic.severity.WARN,
|
||||
user_data = {lsp = {code = 'L013'}},
|
||||
}
|
||||
assert.are.same(expected[2], result[2])
|
||||
|
||||
Reference in New Issue
Block a user