Skip to content

Commit

Permalink
adding lua annotations. Close #7
Browse files Browse the repository at this point in the history
  • Loading branch information
ellisonleao committed Jul 28, 2023
1 parent 4df356c commit aed46b1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
21 changes: 13 additions & 8 deletions lua/plugin_name.lua
Original file line number Diff line number Diff line change
@@ -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
Expand Down
3 changes: 2 additions & 1 deletion lua/plugin_name/module.lua
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit aed46b1

Please sign in to comment.