Compare commits

..

2 Commits

Author SHA1 Message Date
613110fdce
Auto install and auto start treesitter 2025-05-26 03:27:33 +02:00
4106e7fdc0
Start with all folds unfolded 2025-05-26 03:11:06 +02:00
3 changed files with 19 additions and 12 deletions

View File

@ -33,14 +33,22 @@ vim.api.nvim_create_autocmd({ "InsertEnter", "WinLeave" }, {
pattern = "*",
})
-- Auto install treesitter parser and start them
vim.api.nvim_create_autocmd("FileType", {
pattern = require("tools.highlight"),
callback = function()
-- syntax highlighting, provided by Neovim
vim.treesitter.start()
-- folds, provided by Neovim
vim.wo.foldexpr = "v:lua.vim.treesitter.foldexpr()"
-- indentation, provided by nvim-treesitter
vim.bo.indentexpr = "v:lua.require'nvim-treesitter'.indentexpr()"
desc = "Enable Treesitter",
group = vim.api.nvim_create_augroup("enable_treesitter", {}),
callback = function(event)
local has_treesitter, treesitter = pcall(require, "nvim-treesitter")
if has_treesitter then
local language = vim.treesitter.language.get_lang(event.match)
treesitter.install(language):await(function(a)
if pcall(vim.treesitter.start) then
-- Use Treesitter indentation and folds.
vim.bo.indentexpr = "v:lua.require'nvim-treesitter'.indentexpr()"
vim.wo.foldmethod = "expr"
vim.wo.foldexpr = "v:lua.vim.treesitter.foldexpr()"
end
end)
end
end,
})

View File

@ -61,3 +61,6 @@ vim.o.scrolloff = 10
-- Highlight tabs and trailing whitespace
vim.o.listchars = "trail:~,tab:¦⁃,nbsp:␣"
vim.o.list = true
-- Fold settings
vim.o.foldlevelstart = 99

View File

@ -11,12 +11,8 @@ return {
branch = "main",
build = ":TSUpdate",
opts = {
-- Add languages to be installed here that you want installed for treesitter
ensure_installed = require("tools.highlight"),
-- Autoinstall languages that are not installed. Defaults to false (but you can change for yourself!)
auto_install = true,
highlight = { enable = true },
indent = { enable = true },
incremental_selection = {