88 lines
2.3 KiB
Lua
88 lines
2.3 KiB
Lua
local status_ok, _ = pcall(require, "nvim-treesitter")
|
|
if not status_ok then
|
|
return
|
|
end
|
|
|
|
vim.api.nvim_create_autocmd("BufEnter", {
|
|
callback = function()
|
|
local ok, stats = pcall(vim.loop.fs_stat, vim.api.nvim_buf_get_name(vim.api.nvim_get_current_buf()))
|
|
if ok and stats and stats.size > 1024 * 1024 then
|
|
-- require("nvim-treesitter.configs").setup({highlight = { enable = false }})
|
|
end
|
|
end,
|
|
})
|
|
|
|
vim.cmd("set foldmethod=expr")
|
|
vim.cmd("set foldexpr=nvim_treesitter#foldexpr()")
|
|
vim.cmd("set nofoldenable")
|
|
|
|
local configs
|
|
status_ok, configs = pcall(require, "nvim-treesitter.configs")
|
|
if not status_ok then
|
|
return
|
|
end
|
|
|
|
configs.setup({
|
|
ensure_installed = { "lua", "markdown", "markdown_inline", "bash", "python" }, -- put the language you want in this array
|
|
-- ensure_installed = "all", -- one of "all" or a list of languages
|
|
ignore_install = { "" }, -- List of parsers to ignore installing
|
|
sync_install = false, -- install languages synchronously (only applied to `ensure_installed`)
|
|
|
|
highlight = {
|
|
enable = true, -- false will disable the whole extension
|
|
-- disable = { "css", "help" },
|
|
disable = function(lang, buf)
|
|
if vim.tbl_contains({ "help", "latex" }, lang) then
|
|
return true
|
|
end
|
|
|
|
local max_filesize = 1024 * 1024
|
|
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
|
|
-- if vim.builtin.illuminate.active then
|
|
-- pcall(require("illuminate").pause_buf)
|
|
-- end
|
|
|
|
vim.schedule(function()
|
|
vim.api.nvim_buf_call(buf, function()
|
|
vim.cmd("setlocal noswapfile noundofile")
|
|
|
|
if vim.tbl_contains({ "json" }, lang) then
|
|
vim.cmd("NoMatchParen")
|
|
vim.cmd("syntax off")
|
|
vim.cmd("syntax clear")
|
|
vim.cmd("setlocal nocursorline nolist bufhidden=unload")
|
|
|
|
vim.api.nvim_create_autocmd({ "BufDelete" }, {
|
|
callback = function()
|
|
vim.cmd("DoMatchParen")
|
|
vim.cmd("syntax on")
|
|
end,
|
|
buffer = buf,
|
|
})
|
|
end
|
|
end)
|
|
end)
|
|
|
|
return true
|
|
end
|
|
end,
|
|
},
|
|
autopairs = {
|
|
enable = true,
|
|
},
|
|
indent = { enable = true, disable = { "python", "css", "rust" } },
|
|
|
|
context_commentstring = {
|
|
enable = true,
|
|
enable_autocmd = false,
|
|
},
|
|
})
|
|
|
|
local context
|
|
status_ok, context = pcall(require, "nvim-treesitter.context")
|
|
if not status_ok then
|
|
return
|
|
end
|
|
|
|
context.setup({})
|