30 lines
852 B
Lua
30 lines
852 B
Lua
return {
|
|
"nvim-treesitter/nvim-treesitter",
|
|
branch = "main",
|
|
build = function()
|
|
require("nvim-treesitter").update()
|
|
end,
|
|
event = { "BufReadPre", "BufNewFile" },
|
|
config = function()
|
|
local ts = require("nvim-treesitter")
|
|
local ensure = { "swift" }
|
|
local installed = ts.get_installed and ts.get_installed() or {}
|
|
local to_install = {}
|
|
for _, lang in ipairs(ensure) do
|
|
if not vim.tbl_contains(installed, lang) then
|
|
table.insert(to_install, lang)
|
|
end
|
|
end
|
|
if #to_install > 0 then
|
|
ts.install(to_install)
|
|
end
|
|
|
|
vim.api.nvim_create_autocmd("FileType", {
|
|
pattern = { "swift" },
|
|
callback = function()
|
|
pcall(vim.treesitter.start)
|
|
end,
|
|
})
|
|
end,
|
|
}
|