dotfiles/modules/programs/nvim/plugins/treesitter.nix

69 lines
2.1 KiB
Nix
Raw Normal View History

2024-08-18 13:03:18 +02:00
{ pkgs, inputs, lib, ... }:
2023-09-10 13:30:29 +02:00
{
2024-06-27 10:12:38 +02:00
config.home-manager.users.moritz.programs.neovim.lazy.plugins = [
2024-01-16 12:45:33 +01:00
(
let
2024-08-18 13:03:18 +02:00
nvim-treesitter = pkgs.vimPlugins.nvim-treesitter;
2024-01-16 12:45:33 +01:00
parserDir = pkgs.symlinkJoin {
name = "tresitter-grammars-all";
2024-08-18 13:03:18 +02:00
paths = nvim-treesitter.withAllGrammars.dependencies;
2023-12-08 16:06:00 +01:00
};
2024-01-16 12:45:33 +01:00
in
{
2024-08-18 13:03:18 +02:00
plugin = nvim-treesitter;
2024-01-16 12:45:33 +01:00
event = [ "BufReadPost" "BufNewFile" ];
opts = {
sync_install = false;
auto_install = false;
highlight = {
enable = true;
2024-06-27 10:12:38 +02:00
disable = [ "latex" ];
2024-01-16 12:45:33 +01:00
};
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 =
2024-08-18 13:03:18 +02:00
/* lua */ ''
vim.opt.runtimepath:append("${parserDir}")
local final_opts = vim.tbl_deep_extend("keep", opts, { parser_install_dir = "${parserDir}" })
require('nvim-treesitter.configs').setup(final_opts)
2023-09-10 13:30:29 +02:00
'';
2024-01-16 12:45:33 +01:00
priority = 100;
dependencies = [
2024-06-27 10:12:38 +02:00
{ plugin = pkgs.vimPlugins.nvim-treesitter-textobjects; }
{ plugin = pkgs.vimPlugins.nvim-ts-context-commentstring; opts = { }; }
2024-01-16 12:45:33 +01:00
];
}
)
2023-09-10 13:30:29 +02:00
];
}