fix(lsp): Fix LSP server attachment and JSON parsing issues

- Replace lspconfig.scl_lsp registration with vim.lsp.start() + FileType autocmd
  for Neovim 0.11+ compatibility
- Fix Lua reserved keyword 'end' in tables (use bracket notation ['end'])
- Fix JSON decoder pattern matching bugs (s:find -> s:sub:match)
- Add LSP method name conversion (textDocument/didOpen -> textDocument_didOpen)
- Handle request vs notification correctly (only respond to requests with id)
- Strip CRLF line endings for Windows compatibility
- Add semantic token handler aliases
- Update documentation with implementation notes
This commit is contained in:
2026-02-18 13:03:14 +01:00
parent 4429280524
commit 96c0c4584f
6 changed files with 201 additions and 91 deletions
+17 -2
View File
@@ -1,6 +1,21 @@
-- SCL Diagnostics - Linter functionality for the LSP server
local M = {}
local parser = require("scl_lsp.parser")
-- Get script path for loading parser (same pattern as main.lua)
local script_path = debug.getinfo(1, "S").source:gsub("^@", ""):match("(.*/)") or ""
if script_path == "" then
script_path = "."
end
if script_path:sub(1, 1) ~= "/" then
local cwd = io.popen("pwd")
if cwd then
script_path = cwd:read("*l") .. "/" .. script_path
cwd:close()
end
end
package.path = package.path .. ";" .. script_path .. "/?.lua"
local parser = dofile(script_path .. "/parser.lua")
local DiagnosticSeverity = {
Error = 1,
@@ -19,7 +34,7 @@ end
local function range_to_lsp(start_line, start_char, end_line, end_char)
return {
start = position_to_lsp(start_line, start_char),
end = position_to_lsp(end_line, end_char),
["end"] = position_to_lsp(end_line, end_char),
}
end