aboutsummaryrefslogtreecommitdiff
path: root/vim
diff options
context:
space:
mode:
authorGrace Yoder <grace_yoder@outlook.com>2026-03-25 14:55:55 -0400
committerGrace Yoder <grace_yoder@outlook.com>2026-03-25 14:55:55 -0400
commita870e9610a23d5cfa6eadfc8bf111f21d11b0d10 (patch)
tree2e7bf1778f50cac6901f225a57b4f30d9f82642f /vim
parent668326d54bf82f24902236281c3d5453a2cb14e0 (diff)
nvim: fixed treesitter for 0.12
Diffstat (limited to 'vim')
-rw-r--r--vim/.config/nvim/lua/plugins.lua153
-rw-r--r--vim/.config/nvim/nvim-pack-lock.json5
2 files changed, 145 insertions, 13 deletions
diff --git a/vim/.config/nvim/lua/plugins.lua b/vim/.config/nvim/lua/plugins.lua
index e856cf3..6500556 100644
--- a/vim/.config/nvim/lua/plugins.lua
+++ b/vim/.config/nvim/lua/plugins.lua
@@ -24,31 +24,158 @@ return require("packed").setup(function(use)
end,
}
-
+ -- https://tduyng.com/blog/neovim-highlight-syntax/
use {
'nvim-treesitter/nvim-treesitter',
branch = 'main',
config = function()
- require('nvim-treesitter').setup()
+ local parser_path = vim.fn.expand("~/.local/share/nvim/site")
+ vim.opt.runtimepath:append(parser_path)
+
+ require("nvim-treesitter").setup({})
+ require("nvim-treesitter").install({
+ "bash",
+ "blade",
+ "c",
+ "comment",
+ "css",
+ "diff",
+ "dockerfile",
+ "fish",
+ "gitcommit",
+ "gitignore",
+ "go",
+ "gomod",
+ "gosum",
+ "gowork",
+ "html",
+ "ini",
+ "javascript",
+ "jsdoc",
+ "json",
+ "lua",
+ "luadoc",
+ "luap",
+ "make",
+ "markdown",
+ "markdown_inline",
+ "nginx",
+ "nix",
+ "proto",
+ "python",
+ "query",
+ "regex",
+ "rust",
+ "scss",
+ "sql",
+ "terraform",
+ "toml",
+ "tsx",
+ "typescript",
+ "vim",
+ "vimdoc",
+ "xml",
+ "yaml",
+ "zig",
+ })
+
+ vim.api.nvim_create_autocmd("PackChanged", {
+ desc = "Handle nvim-treesitter updates",
+ group = vim.api.nvim_create_augroup("nvim-treesitter-pack-changed-update-handler", { clear = true }),
+ callback = function(event)
+ if event.data.kind == "update" then
+ local ok = pcall(vim.cmd, "TSUpdate")
+ if ok then
+ vim.notify("TSUpdate completed successfully!", vim.log.levels.INFO)
+ else
+ vim.notify("TSUpdate command not available yet, skipping", vim.log.levels.WARN)
+ end
+ end
+ end,
+ })
- require('nvim-treesitter').install({
- 'c', 'lua', 'vim', 'vimdoc', 'query', 'markdown', 'markdown_inline', 'go'
- }):wait()
+ vim.wo.foldexpr = "v:lua.vim.treesitter.foldexpr()"
+ vim.bo.indentexpr = "v:lua.require'nvim-treesitter'.indentexpr()"
- -- enable highlighting
- vim.api.nvim_create_autocmd('FileType', {
- callback = function(args)
- local max_filesize = 100 * 1024 -- 100 KB
- local ok, stats = pcall(vim.loop.fs_stat, vim.api.nvim_buf_get_name(args.buf))
- if ok and stats and stats.size > max_filesize then
- return
+ vim.api.nvim_create_autocmd("FileType", {
+ pattern = { "*" },
+ callback = function()
+ local filetype = vim.bo.filetype
+ if filetype and filetype ~= "" then
+ local success = pcall(function()
+ vim.treesitter.start()
+ end)
+ if not success then
+ return
+ end
end
- pcall(vim.treesitter.start)
end,
})
end
}
+ use {
+ src = "https://github.com/nvim-treesitter/nvim-treesitter-textobjects",
+ version = "main",
+ config = function()
+ require("nvim-treesitter-textobjects").setup({
+ select = {
+ enable = true,
+ lookahead = true,
+ selection_modes = {
+ ["@parameter.outer"] = "v", -- charwise
+ ["@function.outer"] = "V", -- linewise
+ ["@class.outer"] = "<c-v>", -- blockwise
+ },
+ include_surrounding_whitespace = false,
+ },
+ move = {
+ enable = true,
+ set_jumps = true,
+ },
+ })
+
+ -- SELECT keymaps
+ local sel = require("nvim-treesitter-textobjects.select")
+ for _, map in ipairs({
+ { { "x", "o" }, "af", "@function.outer" },
+ { { "x", "o" }, "if", "@function.inner" },
+ { { "x", "o" }, "ac", "@class.outer" },
+ { { "x", "o" }, "ic", "@class.inner" },
+ { { "x", "o" }, "aa", "@parameter.outer" },
+ { { "x", "o" }, "ia", "@parameter.inner" },
+ { { "x", "o" }, "ad", "@comment.outer" },
+ { { "x", "o" }, "as", "@statement.outer" },
+ }) do
+ vim.keymap.set(map[1], map[2], function()
+ sel.select_textobject(map[3], "textobjects")
+ end, { desc = "Select " .. map[3] })
+ end
+
+ -- MOVE keymaps
+ local mv = require("nvim-treesitter-textobjects.move")
+ for _, map in ipairs({
+ { { "n", "x", "o" }, "]]", mv.goto_next_start, "@function.outer" },
+ { { "n", "x", "o" }, "[[", mv.goto_previous_start, "@function.outer" },
+ { { "n", "x", "o" }, "]f", mv.goto_next_start, "@function.outer" },
+ { { "n", "x", "o" }, "[f", mv.goto_previous_start, "@function.outer" },
+ { { "n", "x", "o" }, "]c", mv.goto_next_start, "@class.outer" },
+ { { "n", "x", "o" }, "[c", mv.goto_previous_start, "@class.outer" },
+ { { "n", "x", "o" }, "]F", mv.goto_next_end, "@function.outer" },
+ { { "n", "x", "o" }, "[F", mv.goto_previous_end, "@function.outer" },
+ { { "n", "x", "o" }, "]o", mv.goto_next_start, { "@loop.inner", "@loop.outer" } },
+ { { "n", "x", "o" }, "[o", mv.goto_previous_start, { "@loop.inner", "@loop.outer" } },
+ }) do
+ local modes, lhs, fn, query = map[1], map[2], map[3], map[4]
+ -- build a human-readable desc
+ local qstr = (type(query) == "table") and table.concat(query, ",") or query
+ vim.keymap.set(modes, lhs, function()
+ fn(query, "textobjects")
+ end, { desc = "Move to " .. qstr })
+ end
+ end
+ }
+
use 'mbbill/undotree'
diff --git a/vim/.config/nvim/nvim-pack-lock.json b/vim/.config/nvim/nvim-pack-lock.json
index ece9140..f5986c3 100644
--- a/vim/.config/nvim/nvim-pack-lock.json
+++ b/vim/.config/nvim/nvim-pack-lock.json
@@ -58,6 +58,11 @@
"src": "https://github.com/nvim-treesitter/nvim-treesitter",
"version": "'main'"
},
+ "nvim-treesitter-textobjects": {
+ "rev": "93d60a475f0b08a8eceb99255863977d3a25f310",
+ "src": "https://github.com/nvim-treesitter/nvim-treesitter-textobjects",
+ "version": "'main'"
+ },
"nvim-web-devicons": {
"rev": "d7462543c9e366c0d196c7f67a945eaaf5d99414",
"src": "https://github.com/nvim-tree/nvim-web-devicons"