nvim -> helix

This commit is contained in:
Grimmauld 2024-05-30 22:12:15 +02:00
parent 6fad466aca
commit e64967fa76
Signed by: Grimmauld
GPG key ID: C2946668769F91FB
13 changed files with 205 additions and 250 deletions

View file

@ -6,7 +6,12 @@
}:
let
inherit (config.grimmShared) enable gaming;
inherit (lib) mkIf getExe mkEnableOption optional;
inherit (lib)
mkIf
getExe
mkEnableOption
optional
;
in
{
config = mkIf (enable && gaming) {
@ -40,23 +45,26 @@ in
GAMEMODERUNEXEC = "env DRI_PRIME=1";
};
environment.systemPackages = with pkgs; [
heroic
prismlauncher
mangohud
the-powder-toy
factorio
pactorio
(symlinkJoin {
name = "osu";
paths = [
(writeShellScriptBin "osu!" ''
exec gamemoderun ${getExe osu-lazer-bin}
'')
osu-lazer-bin
];
})
] ++ optional (!isNull factorio.passthru.updateScript) factorio;
environment.systemPackages =
with pkgs;
[
heroic
prismlauncher
mangohud
the-powder-toy
factorio
pactorio
(symlinkJoin {
name = "osu";
paths = [
(writeShellScriptBin "osu!" ''
exec gamemoderun ${getExe osu-lazer-bin}
'')
osu-lazer-bin
];
})
]
++ optional (!isNull factorio.passthru.updateScript) factorio;
};
options.grimmShared.gaming = mkEnableOption "enables steam, heroic, prism and gamemoded";

View file

@ -28,26 +28,18 @@ in
glibc
clang
clang-tools
cmake
]
++ optionals graphical [
libva-utils
jetbrains.clion
];
environment.sessionVariables.CMAKE_EXPORT_COMPILE_COMMANDS = "1";
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;
@ -60,6 +52,11 @@ in
];
};
}
{
lsp = {
package = pkgs.cmake-language-server;
};
}
];
};

View file

@ -8,8 +8,6 @@ let
inherit (config.grimmShared) enable tooling graphical;
inherit (lib)
mkEnableOption
mkOption
types
getExe
optionals
mkIf
@ -17,13 +15,13 @@ let
in
{
imports = [
./lilypond.nix
# ./lilypond.nix
./nix.nix
./security.nix
./python.nix
./rust.nix
./nvim.nix
./lsp.nix
./helix.nix
./git.nix
./c.nix
./java.nix
@ -100,19 +98,23 @@ in
};
programs.thefuck.enable = true;
programs.starship.enable = true;
programs.bash.shellInit = ''
eval "$(starship init bash)"
'';
programs.starship = {
enable = true;
settings = {
format = "$all$directory$character";
nodejs.disabled = true;
cmake.symbol = "cmake ";
custom.shell = {
command = "basename $SHELL";
when = "test -v SHELL";
format = " in [$output]($style)";
};
# env_var.SHELL = {variable = "SHELL"; default = ""; };
};
};
};
options.grimmShared.tooling = {
enable = mkEnableOption "grimm-tooling";
supportedLangs = mkOption {
type = types.listOf (types.enum [ ]);
default = [ ];
description = "Languages for which to enable support";
};
};
}

View file

