From c6a388aeef9f7a8832c4860316a14ce680c039d5 Mon Sep 17 00:00:00 2001 From: ache Date: Fri, 9 Aug 2024 06:00:41 +0200 Subject: Lintting ESLint without config --- lua/ache/plugins/linting.lua | 59 +++++++++++++++++++++++++++----------------- 1 file changed, 37 insertions(+), 22 deletions(-) diff --git a/lua/ache/plugins/linting.lua b/lua/ache/plugins/linting.lua index 253107e..e6be595 100644 --- a/lua/ache/plugins/linting.lua +++ b/lua/ache/plugins/linting.lua @@ -1,28 +1,43 @@ +-- TODO: Add explaination of how to configure and how does it works +-- return { - "mfussenegger/nvim-lint", - event = { "BufReadPre", "BufNewFile" }, - config = function() - local lint = require("lint") + "mfussenegger/nvim-lint", + event = { "BufReadPre", "BufNewFile" }, + config = function() + local lint = require("lint") - lint.linters_by_ft = { - javascript = { "eslint_d" }, - typescript = { "eslint_d" }, - svelte = { "eslint_d" }, - python = { "ruff" }, - } + lint.linters_by_ft = { + javascript = { "eslint_d" }, + typescript = { "eslint_d" }, + svelte = { "eslint_d" }, + python = { "ruff" }, + } - local lint_augroup = vim.api.nvim_create_augroup("lint", { clear = true }) + local lint_augroup = vim.api.nvim_create_augroup("lint", { clear = true }) + local eslint = lint.linters.eslint_d - vim.api.nvim_create_autocmd({ "BufEnter", "BufWritePost", "InsertLeave" }, { - group = lint_augroup, - callback = function() - lint.try_lint() - end, - }) + -- To ignore missing configuration + eslint.args = { + "--no-warn-ignored", + "--format", + "json", + "--stdin", + "--stdin-filename", + function() + return vim.api.nvim_buf_get_name(0) + end, + } - vim.keymap.set("n", "l", function() - lint.try_lint() - -- TODO: Linting for file or buffer ? - end, { desc = "Trigger linting for current file" }) - end, + vim.api.nvim_create_autocmd({ "BufEnter", "BufWritePost", "InsertLeave" }, { + group = lint_augroup, + callback = function() + lint.try_lint() + end, + }) + + vim.keymap.set("n", "l", function() + lint.try_lint() + -- TODO: Linting for file or buffer ? + end, { desc = "Trigger linting for current file" }) + end, } -- cgit v1.3-2-g11bf