Skip to content

Commit 31f5f69

Browse files
committed
Configure gopls
1 parent 689a804 commit 31f5f69

File tree

1 file changed

+41
-3
lines changed

1 file changed

+41
-3
lines changed

home-manager/modules/dev-golang.nix

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,47 @@ in
5757
};
5858

5959
simonswine.neovim = {
60-
lspconfig.gopls.cmd = [
61-
"${pkgs.gopls}/bin/gopls"
62-
];
60+
lspconfig.gopls = {
61+
cmd = [
62+
"${pkgs.gopls}/bin/gopls"
63+
];
64+
gopls = {
65+
# general settings
66+
# https://github.com/golang/tools/blob/master/gopls/doc/settings.md
67+
gofumpt = true;
68+
analyses = {
69+
# analyzers settings
70+
# https://github.com/golang/tools/blob/master/gopls/doc/analyzers.md
71+
fieldalignment = true;
72+
nilness = true;
73+
shadow = true;
74+
unusedparams = true;
75+
unusedwrite = true;
76+
useany = true;
77+
unusedvariable = true;
78+
};
79+
# use linters from staticcheck.io
80+
staticcheck = true;
81+
# diagnostics reported by the gc_details command
82+
annotations = {
83+
bounds = true;
84+
escape = true;
85+
inline = true;
86+
nil = true;
87+
};
88+
hints = {
89+
# inlayhints settings
90+
# https://github.com/golang/tools/blob/master/gopls/doc/inlayHints.md
91+
assignVariableTypes = true;
92+
compositeLiteralFields = true;
93+
compositeLiteralTypes = true;
94+
constantValues = true;
95+
functionTypeParameters = true;
96+
parameterNames = true;
97+
rangeVariableTypes = true;
98+
};
99+
};
100+
};
63101
lspconfig.golangci_lint_ls.cmd = [
64102
"${pkgs.golangci-lint-langserver}/bin/golangci-lint-langserver"
65103
];

0 commit comments

Comments
 (0)