diff support in treesitter/fold

This commit is contained in:
2026-08-05 06:40:09 +02:00
parent d584ef391a
commit 8daff33d2d
2 changed files with 13 additions and 1 deletions
+12
View File
@@ -24,6 +24,18 @@ vim.api.nvim_create_autocmd({ "FocusGained", "BufEnter", "CursorHold", "CursorHo
command = "if mode() != 'c' | checktime | endif", command = "if mode() != 'c' | checktime | endif",
}) })
-- `git show`/`git diff`/`git log -p` piped into nvim (e.g. `git show <hash> | nvim -`)
-- arrive as stdin with no filename, so normal filetype detection never fires
-- and folding/highlighting silently stay off. Sniff the content instead.
vim.api.nvim_create_autocmd("StdinReadPost", {
callback = function()
local first = vim.fn.getline(1)
if first:match("^commit %x+") or first:match("^diff %-%-git ") or first:match("^From %x+") then
vim.bo.filetype = "diff"
end
end,
})
vim.filetype.add({ extension = { asm = "asm", s = "asm", S = "asm" } }) vim.filetype.add({ extension = { asm = "asm", s = "asm", S = "asm" } })
vim.api.nvim_create_autocmd("FileType", { vim.api.nvim_create_autocmd("FileType", {
pattern = "asm", pattern = "asm",
+1 -1
View File
@@ -275,7 +275,7 @@ require("nvim-treesitter").install({
"lua", "vim", "vimdoc", "bash", "c", "cpp", "rust", "python", "lua", "vim", "vimdoc", "bash", "c", "cpp", "rust", "python",
"javascript", "typescript", "tsx", "svelte", "css", "html", "javascript", "typescript", "tsx", "svelte", "css", "html",
"json", "toml", "yaml", "markdown", "markdown_inline", "json", "toml", "yaml", "markdown", "markdown_inline",
"java", "typst", "vala", "java", "typst", "vala", "diff",
}) })
vim.api.nvim_create_autocmd("FileType", { vim.api.nvim_create_autocmd("FileType", {