summaryrefslogtreecommitdiffstats
path: root/nvim/lua
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/lua
parenta19acfde274fbb2be6b839a33019ca4a24eb3891 (diff)
Adds go functionality
Diffstat (limited to 'nvim/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