Commit Graph
70 Commits
Author SHA1 Message Date
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
lazar 1f9c99272c fix(parser): add support for .udt and .db file parsing and goto declaration
- extract_variables: Parse STRUCT fields in TYPE sections for .udt files
- extract_types: Handle quoted type names and multiple type definitions
- declaration handler: Extract quoted type names for goto declaration
- Add filetype detection for .udt and .db files in nvim config
2026-02-20 08:59:54 +01:00
lazar 9b393a65f0 docs: update README with goto declaration feature 2026-02-19 18:07:04 +01:00
lazar 577ffa5213 feat(lsp): add goto declaration for FB, DB, and UDT types
- Add declaration provider (gD) that finds definitions for:
  - Functions in .scl files
  - Function Blocks (FB) in .scl files
  - Data Blocks (DB) in .scl and .db files
  - User-Defined Types (UDT) in .scl and .udt files
- Implement project root detection for cross-directory searches
- Add duplicate location filtering to prevent multiple results
- Load UDT types from .udt files in plc_json
- Update documentation with goto declaration feature
2026-02-19 18:01:30 +01:00
lazar cb0b24d47b feat(lsp): add references provider for goto references
Add referencesProvider capability and handler to support LSP
references (gr keybinding in LazyVim). Searches all occurrences
of a symbol in the current document.
2026-02-19 14:10:14 +01:00
lazar e002e7f56d fix(diagnostics): correctly validate array element types
Extract actual element type for array declarations like 'Array[0..3] OF
IEC_TIMER' instead of incorrectly flagging 'Array' as unknown.
2026-02-19 13:33:52 +01:00
lazar 9f67b4828c fix(lsp): disable semantic tokens to prevent errors
The semantic tokens were causing 'Invalid line: out of range' errors
when opening certain files. This appears to be related to the delta
mode not being properly handled. Disabled semantic tokens for now
to prevent the errors.
2026-02-19 12:06:33 +01:00
lazar d94cb62e0b fix(lsp): add more robust validation in semantic tokens
- Wrap token generation in pcall to catch any errors
- Add validation for all token parameters (line, startChar, length)
- Validate deltaStart is non-negative
- Return empty tokens if any error occurs
- This should prevent the 'Invalid line: out of range' errors
2026-02-19 12:01:33 +01:00
lazar 1808edc1f0 fix(lsp): validate line numbers in semantic tokens and inlay hints
The error 'Invalid line: out of range' was caused by semantic tokens
and inlay hints using variable line numbers that might be out of bounds
for the current document content. This could happen when the cached
variables from a previous document version have line numbers that don't
match the current content.

Added validation to both textDocument_semanticTokensFull and
textDocument_inlayHint to ensure line numbers are within the valid
range (0 to total_lines - 1) before processing.
2026-02-19 11:56:09 +01:00
lazar 313f5035ee docs(README): clarify formatter attribute collapsing behavior 2026-02-19 11:24:45 +01:00
lazar 5b89157790 docs: document formatter collapseAttributes default change 2026-02-19 11:24:22 +01:00
lazar ae75108f32 fix(formatter): disable automatic attribute collapsing by default
When the formatter automatically collapses attribute blocks, the
original content is lost and cannot be restored by the toggle
module. This broke the attribute expand/collapse functionality.

Changed default from collapseAttributes = true to false.

Users who want collapsing should:
1. Use :LspSCLFormat to format (preserves original content)
2. Then use :SCLCollapseAllAttrBlocks to collapse (stores original)
3. Now toggle/expand works correctly because content is stored
2026-02-19 11:24:08 +01:00
lazar 3d9d1599b9 docs: document attr_toggle behavior after formatting 2026-02-19 11:18:16 +01:00
lazar 4ac49eeb95 fix(formatter): correctly indent variables in VAR_IN_OUT sections
The get_keyword() function was using pattern ^(%w+_%w+) which only
matched up to the second underscore, causing VAR_IN_OUT to be
extracted as VAR_IN. Since VAR_IN is not in VAR_KEYWORDS, the
VAR_IN_OUT block was not being pushed onto the stack.

Fixed by changing the pattern to ^([%w_]+) to capture the entire
keyword including all underscores.

This ensures variables inside VAR_IN_OUT, VAR_CONSTANT, and other
multi-underscore VAR sections are properly indented.
2026-02-19 11:10:04 +01:00