From 8f49547f85f36455d851f6665642fe184d8faaca Mon Sep 17 00:00:00 2001 From: kyasuda Date: Tue, 19 Aug 2025 15:21:21 -0700 Subject: [PATCH] update docstrings --- .config/nvim/lua/core/keymaps.lua | 4 ++++ .../nvim/lua/utils/keymaps/converters/from_table/init.lua | 7 +++++++ .../nvim/lua/utils/keymaps/converters/whichkey/init.lua | 4 ++-- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/.config/nvim/lua/core/keymaps.lua b/.config/nvim/lua/core/keymaps.lua index 3a56120..8017457 100644 --- a/.config/nvim/lua/core/keymaps.lua +++ b/.config/nvim/lua/core/keymaps.lua @@ -13,6 +13,10 @@ vim.g.mapleader = " " vim.g.maplocalleader = "," -- Create a custom command with the given trigger, command, and description +--- @param trigger string The command trigger +--- @param command string The command to execute +--- @param description string Description of the command +--- @return nil function create_custom_command(trigger, command, description) vim.api.nvim_create_user_command(trigger, command, { desc = description }) end diff --git a/.config/nvim/lua/utils/keymaps/converters/from_table/init.lua b/.config/nvim/lua/utils/keymaps/converters/from_table/init.lua index 53a1c7f..4d756fc 100644 --- a/.config/nvim/lua/utils/keymaps/converters/from_table/init.lua +++ b/.config/nvim/lua/utils/keymaps/converters/from_table/init.lua @@ -2,6 +2,13 @@ local M = {} local map = vim.keymap.set local opts = { noremap = true, silent = true } +--- Set keybindings from a table of mappings. +--- @param bindings table A list of keybinding mappings. +--- Each mapping should be a table with the following keys: +--- - mode: string, the mode in which the keybinding applies (e.g., 'n', 'i', 'v'). +--- - key: string, the key to bind. +--- - cmd: string, the command to execute when the key is pressed. +--- - opts: table, optional, additional options for the keybinding (default: function M.set_keybindings(bindings) for _, binding in ipairs(bindings) do map(binding.mode, binding.key, binding.cmd, binding.opts or opts) diff --git a/.config/nvim/lua/utils/keymaps/converters/whichkey/init.lua b/.config/nvim/lua/utils/keymaps/converters/whichkey/init.lua index 2a5f2bf..d093d8b 100644 --- a/.config/nvim/lua/utils/keymaps/converters/whichkey/init.lua +++ b/.config/nvim/lua/utils/keymaps/converters/whichkey/init.lua @@ -4,8 +4,8 @@ local whichkey = require("which-key") vim.notify = require("notify") ---Helper function to add mappings to which-key ----@parm mappings table : List of mappings to add to which-key ----@parm group table : Group to add mappings to (optional) +---@param mappings table List of mappings to add +---@param group table Group to add mappings to (optional) ---@return nil ---@usage addToWhichKey(mappings, group) ---@example addToWhichKey({{key = "n", cmd = "next", mode = "n", desc = "Next Line", group = "Navigation"}, {key = "t", group = "example"})