aboutsummaryrefslogtreecommitdiffstats
path: root/nvim/lua/user/go.lua
diff options
context:
space:
mode:
authorMatthew Lemon <y@yulqen.org>2023-05-14 17:36:54 +0100
committerMatthew Lemon <y@yulqen.org>2023-05-14 17:37:09 +0100
commit6032dc31bc879e785157701b7c49d28567e8bdb7 (patch)
treeade6aed1b0f7d68702814bdbfacf3f70c7d9983f /nvim/lua/user/go.lua
parent383897fe36290a6844af54619241603ff28977ce (diff)
added go.lua - a Neovim plugin for Go
Diffstat (limited to 'nvim/lua/user/go.lua')
-rw-r--r--nvim/lua/user/go.lua26
1 files changed, 26 insertions, 0 deletions
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