feat(gopls): add formatter/linter config
This commit is contained in:
@@ -1,10 +1,47 @@
|
|||||||
-- spec: https://rust-analyzer.github.io/manual.html#configuration
|
local utils = require("utils")
|
||||||
|
|
||||||
|
---@type ServerConfig
|
||||||
return {
|
return {
|
||||||
enable = true,
|
enable = true,
|
||||||
mason = {
|
mason = { "gopls", dependencies = { "golines", "golangci-lint" } },
|
||||||
name = "gopls",
|
keymaps = {
|
||||||
-- version = "",
|
{
|
||||||
|
mode = "n",
|
||||||
|
lhs = "<leader>lf",
|
||||||
|
rhs = function()
|
||||||
|
utils.format({
|
||||||
|
cmd = { "golines", "-m", "80", "--shorten-comments" },
|
||||||
|
output = "stdout",
|
||||||
|
})
|
||||||
|
vim.lsp.buf.format({ async = true })
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
linters = {
|
||||||
|
{
|
||||||
|
cmd = {
|
||||||
|
"golangci-lint",
|
||||||
|
"run",
|
||||||
|
"--output.json.path=stdout",
|
||||||
|
"--show-stats=false",
|
||||||
|
"%file%",
|
||||||
|
},
|
||||||
|
stdin = true,
|
||||||
|
stdout = true,
|
||||||
|
json = {
|
||||||
|
diagnostics_root = "Issues",
|
||||||
|
source = "FromLinter",
|
||||||
|
message = "Text",
|
||||||
|
lnum = "Pos.Line",
|
||||||
|
col = "Pos.Column",
|
||||||
|
callback = function(diag)
|
||||||
|
if not diag.severity or diag.severity == "" then
|
||||||
|
diag.severity = vim.diagnostic.severity.WARN
|
||||||
|
end
|
||||||
|
utils.debug(vim.inspect(diag))
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
lspconfig = {
|
lspconfig = {
|
||||||
filetypes = {
|
filetypes = {
|
||||||
@@ -13,7 +50,7 @@ return {
|
|||||||
"gowork",
|
"gowork",
|
||||||
"gotmpl",
|
"gotmpl",
|
||||||
},
|
},
|
||||||
cmd = { "gopls", },
|
cmd = { "gopls" },
|
||||||
single_file_support = true,
|
single_file_support = true,
|
||||||
settings = {
|
settings = {
|
||||||
gopls = {
|
gopls = {
|
||||||
@@ -21,7 +58,7 @@ return {
|
|||||||
unusedparams = true,
|
unusedparams = true,
|
||||||
},
|
},
|
||||||
staticcheck = true,
|
staticcheck = true,
|
||||||
gofumpt = true,
|
gofumpt = false,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user