Files
TheaninovOS/modules/home-manager/programs/nixvim/presets/languages/js.nix
2025-02-01 11:55:20 +01:00

76 lines
2.3 KiB
Nix

{
lib,
pkgs,
config,
...
}:
let
cfg = config.presets.languages.js;
in
{
options.presets.languages.js = {
enable = lib.mkEnableOption "JS";
eslint = lib.mkEnableOption "ESLint";
npm = lib.mkEnableOption "NPM package completion";
};
config = lib.mkIf cfg.enable {
extraConfigLua =
lib.mkIf cfg.npm # lua
''
require("cmp-npm").setup({})
'';
plugins = {
lspkind = lib.mkIf cfg.npm {
cmp.after = # lua
''
function(entry, vim_item, kind)
if entry.source.name == "npm" then
kind.kind = ""
kind.kind_hl_group = "CmpItemKindNpm"
end
kind.kind = kind.kind .. " "
return kind
end
'';
};
cmp.settings.sources = lib.mkIf cfg.npm [
{
name = "npm";
keywordLength = 4;
priority = 10;
}
];
lsp.servers = {
ts_ls = {
enable = true;
settings = {
typescript.inlayHints = {
includeInlayParameterNameHints = "all";
includeInlayParameterNameHintsWhenArgumentMatchesName = true;
includeInlayFunctionParameterTypeHints = true;
includeInlayVariableTypeHints = true;
includeInlayVariableTypeHintsWhenTypeMatchesName = true;
includeInlayPropertyDeclarationTypeHints = true;
includeInlayFunctionLikeReturnTypeHints = true;
includeInlayEnumMemberValueHints = true;
};
javascript.inlayHints = {
includeInlayParameterNameHints = "all";
includeInlayParameterNameHintsWhenArgumentMatchesName = true;
includeInlayFunctionParameterTypeHints = true;
includeInlayVariableTypeHints = true;
includeInlayVariableTypeHintsWhenTypeMatchesName = true;
includeInlayPropertyDeclarationTypeHints = true;
includeInlayFunctionLikeReturnTypeHints = true;
includeInlayEnumMemberValueHints = true;
};
};
};
eslint.enable = lib.mkIf cfg.eslint true;
};
};
extraPackages = [ pkgs.nodePackages.typescript-language-server ];
};
}