helix
helix copied to clipboard
Recognize `.ispc` extension as CPP
Intel's Implicit SIMD Program Compiler (https://ispc.github.io/) files are "a variant of the C programming language" with support for templates and references.
Unfortunately they also use some custom keywords and constructs that make this language unsuitable for clangd, but the CPP grammar works well enough for most highlighting. There is supposedly a user-made tree-sitter grammar: https://github.com/tree-sitter/tree-sitter/pull 2282
Creating this as draft as we should probably not use clangd as LSP here, and perhaps switch to https://github.com/fab4100/tree-sitter-ispc for grammar.
ISPC has a language server and is pending a release https://togithub.com/ispc/ispc/issues/1605#issuecomment-1771833547
Let's focus this PR on using tree-sitter-ispc and the ispc language server. For those looking for some basic syntax highlighting for ispc in the mean time, the current change can be added to your custom language config:
# ~/.config/helix/languages.toml
[[language]]
name = "cpp"
file-types = ["cc", "hh", "c++", "cpp", "hpp", "h", "ipp", "tpp", "cxx", "hxx", "ixx", "txx", "ino", "C", "H", "cu", "cuh", "cppm", "h++", "ii", "inl", "ispc", { suffix = ".hpp.in" }, { suffix = ".h.in" }]
Imported the grammar from https://github.com/fab4100/tree-sitter-ispc.
Somewhat strangely some of the queries were removed in https://github.com/fab4100/tree-sitter-ispc/commit/0197076648b8f31aab85c447015f29dadb53a8b3 and have been moved into https://github.com/nvim-treesitter/nvim-treesitter/tree/7da3cb6323d1e1fbfc4d7dc05cac74946458b8a0/queries/ispc. I have imported the latter and should probably update the commit hash to 0197076648b8f31aab85c447015f29dadb53a8b3~, or ask the author what source is supposed to be latest/source-of-truth. At least it provides indent queries.