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.)
This commit is contained in:
@@ -30,7 +30,8 @@ scl_lsp/
|
||||
│ ├── diagnostics.lua # Linter
|
||||
│ ├── formatter.lua # Document formatter
|
||||
│ ├── treesitter.lua # Tree-sitter integration
|
||||
│ ├── plc_json.lua # External UDT loading
|
||||
│ ├── plc_json.lua # External UDT/DB loading
|
||||
│ ├── builtin_instructions.lua # TIA Portal built-in types/FBs/functions
|
||||
│ └── json.lua # JSON encoder/decoder
|
||||
├── lua/scl/ # Neovim plugin (uses require)
|
||||
│ ├── init.lua # Main plugin setup
|
||||
@@ -155,12 +156,30 @@ if ok and module then
|
||||
end
|
||||
```
|
||||
|
||||
## Diagnostics
|
||||
|
||||
The LSP validates data types and provides warnings for unknown types. It recognizes:
|
||||
- **Elementary data types** - BOOL, BYTE, WORD, DWORD, LWORD, CHAR, WCHAR, STRING, WSTRING, INT, DINT, LINT, USINT, SINT, UINT, UDINT, ULINT, REAL, LREAL, TIME, DATE, TOD, TIME_OF_DAY, DATE_AND_TIME, DT, S5TIME, LTIME, DTL
|
||||
- **Timer/counter types** - IEC_TIMER, TON_TIME, TOF_TIME, TONR_TIME, TP_TIME, CTU, CTD, CTUD
|
||||
- **TIA Portal built-in instructions** - Functions and function blocks
|
||||
- **Workspace types** - UDTs from `.udt` files and data blocks from `.db` files
|
||||
|
||||
## Completion Triggers
|
||||
- `#` - Local variables (after BEGIN)
|
||||
- `.` - Member access (UDT/DB)
|
||||
- `"` - Global DB names
|
||||
- `(` - FB/Function parameters
|
||||
- ` ` (space) - General completion
|
||||
- `:` - Type declaration (in VAR section)
|
||||
|
||||
### Completion Types
|
||||
The LSP provides auto-completion for:
|
||||
- **Local variables** - Variables declared in VAR sections
|
||||
- **UDT types** - User-defined types from `.udt` files
|
||||
- **Global DBs** - Data blocks from `.db` files
|
||||
- **Elementary types** - BOOL, INT, DINT, REAL, TIME, etc.
|
||||
- **TIA Portal built-in FBs** - TON, TOF, TP, CTU, CTD, CTUD, R_TRIG, etc.
|
||||
- **TIA Portal built-in functions** - ADD, SUB, MUL, DIV, SIN, COS, SQRT, etc.
|
||||
|
||||
## Formatter Options
|
||||
|
||||
|
||||
Reference in New Issue
Block a user