added tree-sitter

This commit is contained in:
2026-06-21 23:15:03 +02:00
parent c06dc8ba3b
commit d1f5d71850
4 changed files with 85 additions and 6 deletions

View File

@@ -62,12 +62,30 @@ Open a terminal in a vertical split:
Leave terminal mode and return to normal mode: Leave terminal mode and return to normal mode:
```vim
<C-\><C-n>
```
In this config, `<Esc>` in terminal mode is mapped to the same command:
```vim ```vim
<Esc> <Esc>
``` ```
## Tree-sitter
Tree-sitter is managed with `nvim-treesitter` via `vim.pack`.
Installing missing parsers requires the external tools from the upstream README:
- `tar`
- `curl`
- `tree-sitter-cli`
- a C compiler
If `tree-sitter` is on your `PATH`, startup will try to install the configured parsers if they are missing.
Useful commands:
```vim
:TSUpdate
:TSInstall lua bash json
:TSInstallInfo
:InspectTree
:checkhealth vim.treesitter
```

View File

@@ -1 +1,2 @@
require("romanzy.plugins.rose-pine") require("romanzy.plugins.rose-pine")
require("romanzy.plugins.nvim-treesitter")

View File

@@ -0,0 +1,56 @@
local parsers = {
"bash",
"c",
"gitcommit",
"javascript",
"json",
"lua",
"markdown",
"python",
"toml",
"typescript",
"vim",
"vimdoc",
"yaml",
}
local filetypes = {
"bash",
"c",
"gitcommit",
"javascript",
"json",
"lua",
"markdown",
"python",
"sh",
"toml",
"typescript",
"vim",
"vimdoc",
"yaml",
}
vim.pack.add({
{
src = "https://github.com/nvim-treesitter/nvim-treesitter",
name = "nvim-treesitter",
},
})
require("nvim-treesitter").setup({
install_dir = vim.fn.stdpath("data") .. "/site",
})
vim.treesitter.language.register("bash", { "sh" })
if vim.fn.executable("tree-sitter") == 1 then
require("nvim-treesitter").install(parsers)
end
vim.api.nvim_create_autocmd("FileType", {
pattern = filetypes,
callback = function(ev)
pcall(vim.treesitter.start, ev.buf)
end,
})

View File

@@ -1,5 +1,9 @@
{ {
"plugins": { "plugins": {
"nvim-treesitter": {
"rev": "4916d6592ede8c07973490d9322f187e07dfefac",
"src": "https://github.com/nvim-treesitter/nvim-treesitter"
},
"rose-pine": { "rose-pine": {
"rev": "ff483051a47e27d84bdef47703538df1ed9f4a47", "rev": "ff483051a47e27d84bdef47703538df1ed9f4a47",
"src": "https://github.com/rose-pine/neovim" "src": "https://github.com/rose-pine/neovim"