Provide generic position-aware text primitives (word-at-position, whole-word occurrences) + a hover MarkupContent builder
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 48/100
- Issue type
- Feature
- Clarity
- Clearly specified
- Activity status
- Quiet
- Tech stack
- rust
Research direction
Read the existing osprey-lsp crates/osprey-lsp/src/text.rs and wire::hover_result implementations, then compare them with lspkit-vfs position conversion and lspkit-server hover handling. Add reusable position-aware text helpers and the optional Markdown hover response builder in the appropriate crates; done means the requested behavior is covered and osprey-lsp can migrate to those shared helpers.
Written by the indexing model from the issue text.
Description
Context
Building hover/definition/references for the Osprey language server (osprey-lsp, built on lspkit/lspkit-server/lspkit-vfs/lspkit-live), we found that lspkit provides the engine contract, JSON-RPC dispatch, capability registration (including the Hover capability), and lspkit-vfs encoding/position conversion — but not the small set of generic, language-agnostic text/position primitives that every LSP backend needs. As a result osprey-lsp hand-rolls them in its own crates/osprey-lsp/src/text.rs.
These are not language-specific: they operate purely on text + PositionEncoding, so they belong in lspkit-vfs (or a lspkit-text module) rather than being reinvented per server.
Requested primitives
-
Word / identifier span at a position — given a line (or rope + position) and a
PositionEncoding, return the identifier under the cursor and its(start, end)character offsets in the negotiated encoding. Today this istext::word_atin osprey-lsp. This is the core lookup behind hover, go-to-definition, signature help, and rename. -
Whole-word occurrence scan — given document text + a name + encoding, return every whole-word occurrence with line/char spans. Today this is
text::occurrences, used for find-references and definition anchoring. -
Encoding-aware column measurement —
char_width(c, encoding)/measure(str, encoding)/prefix_to(line, character, encoding).lspkit-vfsalready hasposition_to_byteinternally; exposing these would let servers stop duplicating the UTF-8/UTF-16 width logic. -
(Minor) Hover
MarkupContentbuilder —lspkit-serverknows theHovercapability but offers no helper to build the{ contents: { kind: \"markdown\", value } }response. A tinyhover_markdown(Option<String>) -> Value(null whenNone) would remove hand-rolled JSON in each server's wire layer.
Why this matters
The "one engine, two surfaces" value of lspkit is undercut if each backend still re-implements identifier extraction and occurrence scanning — exactly the bits most prone to off-by-one and encoding bugs. Centralizing them in lspkit-vfs would make these correct once.
Current workaround
osprey-lsp carries its own text.rs (word_at, occurrences, char_width, measure, prefix_to) and a wire::hover_result JSON builder. We'd happily migrate to lspkit equivalents once available.
Filed while implementing variable hover (type + doc comments) in osprey-lsp; the hover content is necessarily language-specific (Osprey type inference + doc-comment grammar), but the position/text plumbing above is not.
- Dominant language
- Rust
- Stars
- 0
- Forks
- 0
- Avg merge
- 1h 46m
- Merged PRs (30d)
- 13
Getting set up
Starts the project's dev container in your browser, under your own GitHub account.
- No Dockerfile or Docker Compose file
- Has a pull request template
- No contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from Nimblesite/lspkit
-
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
Nimblesite/lspkit#26 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Nimblesite/lspkit#25 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Nimblesite/lspkit#24 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Nimblesite/lspkit#23 ·
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 48/100
Nimblesite/lspkit#28 ·
Maintainers usually reply within 1 day
All issues in Nimblesite/lspkit
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 61/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
rust-embedded/heapless#694 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 75/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
farion1231/cc-switch#8899 · 2 comments ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
manuscript-lang/manuscript#1364 ·
Maintainers usually reply within 1 day