- replaced null-ls with none-ls
- added deprecated formatters and diagnostics
This commit is contained in:
+1
-1
@@ -19,7 +19,7 @@
|
|||||||
"lualine.nvim": { "branch": "master", "commit": "f4f791f67e70d378a754d02da068231d2352e5bc" },
|
"lualine.nvim": { "branch": "master", "commit": "f4f791f67e70d378a754d02da068231d2352e5bc" },
|
||||||
"mason-lspconfig.nvim": { "branch": "main", "commit": "1a31f824b9cd5bc6f342fc29e9a53b60d74af245" },
|
"mason-lspconfig.nvim": { "branch": "main", "commit": "1a31f824b9cd5bc6f342fc29e9a53b60d74af245" },
|
||||||
"mason.nvim": { "branch": "main", "commit": "fc98833b6da5de5a9c5b1446ac541577059555be" },
|
"mason.nvim": { "branch": "main", "commit": "fc98833b6da5de5a9c5b1446ac541577059555be" },
|
||||||
"null-ls.nvim": { "branch": "main", "commit": "0010ea927ab7c09ef0ce9bf28c2b573fc302f5a7" },
|
"none-ls.nvim": { "branch": "main", "commit": "a117163db44c256d53c3be8717f3e1a2a28e6299" },
|
||||||
"nvim-autopairs": { "branch": "master", "commit": "68f0e5c3dab23261a945272032ee6700af86227a" },
|
"nvim-autopairs": { "branch": "master", "commit": "68f0e5c3dab23261a945272032ee6700af86227a" },
|
||||||
"nvim-cmp": { "branch": "main", "commit": "12509903a5723a876abd65953109f926f4634c30" },
|
"nvim-cmp": { "branch": "main", "commit": "12509903a5723a876abd65953109f926f4634c30" },
|
||||||
"nvim-fzf": { "branch": "master", "commit": "305aa90aeb8409b4bd2af1812a4b6e157ee93953" },
|
"nvim-fzf": { "branch": "master", "commit": "305aa90aeb8409b4bd2af1812a4b6e157ee93953" },
|
||||||
|
|||||||
+8
-32
@@ -315,38 +315,18 @@ function M.null_ls()
|
|||||||
local null_ls = require("null-ls")
|
local null_ls = require("null-ls")
|
||||||
local config = lsp_config_defaults()
|
local config = lsp_config_defaults()
|
||||||
|
|
||||||
local h = require("null-ls.helpers")
|
local builtins = require("plugins.null_ls_builtins")
|
||||||
local methods = require("null-ls.methods")
|
local formatters = builtins.formatters
|
||||||
local FORMATTING = methods.internal.FORMATTING
|
local diagnostics = builtins.diagnostics
|
||||||
|
|
||||||
local templ_fmt = h.make_builtin({
|
|
||||||
name = "templ",
|
|
||||||
method = FORMATTING,
|
|
||||||
filetypes = { "templ" },
|
|
||||||
generator_opts = {
|
|
||||||
command = "templ",
|
|
||||||
args = { "fmt" },
|
|
||||||
to_stdin = true,
|
|
||||||
},
|
|
||||||
factory = h.formatter_factory,
|
|
||||||
})
|
|
||||||
|
|
||||||
-- ORDER IN TABLE DETERMINES EXECUTION ORDER
|
-- ORDER IN TABLE DETERMINES EXECUTION ORDER
|
||||||
local sources = {
|
local sources = {
|
||||||
-- python
|
-- python
|
||||||
null_ls.builtins.diagnostics.ruff.with({
|
diagnostics.ruff(),
|
||||||
args = { "check", "-n", "-e", "--stdin-filename", "$FILENAME", "-" },
|
formatters.ruff_imports(),
|
||||||
}),
|
formatters.ruff_code(),
|
||||||
null_ls.builtins.formatting.ruff.with({
|
|
||||||
args = { "format", "--stdin-filename", "$FILENAME", "-" },
|
|
||||||
}),
|
|
||||||
null_ls.builtins.formatting.ruff.with({
|
|
||||||
args = { "check", "--select", "I", "--fix", "--stdin-filename", "$FILENAME", "-" },
|
|
||||||
}),
|
|
||||||
|
|
||||||
-- js
|
-- js
|
||||||
null_ls.builtins.diagnostics.eslint,
|
|
||||||
null_ls.builtins.code_actions.eslint,
|
|
||||||
null_ls.builtins.formatting.prettier.with({
|
null_ls.builtins.formatting.prettier.with({
|
||||||
extra_filetypes = { "svelte" },
|
extra_filetypes = { "svelte" },
|
||||||
extra_args = { "--tab-width", "4" },
|
extra_args = { "--tab-width", "4" },
|
||||||
@@ -357,8 +337,7 @@ function M.null_ls()
|
|||||||
|
|
||||||
-- bash
|
-- bash
|
||||||
null_ls.builtins.formatting.shfmt,
|
null_ls.builtins.formatting.shfmt,
|
||||||
null_ls.builtins.diagnostics.shellcheck,
|
diagnostics.shellcheck(),
|
||||||
null_ls.builtins.code_actions.shellcheck,
|
|
||||||
|
|
||||||
-- cpp
|
-- cpp
|
||||||
null_ls.builtins.formatting.clang_format,
|
null_ls.builtins.formatting.clang_format,
|
||||||
@@ -366,7 +345,7 @@ function M.null_ls()
|
|||||||
-- golang
|
-- golang
|
||||||
--null_ls.builtins.diagnostics.golangci_lint,
|
--null_ls.builtins.diagnostics.golangci_lint,
|
||||||
null_ls.builtins.formatting.gofmt,
|
null_ls.builtins.formatting.gofmt,
|
||||||
templ_fmt,
|
formatters.templ(),
|
||||||
|
|
||||||
-- sql
|
-- sql
|
||||||
-- null_ls.builtins.diagnostics.sqlfluff.with(sqlfluff_args),
|
-- null_ls.builtins.diagnostics.sqlfluff.with(sqlfluff_args),
|
||||||
@@ -378,9 +357,6 @@ function M.null_ls()
|
|||||||
null_ls.builtins.diagnostics.credo,
|
null_ls.builtins.diagnostics.credo,
|
||||||
null_ls.builtins.formatting.mix,
|
null_ls.builtins.formatting.mix,
|
||||||
|
|
||||||
-- zig
|
|
||||||
null_ls.builtins.formatting.zigfmt,
|
|
||||||
|
|
||||||
-- c_sharp
|
-- c_sharp
|
||||||
null_ls.builtins.formatting.csharpier,
|
null_ls.builtins.formatting.csharpier,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ function M.install_plugins()
|
|||||||
},
|
},
|
||||||
"nvim-treesitter/nvim-treesitter-context",
|
"nvim-treesitter/nvim-treesitter-context",
|
||||||
"nvim-treesitter/playground",
|
"nvim-treesitter/playground",
|
||||||
"jose-elias-alvarez/null-ls.nvim",
|
"nvimtools/none-ls.nvim",
|
||||||
"windwp/nvim-autopairs",
|
"windwp/nvim-autopairs",
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -0,0 +1,172 @@
|
|||||||
|
local M = {}
|
||||||
|
|
||||||
|
local h = require("null-ls.helpers")
|
||||||
|
local methods = require("null-ls.methods")
|
||||||
|
local DIAGNOSTICS = methods.internal.DIAGNOSTICS
|
||||||
|
local FORMATTING = methods.internal.FORMATTING
|
||||||
|
|
||||||
|
M.diagnostics = {
|
||||||
|
ruff = function()
|
||||||
|
local custom_end_col = {
|
||||||
|
end_col = function(entries, line)
|
||||||
|
if not line then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local start_col = entries["col"]
|
||||||
|
local message = entries["message"]
|
||||||
|
local code = entries["code"]
|
||||||
|
local default_position = start_col + 1
|
||||||
|
|
||||||
|
local pattern = nil
|
||||||
|
local trimmed_line = line:sub(start_col, -1)
|
||||||
|
|
||||||
|
if code == "F841" or code == "F823" then
|
||||||
|
pattern = [[Local variable %`(.*)%`]]
|
||||||
|
elseif code == "F821" or code == "F822" then
|
||||||
|
pattern = [[Undefined name %`(.*)%`]]
|
||||||
|
elseif code == "F401" then
|
||||||
|
pattern = [[%`(.*)%` imported but unused]]
|
||||||
|
elseif code == "F841" then
|
||||||
|
pattern = [[Local variable %`(.*)%` is assigned to but never used]]
|
||||||
|
end
|
||||||
|
if not pattern then
|
||||||
|
return default_position
|
||||||
|
end
|
||||||
|
|
||||||
|
local results = message:match(pattern)
|
||||||
|
local _, end_col = trimmed_line:find(results, 1, true)
|
||||||
|
|
||||||
|
if not end_col then
|
||||||
|
return default_position
|
||||||
|
end
|
||||||
|
|
||||||
|
end_col = end_col + start_col
|
||||||
|
if end_col > tonumber(start_col) then
|
||||||
|
return end_col
|
||||||
|
end
|
||||||
|
|
||||||
|
return default_position
|
||||||
|
end,
|
||||||
|
}
|
||||||
|
|
||||||
|
return h.make_builtin({
|
||||||
|
name = "ruff",
|
||||||
|
meta = {
|
||||||
|
url = "https://github.com/charliermarsh/ruff/",
|
||||||
|
description = "An extremely fast Python linter, written in Rust.",
|
||||||
|
},
|
||||||
|
method = DIAGNOSTICS,
|
||||||
|
filetypes = { "python" },
|
||||||
|
generator_opts = {
|
||||||
|
command = "ruff",
|
||||||
|
args = { "check", "-n", "-e", "--stdin-filename", "$FILENAME", "-" },
|
||||||
|
format = "line",
|
||||||
|
check_exit_code = function(code)
|
||||||
|
return code == 0
|
||||||
|
end,
|
||||||
|
to_stdin = true,
|
||||||
|
ignore_stderr = true,
|
||||||
|
on_output = h.diagnostics.from_pattern(
|
||||||
|
[[(%d+):(%d+): ((%u)%w+) (.*)]],
|
||||||
|
{ "row", "col", "code", "severity", "message" },
|
||||||
|
{
|
||||||
|
adapters = {
|
||||||
|
custom_end_col,
|
||||||
|
},
|
||||||
|
severities = {
|
||||||
|
E = h.diagnostics.severities["error"], -- pycodestyle errors
|
||||||
|
W = h.diagnostics.severities["warning"], -- pycodestyle warnings
|
||||||
|
F = h.diagnostics.severities["information"], -- pyflakes
|
||||||
|
A = h.diagnostics.severities["information"], -- flake8-builtins
|
||||||
|
B = h.diagnostics.severities["warning"], -- flake8-bugbear
|
||||||
|
C = h.diagnostics.severities["warning"], -- flake8-comprehensions
|
||||||
|
T = h.diagnostics.severities["information"], -- flake8-print
|
||||||
|
U = h.diagnostics.severities["information"], -- pyupgrade
|
||||||
|
D = h.diagnostics.severities["information"], -- pydocstyle
|
||||||
|
M = h.diagnostics.severities["information"], -- Meta
|
||||||
|
},
|
||||||
|
}
|
||||||
|
),
|
||||||
|
},
|
||||||
|
factory = h.generator_factory,
|
||||||
|
})
|
||||||
|
end,
|
||||||
|
|
||||||
|
shellcheck = function()
|
||||||
|
return h.make_builtin({
|
||||||
|
name = "shellcheck",
|
||||||
|
meta = {
|
||||||
|
url = "https://www.shellcheck.net/",
|
||||||
|
description = "A shell script static analysis tool.",
|
||||||
|
},
|
||||||
|
method = DIAGNOSTICS,
|
||||||
|
filetypes = { "sh" },
|
||||||
|
generator_opts = {
|
||||||
|
command = "shellcheck",
|
||||||
|
args = { "--format", "json1", "--source-path=$DIRNAME", "--external-sources", "-" },
|
||||||
|
to_stdin = true,
|
||||||
|
format = "json",
|
||||||
|
check_exit_code = function(code)
|
||||||
|
return code <= 1
|
||||||
|
end,
|
||||||
|
on_output = function(params)
|
||||||
|
local parser = h.diagnostics.from_json({
|
||||||
|
attributes = { code = "code" },
|
||||||
|
severities = {
|
||||||
|
info = h.diagnostics.severities["information"],
|
||||||
|
style = h.diagnostics.severities["hint"],
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
return parser({ output = params.output.comments })
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
factory = h.generator_factory,
|
||||||
|
})
|
||||||
|
end,
|
||||||
|
}
|
||||||
|
|
||||||
|
M.formatters = {
|
||||||
|
templ = function()
|
||||||
|
return h.make_builtin({
|
||||||
|
name = "templ",
|
||||||
|
method = FORMATTING,
|
||||||
|
filetypes = { "templ" },
|
||||||
|
generator_opts = {
|
||||||
|
command = "templ",
|
||||||
|
args = { "fmt" },
|
||||||
|
to_stdin = true,
|
||||||
|
},
|
||||||
|
factory = h.formatter_factory,
|
||||||
|
})
|
||||||
|
end,
|
||||||
|
ruff_code = function()
|
||||||
|
return h.make_builtin({
|
||||||
|
name = "ruff",
|
||||||
|
method = FORMATTING,
|
||||||
|
filetypes = { "python" },
|
||||||
|
generator_opts = {
|
||||||
|
command = "ruff",
|
||||||
|
args = { "format", "--stdin-filename", "$FILENAME", "-" },
|
||||||
|
to_stdin = true,
|
||||||
|
},
|
||||||
|
factory = h.formatter_factory,
|
||||||
|
})
|
||||||
|
end,
|
||||||
|
ruff_imports = function()
|
||||||
|
return h.make_builtin({
|
||||||
|
name = "ruff",
|
||||||
|
method = FORMATTING,
|
||||||
|
filetypes = { "python" },
|
||||||
|
generator_opts = {
|
||||||
|
command = "ruff",
|
||||||
|
args = { "check", "--select", "I", "--fix", "--stdin-filename", "$FILENAME", "-" },
|
||||||
|
to_stdin = true,
|
||||||
|
},
|
||||||
|
factory = h.formatter_factory,
|
||||||
|
})
|
||||||
|
end,
|
||||||
|
}
|
||||||
|
|
||||||
|
return M
|
||||||
Reference in New Issue
Block a user