From 091e9228ef0d4db33f95f0078dbe5848dd672472 Mon Sep 17 00:00:00 2001 From: Matthew Lemon Date: Sun, 14 May 2023 19:38:34 +0100 Subject: Adds go functionality --- nvim/lua/user/go.lua | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 nvim/lua/user/go.lua (limited to 'nvim/lua') diff --git a/nvim/lua/user/go.lua b/nvim/lua/user/go.lua new file mode 100644 index 0000000..9ee8d6b --- /dev/null +++ b/nvim/lua/user/go.lua @@ -0,0 +1,26 @@ +local M = { + "ray-x/go.nvim", + dependencies = { -- optional packages + "ray-x/guihua.lua", + "neovim/nvim-lspconfig", + "nvim-treesitter/nvim-treesitter", + }, + event = {"CmdlineEnter"}, + ft = {"go", 'gomod'}, + build = ':lua require("go.install").update_all_sync()' -- if you need to install/update all binaries +} + +function M.config() + -- Run gofmt on save + require("go").setup() + local format_sync_grp = vim.api.nvim_create_augroup("GoFormat", {}) + vim.api.nvim_create_autocmd("BufWritePre", { + pattern = "*.go", + callback = function() + require('go.format').gofmt() + end, + group = format_sync_grp, + }) +end + +return M -- cgit v1.2.3