dotfiles
Clone
https://git.tahinli.com/Tahinli/dotfiles.git
0 watching0 forksShellGPL-3.0334.8 KiBb1320e9Tahinli17 days ago105 commits
| 1 | return { |
| 2 | "nvim-treesitter/nvim-treesitter", |
| 3 | lazy = false, |
| 4 | build = ":TSUpdate", |
| 5 | config = function() |
| 6 | local ts = require("nvim-treesitter") |
| 7 | local available = {} |
| 8 | for _, lang in ipairs(ts.get_available()) do |
| 9 | available[lang] = true |
| 10 | end |
| 11 | |
| 12 | local |
| 13 | if not vim.api.nvim_buf_is_valid(buf) or not pcall(vim.treesitter.start, buf) then |
| 14 | return |
| 15 | end |
| 16 | vim.bo[buf].indentexpr = "v:lua.require'nvim-treesitter'.indentexpr()" |
| 17 | end |
| 18 | |
| 19 | vim.api.nvim_create_autocmd("FileType", { |
| 20 | callback = function(args) |
| 21 | local lang = vim.treesitter.language.get_lang(args.match) |
| 22 | if not lang or not available[lang] then |
| 23 | return |
| 24 | end |
| 25 | if vim.list_contains(ts.get_installed(), lang) then |
| 26 | enable(args.buf) |
| 27 | else |
| 28 | ts.install(lang):await(function() |
| 29 | vim.schedule(function() |
| 30 | enable(args.buf) |
| 31 | end) |
| 32 | end) |
| 33 | end |
| 34 | end, |
| 35 | }) |
| 36 | end, |
| 37 | } |