Add custom null-ls sources for godot
parent
9d3a6d6bad
commit
a706fe44a0
|
@ -3,6 +3,7 @@
|
|||
-------------------------------------------------------------------------------
|
||||
|
||||
local null_ls = require("null-ls")
|
||||
local custom_sources = require("lsp.null-ls_sources")
|
||||
|
||||
null_ls.setup({
|
||||
sources = {
|
||||
|
@ -44,7 +45,10 @@ null_ls.setup({
|
|||
null_ls.builtins.formatting.trim_whitespace,
|
||||
null_ls.builtins.hover.dictionary,
|
||||
null_ls.builtins.code_actions.gitsigns,
|
||||
null_ls.builtins.code_actions.refactoring,
|
||||
|
||||
-- Godot
|
||||
custom_sources.formatters.gdformat,
|
||||
custom_sources.diagnostics.gdlint,
|
||||
},
|
||||
on_attach = function(client)
|
||||
if client.resolved_capabilities.document_formatting then
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
local null_ls = require("null-ls")
|
||||
local helpers = require("null-ls.helpers")
|
||||
|
||||
return {
|
||||
name = "gdformat",
|
||||
meta = {
|
||||
url = "https://github.com/Scony/godot-gdscript-toolkit",
|
||||
description = "Formatter for GDScript",
|
||||
},
|
||||
method = null_ls.methods.FORMATTING,
|
||||
filetypes = { "gdscript" },
|
||||
generator = helpers.formatter_factory({
|
||||
command = "gdformat",
|
||||
args = { "--diff", "-" },
|
||||
to_stdin = true,
|
||||
}),
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
local null_ls = require("null-ls")
|
||||
local helpers = require("null-ls.helpers")
|
||||
|
||||
return {
|
||||
name = "gdlint",
|
||||
meta = {
|
||||
url = "https://github.com/Scony/godot-gdscript-toolkit",
|
||||
description = "Linter for GDScript",
|
||||
},
|
||||
method = null_ls.methods.DIAGNOSTICS_ON_SAVE,
|
||||
filetypes = { "gdscript" },
|
||||
generator = helpers.generator_factory({
|
||||
command = "gdlint",
|
||||
args = { "$FILENAME" },
|
||||
format = "line",
|
||||
from_stderr = true,
|
||||
multiple_files = true,
|
||||
check_exit_code = function(code)
|
||||
return code == 0
|
||||
end,
|
||||
on_output = helpers.diagnostics.from_patterns({
|
||||
{
|
||||
pattern = "(.+):(%d+): Error: (.*)",
|
||||
groups = { "filename", "row", "message" },
|
||||
overrides = {
|
||||
diagnostic = {
|
||||
severity = helpers.diagnostics.severities.error,
|
||||
},
|
||||
},
|
||||
},
|
||||
}),
|
||||
}),
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
-- Place for custom null-ls sources
|
||||
return {
|
||||
formatters = {
|
||||
gdformat = require("lsp.null-ls_sources.gdformat"),
|
||||
},
|
||||
diagnostics = {
|
||||
gdlint = require("lsp.null-ls_sources.gdlint"),
|
||||
},
|
||||
}
|
Loading…
Reference in New Issue