Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(typescript): Move eslint-lsp to the proper plugin, and add autocmd to format on save #683

Merged
merged 4 commits into from
Dec 15, 2023
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion lua/astrocommunity/pack/typescript/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,25 @@ return {
},
{
"williamboman/mason-lspconfig.nvim",
opts = function(_, opts) opts.ensure_installed = utils.list_insert_unique(opts.ensure_installed, "tsserver") end,
opts = function(_, opts)
opts.ensure_installed = utils.list_insert_unique(opts.ensure_installed, "tsserver", "eslint")
vim.api.nvim_create_autocmd("LspAttach", {
mehalter marked this conversation as resolved.
Show resolved Hide resolved
group = vim.api.nvim_create_augroup("eslint_fix_creator", { clear = true }),
desc = "Create autocommand in buffers where eslint attaches",
callback = function(args)
if assert(vim.lsp.get_client_by_id(args.data.client_id)).name == "eslint" then
vim.api.nvim_create_autocmd("BufWritePost", {
desc = "Fix all eslint errors",
buffer = args.buf,
group = vim.api.nvim_create_augroup(("eslint_fix_%d"):format(args.buf), { clear = true }),
callback = function()
if vim.fn.exists ":EslintFixAll" > 0 then vim.cmd.EslintFixAll() end
end,
})
end
end,
})
end,
},
{
"jay-babu/mason-null-ls.nvim",
Expand Down