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.
This commit is contained in:
2026-07-18 11:30:55 +02:00
parent 137eda3e77
commit 8c6a050efb
20 changed files with 194 additions and 388 deletions
+90 -40
View File
@@ -1,6 +1,11 @@
# SCL Language Server - Unified Plugin for Siemens SCL
# tia-lsp - Language Server for Siemens TIA Portal
A comprehensive Neovim/LazyVim plugin providing **Language Server Protocol (LSP)**, **Linting**, **Formatting**, and **Syntax Highlighting** for Siemens SCL (Structured Control Language) used in Siemens TIA Portal.
A Neovim/LazyVim plugin and standalone LSP server providing **Language Server Protocol (LSP)**, **Linting**, **Formatting**, and **Syntax Highlighting** for Siemens TIA Portal languages. Currently supports **SCL** (Structured Control Language), with planned support for **STL/AWL**, **LAD**, and **FBD**.
The project is split into two repos:
- **`tia-lsp`** (this repo) — the standalone LSP server (`src/`) plus the tree-sitter grammar (`grammar.js`, `src/parser.c`). Speaks JSON-RPC over stdio. Editor-agnostic: usable from Neovim, VS Code, or any LSP client.
- **`tia-lsp.nvim`** — the Neovim plugin (`lua/`) that launches the server via `vim.lsp.start()` and adds editor-specific features (auto-prefix, blink.cmp source, workspace UDT scanning, attribute toggle, multiline params).
## Features
@@ -58,11 +63,13 @@ A comprehensive Neovim/LazyVim plugin providing **Language Server Protocol (LSP)
## Installation
The plugin auto-detects the mason-installed `tia-lsp` executable via `vim.fn.exepath("tia-lsp")` and falls back to `lua <server_path>` for manual installs. See [Mason installation](#mason-installation) below for the recommended path.
### LazyVim
```lua
-- ~/.config/nvim/lua/plugins/scl.lua
-- ~/.config/nvim/lua/plugins/tia-lsp.lua
return {
"lazar/scl_lsp",
"lazar/tia-lsp.nvim",
ft = "scl",
lazy = true,
dependencies = {
@@ -71,7 +78,7 @@ return {
"saghen/blink.cmp",
},
config = function()
require("scl_lsp").setup({
require("tia_lsp").setup({
-- LSP options
lsp = {
on_attach = function(client, bufnr)
@@ -90,19 +97,59 @@ return {
### Manual Setup
```lua
-- In your init.lua or plugin file
require("scl_lsp").setup({
server_path = "/path/to/scl_lsp/src/main.lua",
require("tia_lsp").setup({
server_path = "/path/to/tia-lsp/src/main.lua", -- only used if tia-lsp is not on PATH
ts_parser_url = "https://your-gitea/tia-lsp.git", -- tree-sitter parser source
cmp = true,
workspace_types = true,
auto_prefix = true,
})
```
### Mason installation
`tia-lsp` can be installed via [mason.nvim](https://github.com/mason-org/mason.nvim) using a custom registry. The setup below uses a `file:` registry sourced from a Gitea-hosted `tia-mason-registry` repo (cloned by lazy.nvim), and falls back to the official mason registry for any other packages.
1. Clone the registry repo as a lazy.nvim plugin:
```lua
-- ~/.config/nvim/lua/plugins/tia-mason-registry.lua
return {
url = "https://your-gitea/tia-mason-registry.git",
name = "tia-mason-registry",
lazy = false, -- must be available before mason setup
}
```
2. Register the registry with mason:
```lua
-- ~/.config/nvim/lua/plugins/mason.lua
return {
"mason-org/mason.nvim",
opts = {
registries = {
"file:" .. vim.fn.expand("~/.local/share/nvim/lazy/tia-mason-registry"),
"github:mason-org/mason-registry",
},
},
}
```
3. Install `yq` (one-time prerequisite for mason's `file:` registry):
```
:MasonInstall yq
```
4. Install the server:
```
:MasonInstall tia-lsp
```
5. Verify: open a `.scl` file and run `:LspInfo` — `tia_lsp` should be attached, and `vim.fn.exepath("tia-lsp")` should resolve to `~/.local/share/nvim/mason/bin/tia-lsp`.
To upgrade: tag a new `vX.Y.Z` release on the `tia-lsp` Gitea repo, bump `source.id` in `tia-mason-registry/packages/tia-lsp/package.yaml`, push the registry repo, then `:MasonInstall tia-lsp` again.
## Configuration Options
| Option | Type | Default | Description |
|--------|------|---------|-------------|
| `server_path` | string | `~/dev/scl_lsp/src/main.lua` | Path to LSP server |
| `server_path` | string | `~/dev/tia-lsp/src/main.lua` | Path to LSP server (only used if `tia-lsp` is not on PATH) |
| `ts_parser_url` | string | `file://~/dev/tia-lsp` | URL passed to nvim-treesitter for the SCL parser source |
| `lsp.on_attach` | function | `nil` | Custom LSP attach callback |
| `lsp.formatting` | boolean | `false` | Enable format command |
| `cmp` | boolean | `true` | Enable blink.cmp integration |
@@ -185,7 +232,7 @@ The LSP automatically scans for SCL files in `data_types/` folder and extracts T
### Option 3: Generate `.plc.json`
```bash
lua /home/lazar/dev/scl_lsp/src/plc_json.lua --generate
lua ~/dev/tia-lsp/src/plc_json.lua --generate
```
## Global Data Block Support
@@ -218,40 +265,43 @@ The plugin automatically scans for `.db` files in the workspace and provides aut
### Project Structure
```
scl_lsp/
tia-lsp/
├── README.md # This file
├── package.json # NPM scripts (tree-sitter)
├── Makefile # Build commands
├── grammar.js # Tree-sitter grammar
├── tree-sitter.json # Parser config
├── queries/ # Tree-sitter queries
── highlights.scm # Syntax highlighting
├── indents.scm # Indentation
├── folds.scm # Code folding
├── locals.scm # Variable scoping
└── tags.scm # Navigation tags
├── src/ # LSP server
│ ├── main.lua # Main entry point
│ ├── parser.lua # Regex-based parser
│ ├── treesitter.lua # Tree-sitter integration
│ ├── json.lua # JSON encoder/decoder
│ ├── plc_json.lua # External UDT loading
│ ├── diagnostics.lua # Linter diagnostics
── formatter.lua # Document formatter
├── grammar.js # Tree-sitter grammar (SCL language)
├── tree-sitter.json # Parser config
├── queries/ # Tree-sitter queries
── scl/ # Per-language query dir (SCL)
├── highlights.scm # Syntax highlighting
├── indents.scm # Indentation
├── folds.scm # Code folding
├── locals.scm # Variable scoping
│ └── tags.scm # Navigation tags
├── src/ # LSP server
│ ├── main.lua # Main entry point (JSON-RPC over stdio)
│ ├── parser.lua # SCL parser (will become parser_scl.lua + dispatch)
│ ├── treesitter.lua # Tree-sitter integration
│ ├── json.lua # JSON encoder/decoder
│ ├── plc_json.lua # External UDT loading (language-agnostic)
── diagnostics.lua # Linter diagnostics
│ └── formatter.lua # Document formatter
└── lua/
── scl_lsp/
├── init.lua # Main plugin setup
── plugins/
│ └── scl.lua # LazyVim plugin spec
└── scl/ # Syntax/completion modules
├── init.lua
├── auto_prefix.lua
├── blink_cmp_source.lua
├── db_parser.lua
├── fb_parser.lua
├── udt_parser.lua
├── variables.lua
── workspace_types.lua
── tia_lsp/ # Neovim plugin
├── init.lua # Main plugin setup
── plugins/
└── scl.lua # LazyVim plugin spec (SCL filetype)
└── tia/ # Language modules (shared across TIA languages)
├── auto_prefix.lua
├── attr_toggle.lua
├── blink_cmp_source.lua
├── builtin_instructions.lua
├── db_parser.lua
├── fb_parser.lua
├── multiline_params.lua
── udt_parser.lua
├── variables.lua
└── workspace_types.lua
```
## Building Tree-sitter Parser
@@ -294,7 +344,7 @@ The plugin uses a standalone LSP server (`src/main.lua`) that communicates via J
- Completion, hover, go-to-definition
- Semantic tokens
The Neovim plugin (`lua/scl_lsp/init.lua`) manages:
The Neovim plugin (`lua/tia_lsp/init.lua`) manages:
- LSP client lifecycle via `vim.lsp.start()`
- FileType autocmd for lazy loading
- blink.cmp integration