Skip to content

Instantly share code, notes, and snippets.

@lopesivan
Created July 24, 2026 12:05
Show Gist options
  • Select an option

  • Save lopesivan/a47ca7d1e79716fe91dae4c3d3aefefc to your computer and use it in GitHub Desktop.

Select an option

Save lopesivan/a47ca7d1e79716fe91dae4c3d3aefefc to your computer and use it in GitHub Desktop.
corrije null-ls
local h = require("null-ls.helpers")
local methods = require("null-ls.methods")
return h.make_builtin({
name = "astyle",
meta = {
url = "https://astyle.sourceforge.net/",
description = "Artistic Style formatter",
},
method = methods.internal.FORMATTING,
filetypes = {
"arduino",
"c",
"cpp",
"cs",
"java",
},
condition = function(params)
local dir = vim.fn.fnamemodify(params.bufname, ":h")
return vim.uv.fs_stat(dir .. "/.astylerc")
or vim.uv.fs_stat(dir .. "/astyle.cfg")
end,
generator_opts = {
command = "astyle",
args = function(params)
local dir = vim.fn.fnamemodify(params.bufname, ":h")
if vim.uv.fs_stat(dir .. "/.astylerc") then
return {
"--quiet",
"--options=" .. dir .. "/.astylerc",
}
end
if vim.uv.fs_stat(dir .. "/astyle.cfg") then
return {
"--quiet",
"--options=" .. dir .. "/astyle.cfg",
}
end
return { "--quiet" }
end,
to_stdin = true,
ignore_stderr = true,
},
factory = h.formatter_factory,
})
local h = require("null-ls.helpers")
local methods = require("null-ls.methods")
local FORMATTING = methods.internal.FORMATTING
local RANGE_FORMATTING = methods.internal.RANGE_FORMATTING
return h.make_builtin({
name = "autopep8",
meta = {
url = "https://github.com/hhatto/autopep8",
description = "A tool that automatically formats Python code to conform to the PEP 8 style guide.",
},
method = { FORMATTING, RANGE_FORMATTING },
filetypes = { "python" },
generator_opts = {
command = "autopep8",
args = h.range_formatting_args_factory({
"-",
}, "--line-range", nil, { use_rows = true }),
to_stdin = true,
},
factory = h.formatter_factory,
})
{
"Comment block": {
"prefix": "/",
"body": [
"/*$0 */"
],
"description": "Convenient comment block"
},
"Multiline comment": {
"prefix": "//",
"body": [
"/*$0",
" */"
],
"description": "Convenient multiline comment"
},
"Starter Template": {
"prefix": "st",
"body": [
"#include <stdbool.h>",
"#include <stdio.h>",
"#include <stdlib.h>",
"",
"int main(int argc, char *argv[])",
"{",
"\t$0",
"\treturn EXIT_SUCCESS;",
"}"
],
"description": "Standard starter template for a tiny C program"
},
"Preprocessor Starter Template": {
"prefix": "#st",
"body": [
"#include <assert.h>",
"#include <errno.h>",
"#include <stdbool.h>",
"#include <stddef.h>",
"#include <stdint.h>",
"#include <stdio.h>",
"#include <stdlib.h>"
],
"description": "Preprocessor starter template for a C project"
},
"main() template": {
"prefix": "main",
"body": [
"int main(int argc, char *argv[])",
"{$0",
"\treturn EXIT_SUCCESS;",
"}"
],
"description": "Standard main() snippet"
},
"main(void) template": {
"prefix": "mainn",
"body": [
"int main(void)",
"{$0",
"\treturn EXIT_SUCCESS;",
"}"
],
"description": "No-args main() snippet"
},
"#include <...>": {
"prefix": "#inc",
"body": [
"#include <$0>"
],
"description": "#include <...> snippet"
},
"#include \"...\"": {
"prefix": "#incl",
"body": [
"#include \"$0\""
],
"description": "#include \"...\" snippet"
},
"#define macro": {
"prefix": "#def",
"body": [
"#define ${1:MACRO}"
],
"description": "Textual macro snippet"
},
"#define macro()": {
"prefix": "#deff",
"body": [
"#define ${1:MACRO}($2) ($3)"
],
"description": "Function-like macro snippet"
},
"_GNU_SOURCE": {
"prefix": "#gnu",
"body": [
"#define _GNU_SOURCE"
],
"description": "Enable GNU extensions (functions)"
},
"#if": {
"prefix": "#if",
"body": [
"#if ${1:0}",
"$0",
"#endif /* if $1 */"
],
"description": "#if snippet"
},
"#ifdef": {
"prefix": "#ifdef",
"body": [
"#ifdef ${1:MACRO}",
"$0",
"#endif /* ifdef $1 */"
],
"description": "#ifdef snippet"
},
"#ifndef": {
"prefix": "#ifndef",
"body": [
"#ifndef ${1:MACRO}",
"$0",
"#endif /* ifndef $1 */"
],
"description": "#ifndef snippet"
},
"include once": {
"prefix": "#once",
"body": [
"#ifndef ${1:FILE}_H",
"#define $1_H",
"$0",
"",
"#endif /* end of include guard: $1_H */"
],
"description": "Header include guard"
},
"extern C": {
"prefix": "#nocpp",
"body": [
"#ifdef __cplusplus",
"extern \"C\" {",
"#endif",
"$0",
"",
"#ifdef __cplusplus",
"} /* extern \"C\" */",
"#endif"
],
"description": "Disable C++ name mangling in C headers"
},
"#error": {
"prefix": "#err",
"body": [
"#error \"$0\""
],
"description": "#error snippet"
},
"#warning": {
"prefix": "#warn",
"body": [
"#warning \"$0\""
],
"description": "#warning snippet"
},
"if": {
"prefix": "if",
"body": [
"if (${1:true}) {$0",
"}"
],
"description": "'if' snippet"
},
"if else": {
"prefix": "ifelse",
"body": [
"if (${1:true}) {$2",
"} else {$0",
"}"
],
"description": "'if' with 'else'"
},
"else": {
"prefix": "else",
"body": [
"else {$0",
"}"
],
"description": "'else' snippet"
},
"else if": {
"prefix": "elseif",
"body": [
"else if (${1:true}) {$0",
"}"
],
"description": "else-if snippet"
},
"if 1L": {
"prefix": "ifi",
"body": [
"if (${1:true})$0"
],
"description": "1-line-if"
},
"elif 1L": {
"prefix": "elseifi",
"body": [
"else if (${1:true})$0"
],
"description": "1-line-else-if"
},
"switch": {
"prefix": "switch",
"body": [
"switch (${1:expression}) {$0",
"}"
],
"description": "'switch' snippet"
},
"case": {
"prefix": "case",
"body": [
"case ${1:0}:$0"
],
"description": "'case' branch"
},
"default": {
"prefix": "default",
"body": [
"default:$0"
],
"description": "'default' branch"
},
"while": {
"prefix": "while",
"body": [
"while (${1:true}) {$0",
"}"
],
"description": "'while' loop snippet"
},
"do...while": {
"prefix": "do",
"body": [
"do {$0",
"} while (${1:false});"
],
"description": "do...while loop snippet"
},
"return": {
"prefix": "return",
"body": [
"return ${1:0};"
],
"description": "'return' snippet"
},
"exit": {
"prefix": "exit",
"body": [
"exit(${1:EXIT_FAILURE});"
],
"description": "exit() snippet"
},
"for": {
"prefix": "for",
"body": [
"for ($1;$2;$3) {$0",
"}"
],
"description": "Generic 'for' loop"
},
"for count": {
"prefix": "forc",
"body": [
"for (${1:size_t} ${2:i} = ${3:0}; $2 < ${4:count}; $2${5:++}) {$0",
"}"
],
"description": "'for' loop focusing on iteration times"
},
"for range": {
"prefix": "forg",
"body": [
"for (${1:size_t} ${2:i} = ${3:1}; $2 <= ${4:last}; $2${5:++}) {$0",
"}"
],
"description": "'for' loop focusing on inclusive range"
},
"for argv[]": {
"prefix": "fora",
"body": [
"for (int ${1:i} = ${2:1}; $1 < argc; $1++) {$0",
"}"
],
"description": "'for' loop for cmdline arguments"
},
"Function ...": {
"prefix": "fun",
"body": [
"${2:void} ${1:fun}(${3:void})$0"
],
"description": "Make a function declaration/definition/pointer"
},
"Function definition": {
"prefix": "func",
"body": [
"${2:void} ${1:fun}(${3:void})",
"{$0",
"}"
],
"description": "Define a function"
},
"typedef": {
"prefix": "typedef",
"body": [
"typedef ${1:void} ${2:Emptiness};"
],
"description": "'typedef' snippet"
},
"Complicated typedef": {
"prefix": "typedeff",
"body": [
"typedef $0;"
],
"description": "Declaration-like typedef for func-ptr,array,etc."
},
"typedef struct": {
"prefix": "typedefst",
"body": [
"typedef struct $1 ${1:Box};"
],
"description": "Implicit struct typedef"
},
"typedef union": {
"prefix": "typedefun",
"body": [
"typedef union $1 ${1:Cell};"
],
"description": "Implicit union typedef"
},
"struct": {
"prefix": "struct",
"body": [
"struct ${1:MyStruct} {$0",
"};"
],
"description": "'struct' snippet"
},
"struct type": {
"prefix": "typestruct",
"body": [
"typedef struct $1 ${1:Box};",
"struct $1 {$0",
"};"
],
"description": "Define a type with struct"
},
"union": {
"prefix": "union",
"body": [
"union ${1:MyUnion} {$0",
"};"
],
"description": "'union' snippet"
},
"union type": {
"prefix": "typeunion",
"body": [
"typedef union $1 ${1:Cell};",
"union $1 {$0",
"};"
],
"description": "Define a type with union"
},
"enum": {
"prefix": "enum",
"body": [
"enum $1{ $0 };"
],
"description": "Define an enumeration"
},
"puts": {
"prefix": "puts",
"body": [
"puts(\"${1:This function doesn't need newline.}\");$0"
],
"description": "puts() snippet"
},
"fputs": {
"prefix": "fputs",
"body": [
"fputs(\"${2:This is a simpler printf.\\n}\", ${1:stdout});$0"
],
"description": "puts() snippet"
},
"printf": {
"prefix": "printf",
"body": [
"printf(\"${1:%s}\\n\"$2);$0"
],
"description": "printf() snippet"
},
"fprintf": {
"prefix": "fprintf",
"body": [
"fprintf(${1:stderr}, \"${2:%s}\\n\"$3);$0"
],
"description": "fprintf() snippet"
},
"sprintf": {
"prefix": "sprintf",
"body": [
"sprintf(${1:buf}, \"${2:%s}\\n\"$3);$0"
],
"description": "sprintf() snippet"
},
"snprintf": {
"prefix": "snprintf",
"body": [
"snprintf(${1:buf}, ${2:max}, \"${3:%s}\\n\"$3);$0"
],
"description": "snprintf() snippet"
},
"scanf": {
"prefix": "scanf",
"body": [
"scanf(\"${1:%d}\"$2);$0"
],
"description": "scanf() snippet"
},
"fscanf": {
"prefix": "fscanf",
"body": [
"fscanf(${1:stdin}, \"${2:%d}\"$3);$0"
],
"description": "fscanf() snippet"
},
"sscanf": {
"prefix": "sscanf",
"body": [
"sscanf(${1:buf}, \"${2:%d}\"$3);$0"
],
"description": "sscanf() snippet"
},
"malloc": {
"prefix": "malloc",
"body": [
"malloc(sizeof(${1:int[69]})$2);$0"
],
"description": "malloc() snippet"
},
"calloc": {
"prefix": "calloc",
"body": [
"calloc(${1:1}, sizeof(${2:int})$3);$0"
],
"description": "calloc() snippet"
},
"realloc": {
"prefix": "realloc",
"body": [
"realloc(${1:ptr}, sizeof(${2:int[69]})$3);$0"
],
"description": "realloc() snippet"
},
"reallocarray": {
"prefix": "reallocarray",
"body": [
"reallocarray(${1:ptr}, ${2:69}, sizeof(${3:int})$4);$0"
],
"description": "reallocarray() snippet"
},
"free": {
"prefix": "free",
"body": [
"free(${1:NULL});"
],
"description": "free() snippet"
},
"assert": {
"prefix": "assert",
"body": [
"assert($0);"
],
"description": "assert() snippet"
},
"static_assert": {
"prefix": "static_assert",
"body": [
"static_assert(${1:false}, \"${2:Oopsie}\");"
],
"description": "static_assert() snippet"
},
"err": {
"prefix": "err",
"body": [
"err(${1:EXIT_FAILURE}, \"${2:%s}\"$3);$0"
],
"description": "err() snippet"
},
"errx": {
"prefix": "errx",
"body": [
"errx(${1:EXIT_FAILURE}, \"${2:%s}\"$0);"
],
"description": "errx() snippet"
},
"warn": {
"prefix": "warn",
"body": [
"warn(\"${1:%s}\"$0);"
],
"description": "warn() snippet"
},
"warnx": {
"prefix": "warnx",
"body": [
"warnx(\"${1:%s}\"$0);"
],
"description": "warnx() snippet"
},
"fputs() errcheck": {
"prefix": "chkio_eof",
"body": [
"if (${1:status} == EOF$2) {",
"\t${3:err(EXIT_FAILURE, \"IO is hard\");}",
"}"
],
"description": "Error checking for int IO functions"
},
"fgets() errcheck": {
"prefix": "chkio_null",
"body": [
"if (!${1:status}) {",
"\t${2:err(EXIT_FAILURE, \"IO is very hard\");}",
"}"
],
"description": "Error checking for pointer-type IO functions"
},
"fseek() errcheck": {
"prefix": "chkio_mi",
"body": [
"if (${1:status} == -1$2) {",
"\t${3:err(EXIT_FAILURE, \"IO is super hard\");}",
"}"
],
"description": "Error checking for fseek(), getline() like functions"
},
"printf() errcheck": {
"prefix": "chkio_neg",
"body": [
"if (${1:status} < 0$2) {",
"\t${3:err(EXIT_FAILURE, \"Ran out of ink\");}",
"}"
],
"description": "Error checking for printf()-like functions"
},
"malloc() errcheck": {
"prefix": "chkmem",
"body": [
"if (!${1:status}) {",
"\t${2:err(EXIT_FAILURE, \"Your memory is doomed\");}",
"}"
],
"description": "Error checking for malloc()-like"
},
"Print a variable": {
"prefix": "printv",
"body": [
"printf(\"$1 = %${2:d}\\n\", ${1:var}$3);"
],
"description": "Call printf() to log value of a variable"
},
"Array length": {
"prefix": "arrlen",
"body": [
"(sizeof ${1:arr} / sizeof $1[0])"
],
"description": "Calculate number of elements in an array"
}
}
local Util = require("todo-comments.util")
--- @class TodoConfig
local M = {}
M.keywords = {}
--- @type TodoOptions
M.options = {}
M.loaded = false
M.ns = vim.api.nvim_create_namespace("todo-comments")
--- @class TodoOptions
-- TODO: add support for markdown todos
local defaults = {
signs = true, -- show icons in the signs column
sign_priority = 8, -- sign priority
-- keywords recognized as todo comments
keywords = {
FIX = {
icon = " ", -- icon used for the sign, and in search results
color = "error", -- can be a hex color, or a named color (see below)
alt = { "FIXME", "BUG", "FIXIT", "ISSUE" }, -- a set of other keywords that all map to this FIX keywords
-- signs = false, -- configure signs for some keywords individually
},
TODO = { icon = " ", color = "info" },
HACK = { icon = " ", color = "warning" },
WARN = { icon = "⚠️", color = "warning", alt = { "WARNING", "XXX" } },
PERF = { icon = " ", alt = { "OPTIM", "PERFORMANCE", "OPTIMIZE" } },
NOTE = { icon = " ", color = "hint", alt = { "INFO" } },
TEST = { icon = "⏲ ", color = "test", alt = { "TESTING", "PASSED", "FAILED" } },
},
gui_style = {
fg = "NONE", -- The gui style to use for the fg highlight group.
bg = "BOLD", -- The gui style to use for the bg highlight group.
},
merge_keywords = true, -- when true, custom keywords will be merged with the defaults
-- highlighting of the line containing the todo comment
-- * before: highlights before the keyword (typically comment characters)
-- * keyword: highlights of the keyword
-- * after: highlights after the keyword (todo text)
highlight = {
multiline = true, -- enable multine todo comments
multiline_pattern = "^.", -- lua pattern to match the next multiline from the start of the matched keyword
multiline_context = 10, -- extra lines that will be re-evaluated when changing a line
before = "", -- "fg" or "bg" or empty
keyword = "wide", -- "fg", "bg", "wide" or empty. (wide is the same as bg, but will also highlight surrounding characters)
after = "fg", -- "fg" or "bg" or empty
-- pattern can be a string, or a table of regexes that will be checked
pattern = [[.*<(KEYWORDS)\s*:]], -- pattern or table of patterns, used for highlightng (vim regex)
-- pattern = { [[.*<(KEYWORDS)\s*:]], [[.*\@(KEYWORDS)\s*]] }, -- pattern used for highlightng (vim regex)
comments_only = true, -- uses treesitter to match keywords in comments only
max_line_len = 400, -- ignore lines longer than this
exclude = {}, -- list of file types to exclude highlighting
throttle = 200,
},
-- list of named colors where we try to extract the guifg from the
-- list of hilight groups or use the hex color if hl not found as a fallback
colors = {
error = { "DiagnosticError", "ErrorMsg", "#DC2626" },
warning = { "DiagnosticWarn", "WarningMsg", "#FBBF24" },
info = { "DiagnosticInfo", "#2563EB" },
hint = { "DiagnosticHint", "#10B981" },
default = { "Identifier", "#7C3AED" },
test = { "Identifier", "#FF00FF" },
},
search = {
command = "rg",
args = {
"--color=never",
"--no-heading",
"--with-filename",
"--line-number",
"--column",
},
-- regex that will be used to match keywords.
-- don't replace the (KEYWORDS) placeholder
pattern = [[\b(KEYWORDS):]], -- ripgrep regex
-- pattern = [[\b(KEYWORDS)\b]], -- match without the extra colon. You'll likely get false positives
},
}
M._options = nil
function M.setup(options)
if vim.fn.has("nvim-0.8.0") == 0 then
error("todo-comments needs Neovim >= 0.8.0. Use the 'neovim-pre-0.8.0' branch for older versions")
end
M._options = options
if vim.api.nvim_get_vvar("vim_did_enter") == 0 then
vim.defer_fn(function()
M._setup()
end, 0)
else
M._setup()
end
end
function M._setup()
M.options = vim.tbl_deep_extend("force", {}, defaults, M.options or {}, M._options or {})
-- -- keywords should always be fully overriden
if M._options and M._options.keywords and M._options.merge_keywords == false then
M.options.keywords = M._options.keywords
end
for kw, opts in pairs(M.options.keywords) do
M.keywords[kw] = kw
for _, alt in pairs(opts.alt or {}) do
M.keywords[alt] = kw
end
end
local function tags(keywords)
local kws = keywords or vim.tbl_keys(M.keywords)
table.sort(kws, function(a, b)
return #b < #a
end)
return table.concat(kws, "|")
end
function M.search_regex(keywords)
return M.options.search.pattern:gsub("KEYWORDS", tags(keywords))
end
M.hl_regex = {}
local patterns = M.options.highlight.pattern
patterns = type(patterns) == "table" and patterns or { patterns }
for _, p in pairs(patterns) do
p = p:gsub("KEYWORDS", tags())
table.insert(M.hl_regex, p)
end
M.colors()
M.signs()
require("todo-comments.highlight").start()
M.loaded = true
end
function M.signs()
for kw, opts in pairs(M.options.keywords) do
vim.fn.sign_define("todo-sign-" .. kw, {
text = opts.icon,
texthl = "TodoSign" .. kw,
})
end
end
function M.colors()
local normal = Util.get_hl("Normal")
local normal_fg = normal.foreground
local normal_bg = normal.background
local default_dark = "#000000"
local default_light = "#FFFFFF"
if not normal_fg and not normal_bg then
normal_fg = default_light
normal_bg = default_dark
elseif not normal_fg then
normal_fg = Util.maximize_contrast(normal_bg, default_dark, default_light)
elseif not normal_bg then
normal_bg = Util.maximize_contrast(normal_fg, default_dark, default_light)
end
local fg_gui = M.options.gui_style.fg
local bg_gui = M.options.gui_style.bg
local sign_hl = Util.get_hl("SignColumn")
local sign_bg = (sign_hl and sign_hl.background) and sign_hl.background or "NONE"
for kw, opts in pairs(M.options.keywords) do
local kw_color = opts.color or "default"
local hex
if kw_color:sub(1, 1) == "#" then
hex = kw_color
else
local colors = M.options.colors[kw_color]
colors = type(colors) == "string" and { colors } or colors
for _, color in pairs(colors) do
if color:sub(1, 1) == "#" then
hex = color
break
end
local c = Util.get_hl(color)
if c and c.foreground then
hex = c.foreground
break
end
end
end
if not hex then
error("Todo: no color for " .. kw)
end
local fg = Util.maximize_contrast(hex, normal_fg, normal_bg)
vim.cmd("hi def TodoBg" .. kw .. " guibg=" .. hex .. " guifg=" .. fg .. " gui=" .. bg_gui)
vim.cmd("hi def TodoFg" .. kw .. " guibg=NONE guifg=" .. hex .. " gui=" .. fg_gui)
vim.cmd("hi def TodoSign" .. kw .. " guibg=" .. sign_bg .. " guifg=" .. hex .. " gui=NONE")
end
end
return M
# Diretórios base
NVIM_CONFIG_DIR = /home/ivan/.config/nvim-pde-local
LAZY_DIR = $(NVIM_CONFIG_DIR)/lazy
# Diretórios de destino específicos
NONE_LS_DIR = $(LAZY_DIR)/none-ls.nvim/lua/null-ls/builtins/formatting
TODO_COMMENTS_DIR = $(LAZY_DIR)/todo-comments.nvim/lua/todo-comments
SNIPPETS_DIR = $(LAZY_DIR)/friendly-snippets/snippets/c
# Diretórios para criação
BAKEFILE_RUNNER_DIR = $(LAZY_DIR)/bakefile_runner
WXPYTHON_RUNNER_DIR = $(LAZY_DIR)/wxpython_runner
CHT_DIR = $(LAZY_DIR)/cht
LLAMMA_DIR = $(LAZY_DIR)/llamma
# Arquivos fonte
AUTOPEP8_SRC = autopep8.lua
ASTYLE_SRC = astyle.lua
XMLFORMATTER_ANDROID_SRC = ./xmlformatter.lua.1
XMLFORMATTER_STD_SRC = ./xmlformatter.lua.2
CONFIG_SRC = config.lua
C_JSON_SRC = c.json
# CLIENT_SRC = client.lua
# Arquivos destino
XMLFORMATTER_ANDROID_DEST = xmlformatter_android.lua
XMLFORMATTER_STD_DEST = xmlformatter_std.lua
# CLIENT_DEST = client.lua
init: clean
echo Abra o vim!
echo execute: make mkdirs copy
mkdirs:
mkdir $(BAKEFILE_RUNNER_DIR)
mkdir $(WXPYTHON_RUNNER_DIR)
mkdir $(CHT_DIR)
mkdir $(LLAMMA_DIR)
copy:
cp $(AUTOPEP8_SRC) $(NONE_LS_DIR)/
cp $(ASTYLE_SRC) $(NONE_LS_DIR)/
cp $(XMLFORMATTER_ANDROID_SRC) $(NONE_LS_DIR)/$(XMLFORMATTER_ANDROID_DEST)
cp $(XMLFORMATTER_STD_SRC) $(NONE_LS_DIR)/$(XMLFORMATTER_STD_DEST)
cp $(CONFIG_SRC) $(TODO_COMMENTS_DIR)/
cp $(C_JSON_SRC) $(SNIPPETS_DIR)/
#cp $(CLIENT_SRC) $(LAZY_DIR)/none-ls.nvim/lua/null-ls/
clean:
rm -rf \
$(LAZY_DIR)/none-ls.nvim \
$(LAZY_DIR)/todo-comments.nvim \
$(LAZY_DIR)/friendly-snippets \
$(LAZY_DIR)/neotemplate.nvim
local h = require("null-ls.helpers")
local methods = require("null-ls.methods")
local FORMATTING = methods.internal.FORMATTING
return h.make_builtin({
name = "xmlformatter",
meta = {
url = "https://github.com/ByteHamster/android-xml-formatter", -- ajuste para o fork/fonte que você usa
description = "Formats XML files according to Android Studio's default formatting rules.",
},
method = FORMATTING,
filetypes = { "xml", "xsd", "xsl", "xslt", "wsdl", "bakefile" },
generator_opts = {
command = "/home/linuxbrew/.linuxbrew/bin/xml-formatter",
args = {
"--indention",
"2",
"--attribute-sort",
"--namespace-sort",
"-",
},
to_stdin = true,
},
factory = h.formatter_factory,
})
local h = require("null-ls.helpers")
local methods = require("null-ls.methods")
local FORMATTING = methods.internal.FORMATTING
return h.make_builtin({
name = "xmlformatter",
meta = {
url = "https://github.com/ByteHamster/android-xml-formatter", -- ajuste para o fork/fonte que você usa
description = "Formats XML files according to Android Studio's default formatting rules.",
},
method = FORMATTING,
filetypes = { "xml", "xsd", "xsl", "xslt", "wsdl", "bakefile" },
generator_opts = {
command = "/home/linuxbrew/.linuxbrew/bin/xml-formatter",
args = {
"--indention",
"2",
"--attribute-sort",
"--namespace-sort",
"-",
},
to_stdin = true,
},
factory = h.formatter_factory,
})
local h = require("null-ls.helpers")
local methods = require("null-ls.methods")
local FORMATTING = methods.internal.FORMATTING
return h.make_builtin({
name = "xmlformat",
meta = {
url = "https://github.com/pamoller/xmlformat", -- ajuste para o fork/fonte que você usa
description = "Formatter para XML com opções de indentação e normalização.",
},
method = FORMATTING,
filetypes = { "xml", "xsd", "xsl", "xslt", "wsdl" },
generator_opts = {
command = "/home/ivan/.config/nvim-pde-local/mason/bin/xmlformat",
args = {
"--indent", "2", -- ajuste aqui se quiser 4
"--selfclose", -- opcional: converte tags vazias para <tag/>
"--eof-newline", -- garante newline no final do arquivo
"-", -- lê de stdin
},
to_stdin = true,
},
factory = h.formatter_factory,
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment