feat: moved linting and formatting to plugins

This commit is contained in:
Devin Lumley 2024-01-09 17:06:19 -08:00
parent 9f98fb46ce
commit 0dcc4fa0ed
3 changed files with 70 additions and 12 deletions

View file

@ -2,14 +2,14 @@ return {
{
"williamboman/mason.nvim",
config = function()
require("mason").setup()
require("mason").setup()
end
},
{
"williamboman/mason-lspconfig.nvim",
config = function()
require("mason-lspconfig").setup({
ensure_installed = { "lua_ls", "tsserver", "eslint" }
ensure_installed = { "lua_ls", "tsserver" }
})
end
},
@ -27,21 +27,50 @@ return {
capabilities = capabilities
})
-- Runs :EslintFixAll when saving
lspconfig.eslint.setup({
on_attach = function(_, bufnr)
vim.api.nvim_create_autocmd("BufWritePre", {
buffer = bufnr,
command = "EslintFixAll",
})
end
})
vim.keymap.set('n', 'gd', vim.lsp.buf.definition, { desc = "Go to definition" })
vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, { desc = "Go to implementation" })
vim.keymap.set('n', 'K', vim.lsp.buf.hover, { desc = "Show signature" })
vim.keymap.set('n', '<Leader>f', vim.lsp.buf.format, { desc = "Format buffer" })
vim.keymap.set('n', '<Leader>ca', vim.lsp.buf.code_action, { desc = "View code actions" })
end
},
{
"WhoIsSethDaniel/mason-tool-installer.nvim",
config = function()
local mason_tool_installer = require("mason-tool-installer")
mason_tool_installer.setup({
ensure_installed = {
"prettierd",
"eslint_d",
},
automatic_installation = true
})
end
},
{
"stevearc/conform.nvim",
opts = {
formatters_by_ft = {
lua = { "stylua" },
javascript = { "eslint_d" },
javascriptreact = { "eslint_d" },
json = { "prettierd" },
jsonc = { "prettierd" },
yaml = { "prettierd" },
typescript = { "eslint_d" },
typescriptreact = { "eslint_d" },
html = { "prettierd" },
ejs = { "prettierd" },
css = { "prettierd" },
scss = { "prettierd" },
graphql = { "prettierd" },
markdown = { "prettierd" },
["_"] = { "trim_whitespace" },
},
format_on_save = {
lsp_fallback = true,
},
},
}
}