summaryrefslogtreecommitdiff
path: root/lua/ache
diff options
context:
space:
mode:
Diffstat (limited to 'lua/ache')
-rw-r--r--lua/ache/plugins/treesitter.lua40
1 files changed, 31 insertions, 9 deletions
diff --git a/lua/ache/plugins/treesitter.lua b/lua/ache/plugins/treesitter.lua
index 139ed50..ff2d176 100644
--- a/lua/ache/plugins/treesitter.lua
+++ b/lua/ache/plugins/treesitter.lua
@@ -10,8 +10,7 @@
return {
"nvim-treesitter/nvim-treesitter",
enabled = true,
- lazy = false,
- -- event = { "BufReadPre", "BufNewFile" },
+ event = { "BufReadPre", "BufNewFile" },
build = ":TSUpdate",
-- dependencies = {
-- "windwp/nvim-ts-autotag",
@@ -26,9 +25,11 @@ return {
highlight = {
enable = true,
additional_vim_regex_highlighting = false,
+ -- disable = {"rust", "python", "lua", "markdown"},
},
indent = {
enable = true,
+ disable = {},
},
-- TODO: Install nvim-ts-autotag
-- autotag = { -- With nvim-ts-autotag plugin
@@ -111,17 +112,38 @@ return {
-- -- filetype = "zu", -- if filetype does not match the parser name
-- }
+ -- ************* Alternative METHOD
+ -- *************************
-- vim.wo.foldmethod = "expr"
-- vim.wo.foldexpr = "v:lua.vim.treesitter.foldexpr()"
-- vim.wo.foldlevel = 9
- vim.wo[0][0].foldexpr = "v:lua.vim.treesitter.foldexpr()"
- vim.wo[0][0].foldmethod = "expr"
- vim.wo[0][0].foldlevel = 9
- vim.bo.indentexpr = "v:lua.require'nvim-treesitter'.indentexpr()"
+ -- vim.wo[0][0].foldexpr = "v:lua.vim.treesitter.foldexpr()"
+ -- vim.wo[0][0].foldmethod = "expr"
+ -- vim.wo[0][0].foldlevel = 9
+ -- vim.bo.indentexpr = "v:lua.require'nvim-treesitter'.indentexpr()"
- vim.keymap.set("n", "<leader>z", function()
- vim.cmd([[set foldexpr=nvim_treesitter#foldexpr()]])
- end, { desc = "Refresh folding from Treesitter" })
+ -- vim.keymap.set("n", "<leader>z", function()
+ -- vim.cmd([[set foldexpr=nvim_treesitter#foldexpr()]])
+ -- end, { desc = "Refresh folding from Treesitter" })
+
+ -- Use treesitter for auto-fold
+
+ -- Create an autocommand for "BufRead" events
+ vim.api.nvim_create_autocmd("FileType", {
+ -- This autocommand will only trigger if the buffer name matches the following patterns
+ -- pattern = { "*.yaml", "*.yml" },
+ -- The autocommand will trigger the following lua function
+ callback = function()
+ local parsers = require("nvim-treesitter.parsers")
+ if parsers.has_parser() then
+ vim.wo.foldmethod = "expr"
+ vim.wo.foldexpr = "v:lua.vim.treesitter.foldexpr()"
+ vim.wo.foldlevel = 9
+ else
+ vim.wo.foldmethod = "syntax"
+ end
+ end,
+ })
end,
}