(sigil lsp positions)
(sigil lsp positions) - Position and range helpers for LSP.
LSP uses 0-based line and character indices, where character indices are UTF-16 code units. Sigil's reader/formatter uses 1-based line and column (codepoints). This module converts between the two representations.
Exports
positionprocedureBuild an LSP Position alist (0-based line, 0-based character).
rangeprocedureBuild an LSP Range alist from two positions.
line/col->positionprocedureConvert 1-based line/column (Sigil reader convention) to an LSP Position. Columns of 0 are clamped to 0; otherwise decremented.
range-single-lineprocedureZero-width range at 1-based line/col, used for point diagnostics.
range-whole-lineprocedureWhole-line range at 0-based line index, spanning to next line start.
range-whole-documentprocedureRange covering the entire text, used for full document formatting.
offset->line-colprocedureConvert a byte/char offset in TEXT to (values line0 char0).
line-col->offsetprocedureInverse of offset->line-col. Returns a 0-based offset or #f if the line/column lies past the end of TEXT.
word-at-positionprocedureReturn the identifier at 0-based LINE/CHAR in TEXT, or #f if the position does not lie inside one. Returned as a string.