neovim: refac extra filetype detect

This commit is contained in:
Dmitriy Pleshevskiy 2024-05-10 22:27:42 +03:00
parent c36bad03eb
commit ee0fcad06f
Signed by: pleshevskiy
GPG key ID: 17041163DA10A9A2

View file

@ -4,6 +4,14 @@ let
inherit (lib.mod) ctrl;
inherit (lib.nix2lua) lambda0 set pipe1 require call call0;
mkFiletypeDetect = ft: pattern: {
"filetype-detect-${ft}" = {
event = [ "BufNewFile" "BufRead" ];
inherit pattern;
command = "setfiletype ${ft}";
};
};
mkLineLimiterGroup = { limit, pattern }: {
"line-limiter-${toString limit}" = {
event = [ "BufNewFile" "BufRead" ];
@ -17,19 +25,14 @@ in
"${modulesPath}/profiles/recommended.nix"
];
vim.namedCmd.extra-ftdetect = ''
aug extra_ftdetect
au!
au BufNewFile,BufRead *.d2 setfiletype d2
au BufNewFile,BufRead *.ncl setfiletype nickel
au BufNewFile,BufRead *.psql setfiletype psql
aug END
'';
# Enable fast navigation between windows
vim.keymap.set = map (k: { mode = "n"; lhs = ctrl k; rhs = "${ctrl "w"}${k}"; }) [ "h" "l" "j" "k" ];
vim.augroup = lib.mkMerge [
(mkFiletypeDetect "d2" "*.d2")
(mkFiletypeDetect "nickel" "*.ncl")
(mkFiletypeDetect "psql" "*.psql")
(mkLineLimiterGroup {
limit = 101;
pattern = [
@ -128,16 +131,12 @@ in
init_options = {
typescript.tsdk = "./node_modules/typescript/lib";
};
};
ltex = {
language = "en-US";
languageToolHttpServerUri = "http://localhost:8081";
};
pylsp = { };
denols = {
root_dir = call "${config.plugin.nvim-lspconfig.varName}.util.root_pattern" [ "deno.json" "deno.jsonc" ];
};