temporary nvim lsp/fmt support

This commit is contained in:
Grimmauld 2024-05-18 16:41:17 +02:00
parent 65b39ce021
commit 21a081e2a5
Signed by: Grimmauld
GPG Key ID: C2946668769F91FB
11 changed files with 182 additions and 35 deletions

View File

@ -26,7 +26,7 @@ in
++ optionals config.services.desktopManager.plasma6.enable [ pkgs.plasma-browser-integration ];
programs.firefox = {
package = pkgs.firefox-beta;
# package = pkgs.firefox-beta;
enable = true;
nativeMessagingHosts.packages =
[ ]

69
common/tooling/c.nix Normal file
View File

@ -0,0 +1,69 @@
{
pkgs,
config,
lib,
...
}:
let
lang_support_id = "c";
inherit (config.grimmShared) enable tooling graphical;
inherit (lib)
optionals
mkIf
getExe'
types
mkOption
elem
;
in
{
config = mkIf (enable && tooling.enable && (elem lang_support_id tooling.supportedLangs)) {
environment.systemPackages =
with pkgs;
[
util-linux
linuxPackages.perf
pkg-config
glib
glibc
clang
clang-tools
]
++ optionals graphical [
libva-utils
jetbrains.clion
];
grimmShared.tooling.lang_servers = [
{
lsp = {
package = pkgs.clang-tools;
lspconf_config = ''
{
cmd = { 'clangd', '--background-index'},
root_dir = require("lspconfig.util").root_pattern(
"CMakeLists.txt",
"flake.nix",
".git"
)
}'';
lspconf_mod_name = "clangd";
};
fmt = rec {
package = pkgs.clang-tools;
command = getExe' package "clang-format";
includes = [
"*.c"
"*.h"
"*.cpp"
"*.hpp"
];
};
}
];
};
options.grimmShared.tooling.supportedLangs = mkOption {
type = types.listOf (types.enum [ lang_support_id ]);
};
}

View File

@ -8,6 +8,8 @@ let
inherit (config.grimmShared) enable tooling graphical;
inherit (lib)
mkEnableOption
mkOption
types
getExe
optionals
mkIf
@ -23,6 +25,8 @@ in
./nvim.nix
./lsp.nix
./git.nix
./c.nix
./java.nix
];
config = mkIf (enable && tooling.enable) {
@ -40,14 +44,9 @@ in
wget
bat
hyfetch
util-linux
btop
linuxPackages.perf
eza
gcc
jdk17
pkg-config
unzip
p7zip
@ -55,13 +54,10 @@ in
gomuks
ranger
visualvm
imagemagick
nmap
parted
glib
glibc
expect
]
++ optionals graphical [
@ -69,8 +65,6 @@ in
qdirstat
libva-utils
gparted
jetbrains.clion
jetbrains.idea-community
];
environment.shellAliases = {
@ -108,5 +102,11 @@ in
options.grimmShared.tooling = {
enable = mkEnableOption "grimm-tooling";
supportedLangs = mkOption {
type = types.listOf (types.enum [ ]);
default = [ ];
description = "Languages for which to enable support";
};
};
}

41
common/tooling/java.nix Normal file
View File

@ -0,0 +1,41 @@
{
pkgs,
config,
lib,
...
}:
let
lang_support_id = "java";
inherit (config.grimmShared) enable tooling graphical;
inherit (lib)
optionals
mkIf
types
mkOption
elem
;
in
{
config = mkIf (enable && tooling.enable && (elem lang_support_id tooling.supportedLangs)) {
environment.systemPackages = [
pkgs.jdk17
pkgs.visualvm
] ++ optionals graphical [ pkgs.jetbrains.idea-community ];
grimmShared.tooling.lang_servers = [
{
lsp = {
package = pkgs.java-language-server;
};
fmt = {
package = pkgs.google-java-format;
includes = [ "*.java" ];
};
}
];
};
options.grimmShared.tooling.supportedLangs = mkOption {
type = types.listOf (types.enum [ lang_support_id ]);
};
}

View File

