Skip to content

Commit

Permalink
feat(go): add gofumpt formatter with conform/none-ls (#1683)
Browse files Browse the repository at this point in the history
* feat(go): only install required packages

* fix: add gofumpt formatter using conform/none-ls

* fix: add mason.nvim as dependency of none-ls
  • Loading branch information
delatorrejuanchi committed Oct 13, 2023
1 parent c7244d9 commit 385c99d
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions lua/lazyvim/plugins/extras/lang/go.lua
Original file line number Diff line number Diff line change
Expand Up @@ -82,15 +82,32 @@ return {
},
},
-- Ensure Go tools are installed
{
"williamboman/mason.nvim",
opts = function(_, opts)
opts.ensure_installed = opts.ensure_installed or {}
vim.list_extend(opts.ensure_installed, { "goimports", "gofumpt" })
end,
},
{
"nvimtools/none-ls.nvim",
optional = true,
dependencies = {
{
"williamboman/mason.nvim",
opts = function(_, opts)
opts.ensure_installed = opts.ensure_installed or {}
vim.list_extend(opts.ensure_installed, { "gomodifytags", "impl" })
end,
},
},
opts = function(_, opts)
local nls = require("null-ls")
opts.sources = vim.list_extend(opts.sources or {}, {
nls.builtins.code_actions.gomodifytags,
nls.builtins.code_actions.impl,
nls.builtins.formatting.goimports,
nls.builtins.formatting.gofumpt,
})
end,
},
Expand All @@ -99,7 +116,7 @@ return {
optional = true,
opts = {
formatters_by_ft = {
go = { "goimports" },
go = { "goimports", "gofumpt" },
},
},
},
Expand All @@ -108,10 +125,10 @@ return {
optional = true,
dependencies = {
{
"mason.nvim",
"williamboman/mason.nvim",
opts = function(_, opts)
opts.ensure_installed = opts.ensure_installed or {}
vim.list_extend(opts.ensure_installed, { "gomodifytags", "impl", "goimports", "delve" })
vim.list_extend(opts.ensure_installed, { "delve" })
end,
},
{
Expand Down

0 comments on commit 385c99d

Please sign in to comment.