docs: encourage adding comments; fix nested IF/ELSIF indentation

- Update AGENTS.md to encourage comments instead of forbidding them
- Add docstrings to all public functions in src/ modules
- Add module headers and function comments to lua/scl/ modules
- Fix formatter to properly indent multi-line IF/ELSIF conditions
- Fix FB call detection to not match IF statements with parentheses
This commit is contained in:
2026-02-23 17:40:44 +01:00
parent bfdec0c4b1
commit 15b0e5360a
4 changed files with 66 additions and 1 deletions
+16
View File
@@ -1,5 +1,9 @@
-- TIA Portal built-in instructions for SCL Neovim plugin
-- Defines functions, function blocks, and their parameters for completion
local M = {}
-- Built-in functions (return values, no state)
M.FUNCTIONS = {
ADD = true,
SUB = true,
@@ -38,6 +42,7 @@ M.FUNCTIONS = {
I_BCD = true,
}
-- Built-in function blocks (have state, need instance)
M.FUNCTION_BLOCKS = {
TON = true,
TOF = true,
@@ -64,6 +69,8 @@ M.FUNCTION_BLOCKS = {
DATALOG = true,
}
-- Parameter definitions for built-in instructions
-- Format: { inputs = { { name, type }, ... }, outputs = { { name, type }, ... } }
M.PARAMETERS = {
TON = { inputs = { { name = "IN", type = "BOOL" }, { name = "PT", type = "TIME" } }, outputs = { { name = "Q", type = "BOOL" }, { name = "ET", type = "TIME" } } },
TOF = { inputs = { { name = "IN", type = "BOOL" }, { name = "PT", type = "TIME" } }, outputs = { { name = "Q", type = "BOOL" }, { name = "ET", type = "TIME" } } },
@@ -121,14 +128,23 @@ M.PARAMETERS = {
I_BCD = { inputs = { { name = "IN" } }, outputs = { { name = "OUT" } } },
}
--- Get parameter info for a built-in instruction
--- @param name string The instruction name
--- @return table|nil Parameter definition with inputs and outputs arrays
function M.get_parameters(name)
return M.PARAMETERS[name:upper()]
end
--- Check if name is a known function block
--- @param name string The name to check
--- @return boolean True if known function block
function M.is_known_function_block(name)
return M.FUNCTION_BLOCKS[name:upper()] or false
end
--- Check if name is a known function
--- @param name string The name to check
--- @return boolean True if known function
function M.is_known_function(name)
return M.FUNCTIONS[name:upper()] or false
end