From aed46b150b8d35a720dc84beb33c257c0db6c3b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ellison=20Lea=CC=83o?= Date: Fri, 28 Jul 2023 15:58:47 -0300 Subject: [PATCH] adding lua annotations. Close #7 --- lua/plugin_name.lua | 21 +++++++++++++-------- lua/plugin_name/module.lua | 3 ++- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/lua/plugin_name.lua b/lua/plugin_name.lua index 5320823..774a1ba 100644 --- a/lua/plugin_name.lua +++ b/lua/plugin_name.lua @@ -1,20 +1,25 @@ -- main module file local module = require("plugin_name.module") -local M = {} -M.config = { - -- default config - opt = "Hello!", +---@class Config +---@field opt string Your config option +local config = { + opt = "Hello!" } --- setup is the public method to setup your plugin +---@class MyModule +local M = {} + +---@type Config +M.config = config + +---@param args Config? +-- you can define your setup function here. Usually configurations can be merged, accepting outside params and +-- you can also put some validation here for those. M.setup = function(args) - -- you can define your setup function here. Usually configurations can be merged, accepting outside params and - -- you can also put some validation here for those. M.config = vim.tbl_deep_extend("force", M.config, args or {}) end --- "hello" is a public method for the plugin M.hello = function() module.my_first_function() end diff --git a/lua/plugin_name/module.lua b/lua/plugin_name/module.lua index 441e923..7bea096 100644 --- a/lua/plugin_name/module.lua +++ b/lua/plugin_name/module.lua @@ -1,6 +1,7 @@ --- module represents a lua module for the plugin +---@class CustomModule local M = {} +---@return string M.my_first_function = function() return "hello world!" end