aboutsummaryrefslogtreecommitdiffstats
path: root/plugin/10-treesitter.lua
diff options
context:
space:
mode:
authorThomas Vanbesien <tvanbesi@proton.me>2026-05-04 08:44:50 +0200
committerThomas Vanbesien <tvanbesi@proton.me>2026-05-06 16:43:16 +0200
commit34510ebc63ff65d51f6979a86169bfc52de6180c (patch)
tree36c8b73c99a3c566ccee888818c60204398991fd /plugin/10-treesitter.lua
downloadnvim-config-34510ebc63ff65d51f6979a86169bfc52de6180c.tar.gz
nvim-config-34510ebc63ff65d51f6979a86169bfc52de6180c.zip
feat: initial setup
- `dotfiles` (this project's CLI) - foot configuration - tmux configuration - bash configuration - nvim (as a git submodule) + configuration - ranger configuration - fzf configuration - KDE global shortcuts - Other miscellaneous dependencies
Diffstat (limited to 'plugin/10-treesitter.lua')
-rw-r--r--plugin/10-treesitter.lua37
1 files changed, 37 insertions, 0 deletions
diff --git a/plugin/10-treesitter.lua b/plugin/10-treesitter.lua
new file mode 100644
index 0000000..4602519
--- /dev/null
+++ b/plugin/10-treesitter.lua
@@ -0,0 +1,37 @@
+--
+-- Treesitter parsers
+--
+
+vim.pack.add({ "https://github.com/nvim-treesitter/nvim-treesitter" })
+
+require("nvim-treesitter").install({
+ "bash",
+ "diff",
+ "gitcommit",
+ "ini",
+ "json",
+ "lua",
+ "markdown",
+ "markdown_inline",
+ "readline",
+ "vim",
+ "vimdoc",
+})
+
+-- Parse the tree as early as possible, which is as soon as we know the filetype
+--
+-- Event handlers for the same event are triggered in the order they were created. This must be the first FileType
+-- handler created so that the tree is parsed for other FileType handlers (which often need the parsed tree). To create
+-- it first put this in a file that comes before alphabetically in the `plugin/` directory.
+vim.api.nvim_create_autocmd("FileType", {
+ desc = "Start treesitter",
+ group = vim.g.dotfiles.augroup,
+ callback = function()
+ local parser = vim.treesitter.get_parser(0)
+ if parser == nil then
+ return
+ end
+ parser:parse() -- Parse once asynchronously; used by logic that needs the parsed tree (like extmarks)
+ vim.treesitter.start()
+ end,
+})