From 4d10724f9318945d33fadd1d993971646821defd Mon Sep 17 00:00:00 2001 From: Daniel Heras Quesada Date: Sun, 3 May 2026 23:01:50 +0200 Subject: [PATCH] chore: eslint and mason setup --- lazy-lock.json | 1 + lua/plugins/code-utils.lua | 10 ++--- lua/plugins/linter.lua | 45 ++++++++++++++++++++++ lua/plugins/opts/conformFormat.lua | 62 +++++++++++++++--------------- lua/plugins/qol.lua | 27 +++++++++++++ 5 files changed, 109 insertions(+), 36 deletions(-) create mode 100644 lua/plugins/linter.lua diff --git a/lazy-lock.json b/lazy-lock.json index 195e830..b9e6290 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -19,6 +19,7 @@ "komau.vim": { "branch": "master", "commit": "4666b5b15f4ab3f6f59f6aae13a394f9e8652767" }, "lazy.nvim": { "branch": "main", "commit": "306a05526ada86a7b30af95c5cc81ffba93fef97" }, "lualine.nvim": { "branch": "master", "commit": "131a558e13f9f28b15cd235557150ccb23f89286" }, + "mason.nvim": { "branch": "main", "commit": "cb8445f8ce85d957416c106b780efd51c6298f89" }, "mini.clue": { "branch": "main", "commit": "43bd6cf1c3ccdea46d403c32dbc4629fa6afa09d" }, "mini.icons": { "branch": "main", "commit": "bac6317300e205335df425296570d84322730067" }, "neo-tree.nvim": { "branch": "main", "commit": "19d20a99bf0061a5ecc4343d2f09fa713306c965" }, diff --git a/lua/plugins/code-utils.lua b/lua/plugins/code-utils.lua index 0ec62c0..d14ddaf 100644 --- a/lua/plugins/code-utils.lua +++ b/lua/plugins/code-utils.lua @@ -39,7 +39,7 @@ return { nerd_font_variant = "mono", }, completion = { - accept = { auto_brackets = { enabled = false }, }, + accept = { auto_brackets = { enabled = false } }, list = { selection = { preselect = false, auto_insert = true } }, menu = { auto_show = true, @@ -47,10 +47,10 @@ return { -- nvim-cmp style menu draw = { columns = { - { "label", "label_description", gap = 1 }, - { "kind_icon", "kind" } + { "label", "label_description", gap = 1 }, + { "kind_icon", "kind" }, }, - } + }, }, -- Show documentation when selecting a completion item @@ -79,7 +79,7 @@ return { }, { - 'm4xshen/autoclose.nvim', + "m4xshen/autoclose.nvim", opts = function() return require("plugins.opts.autoclose") end, diff --git a/lua/plugins/linter.lua b/lua/plugins/linter.lua new file mode 100644 index 0000000..1b8e688 --- /dev/null +++ b/lua/plugins/linter.lua @@ -0,0 +1,45 @@ +return { + { + "mfussenegger/nvim-lint", + events = { "BufWritePost", "BufReadPost", "InsertLeave" }, + opts = { + linters_by_ft = { + fish = { "fish" }, + css = { "stylelint" }, + scss = { "stylelint" }, + ts = { "eslint_d" }, + js = { "eslint_d" }, + jsx = { "eslint_d" }, + tsx = { "eslint_d" }, + -- Use the "*" filetype to run linters on all filetypes. + -- ['*'] = { 'global linter' }, + -- Use the "_" filetype to run linters on filetypes that don't have other linters configured. + -- ['_'] = { 'fallback linter' }, + -- ["*"] = { "typos" }, + }, + }, + + config = function() + local lint = require("lint") + + lint.linters_by_ft = { + javascript = { "biomejs" }, + typescript = { "eslint_d" }, + javascriptreact = { "biomejs" }, + typescriptreact = { "biomejs" }, + svelte = { "biomejs" }, + python = { "ruff" }, + go = { "golangcilint" }, + } + + local lint_augroup = vim.api.nvim_create_augroup("lint", { clear = true }) + + vim.api.nvim_create_autocmd({ "BufEnter", "BufWritePost", "InsertLeave" }, { + group = lint_augroup, + callback = function() + lint.try_lint() + end, + }) + end, + }, +} diff --git a/lua/plugins/opts/conformFormat.lua b/lua/plugins/opts/conformFormat.lua index faa10fa..f059ca4 100644 --- a/lua/plugins/opts/conformFormat.lua +++ b/lua/plugins/opts/conformFormat.lua @@ -1,35 +1,35 @@ local config = { - -- Define your formatters - formatters_by_ft = { - rust = { "rustfmt" }, - lua = { "stylua" }, - go = { "goimports", "gofmt" }, - javascript = { "prettierd", "prettier", "biome", stop_after_first = true }, - javascriptreact = { "prettierd", "prettier", "biome", stop_after_first = true }, - typescript = { "prettierd", "prettier", "biome", stop_after_first = true }, - typescriptreact = { "prettierd", "prettier", "biome", stop_after_first = true }, - css = { "prettierd", "prettier", "biome", stop_after_first = true }, - scss = { "prettierd", "prettier", "biome", stop_after_first = true }, - -- python = function(bufnr) - -- if require("conform").get_formatter_info("ruff_format", bufnr).available then - -- return { "ruff_format" } - -- else - -- return { "isort", "black" } - -- end - -- end, - ["_"] = { "trim_whitespace" }, -- run only on filetypes without formater - -- ["*"] = { "trim_whitespace" }, -- run in all filetypes - }, - format_on_save = { - timeout_ms = 500, - lsp_format = "fallback", - }, - -- Customize formatters - formatters = { - shfmt = { - prepend_args = { "-i", "2" }, - }, - }, + -- Define your formatters + formatters_by_ft = { + rust = { "rustfmt" }, + lua = { "stylua" }, + go = { "goimports", "gofmt" }, + javascript = { "prettierd", "prettier", "biome", stop_after_first = true }, + javascriptreact = { "prettierd", "prettier", "biome", stop_after_first = true }, + typescript = { "prettierd", "prettier", "biome", stop_after_first = true }, + typescriptreact = { "prettierd", "prettier", "biome", stop_after_first = true }, + css = { "prettierd", "prettier", "biome", stop_after_first = true }, + scss = { "prettierd", "prettier", "biome", stop_after_first = true }, + -- python = function(bufnr) + -- if require("conform").get_formatter_info("ruff_format", bufnr).available then + -- return { "ruff_format" } + -- else + -- return { "isort", "black" } + -- end + -- end, + ["_"] = { "trim_whitespace" }, -- run only on filetypes without formater + -- ["*"] = { "trim_whitespace" }, -- run in all filetypes + }, + format_on_save = { + timeout_ms = 500, + lsp_format = "fallback", + }, + -- Customize formatters + formatters = { + shfmt = { + prepend_args = { "-i", "2" }, + }, + }, } return config diff --git a/lua/plugins/qol.lua b/lua/plugins/qol.lua index 055eaaa..99e06ad 100644 --- a/lua/plugins/qol.lua +++ b/lua/plugins/qol.lua @@ -1,4 +1,31 @@ local config = { + { + "mason-org/mason.nvim", + opts = { + ui = { + icons = { + package_installed = "✓", + package_pending = "➜", + package_uninstalled = "✗" + } + }, + ensure_isntalled = { + lsp = { + "typescript-language-server", + "eslint-lsp" + }, + dap = { + }, + linter = { + "eslint_d" + }, + formatter = { + "prettier" + } + } + } + } + , { "folke/snacks.nvim", priority = 1000,