mirror of
https://github.com/itme-brain/nvim.git
synced 2026-05-08 07:00:13 -04:00
fix(treesitter): migrate to neovim 0.12 APIs
This commit is contained in:
parent
da6106c774
commit
08d1df4643
1 changed files with 67 additions and 15 deletions
|
|
@ -18,13 +18,40 @@ local mason_ensure_installed = {
|
||||||
"yamlls", -- YAML
|
"yamlls", -- YAML
|
||||||
}
|
}
|
||||||
|
|
||||||
|
local treesitter_parsers = {
|
||||||
|
"lua",
|
||||||
|
"c",
|
||||||
|
"cpp",
|
||||||
|
"python",
|
||||||
|
"nix",
|
||||||
|
"rust",
|
||||||
|
"bash",
|
||||||
|
"markdown",
|
||||||
|
"html",
|
||||||
|
"html_tags",
|
||||||
|
"javascript",
|
||||||
|
"ecma",
|
||||||
|
"jsx",
|
||||||
|
"css",
|
||||||
|
"vim",
|
||||||
|
"git_config",
|
||||||
|
"git_rebase",
|
||||||
|
"gitattributes",
|
||||||
|
"gitcommit",
|
||||||
|
"gitignore",
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
{
|
{
|
||||||
"nvim-treesitter/nvim-treesitter",
|
"neovim-treesitter/nvim-treesitter",
|
||||||
|
name = "nvim-treesitter",
|
||||||
|
dependencies = { "neovim-treesitter/treesitter-parser-registry" },
|
||||||
|
lazy = false,
|
||||||
build = ":TSUpdate",
|
build = ":TSUpdate",
|
||||||
config = function()
|
init = function()
|
||||||
require('nvim-treesitter.configs').setup({
|
vim.api.nvim_create_autocmd("FileType", {
|
||||||
ensure_installed = {
|
group = vim.api.nvim_create_augroup("config_treesitter", { clear = true }),
|
||||||
|
pattern = {
|
||||||
"lua",
|
"lua",
|
||||||
"c",
|
"c",
|
||||||
"cpp",
|
"cpp",
|
||||||
|
|
@ -35,22 +62,47 @@ return {
|
||||||
"markdown",
|
"markdown",
|
||||||
"html",
|
"html",
|
||||||
"javascript",
|
"javascript",
|
||||||
|
"javascriptreact",
|
||||||
"css",
|
"css",
|
||||||
|
|
||||||
"vim",
|
"vim",
|
||||||
|
"gitconfig",
|
||||||
"git_config",
|
"gitrebase",
|
||||||
"git_rebase",
|
|
||||||
"gitattributes",
|
"gitattributes",
|
||||||
"gitcommit",
|
"gitcommit",
|
||||||
"gitignore"
|
"gitignore",
|
||||||
},
|
},
|
||||||
auto_install = true,
|
callback = function(event)
|
||||||
sync_install = true,
|
if pcall(vim.treesitter.start, event.buf) then
|
||||||
highlight = {
|
vim.wo.foldexpr = "v:lua.vim.treesitter.foldexpr()"
|
||||||
enable = true,
|
vim.wo.foldmethod = "expr"
|
||||||
}
|
vim.bo[event.buf].indentexpr = "v:lua.require'nvim-treesitter'.indentexpr()"
|
||||||
|
end
|
||||||
|
end,
|
||||||
})
|
})
|
||||||
|
end,
|
||||||
|
config = function()
|
||||||
|
require("nvim-treesitter").setup()
|
||||||
|
|
||||||
|
local installed = require("nvim-treesitter.config").get_installed()
|
||||||
|
local missing = vim.iter(treesitter_parsers)
|
||||||
|
:filter(function(parser)
|
||||||
|
return not vim.tbl_contains(installed, parser)
|
||||||
|
end)
|
||||||
|
:totable()
|
||||||
|
|
||||||
|
if #missing == 0 then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
if vim.fn.executable("tree-sitter") == 0 then
|
||||||
|
vim.notify_once(
|
||||||
|
"tree-sitter CLI is required to install or update parsers; enter a Nix shell that provides tree-sitter before running :TSUpdate",
|
||||||
|
vim.log.levels.WARN
|
||||||
|
)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
require("nvim-treesitter").install(missing)
|
||||||
end
|
end
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
@ -302,7 +354,7 @@ return {
|
||||||
|
|
||||||
{
|
{
|
||||||
"taproot-wizards/bitcoin-script-hints.nvim",
|
"taproot-wizards/bitcoin-script-hints.nvim",
|
||||||
dependencies = { "nvim-treesitter/nvim-treesitter" },
|
dependencies = { "nvim-treesitter" },
|
||||||
config = function()
|
config = function()
|
||||||
require("bitcoin-script-hints").setup()
|
require("bitcoin-script-hints").setup()
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue