Added nvim-treesitter deps and basic config
This commit is contained in:
@@ -1,6 +1,57 @@
|
|||||||
return {
|
return {
|
||||||
'nvim-treesitter/nvim-treesitter',
|
'nvim-treesitter/nvim-treesitter',
|
||||||
|
branch = 'main',
|
||||||
lazy = false,
|
lazy = false,
|
||||||
build = ':TSUpdate'
|
build = ':TSUpdate',
|
||||||
|
config = function()
|
||||||
|
-- Old `ensure_installed`
|
||||||
|
require('nvim-treesitter').install({
|
||||||
|
-- Neovim config
|
||||||
|
'lua', 'vim', 'vimdoc', 'query',
|
||||||
|
|
||||||
|
-- Rust
|
||||||
|
'rust', 'toml',
|
||||||
|
|
||||||
|
-- Ansible
|
||||||
|
'yaml',
|
||||||
|
|
||||||
|
-- Frontend stuff
|
||||||
|
'html', 'css', 'javascript', 'typescript', 'tsx', 'json',
|
||||||
|
|
||||||
|
-- Low level stuff
|
||||||
|
'c', 'asm',
|
||||||
|
})
|
||||||
|
|
||||||
|
-- Old `auto_install`
|
||||||
|
local ts_autoinstall_group = vim.api.nvim_create_augroup('TSAutoInstall', { clear = true })
|
||||||
|
vim.api.nvim_create_autocmd('FileType', {
|
||||||
|
group = ts_autoinstall_group,
|
||||||
|
callback = function(args)
|
||||||
|
local lang = vim.treesitter.language.get_lang(args.match) or args.match
|
||||||
|
|
||||||
|
-- Try starting right away: if it works, the parser was already installed
|
||||||
|
if pcall(vim.treesitter.start, args.buf, lang) then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Didn't work: download the parser in the background
|
||||||
|
local ok = pcall(function()
|
||||||
|
require('nvim-treesitter').install({ lang }, { summary = false })
|
||||||
|
end)
|
||||||
|
if not ok then return end
|
||||||
|
|
||||||
|
-- Poll (non-blocking) until start() succeeds, or give up after 9s
|
||||||
|
local function try_start(attempts)
|
||||||
|
attempts = attempts or 0
|
||||||
|
if pcall(vim.treesitter.start, args.buf, lang) then
|
||||||
|
return
|
||||||
|
elseif attempts < 30 then
|
||||||
|
vim.defer_fn(function() try_start(attempts + 1) end, 300)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
try_start()
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
end,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,3 +9,14 @@
|
|||||||
ansible.builtin.pacman:
|
ansible.builtin.pacman:
|
||||||
name: "{{ 'wl-clipboard' if lookup('env', 'XDG_SESSION_TYPE') == 'wayland' else 'xclip' }}"
|
name: "{{ 'wl-clipboard' if lookup('env', 'XDG_SESSION_TYPE') == 'wayland' else 'xclip' }}"
|
||||||
when: chezmoi.osRelease.id == "arch"
|
when: chezmoi.osRelease.id == "arch"
|
||||||
|
|
||||||
|
- name: Install plugin dependencies
|
||||||
|
become: true
|
||||||
|
ansible.builtin.pacman:
|
||||||
|
name:
|
||||||
|
# nvim-treesitter
|
||||||
|
- tree-sitter-cli
|
||||||
|
- gcc
|
||||||
|
- curl
|
||||||
|
- tar
|
||||||
|
when: chezmoi.osRelease.id == "arch"
|
||||||
|
|||||||
Reference in New Issue
Block a user