fix js linting
This commit is contained in:
parent
465540484d
commit
947508b8b2
|
@ -1,3 +1,11 @@
|
||||||
|
local lsp_capabilities = require("cmp_nvim_lsp").default_capabilities()
|
||||||
|
|
||||||
|
local default_setup = function(server)
|
||||||
|
require("lspconfig")[server].setup({
|
||||||
|
capabilities = lsp_capabilities,
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
-- enable mason and configure icons
|
-- enable mason and configure icons
|
||||||
require("mason").setup({
|
require("mason").setup({
|
||||||
ui = {
|
ui = {
|
||||||
|
@ -9,43 +17,75 @@ require("mason").setup({
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
require("mason-tool-installer").setup({
|
require("mason-lspconfig").setup({
|
||||||
ensure_installed = {
|
ensure_installed = {},
|
||||||
"prettier", -- prettier formatter
|
handlers = {
|
||||||
-- "stylua", -- lua formatter
|
default_setup,
|
||||||
"isort", -- python formatter
|
-- lua_ls = function()
|
||||||
"black", -- python formatter
|
-- require("lspconfig").eslint.setup({
|
||||||
"pylint", -- python linter
|
-- capabilities = lsp_capabilities,
|
||||||
"eslint_d", -- js linter
|
-- args = {
|
||||||
|
-- "--no-warn-ignored", -- <-- this is the key argument
|
||||||
|
-- "--format",
|
||||||
|
-- "json",
|
||||||
|
-- "--stdin",
|
||||||
|
-- "--stdin-filename",
|
||||||
|
-- function()
|
||||||
|
-- return vim.api.nvim_buf_get_name(0)
|
||||||
|
-- end,
|
||||||
|
-- },
|
||||||
|
-- })
|
||||||
|
-- end,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
--#################################################################################
|
|
||||||
--##### THESE ARE THE LANGUAGE SERVERS WE WANT
|
|
||||||
--#################################################################################
|
|
||||||
local lsps_for_install = { "eslint", "html", "cssls", "bashls", "grammarly" }
|
|
||||||
--make this table 2d to add configs
|
|
||||||
local mason_lspconfig = require("mason-lspconfig")
|
|
||||||
mason_lspconfig.setup {
|
|
||||||
ensure_installed = lsps_for_install
|
|
||||||
}
|
|
||||||
|
|
||||||
local lspconfig = require("lspconfig")
|
local cmp = require("cmp")
|
||||||
local lsp_capabilities = require("cmp_nvim_lsp").default_capabilities()
|
|
||||||
for _, lsp in pairs(lsps_for_install) do
|
|
||||||
lspconfig[lsp].setup {
|
|
||||||
capabilities = lsp_capabilities,
|
|
||||||
}
|
|
||||||
end
|
|
||||||
|
|
||||||
|
cmp.setup({
|
||||||
|
sources = {
|
||||||
lspconfig.lua_ls.setup {
|
{ name = "nvim_lsp" },
|
||||||
capabilities = lsp_capabilities,
|
|
||||||
settings = {
|
|
||||||
Lua = {
|
|
||||||
diagnostics = {
|
|
||||||
globals = { "vim" },
|
|
||||||
},
|
},
|
||||||
|
mapping = cmp.mapping.preset.insert({
|
||||||
|
-- Enter key confirms completion item
|
||||||
|
["<CR>"] = cmp.mapping.confirm({ select = false }),
|
||||||
|
|
||||||
|
-- Ctrl + space triggers completion menu
|
||||||
|
["<C-Space>"] = cmp.mapping.complete(),
|
||||||
|
}),
|
||||||
|
snippet = {
|
||||||
|
expand = function(args)
|
||||||
|
require("luasnip").lsp_expand(args.body)
|
||||||
|
end,
|
||||||
},
|
},
|
||||||
},
|
})
|
||||||
}
|
|
||||||
|
-- local lsps_for_install = { --[[ "eslint", ]]
|
||||||
|
-- "html",
|
||||||
|
-- "cssls",
|
||||||
|
-- "bashls",
|
||||||
|
-- "grammarly",
|
||||||
|
-- }
|
||||||
|
-- --make this table 2d to add configs
|
||||||
|
-- local mason_lspconfig = require("mason-lspconfig")
|
||||||
|
-- mason_lspconfig.setup({
|
||||||
|
-- ensure_installed = lsps_for_install,
|
||||||
|
-- })
|
||||||
|
--
|
||||||
|
-- local lspconfig = require("lspconfig")
|
||||||
|
-- local lsp_capabilities = require("cmp_nvim_lsp").default_capabilities()
|
||||||
|
-- for _, lsp in pairs(lsps_for_install) do
|
||||||
|
-- lspconfig[lsp].setup({
|
||||||
|
-- capabilities = lsp_capabilities,
|
||||||
|
-- })
|
||||||
|
-- end
|
||||||
|
--
|
||||||
|
-- lspconfig.lua_ls.setup({
|
||||||
|
-- capabilities = lsp_capabilities,
|
||||||
|
-- settings = {
|
||||||
|
-- Lua = {
|
||||||
|
-- diagnostics = {
|
||||||
|
-- globals = { "vim" },
|
||||||
|
-- },
|
||||||
|
-- },
|
||||||
|
-- },
|
||||||
|
-- })
|
||||||
|
|
|
@ -5,17 +5,42 @@ return {
|
||||||
"BufReadPre",
|
"BufReadPre",
|
||||||
"BufNewFile",
|
"BufNewFile",
|
||||||
},
|
},
|
||||||
|
|
||||||
config = function()
|
config = function()
|
||||||
|
require("mason-tool-installer").setup({
|
||||||
|
ensure_installed = {
|
||||||
|
"prettier", -- prettier formatter
|
||||||
|
-- "stylua", -- lua formatter
|
||||||
|
"isort", -- python formatter
|
||||||
|
"black", -- python formatter
|
||||||
|
"pylint", -- python linter
|
||||||
|
"biome", -- js linter
|
||||||
|
},
|
||||||
|
})
|
||||||
local lint = require("lint")
|
local lint = require("lint")
|
||||||
lint.linters_by_ft = {
|
lint.linters_by_ft = {
|
||||||
javascript = { "eslint_d" },
|
javascript = { "biomejs" },
|
||||||
typescript = { "eslint_d" },
|
typescript = { "biomejs" },
|
||||||
javascriptreact = { "eslint_d" },
|
javascriptreact = { "biomejs" },
|
||||||
typescriptreact = { "eslint_d" },
|
typescriptreact = { "biomejs" },
|
||||||
svelte = { "eslint_d" },
|
svelte = { "biomejs" },
|
||||||
python = { "pylint" },
|
python = { "pylint" },
|
||||||
markdown = { "proselint" },
|
markdown = { "proselint" },
|
||||||
}
|
}
|
||||||
|
--###### ESLINT HACK ######
|
||||||
|
local eslint = lint.linters.eslint_d
|
||||||
|
|
||||||
|
eslint.args = {
|
||||||
|
"--no-warn-ignored", -- <-- this is the key argument
|
||||||
|
"--format",
|
||||||
|
"json",
|
||||||
|
"--stdin",
|
||||||
|
"--stdin-filename",
|
||||||
|
function()
|
||||||
|
return vim.api.nvim_buf_get_name(0)
|
||||||
|
end,
|
||||||
|
}
|
||||||
|
--##### END ESLINT HACK ######
|
||||||
|
|
||||||
local lint_augroup = vim.api.nvim_create_augroup("lint", { clear = true })
|
local lint_augroup = vim.api.nvim_create_augroup("lint", { clear = true })
|
||||||
|
|
||||||
|
@ -38,7 +63,7 @@ return {
|
||||||
"WhoIsSethDaniel/toggle-lsp-diagnostics.nvim",
|
"WhoIsSethDaniel/toggle-lsp-diagnostics.nvim",
|
||||||
config = function()
|
config = function()
|
||||||
require("toggle_lsp_diagnostics").init({
|
require("toggle_lsp_diagnostics").init({
|
||||||
start_on = false,
|
start_on = true,
|
||||||
})
|
})
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue