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
|
||||
require("mason").setup({
|
||||
ui = {
|
||||
|
@ -9,43 +17,75 @@ require("mason").setup({
|
|||
},
|
||||
})
|
||||
|
||||
require("mason-tool-installer").setup({
|
||||
ensure_installed = {
|
||||
"prettier", -- prettier formatter
|
||||
-- "stylua", -- lua formatter
|
||||
"isort", -- python formatter
|
||||
"black", -- python formatter
|
||||
"pylint", -- python linter
|
||||
"eslint_d", -- js linter
|
||||
require("mason-lspconfig").setup({
|
||||
ensure_installed = {},
|
||||
handlers = {
|
||||
default_setup,
|
||||
-- lua_ls = function()
|
||||
-- require("lspconfig").eslint.setup({
|
||||
-- capabilities = lsp_capabilities,
|
||||
-- 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 lsp_capabilities = require("cmp_nvim_lsp").default_capabilities()
|
||||
for _, lsp in pairs(lsps_for_install) do
|
||||
lspconfig[lsp].setup {
|
||||
capabilities = lsp_capabilities,
|
||||
}
|
||||
end
|
||||
local cmp = require("cmp")
|
||||
|
||||
|
||||
|
||||
lspconfig.lua_ls.setup {
|
||||
capabilities = lsp_capabilities,
|
||||
settings = {
|
||||
Lua = {
|
||||
diagnostics = {
|
||||
globals = { "vim" },
|
||||
},
|
||||
},
|
||||
cmp.setup({
|
||||
sources = {
|
||||
{ name = "nvim_lsp" },
|
||||
},
|
||||
}
|
||||
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",
|
||||
"BufNewFile",
|
||||
},
|
||||
|
||||
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")
|
||||
lint.linters_by_ft = {
|
||||
javascript = { "eslint_d" },
|
||||
typescript = { "eslint_d" },
|
||||
javascriptreact = { "eslint_d" },
|
||||
typescriptreact = { "eslint_d" },
|
||||
svelte = { "eslint_d" },
|
||||
javascript = { "biomejs" },
|
||||
typescript = { "biomejs" },
|
||||
javascriptreact = { "biomejs" },
|
||||
typescriptreact = { "biomejs" },
|
||||
svelte = { "biomejs" },
|
||||
python = { "pylint" },
|
||||
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 })
|
||||
|
||||
|
@ -38,7 +63,7 @@ return {
|
|||
"WhoIsSethDaniel/toggle-lsp-diagnostics.nvim",
|
||||
config = function()
|
||||
require("toggle_lsp_diagnostics").init({
|
||||
start_on = false,
|
||||
start_on = true,
|
||||
})
|
||||
end,
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue