End of config for now
This commit is contained in:
83
lua/config/lsp/web.lua
Normal file
83
lua/config/lsp/web.lua
Normal file
@@ -0,0 +1,83 @@
|
||||
local ok, mason_lspconfig, mason_tool_installer, lspconfig, conform, lint = pcall(function()
|
||||
return require("mason-lspconfig"),
|
||||
require("mason-tool-installer"),
|
||||
require("lspconfig"),
|
||||
require("conform"),
|
||||
require("lint")
|
||||
end)
|
||||
|
||||
if not ok then
|
||||
return
|
||||
end
|
||||
|
||||
mason_lspconfig.setup({
|
||||
ensure_installed = {
|
||||
"tsserver",
|
||||
"html",
|
||||
"emmet_ls",
|
||||
"cssls",
|
||||
},
|
||||
})
|
||||
|
||||
lspconfig.tsserver.setup({
|
||||
capabilities = require("config/lsp/capabilities"),
|
||||
on_attach = require("config/lsp/attach"),
|
||||
})
|
||||
|
||||
lspconfig.html.setup({
|
||||
capabilities = require("config/lsp/capabilities"),
|
||||
on_attach = require("config/lsp/attach"),
|
||||
})
|
||||
|
||||
lspconfig.emmet_ls.setup({
|
||||
capabilities = require("config/lsp/capabilities"),
|
||||
on_attach = require("config/lsp/attach"),
|
||||
})
|
||||
|
||||
lspconfig.cssls.setup({
|
||||
capabilities = require("config/lsp/capabilities"),
|
||||
on_attach = require("config/lsp/attach"),
|
||||
})
|
||||
|
||||
mason_tool_installer.setup({
|
||||
ensure_installed = {
|
||||
"prettierd",
|
||||
"prettier",
|
||||
"eslint_d",
|
||||
},
|
||||
})
|
||||
|
||||
conform.setup({
|
||||
formatters_by_ft = {
|
||||
javascript = { { "prettierd", "prettier" } },
|
||||
json = { { "prettierd", "prettier" } },
|
||||
},
|
||||
format_on_save = {
|
||||
async = false,
|
||||
timeout_ms = 500,
|
||||
lsp_fallback = true,
|
||||
},
|
||||
})
|
||||
|
||||
vim.keymap.set({ "n", "v" }, "<leader>lf", function()
|
||||
conform.format({
|
||||
async = false,
|
||||
timeout_ms = 500,
|
||||
lsp_fallback = true,
|
||||
})
|
||||
end, { desc = "Format" })
|
||||
|
||||
lint.linters_by_ft = {
|
||||
javascript = { "eslint_d" },
|
||||
json = { "eslint_d" },
|
||||
}
|
||||
|
||||
vim.api.nvim_create_autocmd({ "BufEnter", "BufWritePost", "InsertLeave" }, {
|
||||
callback = function()
|
||||
lint.try_lint()
|
||||
end,
|
||||
})
|
||||
|
||||
vim.keymap.set("n", "<leader>ll", function()
|
||||
lint.try_lint()
|
||||
end, { desc = "Lint" })
|
||||
Reference in New Issue
Block a user