dotfiles/modules/common/neovim/default.nix

68 lines
2.0 KiB
Nix
Raw Normal View History

2022-11-30 03:40:15 +00:00
{ config, pkgs, lib, ... }:
2022-04-28 23:11:33 +00:00
2022-11-30 03:40:15 +00:00
let
2022-04-28 23:11:33 +00:00
2022-11-30 03:40:15 +00:00
neovim = import ./package {
inherit pkgs;
colors = config.theme.colors;
2023-11-06 01:40:18 +00:00
terraform = config.terraform.enable;
github = true;
kubernetes = config.kubernetes.enable;
2022-11-30 03:40:15 +00:00
};
2022-04-28 23:11:33 +00:00
2022-11-30 03:40:15 +00:00
in {
2022-12-21 21:18:03 +00:00
options.neovim.enable = lib.mkEnableOption "Neovim.";
2022-11-30 03:40:15 +00:00
2022-12-21 21:18:03 +00:00
config = lib.mkIf config.neovim.enable {
home-manager.users.${config.user} =
2022-11-30 03:40:15 +00:00
2022-12-21 21:18:03 +00:00
{
2022-11-30 03:40:15 +00:00
2022-12-21 21:18:03 +00:00
home.packages = [ neovim ];
2023-07-31 00:26:23 +00:00
# Use Neovim as the editor for git commit messages
2022-12-21 21:18:03 +00:00
programs.git.extraConfig.core.editor = "nvim";
2023-08-06 20:37:53 +00:00
programs.jujutsu.settings.ui.editor = "nvim";
2023-07-31 00:26:23 +00:00
# Set Neovim as the default app for text editing and manual pages
2022-12-21 21:18:03 +00:00
home.sessionVariables = {
EDITOR = "nvim";
MANPAGER = "nvim +Man!";
};
2023-07-31 00:26:23 +00:00
# Create quick aliases for launching Neovim
2022-12-21 21:18:03 +00:00
programs.fish = {
shellAliases = { vim = "nvim"; };
shellAbbrs = {
v = lib.mkForce "nvim";
vl = lib.mkForce "nvim -c 'normal! `0' -c 'bdelete 1'";
vll = "nvim -c 'Telescope oldfiles'";
};
2022-11-30 03:40:15 +00:00
};
2023-07-31 00:26:23 +00:00
# Set Neovim as the kitty terminal "scrollback" (vi mode) option.
# Requires removing some of the ANSI escape codes that are sent to the
# scrollback using sed and baleia, as well as removing several
# unnecessary features.
programs.kitty.settings.scrollback_pager =
"${neovim}/bin/nvim --headless +'KittyScrollbackGenerateKittens' +'set nonumber' +'set norelativenumber' +'%print' +'quit!' 2>&1";
2022-12-21 21:18:03 +00:00
2023-07-31 00:26:23 +00:00
# Create a desktop option for launching Neovim from a file manager
# (Requires launching the terminal and then executing Neovim)
xdg.desktopEntries.nvim = lib.mkIf pkgs.stdenv.isLinux {
2023-03-09 03:55:34 +00:00
name = "Neovim wrapper";
exec = "kitty nvim %F";
2023-07-31 00:26:23 +00:00
mimeType = [ "text/plain" "text/markdown" ];
2023-03-09 03:55:34 +00:00
};
xdg.mimeApps.defaultApplications = lib.mkIf pkgs.stdenv.isLinux {
"text/plain" = [ "nvim.desktop" ];
"text/markdown" = [ "nvim.desktop" ];
2023-03-09 03:55:34 +00:00
};
2022-11-30 03:40:15 +00:00
};
2022-12-21 21:18:03 +00:00
};
2022-04-29 01:56:21 +00:00
2022-04-28 23:11:33 +00:00
}