Nvim: some treesitter updates
This commit is contained in:
@@ -1,147 +1,61 @@
|
|||||||
return {
|
return {
|
||||||
'nvim-treesitter/nvim-treesitter',
|
{
|
||||||
dependencies = {
|
"nvim-treesitter/nvim-treesitter",
|
||||||
{
|
branch = "master",
|
||||||
|
config = {
|
||||||
|
sync_install = true,
|
||||||
|
modules = {
|
||||||
|
},
|
||||||
|
|
||||||
|
highlight = {
|
||||||
|
enable = true,
|
||||||
|
disable = {
|
||||||
|
"html"
|
||||||
|
},
|
||||||
|
additional_vim_regex_highlighting = true,
|
||||||
|
},
|
||||||
|
|
||||||
|
indent = { enable = true, },
|
||||||
|
incremental_selection = {
|
||||||
|
enable = true,
|
||||||
|
keymaps = {
|
||||||
|
init_selection = "<space>,",
|
||||||
|
scope_incremental = "<space><space>",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
refactor = {
|
||||||
|
highlight_definitions = { enable = true },
|
||||||
|
highlight_current_scope = { enable = true },
|
||||||
|
smart_rename = {
|
||||||
|
enable = true,
|
||||||
|
keymaps = {
|
||||||
|
smart_rename = "<space>r",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
navigation = {
|
||||||
|
enable = true,
|
||||||
|
keymaps = {
|
||||||
|
goto_definition = "<space>d",
|
||||||
|
list_definitions = "<space>l",
|
||||||
|
list_definitions_toc = "<space>L",
|
||||||
|
goto_next_usage = "<space>]",
|
||||||
|
goto_previous_usage = "<space>[",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
'nvim-treesitter/nvim-treesitter-context',
|
'nvim-treesitter/nvim-treesitter-context',
|
||||||
opts = {
|
opts = {
|
||||||
max_lines = 4,
|
max_lines = 4,
|
||||||
multiline_threshold = 2,
|
multiline_threshold = 2,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'mizlan/iswap.nvim',
|
'mizlan/iswap.nvim',
|
||||||
enabled = false,
|
enabled = false,
|
||||||
}
|
}
|
||||||
},
|
|
||||||
lazy = false,
|
|
||||||
branch = 'main',
|
|
||||||
--build = ':TSUpdate',
|
|
||||||
config = function()
|
|
||||||
local ts = require('nvim-treesitter')
|
|
||||||
|
|
||||||
-- State tracking for async parser loading
|
|
||||||
local parsers_loaded = {}
|
|
||||||
local parsers_pending = {}
|
|
||||||
local parsers_failed = {}
|
|
||||||
|
|
||||||
local ns = vim.api.nvim_create_namespace('treesitter.async')
|
|
||||||
|
|
||||||
-- Helper to start highlighting and indentation
|
|
||||||
local function start(buf, lang)
|
|
||||||
local ok = pcall(vim.treesitter.start, buf, lang)
|
|
||||||
if ok then
|
|
||||||
-- vim.bo[buf].indentexpr = "v:lua.require'nvim-treesitter'.indentexpr()"
|
|
||||||
end
|
|
||||||
return ok
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Install core parsers after lazy.nvim finishes loading all plugins
|
|
||||||
vim.api.nvim_create_autocmd('User', {
|
|
||||||
pattern = 'LazyDone',
|
|
||||||
once = true,
|
|
||||||
callback = function()
|
|
||||||
ts.install({
|
|
||||||
"arduino",
|
|
||||||
"awk",
|
|
||||||
"bash",
|
|
||||||
"bibtex",
|
|
||||||
"bitbake",
|
|
||||||
"c",
|
|
||||||
"cmake",
|
|
||||||
--"comment",
|
|
||||||
"cpp",
|
|
||||||
"csv",
|
|
||||||
"devicetree",
|
|
||||||
"diff",
|
|
||||||
"fish",
|
|
||||||
"gitattributes",
|
|
||||||
"gitcommit",
|
|
||||||
"gitignore",
|
|
||||||
"git_config",
|
|
||||||
"git_rebase",
|
|
||||||
"html",
|
|
||||||
"vimdoc",
|
|
||||||
"http",
|
|
||||||
"ini",
|
|
||||||
"jq",
|
|
||||||
"json",
|
|
||||||
--"latex",
|
|
||||||
"lua",
|
|
||||||
"make",
|
|
||||||
"markdown",
|
|
||||||
"markdown_inline",
|
|
||||||
"matlab",
|
|
||||||
"ninja",
|
|
||||||
"proto",
|
|
||||||
"python",
|
|
||||||
"regex",
|
|
||||||
"rust",
|
|
||||||
"toml",
|
|
||||||
"vim",
|
|
||||||
"yaml",
|
|
||||||
}, {
|
|
||||||
max_jobs = 8,
|
|
||||||
})
|
|
||||||
end,
|
|
||||||
})
|
|
||||||
|
|
||||||
-- Decoration provider for async parser loading
|
|
||||||
vim.api.nvim_set_decoration_provider(ns, {
|
|
||||||
on_start = vim.schedule_wrap(function()
|
|
||||||
if #parsers_pending == 0 then
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
for _, data in ipairs(parsers_pending) do
|
|
||||||
if vim.api.nvim_buf_is_valid(data.buf) then
|
|
||||||
if start(data.buf, data.lang) then
|
|
||||||
parsers_loaded[data.lang] = true
|
|
||||||
else
|
|
||||||
parsers_failed[data.lang] = true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
parsers_pending = {}
|
|
||||||
end),
|
|
||||||
})
|
|
||||||
|
|
||||||
local group = vim.api.nvim_create_augroup('TreesitterSetup', { clear = true })
|
|
||||||
|
|
||||||
local ignore_filetypes = {
|
|
||||||
'checkhealth',
|
|
||||||
'lazy',
|
|
||||||
'mason',
|
|
||||||
'snacks_dashboard',
|
|
||||||
'snacks_notif',
|
|
||||||
'snacks_win',
|
|
||||||
}
|
|
||||||
|
|
||||||
-- Auto-install parsers and enable highlighting on FileType
|
|
||||||
vim.api.nvim_create_autocmd('FileType', {
|
|
||||||
group = group,
|
|
||||||
desc = 'Enable treesitter highlighting and indentation (non-blocking)',
|
|
||||||
callback = function(event)
|
|
||||||
if vim.tbl_contains(ignore_filetypes, event.match) then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
local lang = vim.treesitter.language.get_lang(event.match) or event.match
|
|
||||||
local buf = event.buf
|
|
||||||
|
|
||||||
if parsers_failed[lang] then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
if parsers_loaded[lang] then
|
|
||||||
-- Parser already loaded, start immediately (fast path)
|
|
||||||
start(buf, lang)
|
|
||||||
else
|
|
||||||
-- Queue for async loading
|
|
||||||
table.insert(parsers_pending, { buf = buf, lang = lang })
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Auto-install missing parsers (async, no-op if already installed)
|
|
||||||
ts.install({ lang })
|
|
||||||
end,
|
|
||||||
})
|
|
||||||
end
|
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-5
@@ -50,8 +50,6 @@
|
|||||||
[rerere]
|
[rerere]
|
||||||
enabled = true
|
enabled = true
|
||||||
autoupdate = true
|
autoupdate = true
|
||||||
[branch]
|
|
||||||
sort = committerdate
|
|
||||||
[tag]
|
[tag]
|
||||||
sort = version:refname
|
sort = version:refname
|
||||||
[alias]
|
[alias]
|
||||||
@@ -117,8 +115,6 @@
|
|||||||
enabled = true
|
enabled = true
|
||||||
[column]
|
[column]
|
||||||
ui = auto
|
ui = auto
|
||||||
[branch]
|
|
||||||
sort = -commiterdate
|
|
||||||
[pull]
|
[pull]
|
||||||
rebase = true
|
rebase = true
|
||||||
[commit]
|
[commit]
|
||||||
@@ -135,7 +131,7 @@
|
|||||||
[column]
|
[column]
|
||||||
ui = auto
|
ui = auto
|
||||||
[branch]
|
[branch]
|
||||||
sort = -commiterdate
|
sort = -committerdate
|
||||||
[maintenance]
|
[maintenance]
|
||||||
repo = /home/kmcr/repos/hems/hemsmilsimulation
|
repo = /home/kmcr/repos/hems/hemsmilsimulation
|
||||||
[sendemail]
|
[sendemail]
|
||||||
|
|||||||
Reference in New Issue
Block a user