Skip to content

Go Extra

lang.go adds Go language support while leaving project configuration in the repository. Use go.mod, golangci.yml, and standard Go toolchain files for project policy.

Enable it

-- ~/.config/blak/lua/blak/user.lua
return {
extras = {
enabled = {
"lang.go",
},
},
}

Or enable it interactively:

:BlakExtras enable lang.go

What it adds

SurfaceContribution
Treesittergo, gomod, gosum, gowork
Masongoimports, gofumpt, golangci-lint
LSPgopls
Formattinggoimports, then gofumpt, for go
Lintinggolangcilint for go

Configure gopls

Add gopls settings under lsp.servers.gopls:

return {
extras = {
enabled = { "lang.go" },
},
lsp = {
servers = {
gopls = {
settings = {
gopls = {
staticcheck = true,
analyses = {
unusedparams = true,
shadow = true,
},
},
},
},
},
},
}

Configure formatting

The default import and formatting chain is:

return {
extras = {
enabled = { "lang.go" },
},
format = {
formatters_by_ft = {
go = { "goimports", "gofumpt" },
},
},
}

If your team only wants gofmt through LSP, override the Go formatter entry:

return {
extras = {
enabled = { "lang.go" },
},
format = {
formatters_by_ft = {
go = { lsp_format = "fallback" },
},
},
}

Configure linting

The extra maps Go files to nvim-lint’s golangcilint linter. Disable it with an empty list when a project uses only LSP diagnostics:

return {
extras = {
enabled = { "lang.go" },
},
lint = {
linters_by_ft = {
go = {},
},
},
}

Install and verify

:BlakToolsInstall
:BlakTreesitterInstall
:BlakDoctor

Open a Go file and check :LspInfo for gopls.