Repository navigation
Conversation
- permission_window: the permission dialog derived the fence language from the raw extension (fnamemodify(path, ':e')) instead of the helper the formatter already used, so `.rs` was labelled `rs` and never highlighted. Reuse the helper, which resolves the full language name (.rs -> rust). - util: rename get_markdown_filetype to get_markdown_language and resolve path -> filetype (vim.filetype.match) -> treesitter language (vim.treesitter.language.get_lang) instead of the hand-written override table, which was incomplete and wrong (yaml -> yml has no parser and turned a case that resolved on its own into a broken one; javascipt -> js was a typo that never matched; text -> txt is not a language; typescript -> ts / javascriptreact -> jsx only worked because nvim-treesitter aliases those extensions). - util: get_lang only maps filetypes to languages when nvim-treesitter is installed, so keep a small filetype -> language table for the common name mismatches (sh -> bash, cs -> c_sharp, svg -> xml, ...) as a fallback for setups without it. With nvim-treesitter, get_lang already resolves those and the table changes nothing. rs needs no entry: vim.filetype.match already turns .rs into the rust filetype. - context/formatter callers: use the renamed function. - tests: cover the filetype -> language mapping (rs -> rust, sh -> bash, svg -> xml, tsx, jsx) and regenerate the snapshots whose fence label changes (txt -> text).
- permission_window: the command/pattern fence used the permission type directly. v1 sets `permission = "bash"` (a real language), while v2 sets `action = "shell"`, which has no parser — so a v2 shell permission never highlighted. Map shell -> bash for the fence only; the `*shell*` label stays. - tests/unit: the v2 spec had asserted the broken `shell` fence; assert `bash` instead (the `*shell*` label is still asserted).
Owner
|
I think the test snapshots needs to be updated to match the new filetypes. |
- util: keep `text -> txt`. Neovim nightly reports the `text` filetype for .txt while older versions fall back to the `txt` extension; without the mapping the fence label (and its snapshot) depends on the Neovim version. The table is checked before get_lang, so this holds with or without nvim-treesitter. - tests/data: revert the diff/permission/redo snapshots regenerated in the fence-language commit. The label is stable again, so they need no change.
Contributor
Author
|
Same issue as 313acb8 — I've reverted those snapshots. |
Contributor
Author
|
I think we can avoid per-version expected snapshots here — |
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.
Problem
Code fences in the output and permission dialog are labelled with a string that
is not always a treesitter language name, so some files never get syntax
highlighting.
.rswas labelledrs(notrust),.yamlbecameyml, etc.Root cause
vim.filetype.match(Neovim core) already resolves almost every path to afiletype. Neovim then resolves a fence's info string with
has_parser(name)/get_lang(name), whereget_langmaps a filetype to a language — not anextension.
The two code paths had also diverged:
from the raw extension (
fnamemodify(path, ':e')), so.rsbecamers,which no parser resolves.
The helper itself used a hand-written override table that was incomplete and
partly wrong, and duplicated what
get_langalready does.Fix
permission_window: reuse the helper instead offnamemodify(path, ':e').util.get_markdown_language(renamed fromget_markdown_filetype): resolvepath -> vim.filetype.match -> vim.treesitter.language.get_lang, fallingback to the extension.
The old table was incomplete (only a handful of the
filetype != languagepairs) and wrong:
yaml -> yml: no parser, and it turned a case that resolved on its own(
yaml) into a broken one.javascipt -> js: a typo that never matched.typescript -> ts,javascriptreact -> jsx: only worked becausenvim-treesitter aliases those extensions.
text -> txt: not a language.Why the small table exists
get_langonly maps filetypes to languages when nvim-treesitter isinstalled — Neovim core registers almost nothing. The plugin keeps a small
table for the common name mismatches so setups without nvim-treesitter still
highlight them. The two overlap and complement each other:
get_lang)get_langVerify by listing every filetype whose name is not its language:
itself, so
sh,cs,javascriptreact, ... have no language and would nothighlight without the table.
sh -> bash,cs -> c_sharp,svg -> xml,javascriptreact -> javascript,pandoc -> markdown.Verification
rs -> rust,sh -> bash,svg -> xml,tsx,jsx, empty filename, unknown extension.regenerated because the fence label changed (
txt -> text).