mirror of
https://github.com/NotAShelf/nvf.git
synced 2026-04-27 03:47:37 +00:00
treesitter: allow setting of filetype pattern and excludes for indent
This commit is contained in:
parent
5ab359ee7d
commit
d30ba87023
3 changed files with 41 additions and 4 deletions
|
|
@ -4,8 +4,10 @@
|
|||
...
|
||||
}: let
|
||||
inherit (lib.modules) mkIf;
|
||||
inherit (lib.strings) optionalString;
|
||||
inherit (lib.lists) optionals;
|
||||
inherit (lib.nvim.dag) entryAfter;
|
||||
inherit (lib.nvim.lua) toLuaObject;
|
||||
|
||||
cfg = config.vim.treesitter;
|
||||
in {
|
||||
|
|
@ -39,8 +41,14 @@ in {
|
|||
-- Enable treesitter highlighting for all filetypes
|
||||
vim.api.nvim_create_autocmd("FileType", {
|
||||
group = "nvf_treesitter",
|
||||
pattern = "*",
|
||||
callback = function()
|
||||
pattern = ${toLuaObject cfg.indent.pattern},
|
||||
callback = function(args)
|
||||
${optionalString (builtins.length cfg.indent.excludes > 0) ''
|
||||
local ft = vim.bo[args.buf].filetype
|
||||
if vim.tbl_contains(${toLuaObject cfg.indent.excludes}, ft) then
|
||||
return
|
||||
end
|
||||
''}
|
||||
vim.bo.indentexpr = "v:lua.require'nvim-treesitter'.indentexpr()"
|
||||
end,
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue