From beed143e64df8e9577b64b99beff836333df3be6 Mon Sep 17 00:00:00 2001 From: Smirnov Oleksandr Date: Tue, 2 Apr 2024 17:44:46 +0300 Subject: [PATCH] docs(iferr): add docs --- doc/gopher.nvim.txt | 9 +++++++++ lua/gopher/iferr.lua | 7 ++++++- scripts/docgen.lua | 1 + 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/doc/gopher.nvim.txt b/doc/gopher.nvim.txt index 236bf00..b5c21db 100644 --- a/doc/gopher.nvim.txt +++ b/doc/gopher.nvim.txt @@ -14,6 +14,7 @@ Table of Contents Modifty struct tags................................|gopher.nvim-struct-tags| Auto implementation of interface methods..................|gopher.nvim-impl| Generating unit tests boilerplate......................|gopher.nvim-gotests| + Iferr....................................................|gopher.nvim-iferr| Setup `nvim-dap` for Go......................................|gopher.nvim-dap| ------------------------------------------------------------------------------ @@ -191,6 +192,14 @@ you can do it with: if you choose to install `gotests` within neovim, i recommend adding it to your `build` section in your |lazy.nvim| +============================================================================== +------------------------------------------------------------------------------ + *gopher.nvim-iferr* +if you're using `iferr` tool, this module provides a way to automatically insert `if err != nil` check. +Usage ~ +execute `:GoIfErr` near any err variable to insert the check + + ============================================================================== ------------------------------------------------------------------------------ *gopher.nvim-dap* diff --git a/lua/gopher/iferr.lua b/lua/gopher/iferr.lua index 1eac0ce..56e9644 100644 --- a/lua/gopher/iferr.lua +++ b/lua/gopher/iferr.lua @@ -1,7 +1,12 @@ +---@toc_entry Iferr +---@tag gopher.nvim-iferr +---@text if you're using `iferr` tool, this module provides a way to automatically insert `if err != nil` check. +---@usage execute `:GoIfErr` near any err variable to insert the check + local c = require "gopher.config" local iferr = {} --- That's Lua of vimscript implementation of: github.com/koron/iferr +-- That's Lua implementation: github.com/koron/iferr function iferr.iferr() local boff = vim.fn.wordcount().cursor_bytes local pos = vim.fn.getcurpos()[2] diff --git a/scripts/docgen.lua b/scripts/docgen.lua index e648e56..7d31e5e 100644 --- a/scripts/docgen.lua +++ b/scripts/docgen.lua @@ -13,6 +13,7 @@ local files = { "lua/gopher/struct_tags.lua", "lua/gopher/impl.lua", "lua/gopher/gotests.lua", + "lua/gopher/iferr.lua", "lua/gopher/dap.lua", }