Files
nixpkgs/modules/home-manager/coding/editors.nix
T

241 lines
6.5 KiB
Nix
Raw Normal View History

2025-10-04 15:53:48 +02:00
{
config,
lib,
2026-03-28 10:08:36 +01:00
options,
2025-10-04 15:53:48 +02:00
pkgs,
...
}:
with lib; let
cfg = config.coding.editors;
2026-03-28 10:08:36 +01:00
# home-manager 26.05+ renamed extraLuaConfig → initLua.
# On stable 25.11 initLua does not exist; fall back to extraLuaConfig.
hasInitLua = options.programs.neovim ? initLua;
lazyVimConfig = ''
-- Bootstrap lazy.nvim
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
vim.fn.system({
"git",
"clone",
"--filter=blob:none",
"https://github.com/folke/lazy.nvim.git",
"--branch=stable",
lazypath,
})
end
vim.opt.rtp:prepend(lazypath)
-- Bootstrap LazyVim via lazy.nvim
-- Docs: https://github.com/folke/lazy.nvim and https://www.lazyvim.org/
require("lazy").setup({
spec = {
{ "LazyVim/LazyVim", import = "lazyvim.plugins" },
{ import = "lazyvim.plugins.extras.lang.typescript" },
{ import = "lazyvim.plugins.extras.lang.python" },
{ import = "lazyvim.plugins.extras.lang.go" },
{ import = "lazyvim.plugins.extras.lang.nix" },
{ import = "lazyvim.plugins.extras.lang.rust" },
{ import = "lazyvim.plugins.extras.lang.nushell" },
{ "Mofiqul/dracula.nvim" },
},
defaults = { lazy = false, version = false },
install = { colorscheme = { "dracula", "tokyonight", "habamax" } },
checker = { enabled = false },
performance = {
rtp = {
disabled_plugins = {
"gzip", "tarPlugin", "tohtml", "tutor", "zipPlugin",
},
},
},
})
vim.o.termguicolors = true
vim.cmd.colorscheme("dracula")
'';
2025-10-04 15:53:48 +02:00
in {
options.coding.editors = {
neovim = {
enable = mkEnableOption "neovim with LazyVim configuration";
};
zed = {
enable = mkEnableOption "zed editor with custom configuration";
};
};
config = mkMerge [
# Neovim configuration
2026-03-28 10:08:36 +01:00
(mkIf cfg.neovim.enable (mkMerge [
{
programs.neovim = {
enable = true;
defaultEditor = true;
viAlias = true;
vimAlias = true;
vimdiffAlias = true;
withNodeJs = true;
withPython3 = true;
};
}
# Use initLua on HM 26.05+ (unstable), extraLuaConfig on HM ≤ 25.11 (stable)
(
if hasInitLua
then {programs.neovim.initLua = lazyVimConfig;}
else {programs.neovim.extraLuaConfig = lazyVimConfig;}
)
]))
2025-10-04 15:53:48 +02:00
# Zed editor configuration
(mkIf cfg.zed.enable {
programs.zed-editor = {
enable = true;
userSettings = {
# CLI Behavior
cli_default_open_behavior = "existing_window";
2025-10-04 15:53:48 +02:00
# UI and Theme
theme = "Dracula";
ui_font_size = 16;
buffer_font_size = 16;
buffer_font_family = "FiraCode Nerd Font";
# Agent UI
agent_ui_font_size = 24.0;
2025-10-04 15:53:48 +02:00
# Editor Behavior
vim_mode = true;
auto_update = false;
format_on_save = "on";
load_direnv = "shell_hook";
# AI Features
features = {
copilot = false;
inline_prediction_provider = "zed";
2025-10-04 15:53:48 +02:00
};
edit_predictions = {
mode = "subtle";
provider = "zed";
2025-10-04 15:53:48 +02:00
};
show_edit_predictions = true;
agent_servers = {
"pi-acp" = {
type = "registry";
2025-10-04 15:53:48 +02:00
};
};
agent = {
dock = "right";
default_profile = "ask";
2025-10-04 15:53:48 +02:00
version = "2";
default_model = {
provider = "anthropic";
model = "claude-4";
};
};
# Language Models
language_models = {
anthropic = {
api_url = "https://api.anthropic.com";
};
openai = {
api_url = "https://api.openai.com/v1";
};
ollama = {
api_url = "http://localhost:11434";
};
};
# Languages Configuration
languages = {
Nix = {
language_servers = ["nixd"];
formatter = {
external = {
command = "alejandra";
arguments = [
"-q"
"-"
];
};
};
};
Python = {
language_servers = ["pyrefly"];
formatter = {
external = {
command = "black";
arguments = ["-"];
};
};
};
};
# LSP Configuration
lsp = {
rust-analyzer = {
initialization_options = {
check = {
command = "clippy";
};
};
};
rust_analyzer = {
binary = {
path_lookup = true;
};
};
2025-10-04 15:53:48 +02:00
pyrefly = {
binary = {
arguments = ["--lsp"];
};
};
};
# Panel Layout
project_panel = {
dock = "left";
};
outline_panel = {
dock = "left";
};
collaboration_panel = {
dock = "left";
};
git_panel = {
dock = "left";
2025-10-04 15:53:48 +02:00
};
# Privacy
telemetry = {
metrics = false;
};
};
};
})
# SSH Connections
(mkIf cfg.zed.enable {
programs.zed-editor.userSettings.ssh_connections = [
{
nickname = "m3-atlas";
host = "152.53.85.162";
args = ["-i" "~/.ssh/m3tam3re"];
}
{
nickname = "self-host-playbook";
host = "95.217.189.186";
port = 2222;
args = ["-i" "~/.ssh/self-host-playbook"];
projects = [
{
paths = ["/etc/nixos/current-systemconfig"];
}
];
}
{
nickname = "m3-daedalus";
host = "192.168.1.152";
port = 22;
args = ["-i" "~/.ssh/m3tam3re"];
projects = [
{
paths = ["/home/m3tam3re/home-config"];
}
];
}
];
})
2025-10-04 15:53:48 +02:00
# Common packages (always installed if either editor is enabled)
(mkIf (cfg.neovim.enable || cfg.zed.enable) {
home.packages = with pkgs; [zig];
})
];
}