From a32a33bde5df93e51fc64939e2a65051ed6d41d5 Mon Sep 17 00:00:00 2001 From: Felix Ingram Date: Tue, 10 Oct 2023 13:06:07 +0100 Subject: [PATCH] add some things --- init.lua | 40 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/init.lua b/init.lua index a43374f9..217e1665 100644 --- a/init.lua +++ b/init.lua @@ -35,6 +35,7 @@ vim.opt.splitright = true vim.opt.hlsearch = false vim.opt.incsearch = true + -- Install package manager -- https://github.com/folke/lazy.nvim -- `:help lazy.nvim.txt` for more info @@ -202,6 +203,21 @@ require('lazy').setup({ "jose-elias-alvarez/null-ls.nvim", }, }, + { + "ray-x/go.nvim", + dependencies = { -- optional packages + "ray-x/guihua.lua", + "neovim/nvim-lspconfig", + "nvim-treesitter/nvim-treesitter", + }, + config = function() + require("go").setup() + end, + event = { "CmdlineEnter" }, + ft = { "go", 'gomod' }, + build = ':lua require("go.install").update_all_sync()' -- if you need to install/update all binaries + }, + -- NOTE: Next Step on Your Neovim Journey: Add/Configure additional "plugins" for kickstart -- These are some example plugins that I've included in the kickstart repository. @@ -230,7 +246,7 @@ vim.o.mouse = 'a' -- Sync clipboard between OS and Neovim. -- Remove this option if you want your OS clipboard to remain independent. -- See `:help 'clipboard'` -vim.o.clipboard = 'unnamedplus' +-- vim.o.clipboard = 'unnamedplus' -- Enable break indent vim.o.breakindent = true @@ -286,6 +302,28 @@ vim.keymap.set({ "n", "v" }, "d", [["_d]]) vim.keymap.set("n", "Q", "") +-- go/golang keymaps + +vim.keymap.set("n", "ee", "oif err != nil {}Oreturn err") +vim.keymap.set("n", "ep", "oif err != nil {}Opanic(err)") + +vim.api.nvim_create_autocmd({ "BufEnter", "BufWinEnter" }, + { pattern = { "*.go" }, command = "setlocal shiftwidth=4 tabstop=4" }) + +-- Run gofmt + goimport on save + +local format_sync_grp = vim.api.nvim_create_augroup("GoImport", {}) +vim.api.nvim_create_autocmd("BufWritePre", { + pattern = "*.go", + callback = function() + require('go.format').goimport() + end, + group = format_sync_grp, +}) + + + + -- [[ Highlight on yank ]] -- See `:help vim.highlight.on_yank()` local highlight_group = vim.api.nvim_create_augroup('YankHighlight', { clear = true })