Commit Graph
21 Commits
Author SHA1 Message Date
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
lazar cba10851d2 fix(parser): correctly extract type from VAR_CONSTANT with initialization
The parser was incorrectly finding the ':' inside attribute blocks like
{EXTERNALACCESSIBLE := 'false'} instead of the ':' after them.

Added 'break' after finding the first ':' outside braces to ensure
we get the correct type separator.

Fixes issue where variables like:
  STARTING_BASEPOS : Int := 30;
were showing data_type as '= 30' instead of 'Int'.
2026-02-19 10:57:17 +01:00
lazar 80d315df81 Merge branch 'feat/scl_formatter' into develop 2026-02-19 10:24:38 +01:00
lazar 374636d2f4 docs: update README with attribute block toggle feature
Add documentation for new attribute block toggle feature including:
- New commands: SCLToggleAttrBlock, SCLExpandAllAttrBlocks, SCLCollapseAllAttrBlocks
- New keybindings: <Leader>xa, <Leader>xae, <Leader>xac
- Feature description and usage example
2026-02-19 10:13:43 +01:00
lazar 978e46ba45 feat: add interactive attribute block toggle with keybindings and commands
Add ability to expand/collapse SCL variable attribute blocks like {EXTERNALACCESSIBLE := 'false'} to {...}

Features:
- Per-variable collapse rules via collapseVariableRules option
- Interactive toggle with <Leader>xa keybinding
- Commands: SCLToggleAttrBlock, SCLExpandAllAttrBlocks, SCLCollapseAllAttrBlocks
- Keybindings: <Leader>xa (toggle), <Leader>xae (expand all), <Leader>xac (collapse all)
- Supports both formatter-collapsed and manually collapsed blocks

Also update AGENTS.md with new documentation and troubleshooting guide
2026-02-19 10:12:58 +01:00
lazar 37ab917422 Rewrite formatter with stack-based approach for proper nested structure handling 2026-02-18 19:08:54 +01:00
lazar 2c4815baec fix(formatter): Fix multi-line condition and END_IF indentation
- Multi-line IF conditions: continuation lines at +1 from IF
- END_IF now decreases indent (reverted previous wrong change)
- Track multi-line condition state separately from THEN tracking
- Now matches TIA Portal expected format
2026-02-18 15:35:35 +01:00
lazar 25c306efee fix(formatter): Handle THEN on separate line and multi-line conditions
- Track when IF has THEN on separate line
- Don't increase indent after IF until THEN is seen
- Increase indent after THEN for content
- Continuation lines in conditions stay at same level as IF
- END_IF stays at same level as content (TIA Portal style)
2026-02-18 15:26:05 +01:00
lazar 5bc6bb0750 fix(formatter): Keep END_IF at same indent level as content
Per TIA Portal standard, END_IF stays at the same indent level as the
code inside the IF block, rather than decreasing. This matches the
reference file Em101Sequence.scl where nested END_IF statements are
properly aligned.
2026-02-18 15:16:16 +01:00
lazar 5b5d9c46f6 fix(formatter): Fix FB call indentation logic
- Track first line of FB call separately with fb_call_first_line flag
- First line of FB call uses normal indent
- Continuation lines use continuation indent (base + fb_name_length + 2)
- Closing line uses normal indent
- Parameters now align correctly
2026-02-18 15:05:13 +01:00
lazar eb11380aea fix(formatter): Fix FB call continuation indent
- Use correct continuation indent formula (base + fb_name_length + 2)
- Fix closing line of FB call to use continuation indent
- Parameters on continuation lines are now aligned
2026-02-18 14:50:49 +01:00
lazar f977d1ea7c fix(formatter): Add comment re-indenting and FB call continuation support
- Re-indent comments to match current block level
- Add FB/function call continuation detection and alignment
- Support both #fbname and "FBName" syntax
- Fix FB call detection to exclude assignment statements
- Continuation lines get +1 indent level
2026-02-18 14:42:41 +01:00
lazar d8e50b3e23 fix(formatter): Implement TIA Portal-compliant SCL formatting
- Default to tabs (not spaces) per TIA Portal standard
- Fix block keyword handling (IF, FOR, WHILE, CASE, REGION, etc.)
- Handle VAR section indentation (variables indented inside VAR)
- Fix IF/ELSIF/ELSE indentation (ELSIF/ELSE at same level as IF)
- Handle CASE labels and nested CASE statements
- Add missing semicolons after END_IF, END_FOR, END_CASE Handle block, etc.
- enders (END_IF, END_REGION, etc.) correctly
- Support compound keywords (END_IF, END_FUNCTION_BLOCK, etc.)
2026-02-18 14:10:50 +01:00
lazar 96c0c4584f fix(lsp): Fix LSP server attachment and JSON parsing issues
- Replace lspconfig.scl_lsp registration with vim.lsp.start() + FileType autocmd
  for Neovim 0.11+ compatibility
- Fix Lua reserved keyword 'end' in tables (use bracket notation ['end'])
- Fix JSON decoder pattern matching bugs (s:find -> s:sub:match)
- Add LSP method name conversion (textDocument/didOpen -> textDocument_didOpen)
- Handle request vs notification correctly (only respond to requests with id)
- Strip CRLF line endings for Windows compatibility
- Add semantic token handler aliases
- Update documentation with implementation notes
2026-02-18 13:03:14 +01:00
lazar 4429280524 docs(AGENTS.md): Update AGENTS.md
The new AGENTS.md includes:
- Reference project for testing
- Build/test commands (LSP and tree-sitter)
- Condensed project structure
- Code style guidelines (module pattern, naming, imports, comments)
- Parser module API convention
- Cache management patterns
- Error handling patterns (return pattern, pcall, validation)
- Completion system documentation
- Commands table
2026-02-18 10:25:35 +01:00
lazar 8a497a7e2b docs: Update AGENTS.md with comprehensive feature documentation 2026-02-17 15:30:30 +01:00
lazar d4ca1bd5b0 Merge branch 'feat/db_workspace_scope_recognition' into develop 2026-02-17 15:22:05 +01:00
lazar 6ab4376671 feat: Add Global Data Block recognition in workspace scope
- Add db_parser.lua to parse .db files (DATA_BLOCK with VAR sections)
- Update workspace_types.lua to scan for .db files in project
- Update blink_cmp_source.lua to provide DB auto-completion:
  - DB names available in general completion (without quotes)
  - Type quote to get DB members
  - Multi-level nested member access support
- Add DB count to workspace commands
- Update README with Global DB documentation
2026-02-17 15:06:36 +01:00
lazar 708a4cd4d5 Add multiline params documentation 2026-02-17 12:36:17 +01:00
lazar 7729593d6e Added .gitignore 2026-02-14 15:06:54 +01:00
lazar 625297106e Inintal commit 2026-02-14 15:05:12 +01:00