@ -14,16 +14,6 @@ let
;
in
{
imports = [
./lilypond.nix
./nix.nix
./security.nix
./python.nix
./rust.nix
./nvim.nix
./lsp.nix
];
config = mkIf (enable && tooling.enable) {
environment.systemPackages = [
(pkgs.writeShellScriptBin "silent-add" "${getExe config.programs.git.package} add --intent-to-add $@ ; ${getExe config.programs.git.package} update-index --assume-unchanged $@")
@ -33,8 +23,6 @@ in
pkgs.delta
];
grimmShared.tooling.nvim.plugins = with pkgs.vimPlugins; [ fugitive ];
programs.git = {
enable = true;
lfs.enable = true;
@ -47,12 +35,14 @@ in
push.autoSetupRemote = true;
core.autocrlf = "input";
commit.gpgsign = true;
core.excludesfile = (pkgs.writeText ".gitignore" ''
.idea
.obsidian
*~
result
'');
core.excludesfile = (
pkgs.writeText ".gitignore" ''
.idea
.obsidian
*~
result
''
);
pull.rebase = false;
include.path = "${pkgs.delta.src}/themes.gitconfig";

73
common/tooling/helix.nix Normal file
View file

@ -0,0 +1,73 @@
{
pkgs,
config,
lib,
...
}:
let
inherit (config.grimmShared) enable tooling;
inherit (lib)
mkOption
types
getExe
mkIf
;
inherit (pkgs)
helix
symlinkJoin
writeTextDir
concatTextFile
makeWrapper
;
inherit (pkgs.writers) writeTOML;
conf-file-name = "config.toml";
lang-file-name = "languages.toml";
helix-conf = symlinkJoin {
name = "helix-conf";
paths = [
(concatTextFile {
name = "helix-conf-partial";
destination = "/${conf-file-name}";
files = [ (writeTOML conf-file-name config.programs.helix.config) ];
})
(writeTextDir lang-file-name ''
[[language]]
language-servers = ["nixd"]
name = "nix"
[language-server.nixd]
command = "${getExe pkgs.nixd}"
'')
];
};
helix-wrapped = pkgs.symlinkJoin {
name = helix.pname;
paths = [ helix ];
buildInputs = [ makeWrapper ];
postBuild = ''
wrapProgram $out/bin/${helix.meta.mainProgram} --add-flags "-c ${helix-conf}/${conf-file-name}"
'';
};
in
{
config = mkIf (enable && tooling.enable) {
environment.systemPackages = [ helix-wrapped ];
environment.sessionVariables.EDITOR = getExe helix;
programs.helix.config = {
theme = "catppuccin_mocha";
};
};
options.programs.helix = {
config = mkOption {
type = types.attrs;
default = { };
description = "Helix configuration";
};
};
}

View file

@ -25,7 +25,7 @@ in
grimmShared.tooling.lang_servers = [
{
lsp = {
package = pkgs.java-language-server;
package = pkgs.jdt-language-server;
};
fmt = {
package = pkgs.google-java-format;

View file

@ -11,7 +11,6 @@ let
types
mkIf
getName
mkEnableOption
getExe
filter
optionalString
@ -43,92 +42,72 @@ in
++ (map (v: v.fmt.package) (filter (v: !isNull v.fmt) tooling.lang_servers));
environment.shellAliases."treefmt" = "${getExe pkgs.treefmt} --config-file $(${getExe find_conf})";
grimmShared.tooling.nvim.extraLuaRC =
[ "vim.g.coq_settings = { auto_start = 'shut-up' }" ]
++ (map (
v:
"require'lspconfig'.${v.lsp.lspconf_mod_name}.setup(require('coq').lsp_ensure_capabilities(${v.lsp.lspconf_config}))"
) (filter (v: !isNull v.lsp && v.lsp.vimIntegration) tooling.lang_servers));
grimmShared.tooling.nvim.plugins = with pkgs.vimPlugins; [
nvim-lspconfig
coq_nvim
coq-artifacts
];
};
options.grimmShared.tooling.lang_servers = mkOption {
type = types.listOf (
types.submodule {
options = {
lsp = mkOption {
type = types.nullOr (
types.submodule (
{ config, ... }:
{
options = {
lspconf_mod_name = mkOption {
type = types.nullOr types.nonEmptyStr;
default = builtins.replaceStrings [ "-" ] [ "_" ] (getName config.package);
description = "lspconfig module name";
};
options.grimmShared.tooling = {
supportedLangs = mkOption {
type = types.listOf (types.enum [ ]);
default = [ ];
description = "Languages for which to enable support";
};
lang_servers = mkOption {
lspconf_config = mkOption {
type = types.nonEmptyStr;
default = "{}";
description = "options to pass to lspconfig";
type = types.listOf (
types.submodule {
options = {
lsp = mkOption {
type = types.nullOr (
types.submodule (
{ config, ... }:
{
options = {
package = mkOption {
type = types.package;
default = null;
description = "LSP package";
};
};
}
)
);
};
package = mkOption {
type = types.package;
default = null;
description = "LSP package";
};
fmt = mkOption {
default = null;
type = types.nullOr (
types.submodule (
{ config, ... }:
{
options = {
package = mkOption {
type = types.package;
description = "FMT package";
};
vimIntegration = mkEnableOption "Enable coq/nvim-lspconfig integration" // {
default = true;
options = mkOption {
type = types.listOf types.nonEmptyStr;
default = [ ];
};
includes = mkOption {
type = types.listOf types.nonEmptyStr;
default = [ ];
};
command = mkOption {
type = types.nonEmptyStr;
default = getExe config.package;
};
};
};
}
)
);
}
)
);
};
};
fmt = mkOption {
type = types.nullOr (
types.submodule (
{ config, ... }:
{
options = {
package = mkOption {
type = types.package;
description = "FMT package";
};
options = mkOption {
type = types.listOf types.nonEmptyStr;
default = [ ];
};
includes = mkOption {
type = types.listOf types.nonEmptyStr;
default = [ ];
};
command = mkOption {
type = types.nonEmptyStr;
default = getExe config.package;
};
};
}
)
);
};
};
}
);
default = { };
description = "Language servers available on the system";
}
);
default = { };
description = "Language servers available on the system";
};
};
}

View file

@ -17,13 +17,9 @@
environment.sessionVariables = lib.mkIf pkgs.config.allowUnfree { NIXPKGS_ALLOW_UNFREE = "1"; };
grimmShared.tooling.nvim = {
plugins = with pkgs.vimPlugins; [ vim-nix ];
};
grimmShared.tooling.lang_servers = [
{
lsp.package = pkgs.nixd;
lsp.package = pkgs.nil;
fmt = {
package = pkgs.nixpkgs-fmt;
includes = [ "*.nix" ];

View file

@ -1,95 +0,0 @@
{
pkgs,
config,
lib,
...
}:
let
inherit (config.grimmShared) enable tooling;
inherit (lib)
mkOption
types
getExe
mkIf
concatLines
;
in
{
config = mkIf (enable && tooling.enable) {
environment.systemPackages = with pkgs; [
dos2unix
neovim-remote
];
programs.git.config.core.editor = getExe pkgs.neovim;
grimmShared.tooling.nvim = {
plugins = with pkgs.vimPlugins; [ vim-monokai-pro ];
# extraLuaRC = [ "vim.lsp.inlay_hint.enable(true)" ];
};
programs.neovim = {
enable = true;
viAlias = true;
defaultEditor = true;
withPython3 = true;
configure = {
customRC =
let
luarc = pkgs.writeText "init.lua" (concatLines tooling.nvim.extraLuaRC);
in
''
set number
set hidden
set fileencodings=utf-8
set nocompatible
set clipboard+=unnamedplus
set ff=unix
set termguicolors
colorscheme monokai_pro
hi Normal guibg=NONE ctermbg=NONE
hi NonText guibg=NONE ctermbg=NONE
" Toggle transparent background
let t:is_transparent = 1
function! Toggle_transparent()
if t:is_transparent == 0
hi Normal guibg=NONE ctermbg=NONE
hi NonText guibg=NONE ctermbg=NONE
let t:is_transparent = 1
else
set background=dark
hi EndOfBuffer ctermfg=bg
let t:is_transparent = 0
endif
endfunction
nnoremap <F12> : call Toggle_transparent()<CR>
luafile ${luarc}
if filereadable($HOME . "/.vimrc")
source ~/.vimrc
endif
'';
packages.myVimPackage = {
start = tooling.nvim.plugins;
opt = [ ];
};
};
};
};
options.grimmShared.tooling.nvim = {
plugins = mkOption {
type = types.listOf types.package;
default = [ ];
description = "Extra vim plugins to include";
};
extraLuaRC = mkOption {
type = types.listOf types.nonEmptyStr;
default = [ ];
description = "Extra init LUA scripts";
};
};
}

View file

@ -36,9 +36,18 @@ in
programs.xonsh = {
enable = true;
config =
''
execx($(${getExe pkgs.starship} init xonsh))
''
(
let
cfg = config.programs.starship;
settingsFormat = pkgs.formats.toml { };
settingsFile = settingsFormat.generate "starship.toml" cfg.settings;
in
''
$STARSHIP_CONFIG="${settingsFile}"
$SHELL="${getExe config.programs.xonsh.package}"
execx($(${getExe pkgs.starship} init xonsh))
''
)
+ concatLines (
mapAttrsToList (
name: value: "aliases[\"${name}\"] = '''${value}'''"
@ -49,7 +58,7 @@ in
grimmShared.tooling.lang_servers = [
{
lsp.package = pkgs.pyright;
lsp.package = pkgs.python311Packages.python-lsp-server;
fmt = {
package = pkgs.yapf;
includes = [ "*.py" ];

View file

@ -25,13 +25,10 @@ in
]
++ optionals graphical [ jetbrains.clion ];
grimmShared.tooling.nvim.plugins = with pkgs.vimPlugins; [ rustaceanvim ];
grimmShared.tooling.lang_servers = [
{
lsp = {
package = pkgs.rust-analyzer;
vimIntegration = false;
};
fmt = {
package = pkgs.rustfmt;

View file

@ -21,7 +21,7 @@ in
group = "nextcloud";
mode = "0600";
};
nextcloud_server_key = {
nextcloud_server_key = {
file = ../secrets/nextcloud_server_key.age;
owner = "nextcloud";
group = "nextcloud";

View file

@ -12,7 +12,6 @@
grimmShared = {
tooling = {
pass = true;
lilypond = true;
};
gaming = true;
printing = true;