plugin/efmls-configs: init + tests (#542)

This commit is contained in:
traxys 2023-08-27 20:49:23 +02:00 committed by GitHub
parent c4354ea9ec
commit 4cd3707e00
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 630 additions and 0 deletions

View file

@ -1,5 +1,6 @@
pkgs: rec {
rust-analyzer-config = pkgs.callPackage ./rust-analyzer {};
efmls-configs-tools = pkgs.callPackage ./efmls-configs {};
autogenerated-configs = pkgs.callPackage ({stdenv}:
stdenv.mkDerivation {
pname = "autogenerated-configs";
@ -11,6 +12,7 @@ pkgs: rec {
installPhase = ''
mkdir -p $out
cp ${rust-analyzer-config}/share/* $out
cp ${efmls-configs-tools}/share/* $out
'';
}) {};
}

View file

@ -0,0 +1,37 @@
{
stdenv,
python3,
vimPlugins,
}: let
extract = stdenv.mkDerivation {
pname = "extract_efmls_tools";
version = "1";
src = ./extract.py;
dontUnpack = true;
dontBuild = true;
buildInputs = [python3];
installPhase = ''
mkdir -p $out/bin
cp $src $out/bin/extract_efmls_tools.py
'';
};
in
stdenv.mkDerivation {
pname = "efmls-configs-tools";
inherit (vimPlugins.efmls-configs-nvim) version src;
nativeBuildInputs = [extract];
buildPhase = ''
extract_efmls_tools.py ./lua/efmls-configs > efmls-configs-tools.json
'';
installPhase = ''
mkdir -p $out/share
cp efmls-configs-tools.json $out/share
'';
}

View file

@ -0,0 +1,25 @@
#!/usr/bin/env python
import sys
import os
import json
tool_path = sys.argv[1]
tools = {
"linters": {},
"formatters": {},
}
for kind in ["linters", "formatters"]:
for file in os.listdir(tool_path + "/" + kind):
tool_name = file.removesuffix(".lua")
languages = []
with open(tool_path + "/" + kind + "/" + file) as f:
for line in f.readlines():
if line.startswith("-- languages:"):
languages = line.split(":")[1].strip().split(",")
break
tools[kind][tool_name] = languages
print(json.dumps(tools, indent=4))