From b35476dbde35cd6b15fa840b1775303af3a93d41 Mon Sep 17 00:00:00 2001 From: Steins7 Date: Tue, 18 Oct 2022 18:47:04 +0200 Subject: [PATCH] Move to more performant syntax highlighting --- lua/plugins.lua | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/lua/plugins.lua b/lua/plugins.lua index b1424cb..fc0104c 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -82,7 +82,40 @@ local function manage_plugins() }, -- Syntax highlight - ["https://github.com/bfrg/vim-cpp-modern.git"] = {}, + ["https://github.com/nvim-treesitter/nvim-treesitter.git"] = { + packadd_hook = function() + local conf = require("nvim-treesitter.configs") + + conf.setup { + -- only enable tested parsers + ensure_installed = { "c", "cpp", "lua", "rust" }, + -- Install parsers synchronously (only applied to `ensure_installed`) + sync_install = false, + -- Automatically install missing parsers when entering buffer + auto_install = false, + -- List of parsers to ignore installing (for "all") + ignore_install = {}, + highlight = { + -- `false` will disable the whole extension + enable = true, + -- list of language that will be disabled + disable = {}, + -- disable slow treesitter highlight for large files + disable = function(lang, buf) + local max_filesize = 100 * 1024 -- 100 KB + local ok, stats = + pcall(vim.loop.fs_stat, vim.api.nvim_buf_get_name(buf)) + if ok and stats and stats.size > max_filesize then + return true + end + end, + -- run `:h syntax` and tree-sitter at the same time. + additional_vim_regex_highlighting = false, + + } + } + end + }, } local manager = require("plogins").manage(plugins)