Skip to content

Commit 8d7f0c3

Browse files
treesitter: add setupOpts
For covering missing options for master, and for main branch just in case someone wants to change the install dir
1 parent 32c2052 commit 8d7f0c3

3 files changed

Lines changed: 25 additions & 18 deletions

File tree

docs/manual/release-notes/rl-0.9.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,5 @@
3939

4040
[jtliang24](https://github.com/jtliang24):
4141

42-
- Updated nix language plugin to use pkgs.nixfmt instead of pkgs.nixfmt-rfc-style
42+
- Updated nix language plugin to use pkgs.nixfmt instead of
43+
pkgs.nixfmt-rfc-style

modules/plugins/treesitter/config.nix

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -28,28 +28,31 @@ in {
2828
2929
if has_configs_module then
3030
-- nvim-treesitter master branch
31-
require('nvim-treesitter.configs').setup({
31+
require('nvim-treesitter.configs').setup(vim.tbl_deep_extend("force", {
3232
${lib.optionalString cfg.highlight.enable ''
33-
highlight = { enable = true },
34-
''}${lib.optionalString cfg.indent.enable ''
35-
indent = { enable = true },
36-
''}
37-
})
33+
highlight = { enable = true },
34+
''}${lib.optionalString cfg.indent.enable ''
35+
indent = { enable = true },
36+
''}
37+
}, ${lib.nvim.lua.toLuaObject cfg.setupOpts}))
3838
else
3939
-- nvim-treesitter main branch
40+
${lib.optionalString (cfg.setupOpts != {}) ''
41+
require('nvim-treesitter').setup(${lib.nvim.lua.toLuaObject cfg.setupOpts})
42+
''}
4043
${lib.optionalString (cfg.highlight.enable || cfg.indent.enable) ''
41-
vim.api.nvim_create_autocmd("FileType", {
42-
group = "nvf_treesitter",
43-
pattern = "*",
44-
callback = function()
45-
${lib.optionalString cfg.highlight.enable ''
46-
pcall(vim.treesitter.start)
47-
''}${lib.optionalString cfg.indent.enable ''
48-
vim.bo.indentexpr = "v:lua.require'nvim-treesitter'.indentexpr()"
49-
''}
50-
end,
51-
})
44+
vim.api.nvim_create_autocmd("FileType", {
45+
group = "nvf_treesitter",
46+
pattern = "*",
47+
callback = function()
48+
${lib.optionalString cfg.highlight.enable ''
49+
pcall(vim.treesitter.start)
50+
''}${lib.optionalString cfg.indent.enable ''
51+
vim.bo.indentexpr = "v:lua.require'nvim-treesitter'.indentexpr()"
5252
''}
53+
end,
54+
})
55+
''}
5356
end
5457
5558
${lib.optionalString cfg.fold ''

modules/plugins/treesitter/treesitter.nix

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
}: let
66
inherit (lib.options) mkOption mkEnableOption literalExpression;
77
inherit (lib.types) listOf package bool;
8+
inherit (lib.nvim.types) mkPluginSetupOption;
89
in {
910
options.vim.treesitter = {
1011
enable = mkEnableOption "treesitter, also enabled automatically through language options";
@@ -66,5 +67,7 @@ in {
6667

6768
indent = {enable = mkEnableOption "indentation with treesitter" // {default = true;};};
6869
highlight = {enable = mkEnableOption "highlighting with treesitter" // {default = true;};};
70+
71+
setupOpts = mkPluginSetupOption "nvim-treesitter" {};
6972
};
7073
}

0 commit comments

Comments
 (0)