102 lines
3.2 KiB
Lua
102 lines
3.2 KiB
Lua
local tool = require("util.tool")
|
|
|
|
local configs = tool.load_module("nvim-treesitter.configs")
|
|
local parsers = tool.load_module("nvim-treesitter.parsers")
|
|
local context = tool.load_module("treesitter-context")
|
|
-- local status_ok, configs = pcall(require, "nvim-treesitter.configs")
|
|
-- if not status_ok then
|
|
-- return
|
|
-- end
|
|
--
|
|
-- local status_ok, parsers = pcall(require, "nvim-treesitter.parsers")
|
|
-- if not status_ok then
|
|
-- return
|
|
-- end
|
|
--
|
|
-- local status_ok, context = pcall(require, "treesitter-context")
|
|
-- if not status_ok then
|
|
-- return
|
|
-- end
|
|
|
|
local ghproxy = tool.ghproxy
|
|
|
|
if parsers == nil or configs == nil or context == nil then
|
|
return
|
|
end
|
|
|
|
for _, parser in pairs(parsers.get_parser_configs()) do
|
|
parser.install_info.url = parser.install_info.url:gsub("https://github.com/", ghproxy .. "https://github.com/")
|
|
end
|
|
|
|
configs.setup({
|
|
-- Do not autoinstall
|
|
auto_install = false,
|
|
-- one of "all" or a list of languages
|
|
ensure_installed = {
|
|
'bash',
|
|
'c',
|
|
'cpp',
|
|
'cmake',
|
|
'dockerfile',
|
|
'gitignore',
|
|
'go',
|
|
'gomod',
|
|
'http',
|
|
'java',
|
|
'javascript',
|
|
'json',
|
|
'json5',
|
|
'lua',
|
|
'make',
|
|
'python',
|
|
'powershell',
|
|
'rust',
|
|
'toml',
|
|
'vim',
|
|
'vimdoc',
|
|
'sql',
|
|
'yaml',
|
|
},
|
|
|
|
sync_install = false,
|
|
ignore_install = {}, -- List of parsers to ignore installing
|
|
highlight = {
|
|
enable = true, -- false will disable the whole extension
|
|
-- disable = {}, -- list of language that will be disabled
|
|
disable = function(lang, buf)
|
|
local max_filesize = 100 * 1024 -- 100 KB
|
|
local ok, stats = pcall(vim.uv.fs_stat, vim.api.nvim_buf_get_name(buf))
|
|
if ok and stats and stats.size > max_filesize then
|
|
return true
|
|
end
|
|
end,
|
|
},
|
|
|
|
rainbow = {
|
|
enable = true,
|
|
-- disable = { "jsx", "cpp" }, list of languages you want to disable the plugin for
|
|
extended_mode = true, -- Also highlight non-bracket delimiters like html tags, boolean or table: lang -> boolean
|
|
max_file_lines = 100000, -- Do not enable for files with more than n lines, int
|
|
-- colors = {}, -- table of hex strings
|
|
-- termcolors = {} -- table of colour name strings
|
|
},
|
|
|
|
indent = { enable = true, disable = { "python", "css" } },
|
|
})
|
|
|
|
context.setup({
|
|
enable = true, -- Enable this plugin (Can be enabled/disabled later via commands)
|
|
multiwindow = false, -- Enable multiwindow support.
|
|
max_lines = 0, -- How many lines the window should span. Values <= 0 mean no limit.
|
|
min_window_height = 0, -- Minimum editor window height to enable context. Values <= 0 mean no limit.
|
|
line_numbers = true,
|
|
multiline_threshold = 20, -- Maximum number of lines to show for a single context
|
|
trim_scope = 'outer', -- Which context lines to discard if `max_lines` is exceeded. Choices: 'inner', 'outer'
|
|
mode = 'cursor', -- Line used to calculate context. Choices: 'cursor', 'topline'
|
|
-- Separator between context and content. Should be a single character string, like '-'.
|
|
-- When separator is set, the context will only show up when there are at least 2 lines above cursorline.
|
|
separator = nil,
|
|
zindex = 20, -- The Z-index of the context window
|
|
on_attach = nil, -- (fun(buf: integer): boolean) return false to disable attaching
|
|
})
|