Compare commits
4
Commits
develop
...
3776ce33ff
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3776ce33ff | ||
|
|
1acac2b73c | ||
|
|
03548dab7d | ||
|
|
aebffc34e7 |
@@ -15,23 +15,49 @@ A Neovim/LazyVim plugin that launches the [`tia-lsp`](https://gitea.l-tech.rs/la
|
||||
| **Attribute Block Toggle** | Interactive expand/collapse of `{...}` blocks with `<Leader>xa` |
|
||||
| **Tree-sitter Highlighting** | Syntax highlighting via tree-sitter queries |
|
||||
|
||||
## Architecture
|
||||
|
||||
This plugin is part of a three-repo ecosystem:
|
||||
|
||||
```
|
||||
tia-lsp.nvim ← Neovim plugin (you are here) — launches the LSP client,
|
||||
│ adds editor features (auto-# prefix, blink.cmp source,
|
||||
│ attribute toggle, workspace scanning, ...)
|
||||
▼
|
||||
tia-lsp ← Standalone LSP server — reads JSON-RPC over stdio,
|
||||
│ provides hover, completion, diagnostics, formatting
|
||||
│ Requires: lua src/main.lua + compiled parser.so
|
||||
▲
|
||||
tia-mason-registry ← mason.nvim recipe — tells mason how to download tia-lsp,
|
||||
compile parser.so, and create the tia-lsp executable
|
||||
```
|
||||
|
||||
- **tia-lsp** ([repo](https://gitea.l-tech.rs/lazar/tia-lsp)) — the actual language server, editor-agnostic
|
||||
- **tia-mason-registry** ([repo](https://gitea.l-tech.rs/lazar/tia-mason-registry)) — a single `package.yaml` for mason
|
||||
- **tia-lsp.nvim** (this repo) — the Neovim-specific integration
|
||||
|
||||
## 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.
|
||||
The plugin auto-detects the mason-installed `tia-lsp` executable via `vim.fn.exepath("tia-lsp")`. If not found, it falls back to running `lua <server_path>` (configurable).
|
||||
|
||||
### LazyVim + Mason (Recommended)
|
||||
|
||||
1. Add the mason registry as a lazy.nvim plugin:
|
||||
Mason downloads and builds the `tia-lsp` server; this plugin configures the LSP client.
|
||||
|
||||
**Step 1: Add the mason registry as a lazy.nvim plugin**
|
||||
|
||||
mason needs a local copy of the registry to read the install recipe. Adding it as a lazy.nvim plugin gets it cloned automatically:
|
||||
|
||||
```lua
|
||||
-- ~/.config/nvim/lua/plugins/tia-mason-registry.lua
|
||||
return {
|
||||
url = "https://gitea.l-tech.rs/lazar/tia-mason-registry.git",
|
||||
name = "tia-mason-registry",
|
||||
lazy = false, -- must be available before mason setup
|
||||
}
|
||||
```
|
||||
|
||||
2. Register the registry with mason:
|
||||
**Step 2: Register the registry with mason**
|
||||
|
||||
```lua
|
||||
-- ~/.config/nvim/lua/plugins/mason.lua
|
||||
return {
|
||||
@@ -45,47 +71,64 @@ The plugin auto-detects the mason-installed `tia-lsp` executable via `vim.fn.exe
|
||||
}
|
||||
```
|
||||
|
||||
3. Add the plugin:
|
||||
> **Why this works:** lazy.nvim clones `tia-mason-registry` to `~/.local/share/nvim/lazy/tia-mason-registry`. The `file:` registry path points mason to that directory, where it finds `packages/tia-lsp/package.yaml`. Mason needs [`yq`](https://github.com/mikefarah/yq) to parse YAML custom registries — install it once: `:MasonInstall yq`
|
||||
|
||||
**Step 3: Install the LSP server**
|
||||
|
||||
```
|
||||
:MasonInstall tia-lsp
|
||||
```
|
||||
|
||||
This clones `tia-lsp` from the source repo, compiles `parser.so` (tree-sitter), and places the `tia-lsp` executable on PATH.
|
||||
|
||||
**Step 4: Add this plugin**
|
||||
|
||||
```lua
|
||||
-- ~/.config/nvim/lua/plugins/tia-lsp.lua
|
||||
return {
|
||||
"lazar/tia-lsp.nvim",
|
||||
"https://gitea.l-tech.rs/lazar/tia-lsp.nvim",
|
||||
ft = "scl",
|
||||
lazy = true,
|
||||
dependencies = {
|
||||
"neovim/nvim-lspconfig",
|
||||
"nvim-treesitter/nvim-treesitter",
|
||||
"saghen/blink.cmp",
|
||||
"saghen/blink.cmp", -- optional, for completion
|
||||
},
|
||||
config = function()
|
||||
require("tia_lsp").setup({
|
||||
opts = {
|
||||
lsp = {
|
||||
on_attach = function(client, bufnr)
|
||||
-- custom keymaps
|
||||
end,
|
||||
-- on_attach = function(client, bufnr) ... end,
|
||||
},
|
||||
cmp = true, -- enable blink.cmp integration
|
||||
workspace_types = true, -- scan project for UDTs and DBs
|
||||
auto_prefix = true, -- auto-# prefix for local variables
|
||||
},
|
||||
cmp = true, -- Enable blink.cmp integration
|
||||
workspace_types = true, -- Enable workspace UDT scanning
|
||||
auto_prefix = true, -- Enable auto-# prefixing
|
||||
debug = false,
|
||||
})
|
||||
end,
|
||||
}
|
||||
```
|
||||
|
||||
4. Install:
|
||||
```
|
||||
:MasonInstall yq " one-time prerequisite for file: registry
|
||||
:MasonInstall tia-lsp " installs the LSP server
|
||||
```
|
||||
**Step 5: Verify**
|
||||
|
||||
5. Verify: open a `.scl` file and run `:LspInfo` — `tia_lsp` should be attached.
|
||||
Open a `.scl` file and run `:LspInfo`. `tia_lsp` should be attached. Run `:checkhealth` for detailed diagnostics.
|
||||
|
||||
---
|
||||
|
||||
### Manual Setup (without Mason)
|
||||
|
||||
Clone and build the server manually, then point the plugin at it.
|
||||
|
||||
```bash
|
||||
# 1. Clone the LSP server
|
||||
git clone --depth 1 https://gitea.l-tech.rs/lazar/tia-lsp.git ~/tia-lsp
|
||||
|
||||
# 2. Compile the tree-sitter parser (required for parsing SCL)
|
||||
cc -fPIC -I ~/tia-lsp/src/tree_sitter -c ~/tia-lsp/src/parser.c -o ~/tia-lsp/parser.o
|
||||
cc -shared ~/tia-lsp/parser.o -o ~/tia-lsp/parser.so
|
||||
```
|
||||
|
||||
Then configure the plugin. The plugin first looks for `tia-lsp` on PATH; if not found, it falls back to running `lua <server_path>`. The tree-sitter parser is loaded from `parser.so` adjacent to the server.
|
||||
|
||||
```lua
|
||||
require("tia_lsp").setup({
|
||||
server_path = "/path/to/tia-lsp/src/main.lua", -- only used if tia-lsp is not on PATH
|
||||
server_path = "~/tia-lsp/src/main.lua", -- fallback if tia-lsp not on PATH
|
||||
ts_parser_url = "https://gitea.l-tech.rs/lazar/tia-lsp.git",
|
||||
cmp = true,
|
||||
workspace_types = true,
|
||||
@@ -97,7 +140,7 @@ require("tia_lsp").setup({
|
||||
|
||||
| Option | Type | Default | Description |
|
||||
|--------|------|---------|-------------|
|
||||
| `server_path` | string | `~/dev/tia-lsp/src/main.lua` | Path to LSP server (only used if `tia-lsp` is not on PATH) |
|
||||
| `server_path` | string | `~/dev/tia-lsp/src/main.lua` | Path to LSP server (fallback when `tia-lsp` not on PATH; change for manual installs) |
|
||||
| `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 |
|
||||
@@ -211,6 +254,17 @@ tia-lsp.nvim/
|
||||
- **blink.cmp** — Optional, for completion
|
||||
- **Lua 5.1+** — LSP server runtime
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
| Symptom | Likely Cause | Fix |
|
||||
|---------|-------------|-----|
|
||||
| `:MasonInstall tia-lsp` fails with "unknown package" | Custom registry not registered with mason | Check the `registries` list in your mason config includes the `file:` path to the cloned registry |
|
||||
| `:MasonInstall tia-lsp` fails with "yq: command not found" | Mason needs `yq` to parse the YAML registry | Run `:MasonInstall yq` to install it, then retry `:MasonInstall tia-lsp` |
|
||||
| `tia_lsp` not attached after opening `.scl` | Server not on PATH or `server_path` points to wrong location | Run `:LspInfo` to see what server is configured. Check `vim.fn.exepath("tia-lsp")` returns a path |
|
||||
| LSP starts but no syntax highlighting | Tree-sitter parser (`parser.so`) not found | mason install generates it automatically. For manual setups, run the `cc` commands in the Manual Setup section |
|
||||
| `parser.so` load error at startup | Compiled for wrong architecture or Lua version | Recompile: clean the old `.so` and run the `cc` build commands again |
|
||||
| LSP starts but no completions/hover | Server can't find its modules | Mason installs to a managed directory. If using manual setup, ensure `src/` contents are present next to `main.lua` |
|
||||
|
||||
## Testing
|
||||
|
||||
```bash
|
||||
|
||||
+111
-17
@@ -13,16 +13,17 @@ function M.setup(opts)
|
||||
setup_package_path()
|
||||
opts = opts or {}
|
||||
|
||||
local server_path = opts.server_path or vim.fn.expand("~/dev/tia-lsp/src/main.lua")
|
||||
local server_path = opts.server_path or vim.fn.expand("~/Documents/lua/tia-lsp/src/main.lua")
|
||||
|
||||
local root_patterns = { ".git", "data_types", "plc.data.json" }
|
||||
|
||||
local function start_lsp(bufnr)
|
||||
local fname = vim.api.nvim_buf_get_name(bufnr)
|
||||
if fname == "" then return end
|
||||
if fname == "" then
|
||||
return
|
||||
end
|
||||
|
||||
local root_dir = vim.fs.root(fname, root_patterns)
|
||||
or vim.fn.fnamemodify(fname, ":p:h")
|
||||
local root_dir = vim.fs.root(fname, root_patterns) or vim.fn.fnamemodify(fname, ":p:h")
|
||||
|
||||
-- Prefer the mason-installed executable (vim.fn.exepath resolves on each
|
||||
-- buffer enter, so a :MasonInstall mid-session is picked up without restart).
|
||||
@@ -53,6 +54,9 @@ function M.setup(opts)
|
||||
pattern = "scl",
|
||||
callback = function(args)
|
||||
start_lsp(args.buf)
|
||||
M.notify_parser_install_if_needed(args.buf)
|
||||
-- Start tree-sitter highlighting if the parser is registered
|
||||
pcall(vim.treesitter.start, args.buf, "scl")
|
||||
end,
|
||||
})
|
||||
|
||||
@@ -65,6 +69,8 @@ function M.setup(opts)
|
||||
for _, bufnr in ipairs(vim.api.nvim_list_bufs()) do
|
||||
if vim.bo[bufnr].filetype == "scl" and vim.api.nvim_buf_is_loaded(bufnr) then
|
||||
start_lsp(bufnr)
|
||||
M.notify_parser_install_if_needed(bufnr)
|
||||
pcall(vim.treesitter.start, bufnr, "scl")
|
||||
end
|
||||
end
|
||||
|
||||
@@ -78,16 +84,87 @@ function M.setup(opts)
|
||||
end
|
||||
end
|
||||
|
||||
-- Find a compiled tree-sitter parser (.so) for SCL.
|
||||
-- Looks in: opts.ts_parser_path, mason package dir, ~/dev/tia-lsp.
|
||||
-- Returns the path to parser.so, or nil if not found.
|
||||
function M.find_parser_so(opts)
|
||||
-- 1. Explicit path from opts
|
||||
if opts.ts_parser_path and vim.fn.filereadable(opts.ts_parser_path) == 1 then
|
||||
return opts.ts_parser_path
|
||||
end
|
||||
-- 2. Mason install: resolve exepath("tia-lsp") -> real bin -> package dir
|
||||
local tia_bin = vim.fn.exepath("tia-lsp")
|
||||
if tia_bin ~= "" then
|
||||
local real_bin = vim.fn.resolve(vim.fn.fnamemodify(tia_bin, ":p"))
|
||||
local pkg_dir = vim.fn.fnamemodify(real_bin, ":h:h")
|
||||
local so = pkg_dir .. "/parser.so"
|
||||
if vim.fn.filereadable(so) == 1 then
|
||||
return so
|
||||
end
|
||||
end
|
||||
-- 3. Local dev path
|
||||
local dev_so = vim.fn.expand("~/dev/tia-lsp/parser.so")
|
||||
if vim.fn.filereadable(dev_so) == 1 then
|
||||
return dev_so
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
-- Notify the user once per session if the tree-sitter parser isn't available.
|
||||
local parser_notified = false
|
||||
|
||||
function M.notify_parser_install_if_needed(bufnr)
|
||||
if parser_notified then
|
||||
return
|
||||
end
|
||||
if vim.bo[bufnr].filetype ~= "scl" then
|
||||
return
|
||||
end
|
||||
local ok = pcall(vim.treesitter.get_parser, bufnr, "scl")
|
||||
if ok then
|
||||
return
|
||||
end
|
||||
parser_notified = true
|
||||
vim.schedule(function()
|
||||
local msg = "SCL: Tree-sitter parser not found. "
|
||||
if vim.fn.exepath("tia-lsp") ~= "" then
|
||||
msg = msg .. "Run :MasonInstall tia-lsp to install it."
|
||||
else
|
||||
msg = msg .. "Install tia-lsp via mason or compile parser.so manually."
|
||||
end
|
||||
vim.notify(msg, vim.log.levels.INFO)
|
||||
end)
|
||||
end
|
||||
|
||||
function M.setup_syntax(opts)
|
||||
local has_ts, ts = pcall(require, "nvim-treesitter.parsers")
|
||||
if has_ts and ts.get_parser_configs then
|
||||
local ok, parser_config = pcall(ts.get_parser_configs)
|
||||
if ok and parser_config then
|
||||
-- Load the compiled tree-sitter parser (.so) via Neovim's built-in API.
|
||||
-- This bypasses nvim-treesitter's install system, which reloads its
|
||||
-- parsers module from source on :TSInstall and wipes runtime config.
|
||||
local parser_so = M.find_parser_so(opts)
|
||||
if parser_so then
|
||||
local ok, err = pcall(vim.treesitter.language.add, "scl", { path = parser_so })
|
||||
if not ok then
|
||||
vim.notify(
|
||||
"SCL: Failed to load tree-sitter parser from " .. parser_so .. ": " .. tostring(err),
|
||||
vim.log.levels.WARN
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
-- Also register with nvim-treesitter (best-effort, for :TSInstall support
|
||||
-- in sessions where the user wants to install from source).
|
||||
local has_ts, parsers = pcall(require, "nvim-treesitter.parsers")
|
||||
if has_ts and type(parsers) == "table" then
|
||||
local parser_config
|
||||
if type(parsers.get_parser_configs) == "function" then
|
||||
parser_config = parsers.get_parser_configs()
|
||||
else
|
||||
parser_config = parsers
|
||||
end
|
||||
if type(parser_config) == "table" then
|
||||
parser_config.scl = {
|
||||
install_info = {
|
||||
-- Override via setup({ ts_parser_url = "https://your-gitea/tia-lsp.git" }).
|
||||
url = opts.ts_parser_url
|
||||
or "https://gitea.l-tech.rs/lazar/tia-lsp.git",
|
||||
url = opts.ts_parser_url or "https://gitea.l-tech.rs/lazar/tia-lsp.git",
|
||||
files = { "src/parser.c" },
|
||||
generate_requires_npm = false,
|
||||
requires_generate_from_grammar = false,
|
||||
@@ -237,15 +314,32 @@ function M.rescan_workspace_types()
|
||||
local udt_result = ws.scan_project_udts()
|
||||
local fb_result = ws.scan_project_fbs()
|
||||
|
||||
vim.notify("Scanned UDTs: " .. udt_result.parsed_count .. "/" .. udt_result.total_files ..
|
||||
", FBs: " .. fb_result.parsed_count .. "/" .. fb_result.total_files, vim.log.levels.INFO)
|
||||
vim.notify(
|
||||
"Scanned UDTs: "
|
||||
.. udt_result.parsed_count
|
||||
.. "/"
|
||||
.. udt_result.total_files
|
||||
.. ", FBs: "
|
||||
.. fb_result.parsed_count
|
||||
.. "/"
|
||||
.. fb_result.total_files,
|
||||
vim.log.levels.INFO
|
||||
)
|
||||
end
|
||||
|
||||
function M.create_commands()
|
||||
vim.api.nvim_create_user_command("SCLShowVariables", function() M.show_variables() end, {})
|
||||
vim.api.nvim_create_user_command("SCLShowWorkspaceTypes", function() M.show_workspace_types() end, {})
|
||||
vim.api.nvim_create_user_command("SCLRescanWorkspaceTypes", function() M.rescan_workspace_types() end, {})
|
||||
vim.api.nvim_create_user_command("SCLPrefixWord", function() M.prefix_current_word() end, {})
|
||||
vim.api.nvim_create_user_command("SCLShowVariables", function()
|
||||
M.show_variables()
|
||||
end, {})
|
||||
vim.api.nvim_create_user_command("SCLShowWorkspaceTypes", function()
|
||||
M.show_workspace_types()
|
||||
end, {})
|
||||
vim.api.nvim_create_user_command("SCLRescanWorkspaceTypes", function()
|
||||
M.rescan_workspace_types()
|
||||
end, {})
|
||||
vim.api.nvim_create_user_command("SCLPrefixWord", function()
|
||||
M.prefix_current_word()
|
||||
end, {})
|
||||
|
||||
-- Attribute toggle commands
|
||||
vim.api.nvim_create_user_command("SCLToggleAttrBlock", function()
|
||||
|
||||
@@ -3,12 +3,21 @@
|
||||
[
|
||||
(organization_block)
|
||||
(function_block)
|
||||
(function)
|
||||
(type_definition)
|
||||
(data_block)
|
||||
(var_declaration)
|
||||
(var_temp_declaration)
|
||||
(var_constant_declaration)
|
||||
(var_retain_declaration)
|
||||
(var_non_retain_declaration)
|
||||
(var_db_specific_declaration)
|
||||
(if_statement)
|
||||
(case_statement)
|
||||
(for_statement)
|
||||
(while_statement)
|
||||
(repeat_statement)
|
||||
(region_statement)
|
||||
(struct_type)
|
||||
(block_comment)
|
||||
] @fold
|
||||
|
||||
+58
-11
@@ -1,66 +1,99 @@
|
||||
; SCL highlights
|
||||
|
||||
; Comments
|
||||
(line_comment) @comment
|
||||
(block_comment) @comment
|
||||
(c_style_comment) @comment
|
||||
|
||||
; Literals
|
||||
(number) @number
|
||||
(hex_number) @number
|
||||
(string) @string
|
||||
(binary_number) @number
|
||||
(octal_number) @number
|
||||
(time_value) @number
|
||||
(date_literal) @number
|
||||
(bool_literal) @constant.builtin
|
||||
(typed_int_literal) @number
|
||||
(wstring_literal) @string
|
||||
(char_literal) @character
|
||||
(string) @string
|
||||
|
||||
; Prefix
|
||||
(prefix) @punctuation.special
|
||||
|
||||
; Variables and identifiers
|
||||
(identifier) @variable
|
||||
|
||||
; FB instance calls - highlight instance name as type
|
||||
; FB instance calls
|
||||
(fb_call
|
||||
instance: (prefixed_identifier
|
||||
(identifier) @type))
|
||||
(fb_call
|
||||
instance: (identifier) @type)
|
||||
|
||||
; FB parameter names (IN :=, PT :=, etc.)
|
||||
; FB parameter names
|
||||
(fb_parameter
|
||||
name: (identifier) @property)
|
||||
|
||||
; Function call names
|
||||
(function_call
|
||||
(identifier) @function)
|
||||
(function_call
|
||||
(string) @function)
|
||||
|
||||
; Method call names
|
||||
(method_callee
|
||||
(identifier) @function)
|
||||
|
||||
; Variable declarations
|
||||
(var_item
|
||||
name: (identifier) @variable)
|
||||
|
||||
; Type references in declarations
|
||||
; Type references
|
||||
(type
|
||||
(identifier) @type)
|
||||
|
||||
(type_builtin) @type.builtin
|
||||
|
||||
; Keywords and operators
|
||||
(keyword) @keyword
|
||||
(constant) @constant.builtin
|
||||
(operator) @operator
|
||||
|
||||
(assignment) @operator
|
||||
(binary_expression) @operator
|
||||
(unary_expression) @operator
|
||||
; Block names
|
||||
(organization_block
|
||||
name: (string) @type)
|
||||
(function_block
|
||||
name: (string) @type)
|
||||
(function
|
||||
name: (string) @function)
|
||||
(data_block
|
||||
name: (string) @type)
|
||||
(type_definition
|
||||
name: (string) @type)
|
||||
|
||||
; Access
|
||||
(field_access
|
||||
"."
|
||||
(identifier) @property)
|
||||
|
||||
(array_access) @property
|
||||
(bit_access) @property
|
||||
|
||||
; Attributes
|
||||
(attribute_list) @attribute
|
||||
(attribute) @attribute
|
||||
(attribute_value) @string
|
||||
|
||||
(var_item) @property
|
||||
; Statements
|
||||
(assignment) @operator
|
||||
(binary_expression) @operator
|
||||
(unary_expression) @operator
|
||||
(chained_assignment) @operator
|
||||
|
||||
; Function/FB calls
|
||||
(function_call) @function.call
|
||||
(fb_call) @function.call
|
||||
|
||||
; Control flow
|
||||
(if_statement) @conditional
|
||||
(elsif_clause) @conditional
|
||||
(else_clause) @conditional
|
||||
@@ -71,6 +104,13 @@
|
||||
(while_statement) @repeat
|
||||
(repeat_statement) @repeat
|
||||
|
||||
(return_statement) @keyword
|
||||
(goto_statement) @keyword
|
||||
|
||||
; Title
|
||||
(title_statement) @comment
|
||||
|
||||
; Punctuation
|
||||
";" @punctuation.delimiter
|
||||
":" @punctuation.delimiter
|
||||
"," @punctuation.delimiter
|
||||
@@ -80,15 +120,22 @@
|
||||
"]" @punctuation.bracket
|
||||
"." @punctuation.delimiter
|
||||
|
||||
; Operators
|
||||
":=" @operator
|
||||
"=>" @operator
|
||||
"+=" @operator
|
||||
"-=" @operator
|
||||
"*=" @operator
|
||||
"/=" @operator
|
||||
"&=" @operator
|
||||
"|=" @operator
|
||||
"^=" @operator
|
||||
"=" @operator
|
||||
"<>" @operator
|
||||
"<" @operator
|
||||
">" @operator
|
||||
"<=" @operator
|
||||
">=" @operator
|
||||
|
||||
"+" @operator
|
||||
"-" @operator
|
||||
"*" @operator
|
||||
|
||||
+26
-2
@@ -1,10 +1,26 @@
|
||||
; Indentation rules for SCL
|
||||
|
||||
; Indent after block keywords
|
||||
; Indent after block definitions
|
||||
[
|
||||
(organization_block)
|
||||
(function_block)
|
||||
(function)
|
||||
(type_definition)
|
||||
(data_block)
|
||||
] @indent.begin
|
||||
|
||||
; Indent after VAR sections
|
||||
[
|
||||
(var_declaration)
|
||||
(var_temp_declaration)
|
||||
(var_constant_declaration)
|
||||
(var_retain_declaration)
|
||||
(var_non_retain_declaration)
|
||||
(var_db_specific_declaration)
|
||||
] @indent.begin
|
||||
|
||||
; Indent after control structures
|
||||
[
|
||||
(if_statement)
|
||||
(case_statement)
|
||||
(for_statement)
|
||||
@@ -13,12 +29,16 @@
|
||||
(region_statement)
|
||||
] @indent.begin
|
||||
|
||||
; Indent after THEN, DO, etc.
|
||||
; Indent after STRUCT in UDTs and inline structs
|
||||
(struct_type) @indent.begin
|
||||
|
||||
; Indent after THEN, DO, ELSE, ELSIF, BEGIN
|
||||
[
|
||||
"THEN"
|
||||
"DO"
|
||||
"ELSE"
|
||||
"ELSIF"
|
||||
(keyword) @indent.branch
|
||||
] @indent.branch
|
||||
|
||||
; Outdent at end keywords
|
||||
@@ -30,8 +50,12 @@
|
||||
"END_WHILE"
|
||||
"END_REPEAT"
|
||||
"END_REGION"
|
||||
"END_STRUCT"
|
||||
"END_ORGANIZATION_BLOCK"
|
||||
"END_FUNCTION_BLOCK"
|
||||
"END_FUNCTION"
|
||||
"END_TYPE"
|
||||
"END_DATA_BLOCK"
|
||||
] @indent.end
|
||||
|
||||
; Outdent for ELSE and ELSIF
|
||||
|
||||
+30
-6
@@ -1,15 +1,39 @@
|
||||
; Local variable scoping for SCL - matches grammar.js structure
|
||||
; Local variable scoping for SCL
|
||||
|
||||
; Variable declarations define local variables
|
||||
(var_item
|
||||
name: (identifier) @definition.var)
|
||||
|
||||
; Variable sections create scopes
|
||||
(var_declaration) @local.scope
|
||||
|
||||
; Blocks create scopes
|
||||
(organization_block) @local.scope
|
||||
(function_block) @local.scope
|
||||
(function) @local.scope
|
||||
(type_definition) @local.scope
|
||||
(data_block) @local.scope
|
||||
|
||||
; Identifiers are references
|
||||
(identifier) @reference
|
||||
; VAR sections create scopes
|
||||
(var_declaration) @local.scope
|
||||
(var_temp_declaration) @local.scope
|
||||
(var_constant_declaration) @local.scope
|
||||
(var_retain_declaration) @local.scope
|
||||
(var_non_retain_declaration) @local.scope
|
||||
(var_db_specific_declaration) @local.scope
|
||||
|
||||
; Struct types create scopes
|
||||
(struct_type) @local.scope
|
||||
|
||||
; Block names are definitions
|
||||
(organization_block
|
||||
name: (string) @definition.function)
|
||||
(function_block
|
||||
name: (string) @definition.function)
|
||||
(function
|
||||
name: (string) @definition.function)
|
||||
(data_block
|
||||
name: (string) @definition.class)
|
||||
(type_definition
|
||||
name: (string) @definition.type)
|
||||
|
||||
; References
|
||||
(prefixed_identifier
|
||||
(identifier) @reference)
|
||||
|
||||
+24
-1
@@ -1,4 +1,4 @@
|
||||
; Tag queries for SCL - matches grammar.js structure
|
||||
; Tag queries for SCL - symbol navigation
|
||||
|
||||
; Organization blocks
|
||||
(organization_block
|
||||
@@ -8,6 +8,18 @@
|
||||
(function_block
|
||||
name: (string) @name) @definition.function
|
||||
|
||||
; Functions
|
||||
(function
|
||||
name: (string) @name) @definition.function
|
||||
|
||||
; Data blocks
|
||||
(data_block
|
||||
name: (string) @name) @definition.class
|
||||
|
||||
; Type definitions (UDTs)
|
||||
(type_definition
|
||||
name: (string) @name) @definition.type
|
||||
|
||||
; Variable definitions within blocks
|
||||
(var_item
|
||||
name: (identifier) @name
|
||||
@@ -25,3 +37,14 @@
|
||||
|
||||
(function_call
|
||||
(string) @name) @reference.call
|
||||
|
||||
; FB calls (references)
|
||||
(fb_call
|
||||
instance: (identifier) @name) @reference.call
|
||||
|
||||
(fb_call
|
||||
instance: (prefixed_identifier
|
||||
(identifier) @name)) @reference.call
|
||||
|
||||
; Region statements
|
||||
(region_statement) @definition.module
|
||||
|
||||
Reference in New Issue
Block a user