Skip to content

Commit

Permalink
feat(typescript): Move eslint-lsp to the proper plugin, and add autoc…
Browse files Browse the repository at this point in the history
…md to format on save (#683)

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

* Update lua/astrocommunity/pack/typescript/init.lua

Co-authored-by: Micah Halter <[email protected]>

* Update lua/astrocommunity/pack/typescript/init.lua

* Update lua/astrocommunity/pack/typescript/init.lua

---------

Co-authored-by: Micah Halter <[email protected]>
  • Loading branch information
Uzaaft and mehalter committed Dec 20, 2023
1 parent aa41c50 commit bb4e7db
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions lua/astrocommunity/pack/typescript/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,26 @@ return {
},
{
"williamboman/mason-lspconfig.nvim",
optional = true,
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", {
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

0 comments on commit bb4e7db

Please sign in to comment.