forked from aylac.top/nixcfg
this repo has no description

this is annoying dude

aylac.top ecad271f df2de760

verified
Changed files
+93 -107
modules
home
programs
helix
zed-editor
snippets
editor
+42 -57
modules/home/programs/helix/default.nix
···
editorCfg = config.mySnippets.editor;
mkHelixServer = name: srv:
-
lib.filterAttrs (_: v: v != null) (
-
{
-
name = name;
-
command = srv.command;
-
}
-
// (
-
if (srv.args or []) != []
-
then {args = srv.args;}
-
else {}
-
)
-
// (
-
if (lib.isAttrs (srv.config or {}) && (builtins.length (builtins.attrNames srv.config)) > 0)
-
then {config = srv.config;}
-
else {}
-
)
-
);
+
lib.filterAttrs (_: v: v != null) {
+
inherit name;
+
command =
+
if srv.helix-command != null
+
then srv.helix-command
+
else srv.command;
+
args = srv.args or null;
+
config = srv.config or null;
+
};
mkHelixLanguage = name: lang: let
-
fmtName = lang.helix-formatter or lang.formatter or null;
+
# this shit is so ugly
+
fmtName = lib.findFirst (x: x != null) null [
+
(lang.helix-formatter or null)
+
(lang.formatter or null)
+
];
+
fmt =
-
if fmtName == null
-
then null
-
else editorCfg.formatters.${fmtName};
+
if fmtName != null
+
then editorCfg.formatters.${fmtName}
+
else null;
-
usesLspFormatter = fmt != null && fmt.type == "lsp";
+
usesLspFormatter = fmt == null || fmt.type == "lsp";
formatter =
if fmt != null && fmt.type == "external"
-
then {
-
command = fmt.command;
-
args = fmt.args or [];
-
}
+
then
+
lib.filterAttrs (_: v: v != null) {
+
command = fmt.command;
+
args = fmt.args;
+
}
else null;
-
languageServers =
-
if usesLspFormatter
-
then
-
map (
-
srvName:
-
if srvName == fmt.lspName
-
then {
-
name = srvName;
-
except-features = ["format"];
-
}
-
else {name = srvName;}
-
)
-
(lang.language-servers
-
++ lang.helix-only-language-servers)
-
else map (srvName: {name = srvName;}) lang.language-servers;
+
fullLspList = lang.language-servers ++ lang.helix-only-language-servers;
+
+
languageServers = map (srvName:
+
lib.filterAttrs (_: v: v != null) {
+
name = srvName;
+
except-features =
+
if (usesLspFormatter && fmtName != null && srvName != fmtName)
+
then ["format"]
+
else null;
+
})
+
fullLspList;
in
-
lib.filterAttrs (_: v: v != null) (
-
{
-
name = lang.name;
-
auto-format = lang.auto-format;
-
language-servers = languageServers;
-
}
-
// (
-
if lang.file-types != []
-
then {file-types = lang.file-types;}
-
else {}
-
)
-
// (
-
if formatter != null
-
then {inherit formatter;}
-
else {}
-
)
-
);
+
lib.filterAttrs (_: v: v != null) {
+
name = lang.name;
+
auto-format = lang.auto-format;
+
language-servers = languageServers;
+
file-types = lang.file-types;
+
inherit formatter;
+
};
in {
options.myHome.programs.helix.enable = lib.mkEnableOption "helix";
+32 -27
modules/home/programs/zed-editor/default.nix
···
mkZedFormatter = fmtName:
if fmtName == null
-
then null
+
then "language_server"
else let
f = editorCfg.formatters.${fmtName};
in
···
};
}
else if f.type == "lsp"
-
then {
-
language_server = {name = f.lspName;};
-
}
+
then {language_server = {name = fmtName;};}
else null;
mkZedLanguage = name: lang:
···
code_actions_on_format = lang.code-actions-on-format;
};
-
mkZedLsp = name: srv: let
-
args = srv.args or [];
-
cfg = srv.config or {};
-
hasArgs = args != [];
-
hasSettings = lib.isAttrs cfg && (builtins.length (builtins.attrNames cfg) > 0);
-
in
-
lib.filterAttrs (_: v: v != null) (
-
{
-
binary = lib.filterAttrs (_: v: v != null) (
-
{path = srv.command;}
-
// (
-
if hasArgs
-
then {arguments = args;}
-
else {}
-
)
-
);
-
}
-
// (
-
if hasSettings
-
then {settings = cfg;}
-
else {}
-
)
-
);
+
mkZedLsp = name: srv:
+
lib.filterAttrs (_: v: v != null) {
+
binary = lib.filterAttrs (_: v: v != null) {
+
path = srv.command;
+
arguments = srv.args or null;
+
};
+
settings = srv.config or null;
+
};
in {
options.myHome.programs.zed-editor.enable = lib.mkEnableOption "zed editor";
···
}
];
userKeymaps = [
+
{
+
context = "(vim_mode == helix_normal || vim_mode == helix_select) && !menu";
+
bindings = {
+
n = "vim::WrappingLeft";
+
e = "vim::Down";
+
i = "vim::Up";
+
o = "vim::WrappingRight";
+
};
+
}
+
{
+
context = "vim_mode == helix_normal && !menu";
+
bindings = {
+
j = "vim::NextWordEnd";
+
J = ["vim::NextWordEnd" {ignore_punctuation = true;}];
+
k = "vim::MoveToNextMatch";
+
K = "vim::MoveToPreviousMatch";
+
l = "vim::HelixInsert";
+
L = "vim::InsertFirstNonWhitespace";
+
h = "vim::InsertLineBelow";
+
H = "vim::InsertLineAbove";
+
};
+
}
{
context = "Workspace";
bindings = {
+19 -23
modules/home/snippets/editor/default.nix
···
# Helper function to create language server definitions
mkLspServer = name: {
command,
-
args ? [],
-
config ? {},
+
helix-command ? null,
+
args ? null,
+
config ? null,
}: {
-
inherit name command args config;
+
inherit name command helix-command args config;
};
# Helper function to create formatter definitions
mkFormatter = name: {
type,
command ? null,
-
args ? [],
+
args ? null,
lspName ? null,
-
config ? {},
+
config ? null,
}: {
inherit name type command args lspName config;
};
···
mkLanguage = name: {
full-name ? name,
auto-format ? true,
-
file-types ? [],
+
file-types ? null,
language-servers ? [],
zed-only-language-servers ? [],
helix-only-language-servers ? [],
formatter ? null,
helix-formatter ? null,
-
code-actions-on-format ? {},
+
code-actions-on-format ? null,
}: {
inherit name full-name auto-format file-types language-servers zed-only-language-servers helix-only-language-servers formatter helix-formatter code-actions-on-format;
};
···
};
tailwindcss-language-server = mkLspServer "tailwindcss-language-server" {
-
command = let
+
command = pkgs.writeScript "tailwindcss-language-server-bun" ''
+
#!${lib.getExe pkgs.bash} -e
+
exec ${lib.getExe pkgs.bun} ${lib.getExe pkgs.tailwindcss-language-server}
+
'';
+
helix-command = let
fd = lib.getExe pkgs.fd;
xargs = "${pkgs.uutils-findutils}/bin/xargs";
grep = lib.getExe pkgs.gnugrep;
-
echo = "${pkgs.uutils-coreutils-noprefix}/bin/echo";
bun = lib.getExe pkgs.bun;
twls = lib.getExe pkgs.tailwindcss-language-server;
-
printf = "${pkgs.uutils-coreutils-noprefix}/bin/printf";
in
-
pkgs.writeScript "tailwindcss-language-server-bun" ''
-
#!${lib.getExe pkgs.bash} -e
+
pkgs.writeScript "tailwindcss-language-server-bun-helix" ''
+
#!${lib.getExe pkgs.bash} -euo
if ! ${fd} -H -I -E "node_modules" "package\\.json$" . | \
${xargs} ${grep} -q '"tailwindcss"'; then
-
${echo} "No tailwindcss found in project; faking clean LSP exit." >&2
-
# Send a fake LSP shutdown + exit sequence to stdout.
-
${printf} 'Content-Length: 47\r\n\r\n{"jsonrpc":"2.0","id":1,"method":"shutdown"}'
-
${printf} 'Content-Length: 41\r\n\r\n{"jsonrpc":"2.0","method":"exit"}'
-
-
# Exit with success so the client treats this as a normal termination.
exit 0
fi
···
formatters = {
biome = mkFormatter "biome" {
type = "lsp";
-
lspName = "biome";
};
biomeHtml = mkFormatter "biomeHtml" {
···
formatter = "gdscript-formatter";
};
-
ruby = mkLanguage "ruby" {
-
full-name = "Ruby";
-
language-servers = ["solargraph" "rubocop" "!ruby-lsp"];
-
};
+
#ruby = mkLanguage "ruby" {
+
# full-name = "Ruby";
+
# language-servers = ["solargraph" "rubocop"];
+
#};
};
};
}