@ -23,7 +23,7 @@ let
(
''
[formatter.${getName fmt.package}]
command = "${getExe fmt.package}"
command = "${fmt.command}"
includes = ${builtins.toJSON fmt.includes}
''
+ (optionalString (fmt.options != [ ]) "options = ${builtins.toJSON fmt.options}\n")
@ -42,7 +42,6 @@ in
++ (map (v: v.lsp.package) (filter (v: !isNull v.lsp) tooling.lang_servers))
++ (map (v: v.fmt.package) (filter (v: !isNull v.fmt) tooling.lang_servers));
# environment.shellAliases."treefmt" = "${getExe pkgs.treefmt} --config-file ${treefmt_conf}";
environment.shellAliases."treefmt" = "${getExe pkgs.treefmt} --config-file $(${getExe find_conf})";
grimmShared.tooling.nvim.extraLuaRC =
@ -71,7 +70,7 @@ in
options = {
lspconf_mod_name = mkOption {
type = types.nullOr types.nonEmptyStr;
default = getName config.package;
default = builtins.replaceStrings [ "-" ] [ "_" ] (getName config.package);
description = "lspconfig module name";
};

View File

@ -23,7 +23,10 @@ in
programs.git.config.core.editor = getExe pkgs.neovim;
grimmShared.tooling.nvim.plugins = with pkgs.vimPlugins; [ vim-monokai-pro ];
grimmShared.tooling.nvim = {
plugins = with pkgs.vimPlugins; [ vim-monokai-pro ];
# extraLuaRC = [ "vim.lsp.inlay_hint.enable(true)" ];
};
programs.neovim = {
enable = true;

View File

@ -5,6 +5,7 @@
...
}:
let
lang_support_id = "python";
inherit (config.grimmShared) enable tooling graphical;
pyLibs =
python-pkgs: with python-pkgs; [
@ -14,17 +15,26 @@ let
scipy
pygobject3
];
inherit (lib)
mkIf
types
mkOption
mapAttrsToList
concatLines
elem
;
in
{
config = lib.mkIf (enable && tooling.enable) {
config = mkIf (enable && tooling.enable && (elem lang_support_id tooling.supportedLangs)) {
environment.systemPackages = [
(pkgs.python3.withPackages pyLibs)
] ++ lib.optionals graphical (with pkgs; [ jetbrains.pycharm-community ]);
programs.xonsh = {
enable = true;
config = lib.concatLines (
lib.mapAttrsToList (
config = concatLines (
mapAttrsToList (
name: value: "aliases[\"${name}\"] = '''${value}'''"
) config.environment.shellAliases
);
@ -42,4 +52,8 @@ in
}
];
};
options.grimmShared.tooling.supportedLangs = mkOption {
type = types.listOf (types.enum [ lang_support_id ]);
};
}

View File

@ -5,19 +5,30 @@
...
}:
let
lang_support_id = "rust";
inherit (lib)
optionals
mkIf
types
mkOption
elem
;
inherit (config.grimmShared) enable tooling graphical;
in
{
config = lib.mkIf (enable && tooling.enable) {
config = mkIf (enable && tooling.enable && (elem lang_support_id tooling.supportedLangs)) {
environment.systemPackages =
with pkgs;
[ pkg-config ] ++ lib.optionals graphical [ jetbrains.clion ];
[
pkg-config
cargo
]
++ optionals graphical [ jetbrains.clion ];
grimmShared.tooling.lang_servers = [
{
lsp = {
package = pkgs.rust-analyzer;
lspconf_mod_name = "rust_analyzer";
};
fmt = {
package = pkgs.rustfmt;
@ -26,4 +37,8 @@ in
}
];
};
options.grimmShared.tooling.supportedLangs = mkOption {
type = types.listOf (types.enum [ lang_support_id ]);
};
}

View File

@ -20,6 +20,12 @@
locale = true;
network = true;
tooling = {
supportedLangs = [
"rust"
"c"
"java"
"python"
];
enable = true;
};
};

View File

@ -28,11 +28,11 @@ let
};
nixpkgs_patches = [
{
# xonsh update
url = "https://patch-diff.githubusercontent.com/raw/NixOS/nixpkgs/pull/305316.patch";
hash = "sha256-W3jh6qRA/7V1fImLm3vRmaT6h6gL5rlNBUuIidZHaZc=";
}
#{
# # xonsh update
# url = "https://patch-diff.githubusercontent.com/raw/NixOS/nixpkgs/pull/305316.patch";
# hash = "sha256-W3jh6qRA/7V1fImLm3vRmaT6h6gL5rlNBUuIidZHaZc=";
#}
];
# enable ccache for lix if ccache is enabled

View File

@ -29,22 +29,22 @@
"homepage": "https://nyx.chaotic.cx",
"owner": "chaotic-cx",
"repo": "nyx",
"rev": "bae54b9e537d17c298b30436990d4962caab73d0",
"sha256": "13p1ygwf7q95na4lc3b4cp8rinpc4jvdhyz4c50ig77iz55mvbij",
"rev": "5b1f4d9d757db78bc0fdf3e3bd0b161d46d6bc5d",
"sha256": "0qsya33g1my8xcvd1a6l1nsmcgnam0wknfrpmvfl39c1jmj7rgzv",
"type": "tarball",
"url": "https://github.com/chaotic-cx/nyx/archive/bae54b9e537d17c298b30436990d4962caab73d0.tar.gz",
"url": "https://github.com/chaotic-cx/nyx/archive/5b1f4d9d757db78bc0fdf3e3bd0b161d46d6bc5d.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
},
"lix-module": {
"branch": "main",
"repo": "https://git.lix.systems/lix-project/nixos-module.git",
"rev": "c8ab1e79ba0140bc75731c75177242089506260b",
"rev": "53d713eb486f21d653af3ef3528e9a19ecfc45e5",
"type": "git"
},
"lix-pkg": {
"branch": "main",
"repo": "https://git.lix.systems/lix-project/lix.git",
"rev": "ceccac835c55e3b5c805851bad871360641ff1d9",
"rev": "005ee33a9a145f714f4837b1c0b5c430ac3bc588",
"type": "git"
},
"nixos-mailserver": {
@ -66,15 +66,15 @@
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
},
"nixpkgs": {
"branch": "nixos-unstable",
"branch": "nixos-unstable-small",
"description": "Nix Packages collection",
"homepage": null,
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "f1010e0469db743d14519a1efd37e23f8513d714",
"sha256": "0khh2y04wp4dy1hy0nxc4raacp8149ds7mpwmnymf55v7xzf10vn",
"rev": "22b25d36f84f5449e2799af1def209278ef75147",
"sha256": "14a1ym1bml6n4lnxhxgsk6dvdn5c8ivhl1xl5v2l6awcw9q2vf0g",
"type": "tarball",
"url": "https://github.com/NixOS/nixpkgs/archive/f1010e0469db743d14519a1efd37e23f8513d714.tar.gz",
"url": "https://github.com/NixOS/nixpkgs/archive/22b25d36f84f5449e2799af1def209278ef75147.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
}
}