aboutsummaryrefslogtreecommitdiff
path: root/lua/plugins/treesitter.lua
diff options
context:
space:
mode:
authorsrdusr <trevorgray@srdusr.com>2025-09-24 04:19:28 +0200
committersrdusr <trevorgray@srdusr.com>2025-09-24 04:19:28 +0200
commit7ed2303648bf83bb081d9bd863660ebf2344ce47 (patch)
tree702f5f832796b572d0faee31c0eb15507e91f49a /lua/plugins/treesitter.lua
parent2a8020a2e9b7ef2ee77ddee14892127a4eb95187 (diff)
downloaddotfiles-7ed2303648bf83bb081d9bd863660ebf2344ce47.tar.gz
dotfiles-7ed2303648bf83bb081d9bd863660ebf2344ce47.zip
Squashed 'common/config/nvim/' changes from 2a8020a..966d12a
966d12a Update/Overhaul git-subtree-dir: common/config/nvim git-subtree-split: 966d12ac730c83da90d60ab24eae539b2ea69441
Diffstat (limited to 'lua/plugins/treesitter.lua')
-rwxr-xr-x[-rw-r--r--]lua/plugins/treesitter.lua81
1 files changed, 52 insertions, 29 deletions
diff --git a/lua/plugins/treesitter.lua b/lua/plugins/treesitter.lua
index 7f481d3..9df99b8 100644..100755
--- a/lua/plugins/treesitter.lua
+++ b/lua/plugins/treesitter.lua
@@ -1,31 +1,54 @@
-require'nvim-treesitter.configs'.setup {
- -- A list of parser names, or "all" (the four listed parsers should always be installed)
+local M = {}
- ensure_installed = {
- "c",
- "bash",
- "lua",
- "rust",
- },
- --ensure_installed = "all", -- one of "all" or a list of languages
- --ignore_install = { "" }, -- List of parsers to ignore installing
- sync_install = false,
- auto_install = true,
- highlight = {
- enable = false,
- disable = {},
- },
- indent = {
- enable = true,
- disable = {},
- --disable = { "python", "css" }
- },
- autotag = {
- enable = true,
- },
-}
---vim.opt.foldmethod = "expr"
---vim.opt.foldexpr = "nvim_treesitter#foldexpr()"
+function M.setup()
+ local ok, treesitter = pcall(require, "nvim-treesitter.configs")
+ if not ok or not treesitter then
+ return false
+ end
---local parser_config = require "nvim-treesitter.parsers".get_parser_configs()
---parser_config.tsx.filetype_to_parsername = { "javascript", "typescript.tsx" }
+ -- Add custom parser directory to runtime path
+ vim.opt.runtimepath:append("$HOME/.local/share/treesitter")
+
+ -- Configure treesitter
+ treesitter.setup({
+ -- Install parsers in custom directory
+ parser_install_dir = "$HOME/.local/share/treesitter",
+
+ -- Enable syntax highlighting
+ highlight = {
+ enable = true,
+ -- Disable additional regex-based highlighting to improve performance
+ additional_vim_regex_highlighting = false,
+ },
+
+ -- Enable indentation
+ indent = {
+ enable = true,
+ },
+
+ -- Additional modules to enable
+ incremental_selection = {
+ enable = true,
+ keymaps = {
+ init_selection = "gnn",
+ node_incremental = "grn",
+ scope_incremental = "grc",
+ node_decremental = "grm",
+ },
+ },
+
+ -- Ensure parsers are installed automatically
+ ensure_installed = {
+ "bash", "c", "cpp", "css", "dockerfile", "go", "html",
+ "javascript", "json", "lua", "markdown", "python", "rust",
+ "toml", "typescript", "vim", "yaml"
+ },
+
+ -- Auto-install parsers
+ auto_install = true,
+ })
+
+ return true
+end
+
+return M