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

View file

@ -28,26 +28,18 @@ in
glibc glibc
clang clang
clang-tools clang-tools
cmake
] ]
++ optionals graphical [ ++ optionals graphical [
libva-utils libva-utils
jetbrains.clion jetbrains.clion
]; ];
environment.sessionVariables.CMAKE_EXPORT_COMPILE_COMMANDS = "1";
grimmShared.tooling.lang_servers = [ grimmShared.tooling.lang_servers = [
{ {
lsp = { lsp = {
package = pkgs.clang-tools; 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 { fmt = rec {
package = pkgs.clang-tools; 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 (config.grimmShared) enable tooling graphical;
inherit (lib) inherit (lib)
mkEnableOption mkEnableOption
mkOption
types
getExe getExe
optionals optionals
mkIf mkIf
@ -17,13 +15,13 @@ let
in in
{ {
imports = [ imports = [
./lilypond.nix # ./lilypond.nix
./nix.nix ./nix.nix
./security.nix ./security.nix
./python.nix ./python.nix
./rust.nix ./rust.nix
./nvim.nix
./lsp.nix ./lsp.nix
./helix.nix
./git.nix ./git.nix
./c.nix ./c.nix
./java.nix ./java.nix
@ -100,19 +98,23 @@ in
}; };
programs.thefuck.enable = true; programs.thefuck.enable = true;
programs.starship.enable = true; programs.starship = {
programs.bash.shellInit = '' enable = true;
eval "$(starship init bash)" 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 = { options.grimmShared.tooling = {
enable = mkEnableOption "grimm-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 in
{ {
imports = [
./lilypond.nix
./nix.nix
./security.nix
./python.nix
./rust.nix
./nvim.nix
./lsp.nix
];
config = mkIf (enable && tooling.enable) { config = mkIf (enable && tooling.enable) {
environment.systemPackages = [ environment.systemPackages = [
(pkgs.writeShellScriptBin "silent-add" "${getExe config.programs.git.package} add --intent-to-add $@ ; ${getExe config.programs.git.package} update-index --assume-unchanged $@") (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 pkgs.delta
]; ];
grimmShared.tooling.nvim.plugins = with pkgs.vimPlugins; [ fugitive ];
programs.git = { programs.git = {
enable = true; enable = true;
lfs.enable = true; lfs.enable = true;
@ -47,12 +35,14 @@ in
push.autoSetupRemote = true; push.autoSetupRemote = true;
core.autocrlf = "input"; core.autocrlf = "input";
commit.gpgsign = true; commit.gpgsign = true;
core.excludesfile = (pkgs.writeText ".gitignore" '' core.excludesfile = (
.idea pkgs.writeText ".gitignore" ''
.obsidian .idea
*~ .obsidian
result *~
''); result
''
);
pull.rebase = false; pull.rebase = false;
include.path = "${pkgs.delta.src}/themes.gitconfig"; 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 = [ grimmShared.tooling.lang_servers = [
{ {
lsp = { lsp = {
package = pkgs.java-language-server; package = pkgs.jdt-language-server;
}; };
fmt = { fmt = {
package = pkgs.google-java-format; package = pkgs.google-java-format;

View file

@ -11,7 +11,6 @@ let
types types
mkIf mkIf
getName getName
mkEnableOption
getExe getExe
filter filter
optionalString optionalString
@ -43,92 +42,72 @@ in
++ (map (v: v.fmt.package) (filter (v: !isNull v.fmt) tooling.lang_servers)); ++ (map (v: v.fmt.package) (filter (v: !isNull v.fmt) tooling.lang_servers));
environment.shellAliases."treefmt" = "${getExe pkgs.treefmt} --config-file $(${getExe find_conf})"; 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 { options.grimmShared.tooling = {
type = types.listOf ( supportedLangs = mkOption {
types.submodule { type = types.listOf (types.enum [ ]);
options = { default = [ ];
lsp = mkOption { description = "Languages for which to enable support";
type = types.nullOr ( };
types.submodule ( lang_servers = mkOption {
{ config, ... }:
{
options = {
lspconf_mod_name = mkOption {
type = types.nullOr types.nonEmptyStr;
default = builtins.replaceStrings [ "-" ] [ "_" ] (getName config.package);
description = "lspconfig module name";
};
lspconf_config = mkOption { type = types.listOf (
type = types.nonEmptyStr; types.submodule {
default = "{}"; options = {
description = "options to pass to lspconfig"; lsp = mkOption {
type = types.nullOr (
types.submodule (
{ config, ... }:
{
options = {
package = mkOption {
type = types.package;
default = null;
description = "LSP package";
};
}; };
}
)
);
};
package = mkOption { fmt = mkOption {
type = types.package; default = null;
default = null; type = types.nullOr (
description = "LSP package"; types.submodule (
}; { config, ... }:
{
options = {
package = mkOption {
type = types.package;
description = "FMT package";
};
vimIntegration = mkEnableOption "Enable coq/nvim-lspconfig integration" // { options = mkOption {
default = true; 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 ( default = { };
types.submodule ( description = "Language servers available on the system";
{ 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";
}; };
} }

View file

@ -17,13 +17,9 @@
environment.sessionVariables = lib.mkIf pkgs.config.allowUnfree { NIXPKGS_ALLOW_UNFREE = "1"; }; environment.sessionVariables = lib.mkIf pkgs.config.allowUnfree { NIXPKGS_ALLOW_UNFREE = "1"; };
grimmShared.tooling.nvim = {
plugins = with pkgs.vimPlugins; [ vim-nix ];
};
grimmShared.tooling.lang_servers = [ grimmShared.tooling.lang_servers = [
{ {
lsp.package = pkgs.nixd; lsp.package = pkgs.nil;
fmt = { fmt = {
package = pkgs.nixpkgs-fmt; package = pkgs.nixpkgs-fmt;
includes = [ "*.nix" ]; 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 = { programs.xonsh = {
enable = true; enable = true;
config = 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 ( + concatLines (
mapAttrsToList ( mapAttrsToList (
name: value: "aliases[\"${name}\"] = '''${value}'''" name: value: "aliases[\"${name}\"] = '''${value}'''"
@ -49,7 +58,7 @@ in
grimmShared.tooling.lang_servers = [ grimmShared.tooling.lang_servers = [
{ {
lsp.package = pkgs.pyright; lsp.package = pkgs.python311Packages.python-lsp-server;
fmt = { fmt = {
package = pkgs.yapf; package = pkgs.yapf;
includes = [ "*.py" ]; includes = [ "*.py" ];

View file

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

View file

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

View file

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