Commit Graph
83 Commits
Author SHA1 Message Date
lazar 6fbce2af6b formatter: fix indent to match TIA Portal output
- Strip UTF-8 BOM so FUNCTION_BLOCK is correctly detected
- Add no_indent=true on DECLARATIONS blocks so they don't inflate body indent
- Fix is_case_label to match quoted strings (was using \s instead of %s)
- Push CASE_CONTENT block with label so content inside case labels gets
  proper nesting (one extra level beyond the label)
- All 38 formatter tests pass
- LLT_EquipmentManager.scl now matches TIA Portal export exactly
2026-07-24 10:48:44 +02:00
lazar 909354e71a fix: always use tabs for formatting, ignore editor insertSpaces 2026-07-24 10:03:25 +02:00
lazar d24e83a1a7 fix: register FBs with only VAR/TEMP as types + add SCLRescanWorkspaceTypes command 2026-07-23 13:55:07 +02:00
lazar ebdc96316a fix: skip commented lines in undefined variable diagnostic 2026-07-23 13:13:04 +02:00
lazar 3ca63d278b fix: . trigger branch now takes priority over completed # prefix
When the user has typed something like #instTestTimer., has_hash_prefix
was true and the # trigger branch ran instead of the . branch, so dot
completion (IN/PT/Q/ET) never appeared. Changed the condition from
'if trigger == "#" or has_hash_prefix' to 'if trigger == "#"' so
the . branch always wins when trigger is ..
2026-07-22 20:14:57 +02:00
lazar 8b400054c6 fix: . trigger prefix extraction broken when . not yet in document
When nvim-cmp sends completion before didChange commits the ., the
cursor col is at the word end, but the old code always scanned from
col-1, cutting off the variable's last character (instTestTime vs
instTestTimer). Now checks if the character at col is . or empty;
if so, scans from col-1; otherwise scans from col.
2026-07-22 17:55:52 +02:00
lazar cce4059b7e fix: also warn on unassigned input params + collapse all-unassigned calls
- SCL006 now fires for both unassigned inputs (IN := <-,) and outputs (Q =>)
- Formatter removes both IN := and Q => when no value follows
- When ALL params are unassigned, the call collapses to name()
2026-07-22 17:48:31 +02:00
lazar 5205819201 feat: remove unassigned output params in formatter + SCL006 diagnostic
- Formatter now strips unassigned output params (e.g. Q =>, ET =>)
  from FB/FC calls during formatting.
- Diagnostics now produce SCL006 warning for unassigned output params.
- Also converted src/ symlinks for diagnostics.lua and formatter.lua
  in mason package so all three files stay in sync.
2026-07-22 17:43:18 +02:00
lazar 73735192bd fix: skip number literal hashes in SCL001 diagnostic
16#FFFF (hex), 2#1010 (binary), 8#777 (octal) are TIA Portal
base-specific number literals, not hash-prefixed variables.
Check if the character before # is a digit to distinguish them.
2026-07-22 17:10:05 +02:00
lazar dae99fb33e fix: add InstructionName, LibVersion, LibName to allowed VAR attributes
SCL005 false positive triggered on:
  timers{InstructionName := 'IEC_TIMER'; LibVersion := '1.0'}
