mirror of
https://github.com/NotAShelf/nvf.git
synced 2026-05-18 21:17:23 +00:00
languages/pug: init
This commit is contained in:
parent
cd45295f9c
commit
75b585be2d
6 changed files with 208 additions and 0 deletions
|
|
@ -116,6 +116,7 @@ isMaximal: {
|
|||
jq.enable = false;
|
||||
fish.enable = false;
|
||||
standard-ml.enable = false;
|
||||
pug.enable = false;
|
||||
|
||||
# Nim LSP is broken on Darwin and therefore
|
||||
# should be disabled by default. Users may still enable
|
||||
|
|
|
|||
|
|
@ -0,0 +1,25 @@
|
|||
From 85c43d3f45b6a5d301b66fe52c0c92b16ddfbc95 Mon Sep 17 00:00:00 2001
|
||||
From: alfarel <alfarelcynthesis@proton.me>
|
||||
Date: Sun, 17 May 2026 22:42:21 -0400
|
||||
Subject: [PATCH] fix: don't touch git state while building
|
||||
|
||||
---
|
||||
package.json | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/package.json b/package.json
|
||||
index 9151c4f..5508237 100644
|
||||
--- a/package.json
|
||||
+++ b/package.json
|
||||
@@ -6,7 +6,7 @@
|
||||
"clean": "git clean -fdx",
|
||||
"build:clean": "git clean -fdx dist",
|
||||
"build:code": "tsup-node",
|
||||
- "build": "run-s build:clean build:code",
|
||||
+ "build": "run-s build:code",
|
||||
"docs:build": "vitepress build docs",
|
||||
"docs:dev": "vitepress dev docs",
|
||||
"docs:serve": "vitepress serve docs --port 5173",
|
||||
--
|
||||
2.53.0
|
||||
|
||||
60
flake/pkgs/by-name/prettier-plugin-pug/package.nix
Normal file
60
flake/pkgs/by-name/prettier-plugin-pug/package.nix
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
{
|
||||
stdenv,
|
||||
nodejs,
|
||||
gitMinimal,
|
||||
pnpm_9,
|
||||
pnpmConfigHook,
|
||||
fetchPnpmDeps,
|
||||
pins,
|
||||
fetchFromGitHub,
|
||||
writableTmpDirAsHomeHook,
|
||||
}: let
|
||||
pin = pins.prettier-plugin-pug;
|
||||
in
|
||||
stdenv.mkDerivation (finalAttrs: {
|
||||
pname = "prettier-plugin-pug";
|
||||
version = pin.version or pin.revision;
|
||||
|
||||
patches = [
|
||||
./0001-fix-don-t-touch-git-state-while-building.patch
|
||||
];
|
||||
|
||||
src = fetchFromGitHub {
|
||||
inherit (pin.repository) owner repo;
|
||||
rev = finalAttrs.version;
|
||||
sha256 = pin.hash;
|
||||
};
|
||||
|
||||
pnpmDeps = fetchPnpmDeps {
|
||||
pnpm = pnpm_9;
|
||||
inherit (finalAttrs) pname src;
|
||||
fetcherVersion = 2;
|
||||
hash = "sha256-4IS2dvcODzeakx8ezIQkoz6PLEP8Sm4OFz0EWQ0jXoA=";
|
||||
};
|
||||
|
||||
nativeBuildInputs = [
|
||||
nodejs
|
||||
gitMinimal
|
||||
writableTmpDirAsHomeHook
|
||||
(pnpmConfigHook.overrideAttrs {
|
||||
propagatedBuildInputs = [pnpm_9];
|
||||
})
|
||||
];
|
||||
|
||||
buildPhase = ''
|
||||
runHook preBuild
|
||||
|
||||
pnpm run build
|
||||
|
||||
runHook postBuild
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
|
||||
cp -r dist/ $out
|
||||
cp -r node_modules $out
|
||||
|
||||
runHook postInstall
|
||||
'';
|
||||
})
|
||||
|
|
@ -42,6 +42,7 @@ in {
|
|||
./nix.nix
|
||||
./ocaml.nix
|
||||
./php.nix
|
||||
./pug.nix
|
||||
./python.nix
|
||||
./qml.nix
|
||||
./r.nix
|
||||
|
|
|
|||
105
modules/plugins/languages/pug.nix
Normal file
105
modules/plugins/languages/pug.nix
Normal file
|
|
@ -0,0 +1,105 @@
|
|||
{
|
||||
config,
|
||||
pkgs,
|
||||
lib,
|
||||
inputs,
|
||||
...
|
||||
}: let
|
||||
inherit (lib.attrsets) attrNames genAttrs;
|
||||
inherit (lib.options) mkOption mkEnableOption literalExpression;
|
||||
inherit (lib.meta) getExe;
|
||||
inherit (lib.modules) mkIf mkMerge;
|
||||
inherit (lib.types) enum listOf;
|
||||
inherit (lib.nvim.attrsets) mapListToAttrs;
|
||||
inherit (lib.nvim.types) mkGrammarOption;
|
||||
|
||||
cfg = config.vim.languages.pug;
|
||||
|
||||
defaultServers = ["emmet-ls"];
|
||||
servers = ["emmet-ls"];
|
||||
|
||||
defaultFormat = ["prettier"];
|
||||
formats = {
|
||||
prettier = {
|
||||
command = getExe pkgs.prettier;
|
||||
options.ft_parsers.pug = "pug";
|
||||
prepend_args = let
|
||||
parser = "${inputs.self.packages.${pkgs.stdenv.hostPlatform.system}.prettier-plugin-pug}/index.js";
|
||||
in ["--plugin=${parser}"];
|
||||
};
|
||||
};
|
||||
in {
|
||||
options.vim.languages.pug = {
|
||||
enable = mkEnableOption "Pug language support";
|
||||
|
||||
treesitter = {
|
||||
enable =
|
||||
mkEnableOption "Pug treesitter"
|
||||
// {
|
||||
default = config.vim.languages.enableTreesitter;
|
||||
defaultText = literalExpression "config.vim.languages.enableTreesitter";
|
||||
};
|
||||
package = mkGrammarOption pkgs "pug";
|
||||
};
|
||||
|
||||
lsp = {
|
||||
enable =
|
||||
mkEnableOption "Pug LSP support"
|
||||
// {
|
||||
default = config.vim.lsp.enable;
|
||||
defaultText = literalExpression "config.vim.lsp.enable";
|
||||
};
|
||||
servers = mkOption {
|
||||
type = listOf (enum servers);
|
||||
default = defaultServers;
|
||||
description = "Pug LSP server to use";
|
||||
};
|
||||
};
|
||||
|
||||
format = {
|
||||
enable =
|
||||
mkEnableOption "Pug formatting"
|
||||
// {
|
||||
default = config.vim.languages.enableFormat;
|
||||
defaultText = literalExpression "config.vim.languages.enableFormat";
|
||||
};
|
||||
|
||||
type = mkOption {
|
||||
type = listOf (enum (attrNames formats));
|
||||
default = defaultFormat;
|
||||
description = "Pug formatter to use";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable (mkMerge [
|
||||
(mkIf cfg.treesitter.enable {
|
||||
vim.treesitter = {
|
||||
enable = true;
|
||||
grammars = [cfg.treesitter.package];
|
||||
};
|
||||
})
|
||||
|
||||
(mkIf cfg.lsp.enable {
|
||||
vim.lsp = {
|
||||
presets = genAttrs cfg.lsp.servers (_: {enable = true;});
|
||||
servers = genAttrs cfg.lsp.servers (_: {filetypes = ["pug"];});
|
||||
};
|
||||
})
|
||||
|
||||
(mkIf cfg.format.enable {
|
||||
vim.formatter.conform-nvim = {
|
||||
enable = true;
|
||||
setupOpts = {
|
||||
formatters_by_ft.pug = cfg.format.type;
|
||||
formatters =
|
||||
mapListToAttrs (name: {
|
||||
inherit name;
|
||||
value = formats.${name};
|
||||
})
|
||||
cfg.format.type;
|
||||
};
|
||||
};
|
||||
})
|
||||
]);
|
||||
}
|
||||
|
|
@ -2395,6 +2395,22 @@
|
|||
"url": "https://api.github.com/repos/withastro/prettier-plugin-astro/tarball/refs/tags/v0.14.1",
|
||||
"hash": "sha256-XGPz4D2UKOonet0tX3up5mCxw3/69XYPScxb9l7nzpE="
|
||||
},
|
||||
"prettier-plugin-pug": {
|
||||
"type": "GitRelease",
|
||||
"repository": {
|
||||
"type": "GitHub",
|
||||
"owner": "prettier",
|
||||
"repo": "plugin-pug"
|
||||
},
|
||||
"pre_releases": false,
|
||||
"version_upper_bound": null,
|
||||
"release_prefix": null,
|
||||
"submodules": false,
|
||||
"version": "3.4.2",
|
||||
"revision": "33c86341f0addf48b09968f2545efcf18331d046",
|
||||
"url": "https://api.github.com/repos/prettier/plugin-pug/tarball/refs/tags/3.4.2",
|
||||
"hash": "sha256-4CsKMj8Xnq+dlGzLAG2hV8jTCMYBYhaV/uoKAfztSGs="
|
||||
},
|
||||
"prettier-plugin-svelte": {
|
||||
"type": "GitRelease",
|
||||
"repository": {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue