summaryrefslogtreecommitdiffstats
path: root/nvim
diff options
context:
space:
mode:
authorMatthew Lemon <y@yulqen.org>2023-05-14 19:38:34 +0100
committerMatthew Lemon <y@yulqen.org>2023-05-14 19:38:34 +0100
commit091e9228ef0d4db33f95f0078dbe5848dd672472 (patch)
tree4ff8bfab0df9e5e37454d3ca93333f5b6fd12582 /nvim
parenta19acfde274fbb2be6b839a33019ca4a24eb3891 (diff)
Adds go functionality
Diffstat (limited to 'nvim')
-rw-r--r--nvim/lazy-lock.json2
-rw-r--r--nvim/lua/user/go.lua26
2 files changed, 28 insertions, 0 deletions
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