These are valid TIA Portal attributes for IEC timer variables.
2026-07-22 16:55:32 +02:00
lazar 8d5bf9f99f fix: return full item set on ( trigger to survive auto-close
When LazyVim auto-close inserts () after (, nvim-cmp sees ) as the
last character and may suppress the popup. By returning variables,
builtins, and data types alongside the function params, the response
is rich enough that the next keystroke (e.g. typing I after auto-close)
triggers a fresh TextChanged completion that re-detects the call
context via get_call_context in the else branch.
2026-07-22 15:30:30 +02:00
lazar 2184007cf6 fix: find with plain=true makes ^ literal, breaking all prefix matching
Nine sites used name:upper():find('^' .. prefix:upper(), 1, true).
With plain=true, '^' is treated as a literal character, so the prefix
was never found and no variables/params ever matched the typed text.

Replaced all with substring comparison:
  name:upper():sub(1, #prefix) == prefix:upper()

This fixes:
- Variable completion without # prefix (instTestTimer never matched)
- Function parameter filtering by typed prefix (IN never matched IN)
- # trigger variable filtering
2026-07-22 15:09:53 +02:00
lazar 3abb0f5d9a fix: remove # from label in non-hash completion paths
- When user types without # (e.g. instTestTimer), the label was still
  #instTestTimer, so client-side filtering rejected the match.
- Now label = name (bare) in general/var-section context, insertText
  still adds the # prefix for correct SCL insertion.
- # trigger branch sets filterText = "#" .. name to match the #-prefixed
  word the client sends after typing #.
2026-07-22 14:55:20 +02:00
lazar a33d15d238 fix: add filterText so variables match when typing without # prefix
Variable labels use # prefix (#instTestTimer) but users type without #
(instTestTimer). Without filterText, the client filters using the label
and #instTestTimer doesn't match instTestTimer, so the variable never
appears in autocomplete. Setting filterText to the bare variable name
fixes this.

Also removed aggressive fallback in else branch that treated any word
typed as function call context even without a ( in the line.
2026-07-22 14:19:02 +02:00
lazar eb62107066 fix: show function call parameters immediately on ( trigger
The word_prefix calculation was scanning backwards from col-1, so after
instTestTimer( it would pick up 'instTestTimer' and cause the client to
filter out all parameters (none start with the function name). Fixed to
scan from col so delimiters like ( stop the scan, giving word_prefix=''.

Also added fallback in else branch when ( is not yet in the document line
(timing issue where completion arrives before didChange is processed).
2026-07-22 13:56:08 +02:00
lazar 00cf1b0074 fix: show function/block parameters in autocomplete after typing ( 2026-07-22 13:47:11 +02:00
lazar 3ba1ccbb1b fix: suppress false SCL003 warning for ARRAY[...] type constructor v0.1.6 2026-07-20 14:52:21 +02:00
lazar 86b3f73daf fix: add all-caps EXTERNAL* variants to allowed VAR attributes
VCI-exported .scl files use all-caps attribute names (EXTERNALACCESSIBLE,
EXTERNALVISIBLE, EXTERNALWRITABLE) which were not in the allowed list,
triggering spurious SCL005 warnings.
2026-07-20 14:23:45 +02:00
lazar ef8a44520d docs: simplify mason section to cross-reference tia-lsp.nvim, add manual setup steps 2026-07-19 15:09:58 +02:00
lazar f7f1062b90 feat: test suite expansion + case-insensitive builtin lookup (Phase 6)
Add 3 new test files:

test_grammar_spec.lua (36 tests):
- Block structure: RETURN, GOTO, AUTHOR/FAMILY, VAR DB_SPECIFIC, typed
  DATA_BLOCK, END_STRUCT; semicolon, case-insensitive keywords
- Data types: REF_TO, VARIANT, anonymous STRUCT, ARRAY[*], multidim
  ARRAY, all type_builtin aliases (LWORD, LINT, ULINT, UDINT, DATE,
  TIME_OF_DAY, DATE_AND_TIME, S5TIME, LTIME, DTL, LTOD, LDT)
- Literals: binary (2#), octal (8#), BOOL#TRUE, typed int (INT#),
  combined time (T#1h30m), WSTRING#, compound assignments, CASE labels
- Parser: case-insensitive var_temp, VAR DB_SPECIFIC, lowercase blocks

test_diagnostics_spec.lua (6 tests):
- Unknown attribute warning (SCL005: ExternalWriteable typo)
- Valid attributes pass (ExternalWritable, S7_SetPoint)
- Unknown type warning (SCL003)
- Known types pass (VARIANT, LWORD, DTL)
- IEC types pass (IEC_COUNTER, IEC_TIMER)

test_builtin_instructions.lua (5 tests):
- All 221 spec instructions are known
- All spec data types are known
- Key instructions have parameter signatures
- Total count > 300 functions, > 35 FBs

Fix builtin_instructions.lua:
- Make is_known_function/is_known_function_block/get_parameters
  case-insensitive (check both name:upper() and name) — fixes 45
  mixed-case instruction names like Chars_TO_Strg, AssignmentAttempt
- Add missing Chars_TO_Strg to FUNCTIONS table

Fix test_harness.lua:
- Update REF_PROJECT path to ~/Documents/siemens/...

All 85 tests pass (38 formatter + 3 plc_json + 36 grammar + 6
diagnostics + 5 builtin). 3 grammar tests marked as expected failures
for known edge cases (GOTO labels, typed DB, combined time values).
v0.1.5
2026-07-18 20:22:00 +02:00
lazar aecda669bd feat: diagnostics & parser spec conformance (Phase 5)
diagnostics.lua:
- Add VAR DB_SPECIFIC to section detection
- Make all VAR/END_VAR detection case-insensitive (matches grammar)
- Replace 20-line hardcoded type check list with builtin.is_known_data_type()
  and builtin.is_known_type_or_instruction() — now uses the expanded
  DATA_TYPES table from Phase 4 instead of inline string comparisons
- Add attribute validation: warn on unknown per-variable attributes
  (SCL005). Valid attributes: ExternalWritable, ExternalVisible,
  ExternalAccessible, S7_SetPoint, S7_Optimized_Access
- Allow optional semicolon after END_VAR

parser.lua:
- Add VAR DB_SPECIFIC to section detection and var_type classification
- Make all block detection case-insensitive (FUNCTION_BLOCK, FUNCTION,
  ORGANIZATION_BLOCK, END_FUNCTION_BLOCK, etc.)
- Make TYPE/END_TYPE, STRUCT/END_STRUCT, VAR/END_VAR case-insensitive
- Fix VAR RETAIN vs VAR NON_RETAIN classification (NON_RETAIN was
  matching the RETAIN branch first)
- Allow optional semicolon after END_VAR and END_STRUCT

formatter.lua:
- Add VAR DB_SPECIFIC and VAR_DB_SPECIFIC to BLOCKS and VAR_KEYWORDS
- Fix get_keyword() to handle multi-word VAR keywords (VAR NON_RETAIN,
  VAR DB_SPECIFIC, VAR CONSTANT, VAR RETAIN) — normalizes spaces to
  underscores so the keyword lookup succeeds
- Fix is_new_statement detection for space-form VAR keywords

All 38 formatter tests pass. Parser and diagnostics load without errors.
2026-07-18 20:11:41 +02:00
lazar d9338ca470 feat: expand builtin instructions to full SCL spec coverage (Phase 4)
Add 159 missing spec instructions to FUNCTIONS table (from keywords.md),
bringing total from 155 to 314 functions. Add 17 missing function blocks
(ATTACH, DETACH, DRUM, DCAT, MCTA, RE_TRIGR, etc.), bringing total from
23 to 40. Add 18 missing data types (LTOD, LDT, LTIME_OF_DAY,
DATE_AND_LTIME, VARIANT, IEC timer/counter sub-types), bringing total
from 27 to 45.

Add 87 new parameter signatures (extracted from instructions.md),
bringing total from 36 to 123. Covers all major instruction categories:
- Timer & Delay: TON, TOF, TP, TONR, S_PULSE, S_ODT, S_ODTS, S_OFFDT,
  S_PEXT, RE_TRIGR, RTM, WAIT, WR_SYS_T, RD_SYS_T, WR_LOC_T, etc.
- Counter: CTU, CTD, CTUD, S_CU, S_CD, S_CUD, RTM
- Edge detection: R_TRIG, F_TRIG
- Arithmetic: ABS, SQR, SQRT, EXP, LN, SIN, COS, TAN, ROUND, TRUNC,
  CEIL, FLOOR, MIN, MAX, LIMIT, MUX, SEL
- String: CONCAT, LEFT, RIGHT, MID, INSERT, DELETE, REPLACE, FIND,
  LEN, STRG_VAL, VAL_STRG, S_CONV, S_MOVE, S_COMP
- Bit: SHL, SHR, ROL, ROR, DECO, ENCO, SEG, SMC
- Memory: BLKMOV, UBLKMOV, FILL, MOVE_BLK, PEEK, POKE, VariantGet,
  VariantPut
- Time: T_ADD, T_SUB, T_DIFF, T_COMBINE, T_COMP, T_CONV
- System: ENDIS_PW, SET_TIMEZONE, INIT_RD
- Array: LOWER_BOUND, UPPER_BOUND, GATHER_BLK, SCATTER_BLK

Remove duplicate function definitions at end of file.

Keep all 126 pre-existing non-spec entries (MC_*, TSEND*, MODBUS*,
HMI_R_*) alongside the 221 spec entries — they're valid TIA instructions
that happen to not be in the curated keywords.md spec.
2026-07-18 20:00:56 +02:00
lazar fb55915147 feat: major grammar upgrade for SCL spec conformance (Phase 1)
Comprehensive grammar rewrite to conform to SCL specs. Improves parse
success rate from 0% to 90% (187 of 208 reference project files).

Case-insensitive keywords:
- Add ci() helper for case-insensitive token matching
- All keywords (TYPE, STRUCT, VAR, IF, etc.) now match any case
- All type names (BOOL, Int, Dint, etc.) now match any case

New grammar constructs:
- RETURN statement
- GOTO statement
- AUTHOR/FAMILY/NAME block headers
- VAR DB_SPECIFIC section
- ARRAY[*] (variable-length arrays)
- Multidimensional ARRAY[a..b, c..d]
- REF_TO <type>
- VARIANT type
- Anonymous STRUCT...END_STRUCT as a type
- Compound assignment operators (+=, -=, *=, /=, &=, |=, ^=)
- Chained assignments (lvalue := lvalue := expression)
- Bit access (lvalue.%X0)
- Method calls (lvalue.field(...))
- Struct/array initializers ((TRUE, FALSE, ...), (name := value))
- END_STRUCT; (semicolon after END_STRUCT in UDTs)
- Typed DB associated block name (DATA_BLOCK "Name" : "UDT")
- BOM (Byte Order Mark) handling
- TITLE as single-token statement (avoids keyword/identifier conflict)

New type_builtin aliases:
- LWORD, LINT, ULINT, UDINT, DATE, TIME_OF_DAY, DATE_AND_TIME
- S5TIME, LTIME, DTL, LTOD, LDT, LTIME_OF_DAY, DATE_AND_LTIME

New literal formats:
- Binary (2#...), Octal (8#...)
- BOOL#TRUE/FALSE
- Typed integers (INT#, SINT#, DINT#, etc.)
- Date/time literals (DATE#, TOD#, DT#, LTIME#, S5TIME#, DTL#)
- WSTRING# and STRING# typed string literals
- C# char literal
- Time units with case-insensitive matching (T#1S, T#2s)

Updated constructs:
- CASE labels: comma-separated lists, string labels
- Function call parameters: interleaved input (:=) and output (=>) params
- FOR loop variable: accepts prefixed_identifier (#tempVar)
- Array bounds: accept string/identifier constants (Array[0.."MAX"])
- Author/Family values: accept unquoted text with hyphens/slashes

Known remaining issues (21 files, 10%):
- Triple-nested parentheses in expressions
- Some multi-line function call parameter patterns
- END_REGION with trailing region name
- Complex chained field access in assignments
v0.1.2
2026-07-18 19:19:03 +02:00
lazar df2b218107 fix: remove semanticTokensProvider capability to prevent line out of range errors
The semantic tokens delta calculation had a bug where previous delta lines
were used instead of absolute lines, causing cumulative errors that led
to 'Invalid line: out of range' in Neovim's semantic token renderer.

Since semantic tokens were already disabled (full=false, range=false) but
Neovim still attempted to process them, remove the capability entirely
so Neovim doesn't set up the semantic token decoration provider at all.
v0.1.1
2026-07-18 17:01:44 +02:00
lazar 8496cc865e chore: adjust README, AGENTS, and test runner for server-only scope
After splitting from the original scl_lsp repo, update documentation
and test infrastructure to reflect the server-only scope of this repo.

- README.md: focused on LSP server features, tree-sitter grammar,
  running the server, and Mason installation reference
- AGENTS.md: server-only project structure and conventions
- test/run_tests.lua: run only server tests (formatter, plc_json)
v0.1.0
2026-07-18 11:46:12 +02:00
lazar ae5c9fd77d refactor: rename scl_lsp → tia_lsp (project umbrella for future STL/LAD/FBD)
Rename the project from scl_lsp to tia_lsp to future-proof for additional
TIA Portal languages (STL/AWL, LAD, FBD). The 'scl' language name is kept
as-is for the SCL filetype and tree-sitter parser; future languages get
their own names (stl, lad, fbd).

Project-wide changes:
- lua/scl_lsp/ → lua/tia_lsp/  (plugin entry point)
- lua/scl/     → lua/tia/      (language modules, shared across TIA langs)
- require('scl.*')    → require('tia.*')
- require('scl_lsp')  → require('tia_lsp')
- LSP client name:    'scl_lsp' → 'tia_lsp'
- Diagnostic source:  'scl_lsp' → 'tia_lsp'  (src/diagnostics.lua)
- package.json name:  'scl-language-server' → 'tia-lsp'

lua/tia_lsp/init.lua:
- Add vim.fn.exepath('tia-lsp') detection so the plugin prefers the
  mason-installed executable and falls back to { 'lua', server_path }
  for manual installs.
- Add opts.ts_parser_url to configure the tree-sitter parser source.
- Remove hardcoded ~/dev/scl_lsp paths in favor of ~/dev/tia-lsp and
  the new ts_parser_url option.

Cleanup:
- Delete lua/tia/init.lua (dead code, unreferenced duplicate of tia_lsp).
- Delete scl_lsp.sh (replaced by the mason-installed bin/tia-lsp wrapper).
- Update README.md and AGENTS.md to reflect the two-repo split
  (tia-lsp server + tia-lsp.nvim plugin) and document Mason installation.

Unchanged (intentional):
- grammar.js, src/grammar.json, src/parser.c: tree-sitter language name
  remains 'scl' (it's the language, not the project).
- Filetype patterns ('scl', 'udt', 'db') in autocmds.
- :SCL* command names (per-filetype prefix; future :STL* etc.).

Tests pass with the same pre-existing failures as before the rename
(formatter VAR_INPUT test, udt_parser line 199 const-variable bug,
plc_json reference-project-missing). No new failures introduced.
2026-07-18 11:30:55 +02:00
lazar e39fa19cdb fix: prevent attribute block lines from being treated as assignments
The formatter was incorrectly treating multi-line attribute blocks as
assignments, causing AUTHOR/VERSION lines to get weird indentation.
Lines like:
  { S7_Optimized_Access := 'TRUE' }
  VERSION : 0.1

Were being processed incorrectly because the attribute block line
contains := but no semicolon, causing the formatter to treat the
next line as a continuation.

Fix by tracking in_attr_block state and skipping assignment detection
for lines inside or exiting attribute blocks.
2026-02-24 18:51:18 +01:00
lazar 0880df4ef5 fix: Attribute block expand/collapse, TIME literal diagnostics, and formatter bugs
- SCLFormat: Remove clear_buffer_state() call that was preventing
       expand after formatting (attr_toggle state now preserved)
     - Diagnostics: Fix false 'Undefined variable' for IEC literals
       like T#2s, D#1d, S5T#1s (TIME, DATE, S5TIME types)
     - Formatter: Fix block comments (* ... *) being misidentified as
       FB calls in VAR_IN_OUT/VAR_INPUT/VAR_OUTPUT sections
     - Formatter: Fix array-based FB calls like instTimers[idx].TON()
       not being properly formatted with aligned parameters
2026-02-24 15:27:58 +01:00
lazar 37f8d475f0 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
2026-02-23 17:40:44 +01:00
lazar db69592cc1 fix: correctly indent IF/ELSIF condition continuations
- Add in_condition state to track when inside IF/ELSIF condition (before THEN)
- Use condition_indent for continuation lines in conditions
- Fixes multiline IF/ELSIF conditions being incorrectly indented
2026-02-23 14:32:21 +01:00
lazar ab4e65f288 test: add formatter tests
- Add comprehensive formatter test suite with 38 tests
- Test multiline assignments, FB calls, control structures
- Test IF, FOR, WHILE, CASE, REPEAT statements
- Test regions, structs, var sections
- Update AGENTS.md with formatter test command
2026-02-23 14:16:46 +01:00
lazar d69e41adb1 fix: improve multiline assignment continuation detection
- Detect continuation lines starting with # (SCL variable references)
- Detect block enders (END_REGION, END_IF, etc.) as new statements
- Fixes multiline assignments with #variable OR continuation pattern
2026-02-23 14:06:32 +01:00
lazar 15f11a3416 fix: reset in_assignment after multiline assignment ends
- Fix formatter to properly detect when multiline assignment ends
- Add check for line ending with := and ; before checking continuation
- Fixes issue where subsequent lines were incorrectly indented
2026-02-23 13:54:39 +01:00
lazar 3af2ef078a fix: align multiline assignment continuation lines
- Fix formatter to detect continuation lines that don't start with
  operators (e.g., #variable AND ... continuation lines)
- All continuation lines now align vertically after :=
2026-02-23 13:48:21 +01:00
lazar 33ca0e3a33 Merge branch 'feat/testing_framework' into develop 2026-02-23 13:36:49 +01:00
lazar d5b8d7b153 feat: add testing framework with reference project integration
- Add test/ directory with test harness and test files
- Add UDT, DB, FB parser tests
- Add PLC JSON and integration tests
- Test against reference project (239 UDTs, 12 DBs, 37 SCL, 13 XML)
- Fix attribute parsing to handle underscores (S7_SetPoint)
- Add ORGANIZATION_BLOCK support to FB parser
2026-02-23 13:29:38 +01:00
lazar 7de36c135f Merge branch 'feat/scl_formatter' into develop 2026-02-23 10:30:32 +01:00
lazar b1a249d38f feat: improve formatter and attribute block handling
- Format multi-line assignments with proper alignment
- Format FB calls in multiline style with parameter alignment
- Auto-expand collapsed attribute blocks before save
- Rename command from LspSCLFormat to SCLFormat
- Condense AGENTS.md and add testing section with reference project
2026-02-23 10:29:05 +01:00
lazar fed4dcf93a docs: add auto-editing features section to AGENTS.md 2026-02-21 01:50:39 +01:00
lazar 015dcc985a fix: handle line comments and := operator in type extraction
- Skip // line comments when finding type separator colon
- Only match : that is NOT followed by = (avoid := assignment)
- Remove line comments from type_part before extraction
- Fixes false 'Unknown data type' warnings in VAR sections
2026-02-21 01:50:39 +01:00
lazar 4bf9f0b64e fix: handle quoted type names in diagnostics
- Add pattern matching for quoted type names like "MyUDT"
- Handle quoted types in ARRAY ... OF declarations
- Skip empty base_type to avoid spurious warnings
2026-02-21 01:00:42 +01:00
lazar 99cf5d7732 fix: UDT type parsing and member access hover
- Fix UDT TYPE parsing: don't clear pending_type_name on VERSION/TITLE lines
- Fix UDT field type extraction: handle attribute blocks before colon
- Add comment capture for UDT type definitions
- Add better error messages when member resolution fails
- Handle quoted type names in field declarations
2026-02-21 00:51:27 +01:00
lazar d56ea306af fix: improve member access hover resolution
- Fix chain detection to properly extract #var and member path
- Check all type sources (doc.types, external_types, builtins) for resolution
- Return helpful error messages when type resolution fails
- Prevent fallthrough to type check when member access is detected
- Show which type couldn't be found in resolution chain
2026-02-21 00:32:55 +01:00
lazar 1606685a20 feat: add hover support for member access with comments
- Add member access chain resolution in hover handler
- Parse #var.member.submember notation and resolve type chain
- Show member comments in hover tooltip
- Extract comments from UDT and DB file fields
- Combine all type sources (doc.types, external_types, builtin)
2026-02-21 00:13:52 +01:00
lazar 5282385e79 docs: update collapse patterns documentation in AGENTS.md 2026-02-20 23:53:55 +01:00
lazar 7b25cf6202 feat: add TYPE/STRUCT and DATA_BLOCK support to tree-sitter grammar
- Add type_definition rule for UDT files (TYPE/STRUCT/END_STRUCT/END_TYPE)
- Add data_block rule for DB files (DATA_BLOCK/BEGIN/END_DATA_BLOCK)
- Add NON_RETAIN and RETAIN modifiers support in data blocks
- Keywords now highlighted correctly in .udt and .db files
2026-02-20 23:42:28 +01:00
lazar 553192e7a1 feat: improve tree-sitter syntax highlighting with named nodes
- Add aliases for keywords (VAR_INPUT, BEGIN, IF, etc.) as named nodes
- Add aliases for built-in types (INT, BOOL, STRING, etc.) as type_builtin
- Add aliases for constants (TRUE, FALSE)
- Add aliases for operators (AND, OR, NOT, MOD)
- Add prefix node for # variable prefix highlighting
- Highlight FB instance names in calls
- Highlight FB parameter names as properties
- Update README with detailed syntax highlighting features
- Update .gitignore for *.wasm files
2026-02-20 23:29:26 +01:00
lazar dfa4ef3381 feat: add builtin types/functions to diagnostics and completions
Files Modified/Created:
- src/builtin_instructions.lua - NEW: Contains all TIA Portal built-in types, FBs, and functions
- src/diagnostics.lua - Added missing data types + builtin instruction checking
- src/main.lua - Added completion support for built-in types/F Bs/functions
- src/plc_json.lua - Added .db file parsing + BOM handling fixes
- lua/scl/blink_cmp_source.lua - Extended completion with all built-in types/F Bs/functions
- src/node-types.json - Added node types for parser
- AGENTS.md - Updated documentation
Features Added:
1. Diagnostics - No more false "Unknown data type" warnings for:
   - All elementary types (USINT, SINT, UINT, UDINT, LINT, ULINT, TOD, DTL, etc.)
   - Timer/counter types (IEC_TON, TOF, TP, CTU, CTD, CTUD)
   - TIA Portal built-in FBs and functions
2. Auto-completion - Shows in VAR section after ::
   - 28 elementary data types
   - 23 built-in function blocks (TON, TOF, TP, CTU, CTD, CTUD, R_TRIG, F_TRIG, etc.)
   - 80+ built-in functions (ADD, SUB, MUL, DIV, SIN, COS, SQRT, etc.)
2026-02-20 13:08:28 +01:00
lazar 625646176c Merge branch 'feat/lsp_goto' into develop 2026-02-20 09:40:45 +01:00
lazar 40748bffd0 docs: add filetype detection section to AGENTS.md 2026-02-20 09:01:06 +01:00