feat: recognize Sublime Text's git language id as git commit messages#3782
Open
costajohnt wants to merge 2 commits into
Open
feat: recognize Sublime Text's git language id as git commit messages#3782costajohnt wants to merge 2 commits into
git language id as git commit messages#3782costajohnt wants to merge 2 commits into
Conversation
Sublime Text's LSP client reports `languageId: "git"` when editing a git commit message, so harper-ls never linted those documents. Add `git` to the git-commit parser match arm, alongside the existing `git-commit`/`scminput` ids. Refs Automattic#3781
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issues
Closes #3781
Description
Sublime Text's LSP client reports
languageId: "git"when you edit a git commit message, so harper-ls was not linting those buffers. This addsgitto the git-commit parser match arm, next to the existinggit-commit/gitcommit/scminputids, so Sublime commit messages get the same grammar checking as the other editors.One thing worth your call: Sublime derives the languageId from the syntax scope's second component (
basescope2languageid), and its wholetext.git.*family (commit, ignore, config, rebase, and so on) collapses togit. So this arm also catches non-commit git files edited in Sublime with harper attached. There is no way to tell them apart at the languageId layer. The blast radius is bounded:GitCommitParsermasks through tree-sitter-gitcommit and only lints the subject and message lines, so a.gitignorejust picks up some prose false positives, no crash. I left a comment on the arm noting this. If you would rather keep it narrower, the alternative is leaving users to add{"text.git.commit": "git-commit"}to theirlanguage-ids.sublime-settings(the reporter's current workaround), but that pushes config onto every Sublime user.Demo
Not applicable, this is an LSP languageId mapping. Behavior: Sublime sends
languageId: "git"for a commit buffer, and harper-ls now routes it to the git commit parser instead of leaving it unlinted.How Has This Been Tested?
cargo clippy -p harper-lsandcargo fmt --check -p harper-lsare clean. The change mirrors the existinggit-commit/scminputarms exactly (same target parser), differing only in the languageId string the client reports.I did not add a Rust test. The languageId match lives inline in
update_documentwith no unit-test seam, and the analogousscminputaddition (#3729) was covered by the VS Code integration suite, which does not apply here since harper ships no Sublime client. Glad to add a test if you have a preferred harness for the languageId routing.AI Disclosure
If Your PR Implements or Enhances a Linter
Not applicable, this adds a language-id mapping rather than a linter rule.
Checklist