From 5cf651c06cca794eb78886c7f8e62aa72330179a Mon Sep 17 00:00:00 2001 From: Yorick Barbanneau Date: Wed, 20 Aug 2025 21:29:20 +0200 Subject: [PATCH] feat(nvim): add go configurations --- modules/home-manager/cli/neovim/default.nix | 2 ++ modules/home-manager/cli/neovim/files/lsp.lua | 1 + modules/home-manager/cli/neovim/files/lsp/go.lua | 14 ++++++++++++++ .../cli/neovim/files/plugins/conform.lua | 1 + 4 files changed, 18 insertions(+) create mode 100644 modules/home-manager/cli/neovim/files/lsp/go.lua diff --git a/modules/home-manager/cli/neovim/default.nix b/modules/home-manager/cli/neovim/default.nix index 8d59ea3..7ea800d 100644 --- a/modules/home-manager/cli/neovim/default.nix +++ b/modules/home-manager/cli/neovim/default.nix @@ -29,6 +29,7 @@ in home.file."${config.xdg.configHome}/nvim/spell/fr.utf-8.sug".source = nvim-spell-fr-utf8-suggestions; home.file."${config.xdg.configHome}/nvim/lsp/bash.lua".source = ./files/lsp/bash.lua; + home.file."${config.xdg.configHome}/nvim/lsp/go.lua".source = ./files/lsp/go.lua; home.file."${config.xdg.configHome}/nvim/lsp/helm.lua".source = ./files/lsp/helm.lua; home.file."${config.xdg.configHome}/nvim/lsp/lua.lua".source = ./files/lsp/lua.lua; home.file."${config.xdg.configHome}/nvim/lsp/nills.lua".source = ./files/lsp/nills.lua; @@ -47,6 +48,7 @@ in # LSP Servers clang-tools hadolint + gopls helm-ls lua-language-server marksman diff --git a/modules/home-manager/cli/neovim/files/lsp.lua b/modules/home-manager/cli/neovim/files/lsp.lua index 4b2a932..dfa5dee 100644 --- a/modules/home-manager/cli/neovim/files/lsp.lua +++ b/modules/home-manager/cli/neovim/files/lsp.lua @@ -1,5 +1,6 @@ -- LSP configuration vim.lsp.enable('bash') +vim.lsp.enable('go') vim.lsp.enable('helm') vim.lsp.enable('lua') vim.lsp.enable('nills') diff --git a/modules/home-manager/cli/neovim/files/lsp/go.lua b/modules/home-manager/cli/neovim/files/lsp/go.lua new file mode 100644 index 0000000..3f18174 --- /dev/null +++ b/modules/home-manager/cli/neovim/files/lsp/go.lua @@ -0,0 +1,14 @@ +return { + cmd = { "gopls" }, + filetypes = { "go" }, + root_markers = { "go.mod", ".git" }, + settings = { + gopls = { + analyses = { + unusedparams = true, + }, + staticcheck = true, + gofumpt = true, + }, + }, +} diff --git a/modules/home-manager/cli/neovim/files/plugins/conform.lua b/modules/home-manager/cli/neovim/files/plugins/conform.lua index 54ec4f6..5e3c884 100644 --- a/modules/home-manager/cli/neovim/files/plugins/conform.lua +++ b/modules/home-manager/cli/neovim/files/plugins/conform.lua @@ -7,6 +7,7 @@ require("conform").setup({ formatters_by_ft = { yaml = {"yamlfmt"}, sh = { "shfmt" }, + go = { "gofmt" }, ["_"] = { "trim_whitespace" }, } })