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:
@@ -1,266 +0,0 @@
|
||||
-- SCL (Siemens Structured Control Language) support for Neovim
|
||||
-- Main setup module
|
||||
|
||||
local M = {}
|
||||
|
||||
function M.setup(opts)
|
||||
opts = opts or {}
|
||||
|
||||
-- Add plugin to runtime path
|
||||
vim.opt.runtimepath:prepend(vim.fn.stdpath("data") .. "/lazy/scl_lsp")
|
||||
|
||||
M.create_commands()
|
||||
|
||||
-- Treesitter setup for Neovim 0.11+
|
||||
local function setup_treesitter()
|
||||
local lang = vim.treesitter.language
|
||||
local parser_path = "/home/lazar/dev/scl_lsp/src/parser.so"
|
||||
|
||||
-- Register the SCL language
|
||||
lang.add("scl", {
|
||||
path = parser_path,
|
||||
filetype = "scl",
|
||||
})
|
||||
end
|
||||
|
||||
pcall(setup_treesitter)
|
||||
|
||||
-- Install queries
|
||||
local queries_src = "/home/lazar/dev/scl_lsp/queries/highlights.scm"
|
||||
local queries_dest = vim.fn.stdpath("data") .. "/site/queries/scl/highlights.scm"
|
||||
if vim.fn.filereadable(queries_src) == 1 then
|
||||
vim.fn.mkdir(vim.fn.stdpath("data") .. "/site/queries/scl", "p")
|
||||
vim.fn.writefile(vim.fn.readfile(queries_src), queries_dest)
|
||||
end
|
||||
|
||||
-- Enable treesitter manually for SCL files - bypass LazyVim
|
||||
vim.api.nvim_create_autocmd("FileType", {
|
||||
pattern = "scl",
|
||||
callback = function(args)
|
||||
vim.treesitter.start(args.buf, "scl")
|
||||
end,
|
||||
})
|
||||
|
||||
-- Register blink.cmp source
|
||||
if opts.cmp then
|
||||
local function try_register()
|
||||
local cmp_ok, cmp = pcall(require, "blink.cmp")
|
||||
if cmp_ok and cmp and cmp.add_source_provider then
|
||||
local source_config = {
|
||||
name = "scl",
|
||||
module = "scl.blink_cmp_source",
|
||||
score_offset = 100,
|
||||
}
|
||||
pcall(cmp.add_source_provider, "scl", source_config)
|
||||
pcall(cmp.add_filetype_source, "scl", "scl")
|
||||
|
||||
-- Create autocmd to trigger completion on ( for SCL files
|
||||
local augroup = vim.api.nvim_create_augroup("SCLCompletionTrigger", { clear = true })
|
||||
vim.api.nvim_create_autocmd("TextChangedI", {
|
||||
group = augroup,
|
||||
pattern = "*.scl",
|
||||
callback = function(args)
|
||||
local line = vim.api.nvim_get_current_line()
|
||||
local col = vim.api.nvim_win_get_cursor(0)[2]
|
||||
-- Check if the character before cursor is (
|
||||
if col > 0 and line:sub(col, col) == "(" then
|
||||
-- Check if there's a known FB variable before the (
|
||||
local before_paren = line:sub(1, col - 1):match("[%w_]+%s*$")
|
||||
if before_paren then
|
||||
vim.schedule(function()
|
||||
pcall(require("blink.cmp").show, { providers = { "scl" } })
|
||||
end)
|
||||
end
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
vim.notify("SCL: blink.cmp source registered", vim.log.levels.INFO)
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
if not try_register() then
|
||||
vim.api.nvim_create_autocmd("BufEnter", {
|
||||
pattern = "*.scl",
|
||||
once = true,
|
||||
callback = try_register,
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
-- Workspace type scanner
|
||||
if opts.workspace_types ~= false then
|
||||
local workspace_types = require("scl.workspace_types")
|
||||
workspace_types.setup({
|
||||
project_root = opts.project_root,
|
||||
library_paths = opts.library_paths,
|
||||
debug = opts.debug,
|
||||
})
|
||||
end
|
||||
|
||||
-- Auto-prefixing (enabled by default)
|
||||
M.setup_auto_prefix()
|
||||
|
||||
-- Multiline parameters feature
|
||||
M.setup_multiline_params()
|
||||
|
||||
-- Attribute block toggle feature
|
||||
M.setup_attr_toggle()
|
||||
end
|
||||
|
||||
function M.setup_multiline_params()
|
||||
local mp = require("scl.multiline_params")
|
||||
|
||||
vim.api.nvim_create_user_command("SCLMultilineParams", function()
|
||||
mp.fill_multiline_params()
|
||||
end, {})
|
||||
|
||||
vim.keymap.set("i", "<Space>mp", function()
|
||||
mp.fill_multiline_params()
|
||||
end, { noremap = true, silent = true, desc = "SCL: Fill multiline parameters" })
|
||||
|
||||
vim.keymap.set("i", "<Tab>", function()
|
||||
local ft = vim.bo.filetype
|
||||
if ft == "scl" or ft == "udt" then
|
||||
if mp.jump_to_next_param() then
|
||||
return ""
|
||||
end
|
||||
end
|
||||
return "<Tab>"
|
||||
end, { noremap = true, silent = true, desc = "SCL: Jump to next param or Tab" })
|
||||
end
|
||||
|
||||
function M.setup_auto_prefix()
|
||||
require("scl.auto_prefix").setup()
|
||||
end
|
||||
|
||||
function M.prefix_current_word()
|
||||
require("scl.auto_prefix").prefix_word()
|
||||
end
|
||||
|
||||
function M.show_variables()
|
||||
local vars = require("scl.variables").extract_variables()
|
||||
if #vars == 0 then
|
||||
vim.notify("No local variables found", vim.log.levels.INFO)
|
||||
return
|
||||
end
|
||||
local lines = { "Local Variables:", "---" }
|
||||
for _, var in ipairs(vars) do
|
||||
local type_info = var.type and (" : " .. var.type) or ""
|
||||
table.insert(lines, "#" .. var.name .. type_info)
|
||||
end
|
||||
vim.notify(table.concat(lines, "\n"), vim.log.levels.INFO)
|
||||
end
|
||||
|
||||
function M.show_workspace_types()
|
||||
local ws = require("scl.workspace_types")
|
||||
local udt = require("scl.udt_parser")
|
||||
local fb = require("scl.fb_parser")
|
||||
local db = require("scl.db_parser")
|
||||
local root = ws.get_project_root()
|
||||
local udt_names = udt.get_all_udt_names()
|
||||
local fb_names = fb.get_all_fb_names()
|
||||
local db_names = db.get_all_db_names()
|
||||
if not root then
|
||||
vim.notify("No project root detected", vim.log.levels.WARN)
|
||||
return
|
||||
end
|
||||
vim.notify("Project: " .. root .. "\nUDTs: " .. #udt_names .. "\nFBs/Functions: " .. #fb_names .. "\nGlobal DBs: " .. #db_names, vim.log.levels.INFO)
|
||||
end
|
||||
|
||||
function M.rescan_workspace_types()
|
||||
local ws = require("scl.workspace_types")
|
||||
local udt = require("scl.udt_parser")
|
||||
local fb = require("scl.fb_parser")
|
||||
local db = require("scl.db_parser")
|
||||
udt.clear_cache()
|
||||
fb.clear_cache()
|
||||
db.clear_cache()
|
||||
ws.clear_root_cache()
|
||||
local udt_result = ws.scan_project_udts()
|
||||
local fb_result = ws.scan_project_fbs()
|
||||
local db_result = ws.scan_project_dbs()
|
||||
vim.notify("Scanned UDTs: " .. udt_result.parsed_count .. "/" .. udt_result.total_files ..
|
||||
", FBs: " .. fb_result.parsed_count .. "/" .. fb_result.total_files ..
|
||||
", DBs: " .. db_result.parsed_count .. "/" .. db_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, {})
|
||||
|
||||
-- Attribute toggle commands
|
||||
vim.api.nvim_create_user_command("SCLToggleAttrBlock", function()
|
||||
local ok, at = pcall(require, "scl.attr_toggle")
|
||||
if ok then
|
||||
at.toggle_attr_block()
|
||||
else
|
||||
vim.notify("SCL: Failed to load attr_toggle module", vim.log.levels.ERROR)
|
||||
end
|
||||
end, {})
|
||||
vim.api.nvim_create_user_command("SCLExpandAllAttrBlocks", function()
|
||||
local ok, at = pcall(require, "scl.attr_toggle")
|
||||
if ok then
|
||||
at.expand_all_attr_blocks()
|
||||
else
|
||||
vim.notify("SCL: Failed to load attr_toggle module", vim.log.levels.ERROR)
|
||||
end
|
||||
end, {})
|
||||
vim.api.nvim_create_user_command("SCLCollapseAllAttrBlocks", function()
|
||||
local ok, at = pcall(require, "scl.attr_toggle")
|
||||
if ok then
|
||||
at.collapse_all_attr_blocks()
|
||||
else
|
||||
vim.notify("SCL: Failed to load attr_toggle module", vim.log.levels.ERROR)
|
||||
end
|
||||
end, {})
|
||||
end
|
||||
|
||||
function M.setup_attr_toggle()
|
||||
local at = require("scl.attr_toggle")
|
||||
at.setup()
|
||||
|
||||
local function setup_buffer_keymaps(bufnr)
|
||||
local opts = { buffer = bufnr, silent = true }
|
||||
local ft = vim.bo[bufnr].filetype
|
||||
|
||||
if ft ~= "scl" and ft ~= "udt" then
|
||||
return
|
||||
end
|
||||
|
||||
-- Toggle individual attribute block under cursor
|
||||
vim.keymap.set({ "n", "i" }, "<Leader>xa", function()
|
||||
at.toggle_attr_block()
|
||||
end, vim.tbl_extend("force", opts, { desc = "SCL: Toggle attribute block" }))
|
||||
|
||||
-- Expand all collapsed blocks
|
||||
vim.keymap.set("n", "<Leader>xae", function()
|
||||
at.expand_all_attr_blocks()
|
||||
end, vim.tbl_extend("force", opts, { desc = "SCL: Expand all attribute blocks" }))
|
||||
|
||||
-- Collapse all attribute blocks
|
||||
vim.keymap.set("n", "<Leader>xac", function()
|
||||
at.collapse_all_attr_blocks()
|
||||
end, vim.tbl_extend("force", opts, { desc = "SCL: Collapse all attribute blocks" }))
|
||||
end
|
||||
|
||||
-- Set up keybindings for SCL files only
|
||||
vim.api.nvim_create_autocmd("FileType", {
|
||||
pattern = { "scl", "udt" },
|
||||
callback = function(args)
|
||||
setup_buffer_keymaps(args.buf)
|
||||
end,
|
||||
})
|
||||
|
||||
-- Also check if there are already SCL buffers open
|
||||
for _, bufnr in ipairs(vim.api.nvim_list_bufs()) do
|
||||
if vim.api.nvim_buf_is_loaded(bufnr) then
|
||||
setup_buffer_keymaps(bufnr)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return M
|
||||
@@ -71,7 +71,7 @@ local function get_local_variables()
|
||||
end
|
||||
end
|
||||
|
||||
local scl_vars = require("scl.variables")
|
||||
local scl_vars = require("tia.variables")
|
||||
local vars = scl_vars.extract_variables(bufnr)
|
||||
|
||||
var_cache = {}
|
||||
@@ -545,7 +545,7 @@ function M.setup()
|
||||
local before_semicolon = line:sub(1, cursor_col - 1)
|
||||
local type_name = before_semicolon:match(":%s*([%w_]+)%s*$")
|
||||
if type_name then
|
||||
local udt_parser = require("scl.udt_parser")
|
||||
local udt_parser = require("tia.udt_parser")
|
||||
local is_udt = udt_parser.is_udt_type(type_name)
|
||||
if is_udt and not before_semicolon:match(":%s*\"" .. type_name .. "\"") then
|
||||
local new_before = before_semicolon:gsub(":%s*" .. type_name .. "%s*$", ':"' .. type_name .. '"')
|
||||
@@ -104,7 +104,7 @@ end
|
||||
|
||||
-- Get all known local variables
|
||||
local function get_known_variables(bufnr)
|
||||
local scl_vars = require("scl.variables")
|
||||
local scl_vars = require("tia.variables")
|
||||
local variables = scl_vars.extract_variables(bufnr)
|
||||
local known = {}
|
||||
for _, v in ipairs(variables) do
|
||||
@@ -115,12 +115,12 @@ end
|
||||
|
||||
-- Check if a type is an FB/Function and get its interface
|
||||
local function get_fb_interface(var_type)
|
||||
local fb_parser = require("scl.fb_parser")
|
||||
local fb_parser = require("tia.fb_parser")
|
||||
local clean_type = var_type:gsub('"', '')
|
||||
|
||||
-- If cache is empty, try to scan workspace for FBs
|
||||
if fb_parser.get_cache_count() == 0 then
|
||||
local ws = require("scl.workspace_types")
|
||||
local ws = require("tia.workspace_types")
|
||||
ws.scan_project_fbs(vim.api.nvim_get_current_buf())
|
||||
end
|
||||
|
||||
@@ -129,12 +129,12 @@ end
|
||||
|
||||
-- Check if a type is an FB/Function
|
||||
local function is_fb_type(var_type)
|
||||
local fb_parser = require("scl.fb_parser")
|
||||
local fb_parser = require("tia.fb_parser")
|
||||
local clean_type = var_type:gsub('"', '')
|
||||
|
||||
-- If cache is empty, try to scan workspace for FBs
|
||||
if fb_parser.get_cache_count() == 0 then
|
||||
local ws = require("scl.workspace_types")
|
||||
local ws = require("tia.workspace_types")
|
||||
ws.scan_project_fbs(vim.api.nvim_get_current_buf())
|
||||
end
|
||||
|
||||
@@ -236,7 +236,7 @@ function M:get_completions(context, callback)
|
||||
local after_closed_db = active_portion:match('"([%w_]+)"%s*%.') ~= nil
|
||||
|
||||
if db_member_pattern or after_closed_db then
|
||||
local db_parser = require("scl.db_parser")
|
||||
local db_parser = require("tia.db_parser")
|
||||
local db_name = active_portion:match('"([%w_]+)"')
|
||||
|
||||
if db_name then
|
||||
@@ -271,7 +271,7 @@ function M:get_completions(context, callback)
|
||||
resolved_path = part
|
||||
if found_member.is_udt then
|
||||
-- This member is a UDT type, continue resolving
|
||||
local udt_parser = require("scl.udt_parser")
|
||||
local udt_parser = require("tia.udt_parser")
|
||||
current_members = udt_parser.get_udt_members(found_member.type)
|
||||
current_type = found_member.type
|
||||
else
|
||||
@@ -306,7 +306,7 @@ function M:get_completions(context, callback)
|
||||
|
||||
-- Get members to show (either from DB or from resolved UDT type)
|
||||
if current_type then
|
||||
local udt_parser = require("scl.udt_parser")
|
||||
local udt_parser = require("tia.udt_parser")
|
||||
current_members = udt_parser.get_udt_members(current_type)
|
||||
end
|
||||
|
||||
@@ -335,11 +335,11 @@ function M:get_completions(context, callback)
|
||||
|
||||
-- Check for just " pattern (start of DB name completion or partial DB name)
|
||||
if is_in_db_name or is_partial_db or is_after_colon_quote then
|
||||
local db_parser = require("scl.db_parser")
|
||||
local db_parser = require("tia.db_parser")
|
||||
|
||||
-- If cache is empty, try to scan workspace for DBs
|
||||
if db_parser.get_cache_count() == 0 then
|
||||
local ws = require("scl.workspace_types")
|
||||
local ws = require("tia.workspace_types")
|
||||
ws.scan_project_dbs(bufnr)
|
||||
end
|
||||
|
||||
@@ -376,7 +376,7 @@ function M:get_completions(context, callback)
|
||||
end
|
||||
end
|
||||
|
||||
local scl_vars = require("scl.variables")
|
||||
local scl_vars = require("tia.variables")
|
||||
local variables = scl_vars.extract_variables(bufnr)
|
||||
|
||||
-- Get all known local variables and their types
|
||||
@@ -747,8 +747,8 @@ function M:get_completions(context, callback)
|
||||
end)
|
||||
|
||||
vim.schedule(function()
|
||||
local udt_parser = require("scl.udt_parser")
|
||||
local db_parser = require("scl.db_parser")
|
||||
local udt_parser = require("tia.udt_parser")
|
||||
local db_parser = require("tia.db_parser")
|
||||
|
||||
-- No member access = show local variables, UDT types, and basic types
|
||||
if not base_var then
|
||||
@@ -779,9 +779,9 @@ function M:get_completions(context, callback)
|
||||
end
|
||||
|
||||
-- Add Global DB names (without quotes - will be wrapped in resolve)
|
||||
local db_parser = require("scl.db_parser")
|
||||
local db_parser = require("tia.db_parser")
|
||||
if db_parser.get_cache_count() == 0 then
|
||||
local ws = require("scl.workspace_types")
|
||||
local ws = require("tia.workspace_types")
|
||||
ws.scan_project_dbs(bufnr)
|
||||
end
|
||||
|
||||
@@ -7,7 +7,7 @@ local M = {}
|
||||
--- @param var_type string The FB type name
|
||||
--- @return table|nil Interface with inputs, outputs, inouts
|
||||
local function get_builtin_interface(var_type)
|
||||
local builtin = require("scl.builtin_instructions")
|
||||
local builtin = require("tia.builtin_instructions")
|
||||
local clean_type = var_type:gsub('"', ''):gsub("#", ""):upper()
|
||||
local params_info = builtin.get_parameters(clean_type)
|
||||
if params_info then
|
||||
@@ -24,11 +24,11 @@ end
|
||||
--- @param var_type string The FB type name
|
||||
--- @return table|nil Interface with inputs, outputs, inouts
|
||||
local function get_fb_interface(var_type)
|
||||
local fb_parser = require("scl.fb_parser")
|
||||
local fb_parser = require("tia.fb_parser")
|
||||
local clean_type = var_type:gsub('"', '')
|
||||
|
||||
if fb_parser.get_cache_count() == 0 then
|
||||
local ws = require("scl.workspace_types")
|
||||
local ws = require("tia.workspace_types")
|
||||
ws.scan_project_fbs(vim.api.nvim_get_current_buf())
|
||||
end
|
||||
|
||||
@@ -39,11 +39,11 @@ end
|
||||
--- @param var_type string The type name to check
|
||||
--- @return boolean True if type is an FB
|
||||
local function is_fb_type(var_type)
|
||||
local fb_parser = require("scl.fb_parser")
|
||||
local fb_parser = require("tia.fb_parser")
|
||||
local clean_type = var_type:gsub('"', '')
|
||||
|
||||
if fb_parser.get_cache_count() == 0 then
|
||||
local ws = require("scl.workspace_types")
|
||||
local ws = require("tia.workspace_types")
|
||||
ws.scan_project_fbs(vim.api.nvim_get_current_buf())
|
||||
end
|
||||
|
||||
@@ -54,7 +54,7 @@ end
|
||||
--- @param bufnr number Buffer number
|
||||
--- @return table Set of variable names
|
||||
local function get_known_variables(bufnr)
|
||||
local scl_vars = require("scl.variables")
|
||||
local scl_vars = require("tia.variables")
|
||||
local variables = scl_vars.extract_variables(bufnr)
|
||||
local known = {}
|
||||
for _, v in ipairs(variables) do
|
||||
@@ -68,7 +68,7 @@ end
|
||||
--- @param bufnr number Buffer number
|
||||
--- @return string|nil Variable type, or nil if not found
|
||||
local function get_variable_type(var_name, bufnr)
|
||||
local scl_vars = require("scl.variables")
|
||||
local scl_vars = require("tia.variables")
|
||||
return scl_vars.get_variable_type(var_name, bufnr)
|
||||
end
|
||||
|
||||
@@ -84,7 +84,7 @@ function M.fill_multiline_params()
|
||||
local line_before_cursor = line:sub(1, col)
|
||||
|
||||
local known_vars = get_known_variables(bufnr)
|
||||
local builtin = require("scl.builtin_instructions")
|
||||
local builtin = require("tia.builtin_instructions")
|
||||
|
||||
local fb_name = nil
|
||||
local fb_prefix = ""
|
||||
@@ -361,7 +361,7 @@ end
|
||||
|
||||
-- Parse all UDT files in project and libraries
|
||||
function M.scan_project_udts(bufnr)
|
||||
local udt_parser = require("scl.udt_parser")
|
||||
local udt_parser = require("tia.udt_parser")
|
||||
local files = M.get_project_udt_files(bufnr)
|
||||
local lib_files = M.get_library_udt_files()
|
||||
|
||||
@@ -391,7 +391,7 @@ end
|
||||
|
||||
-- Parse all FB/Function files in project and libraries
|
||||
function M.scan_project_fbs(bufnr)
|
||||
local fb_parser = require("scl.fb_parser")
|
||||
local fb_parser = require("tia.fb_parser")
|
||||
local files = M.get_project_fb_files(bufnr)
|
||||
local lib_files = M.get_library_fb_files()
|
||||
|
||||
@@ -421,7 +421,7 @@ end
|
||||
|
||||
-- Parse all Global DB files in project and libraries
|
||||
function M.scan_project_dbs(bufnr)
|
||||
local db_parser = require("scl.db_parser")
|
||||
local db_parser = require("tia.db_parser")
|
||||
local files = M.get_project_db_files(bufnr)
|
||||
local lib_files = M.get_library_db_files()
|
||||
|
||||
@@ -486,9 +486,9 @@ function M.setup(opts)
|
||||
pattern = "*.scl",
|
||||
callback = function(args)
|
||||
-- Clear cache and rescan
|
||||
local udt_parser = require("scl.udt_parser")
|
||||
local fb_parser = require("scl.fb_parser")
|
||||
local db_parser = require("scl.db_parser")
|
||||
local udt_parser = require("tia.udt_parser")
|
||||
local fb_parser = require("tia.fb_parser")
|
||||
local db_parser = require("tia.db_parser")
|
||||
udt_parser.clear_cache()
|
||||
fb_parser.clear_cache()
|
||||
db_parser.clear_cache()
|
||||
@@ -506,7 +506,7 @@ function M.setup(opts)
|
||||
pattern = "*.udt",
|
||||
callback = function(args)
|
||||
-- Re-parse the changed UDT file
|
||||
local udt_parser = require("scl.udt_parser")
|
||||
local udt_parser = require("tia.udt_parser")
|
||||
udt_parser.parse_udt_file(args.file)
|
||||
end,
|
||||
})
|
||||
@@ -517,7 +517,7 @@ function M.setup(opts)
|
||||
pattern = "*.scl",
|
||||
callback = function(args)
|
||||
-- Re-parse the changed FB file
|
||||
local fb_parser = require("scl.fb_parser")
|
||||
local fb_parser = require("tia.fb_parser")
|
||||
fb_parser.parse_fb_file(args.file)
|
||||
end,
|
||||
})
|
||||
@@ -527,7 +527,7 @@ function M.setup(opts)
|
||||
group = augroup,
|
||||
pattern = "*.db",
|
||||
callback = function(args)
|
||||
local db_parser = require("scl.db_parser")
|
||||
local db_parser = require("tia.db_parser")
|
||||
db_parser.parse_db_file(args.file)
|
||||
end,
|
||||
})
|
||||
@@ -2,7 +2,7 @@ local M = {}
|
||||
|
||||
local function setup_package_path()
|
||||
local plugin_path = debug.getinfo(1, "S").source:gsub("^@", ""):match("(.*/)") or ""
|
||||
plugin_path = plugin_path:gsub("/lua/scl_lsp", "")
|
||||
plugin_path = plugin_path:gsub("/lua/tia_lsp", "")
|
||||
local lua_path = plugin_path .. "/lua"
|
||||
if not package.path:match(lua_path) then
|
||||
package.path = lua_path .. "/?.lua;" .. package.path
|
||||
@@ -13,7 +13,7 @@ function M.setup(opts)
|
||||
setup_package_path()
|
||||
opts = opts or {}
|
||||
|
||||
local server_path = opts.server_path or vim.fn.expand("~/dev/scl_lsp/src/main.lua")
|
||||
local server_path = opts.server_path or vim.fn.expand("~/dev/tia-lsp/src/main.lua")
|
||||
|
||||
local root_patterns = { ".git", "data_types", "plc.data.json" }
|
||||
|
||||
@@ -24,9 +24,15 @@ function M.setup(opts)
|
||||
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).
|
||||
-- Fall back to running the server via `lua <server_path>` for manual installs.
|
||||
local tia_bin = vim.fn.exepath("tia-lsp")
|
||||
local cmd = tia_bin ~= "" and { "tia-lsp" } or { "lua", server_path }
|
||||
|
||||
vim.lsp.start({
|
||||
name = "scl_lsp",
|
||||
cmd = { "lua", server_path },
|
||||
name = "tia_lsp",
|
||||
cmd = cmd,
|
||||
root_dir = root_dir,
|
||||
on_attach = function(client, b)
|
||||
if opts.lsp and opts.lsp.on_attach then
|
||||
@@ -35,7 +41,7 @@ function M.setup(opts)
|
||||
|
||||
if opts.lsp and opts.lsp.formatting then
|
||||
vim.api.nvim_buf_create_user_command(b, "SCLFormat", function()
|
||||
vim.lsp.buf.format({ name = "scl_lsp" })
|
||||
vim.lsp.buf.format({ name = "tia_lsp" })
|
||||
end, {})
|
||||
end
|
||||
end,
|
||||
@@ -52,7 +58,7 @@ function M.setup(opts)
|
||||
|
||||
-- Create global format command (works on current buffer)
|
||||
vim.api.nvim_create_user_command("SCLFormat", function()
|
||||
vim.lsp.buf.format({ name = "scl_lsp" })
|
||||
vim.lsp.buf.format({ name = "tia_lsp" })
|
||||
end, {})
|
||||
|
||||
-- Start LSP for any existing scl buffers (handles lazy loading case)
|
||||
@@ -79,7 +85,11 @@ function M.setup_syntax(opts)
|
||||
if ok and parser_config then
|
||||
parser_config.scl = {
|
||||
install_info = {
|
||||
url = "file://" .. vim.fn.expand("~/dev/scl_lsp"),
|
||||
-- Override via setup({ ts_parser_url = "https://your-gitea/tia-lsp.git" }).
|
||||
-- Default is the upstream TIA Portal LSP server repo (placeholder until
|
||||
-- the split is complete; see README "Mason installation").
|
||||
url = opts.ts_parser_url
|
||||
or "file://" .. vim.fn.expand("~/dev/tia-lsp"),
|
||||
files = { "src/parser.c" },
|
||||
generate_requires_npm = false,
|
||||
requires_generate_from_grammar = false,
|
||||
@@ -92,7 +102,7 @@ function M.setup_syntax(opts)
|
||||
if opts.cmp then
|
||||
local function try_register()
|
||||
local cmp_ok, cmp = pcall(require, "blink.cmp")
|
||||
local blink_source_ok, blink_source = pcall(require, "scl.blink_cmp_source")
|
||||
local blink_source_ok, blink_source = pcall(require, "tia.blink_cmp_source")
|
||||
if cmp_ok and cmp and cmp.add_source_provider and blink_source_ok then
|
||||
local source_config = {
|
||||
name = "scl",
|
||||
@@ -118,7 +128,7 @@ function M.setup_syntax(opts)
|
||||
end
|
||||
|
||||
if opts.workspace_types ~= false then
|
||||
local ok, workspace_types = pcall(require, "scl.workspace_types")
|
||||
local ok, workspace_types = pcall(require, "tia.workspace_types")
|
||||
if ok then
|
||||
workspace_types.setup({
|
||||
project_root = opts.project_root,
|
||||
@@ -130,14 +140,14 @@ function M.setup_syntax(opts)
|
||||
end
|
||||
|
||||
function M.setup_auto_prefix()
|
||||
local ok, auto_prefix = pcall(require, "scl.auto_prefix")
|
||||
local ok, auto_prefix = pcall(require, "tia.auto_prefix")
|
||||
if ok then
|
||||
auto_prefix.setup()
|
||||
end
|
||||
end
|
||||
|
||||
function M.setup_multiline_params()
|
||||
local ok, mp = pcall(require, "scl.multiline_params")
|
||||
local ok, mp = pcall(require, "tia.multiline_params")
|
||||
if not ok then
|
||||
vim.notify("SCL multiline_params module not found", vim.log.levels.WARN)
|
||||
return
|
||||
@@ -163,14 +173,14 @@ function M.setup_multiline_params()
|
||||
end
|
||||
|
||||
function M.prefix_current_word()
|
||||
local ok, auto_prefix = pcall(require, "scl.auto_prefix")
|
||||
local ok, auto_prefix = pcall(require, "tia.auto_prefix")
|
||||
if ok then
|
||||
auto_prefix.prefix_word()
|
||||
end
|
||||
end
|
||||
|
||||
function M.show_variables()
|
||||
local ok, variables = pcall(require, "scl.variables")
|
||||
local ok, variables = pcall(require, "tia.variables")
|
||||
if not ok then
|
||||
vim.notify("SCL variables module not found", vim.log.levels.WARN)
|
||||
return
|
||||
@@ -191,9 +201,9 @@ function M.show_variables()
|
||||
end
|
||||
|
||||
function M.show_workspace_types()
|
||||
local ok_ws, ws = pcall(require, "scl.workspace_types")
|
||||
local ok_udt, udt = pcall(require, "scl.udt_parser")
|
||||
local ok_fb, fb = pcall(require, "scl.fb_parser")
|
||||
local ok_ws, ws = pcall(require, "tia.workspace_types")
|
||||
local ok_udt, udt = pcall(require, "tia.udt_parser")
|
||||
local ok_fb, fb = pcall(require, "tia.fb_parser")
|
||||
|
||||
if not ok_ws or not ok_udt or not ok_fb then
|
||||
vim.notify("SCL workspace modules not found", vim.log.levels.WARN)
|
||||
@@ -213,9 +223,9 @@ function M.show_workspace_types()
|
||||
end
|
||||
|
||||
function M.rescan_workspace_types()
|
||||
local ok_ws, ws = pcall(require, "scl.workspace_types")
|
||||
local ok_udt, udt = pcall(require, "scl.udt_parser")
|
||||
local ok_fb, fb = pcall(require, "scl.fb_parser")
|
||||
local ok_ws, ws = pcall(require, "tia.workspace_types")
|
||||
local ok_udt, udt = pcall(require, "tia.udt_parser")
|
||||
local ok_fb, fb = pcall(require, "tia.fb_parser")
|
||||
|
||||
if not ok_ws or not ok_udt or not ok_fb then
|
||||
vim.notify("SCL workspace modules not found", vim.log.levels.WARN)
|
||||
@@ -241,7 +251,7 @@ function M.create_commands()
|
||||
|
||||
-- Attribute toggle commands
|
||||
vim.api.nvim_create_user_command("SCLToggleAttrBlock", function()
|
||||
local ok, at = pcall(require, "scl.attr_toggle")
|
||||
local ok, at = pcall(require, "tia.attr_toggle")
|
||||
if ok then
|
||||
at.toggle_attr_block()
|
||||
else
|
||||
@@ -250,7 +260,7 @@ function M.create_commands()
|
||||
end, {})
|
||||
|
||||
vim.api.nvim_create_user_command("SCLExpandAllAttrBlocks", function()
|
||||
local ok, at = pcall(require, "scl.attr_toggle")
|
||||
local ok, at = pcall(require, "tia.attr_toggle")
|
||||
if ok then
|
||||
at.expand_all_attr_blocks()
|
||||
else
|
||||
@@ -259,7 +269,7 @@ function M.create_commands()
|
||||
end, {})
|
||||
|
||||
vim.api.nvim_create_user_command("SCLCollapseAllAttrBlocks", function()
|
||||
local ok, at = pcall(require, "scl.attr_toggle")
|
||||
local ok, at = pcall(require, "tia.attr_toggle")
|
||||
if ok then
|
||||
at.collapse_all_attr_blocks()
|
||||
else
|
||||
@@ -269,7 +279,7 @@ function M.create_commands()
|
||||
end
|
||||
|
||||
function M.setup_attr_toggle()
|
||||
local ok, at = pcall(require, "scl.attr_toggle")
|
||||
local ok, at = pcall(require, "tia.attr_toggle")
|
||||
if not ok then
|
||||
vim.notify("SCL: attr_toggle module not found", vim.log.levels.WARN)
|
||||
return
|
||||
@@ -1,5 +1,5 @@
|
||||
return {
|
||||
"lazar/scl_lsp",
|
||||
"lazar/tia-lsp.nvim",
|
||||
ft = "scl",
|
||||
lazy = true,
|
||||
dependencies = {
|
||||
@@ -8,8 +8,9 @@ return {
|
||||
"saghen/blink.cmp",
|
||||
},
|
||||
config = function(_, opts)
|
||||
require("scl_lsp").setup({
|
||||
require("tia_lsp").setup({
|
||||
server_path = opts.server_path,
|
||||
ts_parser_url = opts.ts_parser_url,
|
||||
lsp = opts.lsp,
|
||||
cmp = opts.cmp ~= false,
|
||||
workspace_types = opts.workspace_types ~= false,
|
||||
Reference in New Issue
Block a user