Skip to content

Commit

Permalink
✨ Add go autoformatting
Browse files Browse the repository at this point in the history
  • Loading branch information
skrewz committed Nov 5, 2024
1 parent ef46002 commit 322d942
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 9 deletions.
26 changes: 18 additions & 8 deletions .config/nvim/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -196,16 +196,26 @@ vim.api.nvim_create_autocmd({"FileType"},{
vim.api.nvim_create_augroup("AutoTest", {})

vim.api.nvim_create_autocmd(
"BufWritePost",
{
pattern = "*.go",
group = "AutoTest",
callback = function()
require("neotest").run.run(vim.fn.expand("%"))
end,
}
"BufWritePost",
{
pattern = "*.go",
group = "AutoTest",
callback = function()
require("neotest").run.run(vim.fn.expand("%"))
end,
}
)

local format_sync_grp = vim.api.nvim_create_augroup("GoFormat", {})
vim.api.nvim_create_autocmd("BufWritePre", {
pattern = "*.go",
callback = function()
require('go.format').goimports()
end,
group = format_sync_grp,
})




--------------------------------------------------------------------------------
Expand Down
15 changes: 14 additions & 1 deletion .config/nvim/lua/plugins.lua
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,20 @@ return {
'cljoly/telescope-repo.nvim',
'nvim-telescope/telescope-frecency.nvim',
'lervag/vimtex',
'ray-x/go.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
},
-- {
-- "jackMort/ChatGPT.nvim",
-- event = "VeryLazy",
Expand Down

0 comments on commit 322d942

Please sign in to comment.