Neovim 中配置 sproto 语法高亮

之前给 nvim-treesittert 提交了个 sproto 语法高亮的功能。现在 LazyVim 也更新 nvim-treesitter 版本了,终于可以使用了。

配置方法很简单,先让 neovim 识别 sproto 文件(这个如果要让 neovim 自动识别有点难,得提pr到vim,vim合并后,才能提pr到neovim,路程太慢了)。所以只能自己配置了:

lua/config/options.lua 文件中加上下面的代码就能识别 sprot 文件:

vim.filetype.add({
    extension = {
        sproto = "sproto",
    },
})

lazyvim 插件配置,新建文件: lua/plugins/treesitter.lua

return {
    "nvim-treesitter/nvim-treesitter",
    highlight = { enable = true },
    indent = { enable = true },
    opts = {
        ensure_installed = {
            "sproto",
        },
    },
}

看看效果:

Image

点击进入评论 ...