2023-02-28 09:01:56 +00:00
|
|
|
{
|
2023-04-17 20:27:27 +00:00
|
|
|
pkgs,
|
2023-02-28 09:01:56 +00:00
|
|
|
config,
|
|
|
|
lib,
|
|
|
|
...
|
|
|
|
}:
|
|
|
|
with lib;
|
|
|
|
with builtins; let
|
|
|
|
cfg = config.vim.treesitter;
|
2023-04-17 20:27:27 +00:00
|
|
|
usingNvimCmp = config.vim.autocomplete.enable && config.vim.autocomplete.type == "nvim-cmp";
|
2023-02-28 09:01:56 +00:00
|
|
|
in {
|
2023-04-17 20:27:27 +00:00
|
|
|
config = mkIf cfg.enable {
|
|
|
|
vim.startPlugins =
|
|
|
|
["nvim-treesitter"]
|
|
|
|
++ optional cfg.autotagHtml "nvim-ts-autotag"
|
|
|
|
++ optional usingNvimCmp "cmp-treesitter";
|
2023-02-28 09:01:56 +00:00
|
|
|
|
2023-04-17 20:27:27 +00:00
|
|
|
vim.autocomplete.sources = ["treesitter"];
|
2023-02-28 09:01:56 +00:00
|
|
|
|
2023-04-17 20:27:27 +00:00
|
|
|
# For some reason treesitter highlighting does not work on start if this is set before syntax on
|
|
|
|
vim.configRC.treesitter-fold = mkIf cfg.fold (nvim.dag.entryBefore ["basic"] ''
|
|
|
|
set foldmethod=expr
|
|
|
|
set foldexpr=nvim_treesitter#foldexpr()
|
|
|
|
set nofoldenable
|
|
|
|
'');
|
2023-02-28 09:01:56 +00:00
|
|
|
|
2023-04-17 20:27:27 +00:00
|
|
|
vim.luaConfigRC.treesitter = nvim.dag.entryAnywhere ''
|
|
|
|
require'nvim-treesitter.configs'.setup {
|
|
|
|
highlight = {
|
|
|
|
enable = true,
|
|
|
|
disable = {},
|
|
|
|
},
|
2023-02-28 09:01:56 +00:00
|
|
|
|
2023-04-17 20:27:27 +00:00
|
|
|
auto_install = false,
|
|
|
|
ensure_installed = {},
|
2023-02-28 09:01:56 +00:00
|
|
|
|
2023-04-17 20:27:27 +00:00
|
|
|
incremental_selection = {
|
|
|
|
enable = true,
|
|
|
|
keymaps = {
|
|
|
|
init_selection = "gnn",
|
|
|
|
node_incremental = "grn",
|
|
|
|
scope_incremental = "grc",
|
|
|
|
node_decremental = "grm",
|
2023-02-28 09:01:56 +00:00
|
|
|
},
|
2023-04-17 20:27:27 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
${optionalString cfg.autotagHtml ''
|
|
|
|
autotag = {
|
|
|
|
enable = true,
|
|
|
|
},
|
|
|
|
''}
|
|
|
|
}
|
|
|
|
'';
|
|
|
|
};
|
2023-02-28 09:01:56 +00:00
|
|
|
}
|