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/lazy-lock.json | 2 ++ nvim/lua/user/go.lua | 26 ++++++++++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 nvim/lua/user/go.lua (limited to 'nvim') diff --git a/nvim/lazy-lock.json b/nvim/lazy-lock.json index 8fac5bb..f7830cf 100644 --- a/nvim/lazy-lock.json +++ b/nvim/lazy-lock.json @@ -13,6 +13,8 @@ "cmp_luasnip": { "branch": "master", "commit": "18095520391186d634a0045dacaa346291096566" }, "friendly-snippets": { "branch": "main", "commit": "a6f7a1609addb4e57daa6bedc300f77f8d225ab7" }, "gitsigns.nvim": { "branch": "main", "commit": "ec4742a7eebf68bec663041d359b95637242b5c3" }, + "go.nvim": { "branch": "master", "commit": "b119217e8324f13a2be12935f5d2d15a1df09b09" }, + "guihua.lua": { "branch": "master", "commit": "ab8b1f09603cc268770efd057115035dc6cfa83d" }, "indent-blankline.nvim": { "branch": "master", "commit": "8299fe7703dfff4b1752aeed271c3b95281a952d" }, "lazy.nvim": { "branch": "main", "commit": "aba872ec78ffe7f7367764ab0fff6f0170421fde" }, "lualine.nvim": { "branch": "master", "commit": "0050b308552e45f7128f399886c86afefc3eb988" }, 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