chore: adjust for plugin-only scope after split
After splitting from the original scl_lsp repo, update for plugin-only scope: - README.md: focused on Neovim plugin installation, configuration, commands, keybindings, and editor features - AGENTS.md: plugin-only project structure and conventions - test/run_tests.lua: run only plugin tests (udt, db, fb, integration) - test/test_integration.lua: remove plc_json dependency (server module) - queries/: move from queries/*.scm to queries/scl/*.scm (nvim-treesitter per-language convention) - ftdetect/scl.vim: add filetype detection for .scl/.udt/.db files
This commit is contained in:
@@ -1,34 +1,19 @@
|
||||
# AGENTS.md - tia-lsp
|
||||
# AGENTS.md - tia-lsp.nvim
|
||||
|
||||
A Neovim/LazyVim plugin and standalone LSP server for Siemens TIA Portal languages. Currently supports **SCL**; planned support for STL/AWL, LAD, FBD. The project is split into two repos:
|
||||
|
||||
- **`tia-lsp`** (this repo) — LSP server (`src/`) + tree-sitter grammar (`grammar.js`). Editor-agnostic.
|
||||
- **`tia-lsp.nvim`** — Neovim plugin (`lua/`) that launches the server and adds editor features.
|
||||
Neovim plugin for Siemens TIA Portal languages. Currently supports **SCL**; planned support for STL/AWL, LAD, FBD. This repo is the plugin only (`lua/` + tree-sitter queries). The companion LSP server lives in `tia-lsp`.
|
||||
|
||||
## Build/Lint/Test Commands
|
||||
|
||||
```bash
|
||||
# LSP Server
|
||||
make start # Start LSP server
|
||||
make test # Run LSP in test mode
|
||||
lua src/main.lua --test # Direct test execution
|
||||
|
||||
# Tree-sitter Parser
|
||||
tree-sitter generate # Generate parser from grammar.js
|
||||
tree-sitter test # Run all parser tests
|
||||
tree-sitter parse <file.scl> # Parse single SCL file
|
||||
|
||||
# Lua Linting
|
||||
luacheck src/ # Lint LSP server code
|
||||
luacheck lua/tia/ # Lint plugin modules
|
||||
luacheck lua/tia/ # Lint language modules
|
||||
luacheck lua/tia_lsp/ # Lint plugin entry point
|
||||
|
||||
# Unit & Integration Tests
|
||||
lua test/run_tests.lua # Run all tests
|
||||
lua test/run_tests.lua # Run all plugin tests
|
||||
lua test/test_udt.lua # Run UDT parser tests
|
||||
lua test/test_db.lua # Run DB parser tests
|
||||
lua test/test_fb.lua # Run FB parser tests
|
||||
lua test/test_formatter.lua # Run formatter tests
|
||||
lua test/test_plc_json.lua # Run plc_json tests
|
||||
lua test/test_integration.lua # Run integration tests
|
||||
|
||||
# Reference Project
|
||||
@@ -39,17 +24,8 @@ lua test/test_integration.lua # Run integration tests
|
||||
## Project Structure
|
||||
|
||||
```
|
||||
tia-lsp/
|
||||
├── src/ # LSP server (uses dofile)
|
||||
│ ├── main.lua # Entry point, JSON-RPC protocol
|
||||
│ ├── parser.lua # SCL parser (will become parser_scl.lua + dispatch)
|
||||
│ ├── diagnostics.lua # Linter (source = "tia_lsp")
|
||||
│ ├── formatter.lua # Document formatter
|
||||
│ ├── treesitter.lua # Tree-sitter integration
|
||||
│ ├── plc_json.lua # External UDT/DB loading (language-agnostic)
|
||||
│ ├── builtin_instructions.lua # TIA Portal built-in types
|
||||
│ └── json.lua # JSON encoder/decoder
|
||||
├── lua/tia/ # Neovim plugin (uses require)
|
||||
tia-lsp.nvim/
|
||||
├── lua/tia/ # Language modules (uses require)
|
||||
│ ├── udt_parser.lua # UDT parser
|
||||
│ ├── db_parser.lua # Global DB parser
|
||||
│ ├── fb_parser.lua # Function Block parser
|
||||
@@ -61,21 +37,20 @@ tia-lsp/
|
||||
├── lua/tia_lsp/ # Plugin entry point
|
||||
│ ├── init.lua # Main plugin setup (vim.lsp.start)
|
||||
│ └── plugins/scl.lua # LazyVim plugin spec
|
||||
├── queries/ # Tree-sitter queries (per-language: queries/scl/)
|
||||
└── grammar.js # Tree-sitter grammar (language name: 'scl')
|
||||
├── queries/scl/ # Tree-sitter queries (per-language)
|
||||
└── ftdetect/scl.vim # Filetype detection
|
||||
```
|
||||
|
||||
## Naming Convention
|
||||
|
||||
- **Project name** (repo, Lua module, LSP server, mason package): `tia-lsp` / `tia_lsp` — umbrella for all TIA languages.
|
||||
- **Language name** (filetype, tree-sitter parser, grammar): `scl` — stays as-is. Future languages (`stl`, `lad`, `fbd`) get their own names.
|
||||
- **Project name** (repo, Lua module): `tia-lsp.nvim` / `tia_lsp` — umbrella for all TIA languages.
|
||||
- **Language name** (filetype, tree-sitter parser): `scl` — stays as-is. Future languages (`stl`, `lad`, `fbd`) get their own names.
|
||||
- **LSP client name**: `tia_lsp` (one client handles all TIA languages; dispatches by `filetype` / `languageId`).
|
||||
- **Diagnostic source**: `tia_lsp`.
|
||||
- **Commands**: `:SCLFormat`, `:SCLShowVariables`, etc. — per-filetype prefix. Future: `:STLFormat`, etc.
|
||||
|
||||
## Filetype Detection
|
||||
|
||||
After the split, `ftdetect/scl.vim` will live in `tia-lsp.nvim`. Currently required in Neovim config:
|
||||
`ftdetect/scl.vim` registers the following extensions as `scl` filetype:
|
||||
```vim
|
||||
au BufRead,BufNewFile *.scl set filetype=scl
|
||||
au BufRead,BufNewFile *.udt set filetype=scl
|
||||
@@ -108,12 +83,10 @@ return M
|
||||
### Imports
|
||||
- `lua/tia/` modules: `require("tia.module_name")`
|
||||
- `lua/tia_lsp/` entry: `require("tia_lsp")`
|
||||
- `src/` modules: `dofile(script_path .. "/module.lua")`
|
||||
- External dependencies: wrap in `pcall()` for safety
|
||||
|
||||
### Code Formatting
|
||||
- `lua/tia/` and `lua/tia_lsp/`: 2 spaces indentation
|
||||
- `src/`: tab-based indentation
|
||||
- Max line length: 120 characters
|
||||
- No trailing whitespace
|
||||
|
||||
@@ -189,7 +162,5 @@ Use the reference project for testing:
|
||||
```
|
||||
|
||||
Contains `.scl`, `.db`, `.udt`, and `.xml` files for comprehensive testing of:
|
||||
- LSP features (hover, completion, go-to-definition)
|
||||
- Formatter (`:SCLFormat`)
|
||||
- Attribute block toggle
|
||||
- Plugin features (auto-prefix, workspace scanning, attribute toggle)
|
||||
- Workspace type scanning
|
||||
|
||||
Reference in New Issue
Block a user