2023-03-24 11:14:12 +01:00
|
|
|
{
|
|
|
|
lib,
|
2023-11-06 15:04:08 +01:00
|
|
|
helpers,
|
|
|
|
config,
|
2023-03-24 11:14:12 +01:00
|
|
|
...
|
2023-11-06 15:04:08 +01:00
|
|
|
}:
|
2023-03-24 11:14:12 +01:00
|
|
|
with lib; let
|
2023-12-09 20:34:24 +01:00
|
|
|
filetypeDefinition =
|
|
|
|
helpers.mkNullOrOption
|
|
|
|
(with types;
|
|
|
|
attrsOf (
|
|
|
|
oneOf [
|
|
|
|
# Raw filetype
|
|
|
|
str
|
|
|
|
# Function to set the filetype
|
|
|
|
helpers.rawType
|
|
|
|
# ["filetype" {priority = xx;}]
|
|
|
|
(listOf (either str (submodule {
|
|
|
|
options = {
|
|
|
|
priority = mkOption {
|
|
|
|
type = int;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
})))
|
|
|
|
]
|
|
|
|
));
|
2023-03-24 11:14:12 +01:00
|
|
|
in {
|
|
|
|
options.filetype =
|
|
|
|
helpers.mkCompositeOption ''
|
|
|
|
Define additional filetypes. The values can either be a literal filetype or a function
|
|
|
|
taking the filepath and the buffer number.
|
|
|
|
|
|
|
|
For more information check `:h vim.filetype.add()`
|
|
|
|
'' {
|
|
|
|
extension = filetypeDefinition "set filetypes matching the file extension";
|
|
|
|
filename = filetypeDefinition "set filetypes matching the file name (or path)";
|
|
|
|
pattern = filetypeDefinition "set filetypes matching the specified pattern";
|
|
|
|
};
|
|
|
|
|
|
|
|
config.extraConfigLua = helpers.mkIfNonNull' config.filetype ''
|
|
|
|
vim.filetype.add(${helpers.toLuaObject config.filetype})
|
|
|
|
'';
|
|
|
|
}
|