Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions neovim/lazy-lock.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
{
"blink.cmp": { "branch": "main", "commit": "b19413d214068f316c78978b08264ed1c41830ec" },
"catppuccin": { "branch": "main", "commit": "cb5665990a797b102715188e73c44c3931b3b42e" },
"catppuccin": { "branch": "main", "commit": "605b4603797de970e9f3a4238c199c850da03186" },
"conform.nvim": { "branch": "master", "commit": "3543d000dafbc41cc7761d860cfdb24e82154f75" },
"fidget.nvim": { "branch": "main", "commit": "b61e8af9b8b68ee0ec7da5fb7a8c203aae854f2e" },
"fzf-lua": { "branch": "main", "commit": "47b85a25c0c0b2c20b4e75199ed01bb71e7814f5" },
"hardtime.nvim": { "branch": "main", "commit": "b9a989191b3a97c9316a0efea02341c4cdab845a" },
"lazy.nvim": { "branch": "main", "commit": "306a05526ada86a7b30af95c5cc81ffba93fef97" },
"lazydev.nvim": { "branch": "main", "commit": "01bc2aacd51cf9021eb19d048e70ce3dd09f7f93" },
"lazygit.nvim": { "branch": "main", "commit": "a04ad0dbc725134edbee3a5eea29290976695357" },
"log-highlight.nvim": { "branch": "main", "commit": "660306841f098c935c85ac3d4c66d67a64317495" },
"log-highlight.nvim": { "branch": "main", "commit": "ca88628f6dd3b9bb46f9a7401669e24cf7de47a4" },
"mini.nvim": { "branch": "main", "commit": "a995fe9cd4193fb492b5df69175a351a74b3d36b" },
"neovim-ayu": { "branch": "master", "commit": "e5a9f0fa2918d6b5f57c21b3ac014314ee5e41c8" },
"nvim-lspconfig": { "branch": "master", "commit": "5bfcc89fd155b4ffc02d18ab3b7d19c2d4e246a7" },
"nvim-treesitter": { "branch": "main", "commit": "42fc28ba918343ebfd5565147a42a26580579482" },
"nvim-treesitter-textobjects": { "branch": "master", "commit": "5ca4aaa6efdcc59be46b95a3e876300cfead05ef" },
"nvim-lspconfig": { "branch": "master", "commit": "0203a9608d63eda57679b01e69f33a7b4c34b0d1" },
"nvim-treesitter": { "branch": "main", "commit": "4916d6592ede8c07973490d9322f187e07dfefac" },
"nvim-treesitter-textobjects": { "branch": "main", "commit": "851e865342e5a4cb1ae23d31caf6e991e1c99f1e" },
"plenary.nvim": { "branch": "master", "commit": "b9fd5226c2f76c951fc8ed5923d85e4de065e509" },
"rose-pine": { "branch": "main", "commit": "f01eac6eedf6197509dde8b66de0263207ee1877" },
"sort.nvim": { "branch": "main", "commit": "101fdda389ea5f9c6da6af13fe9d61d0a0aadff2" },
Expand Down
183 changes: 93 additions & 90 deletions neovim/lua/plugins/tree-sitter.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@ return {
{ "fei6409/log-highlight.nvim", event = "BufRead *.log", opts = {} },
{
"nvim-treesitter/nvim-treesitter",
branch = "main",
build = ":TSUpdate",
config = function(_, opts)
---@diagnostic disable-next-line: missing-fields
require("nvim-treesitter.configs").setup(opts)
lazy = false,
dependencies = { "nvim-treesitter/nvim-treesitter-textobjects" },
config = function()
-- Custom filetype detection for Helm and Go templates
vim.filetype.add({
extension = { gotmpl = "gotmpl" },
pattern = {
Expand All @@ -15,11 +17,9 @@ return {
["helmfile.*%.ya?ml"] = "helm",
},
})
end,
dependencies = { "nvim-treesitter/nvim-treesitter-textobjects" },
event = { "BufNew", "BufRead" },
opts = {
ensure_installed = {

-- Parsers to install. Compiled locally via the tree-sitter CLI.
require("nvim-treesitter").install({
"bash",
"comment",
"diff",
Expand All @@ -39,87 +39,90 @@ return {
"vim",
"vimdoc",
"yaml",
},
textobjects = {
select = {
enable = true,
lookahead = true,
keymaps = {
["aa"] = {
query = "@parameter.outer",
desc = "Select around argument/parameter",
},
["ac"] = {
query = "@comment.outer",
desc = "Select around comment",
},
["af"] = {
query = "@function.outer",
desc = "Select around function",
},
["at"] = {
query = "@class.outer",
desc = "Select around type/class",
},
["ia"] = {
query = "@parameter.inner",
desc = "Select inside argument/parameter",
},
["ic"] = {
query = "@comment.inner",
desc = "Select inside comment",
},
["if"] = {
query = "@function.inner",
desc = "Select inside function",
},
["it"] = {
query = "@class.inner",
desc = "Select inside type/class",
},
},
},
move = {
enable = true,
set_jumps = true, -- whether to set jumps in the jumplist
goto_next_start = {
["]a"] = {
query = "@parameter.inner",
desc = "Next argument/parameter",
},
["]c"] = { query = "@comment.outer", desc = "Next comment" },
["]f"] = { query = "@function.outer", desc = "Next function" },
["]t"] = { query = "@class.outer", desc = "Next type/class" },
},
goto_previous_start = {
["[a"] = {
query = "@parameter.inner",
desc = "Previous argument/parameter",
},
["[c"] = { query = "@comment.outer", desc = "Previous comment" },
["[f"] = {
query = "@function.outer",
desc = "Previous function",
},
["[t"] = {
query = "@class.outer",
desc = "Previous type/class",
},
},
},
},
-- Autoinstall languages that are not installed
auto_install = true,
highlight = {
enable = true,
-- Some languages depend on vim's regex highlighting system (such as
-- Ruby) for indent rules. If you are experiencing weird indenting
-- issues, add the language to the list of
-- additional_vim_regex_highlighting and disabled languages for indent.
additional_vim_regex_highlighting = { "ruby" },
},
indent = { enable = true, disable = { "ruby" } },
},
version = "*",
})

-- Filetypes to enable treesitter highlighting + indent for.
-- Note: parser names and filetype names sometimes differ
-- (e.g. `vimdoc` parser → `help` filetype, `bash` parser → `sh` filetype).
-- The `comment` parser has no filetype; it is used for injections only.
local filetypes = {
"bash",
"diff",
"dockerfile",
"elm",
"gitcommit",
"gleam",
"go",
"gotmpl",
"helm",
"help",
"json",
"lua",
"markdown",
"python",
"sh",
"terraform",
"toml",
"vim",
"yaml",
}

vim.api.nvim_create_autocmd("FileType", {
pattern = filetypes,
callback = function()
vim.treesitter.start()
vim.bo.indentexpr = "v:lua.require'nvim-treesitter'.indentexpr()"
end,
})
end,
},
{
"nvim-treesitter/nvim-treesitter-textobjects",
branch = "main",
lazy = false,
config = function()
require("nvim-treesitter-textobjects").setup({
move = { set_jumps = true },
})

local select = require("nvim-treesitter-textobjects.select")
local move = require("nvim-treesitter-textobjects.move")

-- Selection keymaps: { lhs, query, desc }
local selects = {
{ "aa", "@parameter.outer", "Select around argument/parameter" },
{ "ac", "@comment.outer", "Select around comment" },
{ "af", "@function.outer", "Select around function" },
{ "at", "@class.outer", "Select around type/class" },
{ "ia", "@parameter.inner", "Select inside argument/parameter" },
{ "ic", "@comment.inner", "Select inside comment" },
{ "if", "@function.inner", "Select inside function" },
{ "it", "@class.inner", "Select inside type/class" },
}
for _, s in ipairs(selects) do
vim.keymap.set({ "x", "o" }, s[1], function()
select.select_textobject(s[2], "textobjects")
end, { desc = s[3] })
end

-- Movement keymaps: { lhs, query, direction, desc }
local moves = {
{ "]a", "@parameter.inner", "next", "Next argument/parameter" },
{ "]c", "@comment.outer", "next", "Next comment" },
{ "]f", "@function.outer", "next", "Next function" },
{ "]t", "@class.outer", "next", "Next type/class" },
{ "[a", "@parameter.inner", "prev", "Previous argument/parameter" },
{ "[c", "@comment.outer", "prev", "Previous comment" },
{ "[f", "@function.outer", "prev", "Previous function" },
{ "[t", "@class.outer", "prev", "Previous type/class" },
}
for _, m in ipairs(moves) do
local fn = m[3] == "next" and move.goto_next_start
or move.goto_previous_start
vim.keymap.set({ "n", "x", "o" }, m[1], function()
fn(m[2], "textobjects")
end, { desc = m[4] })
end
end,
},
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
- neovim
- ripgrep
- starship
- tree-sitter-cli
- uv
- vim
- yq
Loading