added tree-sitter
This commit is contained in:
@@ -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
|
||||||
|
```
|
||||||
|
|||||||
@@ -1 +1,2 @@
|
|||||||
require("romanzy.plugins.rose-pine")
|
require("romanzy.plugins.rose-pine")
|
||||||
|
require("romanzy.plugins.nvim-treesitter")
|
||||||
|
|||||||
56
nvim/.config/nvim/lua/romanzy/plugins/nvim-treesitter.lua
Normal file
56
nvim/.config/nvim/lua/romanzy/plugins/nvim-treesitter.lua
Normal 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,
|
||||||
|
})
|
||||||
@@ -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"
|
||||||
|
|||||||
Reference in New Issue
Block a user