This plugin exposes utility functions to enhance coding Go in Neovim.
- RunCurrTest: Runs the test under the cursor and shows the results in a popup window.
- BuildCurrPackage: Build the package in the current dir.
- OrgBufImports: Update imports of the current buffer.
- SignatureInStatusLine: Shows the element under the cursor signature info on hover in the status line.
- AddTagToField: Adds go tag element to the struct field under the cursor, can handle exisiting elements. If no value is passed the snake cased field name will be the element value.
- AddTagsToStruct: Adds go tag element to all fields inside the struct under the cursor, can handle exisiting elements. If no value is passed the snake cased field name will be the element value.
- RemoveTagFromField: Removes a tag element from the field under the cursor.
- RemoveTagsFromStruct: Removes a tag element from all the fields inside the struct under the cursor.
With the dependencies installed add to your favorite package manager:
use 'ardanlabs/ardango.nvim'
Plug 'ardanlabs/ardango.nvim'
local ardango = require "ardango"
-- Update imports on save.
vim.api.nvim_create_autocmd("BufWritePre", {
group = "my_augroup",
pattern = "*.go",
callback = function() ardango.OrgBufImports(1000) end,
})
local ardango = require "ardango"
local opts = { noremap = true, silent = true }
-- Set the keymap to test the package under the cursor.
vim.keymap.set('n', '<leader>gt', ardango.RunCurrTest, opts)
-- Set the keymap to build the package under the cursor.
vim.keymap.set('n', '<leader>gp', ardango.BuildCurrPackage, opts)
-- Adds tag element to the field under the cursor field.
vim.keymap.set('n', '<leader>taf', ardango.AddTagToField, { buffer = 0 })
-- Adds tag element to all fields of the struct under the cursor field.
vim.keymap.set('n', '<leader>tas', ardango.AddTagsToStruct, { buffer = 0 })
-- Removes tag element from the field under the cursor.
vim.keymap.set('n', '<leader>trf', ardango.RemoveTagFromField, { buffer = 0 })
-- Removes tag element from the all fields of the struct under the cursor.
vim.keymap.set('n', '<leader>trs', ardango.RemoveTagsFromStruct, { buffer = 0 })