2024-01-16 12:45:33 +01:00
|
|
|
{ pkgs, config, ... }:
|
2023-09-10 13:30:29 +02:00
|
|
|
|
|
|
|
with builtins;
|
|
|
|
{
|
2023-09-17 09:35:10 +02:00
|
|
|
config.home-manager.users.moritz.programs.neovim.lazy.plugins = with pkgs.vimPlugins; [
|
2024-01-16 12:45:33 +01:00
|
|
|
(
|
|
|
|
let
|
|
|
|
parserDir = pkgs.symlinkJoin {
|
|
|
|
name = "tresitter-grammars-all";
|
|
|
|
paths = pkgs.vimPlugins.nvim-treesitter.withAllGrammars.dependencies;
|
2023-12-08 16:06:00 +01:00
|
|
|
};
|
2024-01-16 12:45:33 +01:00
|
|
|
in
|
|
|
|
{
|
|
|
|
plugin = nvim-treesitter;
|
|
|
|
event = [ "BufReadPost" "BufNewFile" ];
|
|
|
|
opts = {
|
|
|
|
sync_install = false;
|
|
|
|
auto_install = false;
|
|
|
|
highlight = {
|
|
|
|
enable = true;
|
|
|
|
};
|
|
|
|
textobjects =
|
|
|
|
{
|
|
|
|
select =
|
|
|
|
{
|
|
|
|
enable = true;
|
2023-12-08 16:06:00 +01:00
|
|
|
|
2024-01-16 12:45:33 +01:00
|
|
|
# Automatically jump forward to textobj, similar to targets.vim
|
|
|
|
lookahead = false;
|
2023-12-08 16:06:00 +01:00
|
|
|
|
2024-01-16 12:45:33 +01:00
|
|
|
keymaps = {
|
|
|
|
# You can use the capture groups defined in textobjects.scm
|
|
|
|
"af" = {
|
|
|
|
query = "@function.outer";
|
|
|
|
desc = "Select outer part of a function region";
|
|
|
|
};
|
|
|
|
"if" = {
|
|
|
|
query = "@function.inner";
|
|
|
|
desc = "Select inner part of a function region";
|
|
|
|
};
|
|
|
|
"ac" = {
|
|
|
|
query = "@class.outer";
|
|
|
|
desc = "Select outer part of a class region";
|
|
|
|
};
|
|
|
|
"ic" = {
|
|
|
|
query = "@class.inner";
|
|
|
|
desc = "Select inner part of a class region";
|
|
|
|
};
|
2023-12-08 16:06:00 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2024-01-16 12:45:33 +01:00
|
|
|
};
|
|
|
|
conf =
|
|
|
|
''
|
|
|
|
local final_opts = vim.tbl_deep_extend("keep", opts, { parser_install_dir = "${parserDir}" })
|
|
|
|
require('nvim-treesitter.configs').setup(final_opts)
|
|
|
|
'';
|
|
|
|
init = ''
|
|
|
|
local runtimepath = vim.opt.runtimepath:get()
|
|
|
|
table.insert(runtimepath, 4, "${parserDir}")
|
|
|
|
vim.opt.runtimepath = runtimepath
|
2023-09-10 13:30:29 +02:00
|
|
|
'';
|
2024-01-16 12:45:33 +01:00
|
|
|
priority = 100;
|
|
|
|
dependencies = [
|
|
|
|
{ plugin = nvim-treesitter-textobjects; }
|
|
|
|
{ plugin = nvim-ts-context-commentstring; opts = { }; }
|
|
|
|
];
|
|
|
|
}
|
|
|
|
)
|
2023-09-10 13:30:29 +02:00
|
|
|
{
|
|
|
|
plugin = nvim-treesitter-textsubjects;
|
|
|
|
event = [ "BufReadPost" "BufNewFile" ];
|
|
|
|
conf = readFile ./lua/nvim-treesitter-textsubjects.lua;
|
|
|
|
}
|
|
|
|
{
|
|
|
|
plugin = nvim-treesitter-context;
|
|
|
|
event = [ "BufReadPost" "BufNewFile" ];
|
|
|
|
opts = { };
|
|
|
|
}
|
|
|
|
];
|
|
|
|
}
|