local null_ls = require "null-ls" -- local php_actions = require "php-code-actions" -- local laravel_actions = require("laravel.code-actions") null_ls.setup { sources = { -- null_ls.builtins.code_actions.gitsigns, require "none-ls.formatting.jq", -- require("none-ls.diagnostics.cpplint"), require "none-ls.code_actions.eslint", null_ls.builtins.code_actions.refactoring, null_ls.builtins.formatting.alejandra, require "none-ls-luacheck.diagnostics.luacheck", null_ls.builtins.formatting.stylua, require "none-ls.diagnostics.yamllint", -- require("none-ls.diagnostics.ruff"), -- require("none-ls.diagnostics.flake8"), require "none-ls-shellcheck.diagnostics", require "none-ls-shellcheck.code_actions", -- null_ls.builtins.diagnostics.yamllint, -- php_actions.getter_setter, -- php_actions.file_creator, -- null_ls.builtins.diagnostics.phpstan.with { -- to_temp_file = false, -- method = null_ls.methods.DIAGNOSTICS_ON_SAVE, -- -- command = "./bin/phpstan", -- -- condition = function () -- -- return vim.fn.findfile("bin/phpstan") ~= "" -- -- end -- }, null_ls.builtins.diagnostics.phpcs.with { method = null_ls.methods.DIAGNOSTICS_ON_SAVE, condition = function(utils) return utils.root_has_file "phpcs.xml" end, }, null_ls.builtins.formatting.pint, null_ls.builtins.formatting.clang_format, null_ls.builtins.formatting.prettier.with { extra_args = { "--print-width", "100", "--tab-width", "2", "--single-quote", "true", "--trailing-comma", "all", "--arrow-parens", "always", "--semi", "false", "--bracket-spacing", "false", "--jsx-single-quote", "true", "--end-of-line", "lf", }, }, -- Opciones avanzadas de Black: -- --line-length 100: ancho máximo de línea -- --fast: omite comprobaciones de seguridad -- --skip-string-normalization: no cambia comillas -- --skip-magic-trailing-comma: ignora trailing comma mágica -- --target-version py310: versión objetivo de Python 3.10 -- --preview: activa funciones experimentales -- --diff: muestra el diff en vez de modificar archivos -- --quiet: suprime la salida normal -- --color: colorea el diff -- --exclude ".*test.*": excluye archivos que coincidan con el patrón -- null_ls.builtins.formatting.black.with { -- extra_args = { -- "--line-length", -- "120", -- -- "--fast", -- "--skip-string-normalization", -- "--skip-magic-trailing-comma", -- "--target-version", -- "py312", -- -- "--preview", -- -- "--diff", -- -- "--quiet", -- -- "--color", -- "--exclude", -- ".*test.*", -- }, -- }, -- Assembly formatter { name = "asmfmt", method = null_ls.methods.FORMATTING, filetypes = { "asm", "s", "S" }, generator = null_ls.formatter { command = "asmfmt", to_stdin = true, condition = function() return vim.fn.executable "asmfmt" == 1 end, }, }, -- null_ls.builtins.formatting.clang_format.with { -- extra_args = { "--style={IndentWidth: 4}" }, -- }, }, } vim.keymap.set({ "n", "v" }, "vca", vim.lsp.buf.code_action, { desc = "LSP (null ls) Code actions" }) vim.keymap.set("n", "vf", function() return vim.lsp.buf.format { async = true } end, { desc = "LSP (null ls) Format file" }) -- function to toogle and possible restart it vim.api.nvim_create_user_command("NullLsToggle", function() local sources = vim.tbl_map(function(el) return el.name end, null_ls.get_sources()) vim.ui.select(sources, {}, function(selected) if not selected then return end null_ls.toggle(selected) end) end, {})