posit-dev / posit-dev/positron

Add pluggable word count provider to Positron

Open
#3,589 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

area: ui enhancement
Dominant language
TypeScript
Stars
4.3k
Forks
184
Avg merge
1d 11h
Merged PRs (30d)
206

Description

There are a few tools already to help count words in Quarto documents.

https://github.com/yunier-olivera/markdown-quarto-word-count
https://github.com/andrewheiss/quarto-wordcount

And there's a word count add-in from Microsoft that counts words in Markdown documents.

https://marketplace.visualstudio.com/items?itemName=ms-vscode.wordcount

However, these tools aren't integrated with the IDE in any meaningful way. They also show the wordcount in the global status bar, which is already overloaded and -- especially in Positron, due to the Console -- some distance from the document whose words are being enumerated.

In this way, it's a bit like spell check -- see #1485.

Word counting can be pretty difficult due to the language-specific context around what counts as a word and what doesn't. I would propose that, as part of our effort to make Positron a first-class environment for scientific authoring, we:

  • Create an API that extensions can use to supply a word count, using the typical *Provider model used to supply other language features. This would be easiest to add to the Positron LSP extensions since they are the right place to efficiently update the word count as the document mutates, without needing to do a full re-scan in most cases.
  • Possibly display the word count, if available, in the editor surface in a small status bar or similar.

Another possibility would be to add an API more generally for contributing to a small status bar that lives on the bottom of the editor.

(originally via slack: https://positpbc.slack.com/archives/C05M2EZCPGR/p1718716125891049)

(interesting project via @hadley: state machine for word counting https://github.com/robertdavidgraham/wc2)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the existing provider APIs and the Positron LSP extensions, then examine how the editor surface currently exposes document information. Clarify whether the goal is only an extension API or also an editor status area; done requires an agreed design for supplying and displaying word counts.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
developer-experience, tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
28/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.