Simplify structure for nvim config files
This commit is contained in:
73
src_files/.config/nvim/lua/plugins_lazy/treesitter.lua
Normal file
73
src_files/.config/nvim/lua/plugins_lazy/treesitter.lua
Normal file
@@ -0,0 +1,73 @@
|
||||
return {
|
||||
{
|
||||
"nvim-treesitter/nvim-treesitter",
|
||||
branch = 'master',
|
||||
lazy = false,
|
||||
build = ":TSUpdate",
|
||||
config = function()
|
||||
require("nvim-treesitter.configs").setup({
|
||||
ensure_installed = {
|
||||
"vimdoc", "bash", "lua", "c", "cpp", "go", "python", "ruby",
|
||||
"html", "css", "javascript", "jsdoc", "sql", "json", "yaml",
|
||||
"markdown", "markdown_inline",
|
||||
-- "odin", "zig", "ocaml", "java", "typescript",
|
||||
},
|
||||
sync_install = false, -- install `ensure_installed` parsers synchronously
|
||||
auto_install = true, -- install missing on BufEnter, requires tree-sitter CLI
|
||||
ignore_install = {},
|
||||
-- indent = { enable = true }, -- TODO: do i want this?
|
||||
highlight = {
|
||||
enable = true, -- `false` will disable the whole extension
|
||||
disable = function(lang, buf)
|
||||
for i, v in ipairs({ "html", }) do
|
||||
if lang == v then
|
||||
print("treesitter disabled for this language")
|
||||
return true
|
||||
end
|
||||
end
|
||||
local ok, stats = pcall(vim.loop.fs_stat, vim.api.nvim_buf_get_name(buf))
|
||||
if ok and stats and stats.size > (100 * 1024) then -- 100 KB
|
||||
vim.notify(
|
||||
"larger file, treesitter disabled for performance",
|
||||
vim.log.levels.WARN,
|
||||
{title = "Treesitter"}
|
||||
)
|
||||
return true
|
||||
end
|
||||
end,
|
||||
-- true, false, or list of langs; may cause slowness or duplicate highlights
|
||||
additional_vim_regex_highlighting = { "markdown" },
|
||||
},
|
||||
})
|
||||
|
||||
-- TODO: decide if needed/wanted
|
||||
-- local treesitter_parser_config = require("nvim-treesitter.parsers").get_parser_configs()
|
||||
-- treesitter_parser_config.templ = {
|
||||
-- install_info = {
|
||||
-- url = "https://github.com/vrischmann/tree-sitter-templ.git",
|
||||
-- files = {"src/parser.c", "src/scanner.c"},
|
||||
-- branch = "master",
|
||||
-- },
|
||||
-- }
|
||||
|
||||
-- vim.treesitter.language.register("templ", "templ")
|
||||
end
|
||||
},
|
||||
{
|
||||
"nvim-treesitter/nvim-treesitter-context",
|
||||
after = "nvim-treesitter",
|
||||
opts = {
|
||||
enable = false, -- can enable/disable via manual command
|
||||
multiwindow = false,
|
||||
max_lines = 0, -- lines the window should span; x <= 0 means no limit
|
||||
min_window_height = 10, -- min window height to enable; x <= 0 means no limit
|
||||
line_numbers = true,
|
||||
multiline_threshold = 40, -- max lines to show for a single context
|
||||
trim_scope = 'outer', -- 'inner', 'outer'; discard lines if max_lines exceeded
|
||||
mode = 'cursor', -- 'cursor', 'topline'; line used to calculate context
|
||||
separator = "-", -- 1 char, like '-'; only shown when >= 2 lines above
|
||||
zindex = 20, -- z-index of the context window
|
||||
on_attach = nil, -- (fun(buf: integer): boolean); return false to disable attaching
|
||||
},
|
||||
},
|
||||
}
|
Reference in New Issue
Block a user