diff --git a/symlinks/config/nvim/lua/lsp/diagnostic.lua b/symlinks/config/nvim/lua/lsp/diagnostic.lua index cf7d0c3..f961682 100644 --- a/symlinks/config/nvim/lua/lsp/diagnostic.lua +++ b/symlinks/config/nvim/lua/lsp/diagnostic.lua @@ -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 diff --git a/symlinks/config/nvim/lua/lsp/null-ls_sources/gdformat.lua b/symlinks/config/nvim/lua/lsp/null-ls_sources/gdformat.lua new file mode 100644 index 0000000..9008af9 --- /dev/null +++ b/symlinks/config/nvim/lua/lsp/null-ls_sources/gdformat.lua @@ -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, + }), +} diff --git a/symlinks/config/nvim/lua/lsp/null-ls_sources/gdlint.lua b/symlinks/config/nvim/lua/lsp/null-ls_sources/gdlint.lua new file mode 100644 index 0000000..883b3d8 --- /dev/null +++ b/symlinks/config/nvim/lua/lsp/null-ls_sources/gdlint.lua @@ -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, + }, + }, + }, + }), + }), +} diff --git a/symlinks/config/nvim/lua/lsp/null-ls_sources/init.lua b/symlinks/config/nvim/lua/lsp/null-ls_sources/init.lua new file mode 100644 index 0000000..a3d838f --- /dev/null +++ b/symlinks/config/nvim/lua/lsp/null-ls_sources/init.lua @@ -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"), + }, +}