mirror of
https://github.com/LazyVim/LazyVim.git
synced 2026-07-25 14:01:06 +00:00
62 lines
1.6 KiB
Lua
62 lines
1.6 KiB
Lua
if lazyvim_docs then
|
|
-- Set to false to disable auto format
|
|
vim.g.lazyvim_eslint_auto_format = true
|
|
vim.g.lazyvim_eslint_auto_fix_all = true
|
|
end
|
|
|
|
local auto_format = vim.g.lazyvim_eslint_auto_format == nil or vim.g.lazyvim_eslint_auto_format
|
|
local auto_fix_all = vim.g.lazyvim_eslint_auto_fix_all == nil or vim.g.lazyvim_eslint_auto_fix_all
|
|
|
|
return {
|
|
{
|
|
"neovim/nvim-lspconfig",
|
|
-- other settings removed for brevity
|
|
opts = {
|
|
---@type table<string, vim.lsp.Config>
|
|
servers = {
|
|
eslint = {
|
|
settings = {
|
|
-- helps eslint find the eslintrc when it's placed in a subfolder instead of the cwd root
|
|
workingDirectories = { mode = "auto" },
|
|
format = auto_format,
|
|
codeActionOnSave = {
|
|
enable = true,
|
|
mode = "all",
|
|
},
|
|
validate = "on",
|
|
probe = {
|
|
"javascript",
|
|
"javascriptreact",
|
|
"typescript",
|
|
"typescriptreact",
|
|
"vue",
|
|
"html",
|
|
"markdown",
|
|
"json",
|
|
"jsonc",
|
|
},
|
|
autoFixOnSave = auto_fix_all,
|
|
quiet = false,
|
|
},
|
|
},
|
|
},
|
|
setup = {
|
|
eslint = function()
|
|
if not auto_format then
|
|
return
|
|
end
|
|
|
|
local formatter = LazyVim.lsp.formatter({
|
|
name = "eslint: lsp",
|
|
primary = false,
|
|
priority = 200,
|
|
filter = "eslint",
|
|
})
|
|
|
|
-- register the formatter with LazyVim
|
|
LazyVim.format.register(formatter)
|
|
end,
|
|
},
|
|
},
|
|
},
|
|
}
|