Skip to content

Commit aed46b1

Browse files
committed
adding lua annotations. Close nvim-java#7
1 parent 4df356c commit aed46b1

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

lua/plugin_name.lua

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,25 @@
11
-- main module file
22
local module = require("plugin_name.module")
33

4-
local M = {}
5-
M.config = {
6-
-- default config
7-
opt = "Hello!",
4+
---@class Config
5+
---@field opt string Your config option
6+
local config = {
7+
opt = "Hello!"
88
}
99

10-
-- setup is the public method to setup your plugin
10+
---@class MyModule
11+
local M = {}
12+
13+
---@type Config
14+
M.config = config
15+
16+
---@param args Config?
17+
-- you can define your setup function here. Usually configurations can be merged, accepting outside params and
18+
-- you can also put some validation here for those.
1119
M.setup = function(args)
12-
-- you can define your setup function here. Usually configurations can be merged, accepting outside params and
13-
-- you can also put some validation here for those.
1420
M.config = vim.tbl_deep_extend("force", M.config, args or {})
1521
end
1622

17-
-- "hello" is a public method for the plugin
1823
M.hello = function()
1924
module.my_first_function()
2025
end

lua/plugin_name/module.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
-- module represents a lua module for the plugin
1+
---@class CustomModule
22
local M = {}
33

4+
---@return string
45
M.my_first_function = function()
56
return "hello world!"
67
end

0 commit comments

Comments
 (0)