mirror of
https://github.com/nmasur/dotfiles
synced 2025-07-05 12:40:13 +00:00
move nixos and darwin back into modules dir
This commit is contained in:
20
modules/common/applications/1password.nix
Normal file
20
modules/common/applications/1password.nix
Normal file
@ -0,0 +1,20 @@
|
||||
{ config, pkgs, lib, ... }: {
|
||||
|
||||
options = {
|
||||
_1password = {
|
||||
enable = lib.mkEnableOption {
|
||||
description = "Enable 1Password.";
|
||||
default = false;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkIf
|
||||
(config.gui.enable && config._1password.enable && pkgs.stdenv.isLinux) {
|
||||
unfreePackages = [ "1password" "_1password-gui" ];
|
||||
home-manager.users.${config.user} = {
|
||||
home.packages = with pkgs; [ _1password-gui ];
|
||||
};
|
||||
};
|
||||
|
||||
}
|
99
modules/common/applications/alacritty.nix
Normal file
99
modules/common/applications/alacritty.nix
Normal file
@ -0,0 +1,99 @@
|
||||
{ config, pkgs, lib, ... }: {
|
||||
|
||||
options = {
|
||||
alacritty = {
|
||||
enable = lib.mkEnableOption {
|
||||
description = "Enable Alacritty.";
|
||||
default = false;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkIf (config.gui.enable && config.alacritty.enable) {
|
||||
home-manager.users.${config.user} = {
|
||||
xsession.windowManager.i3.config.terminal = "alacritty";
|
||||
programs.rofi.terminal = "${pkgs.alacritty}/bin/alacritty";
|
||||
programs.alacritty = {
|
||||
enable = true;
|
||||
settings = {
|
||||
window = {
|
||||
dimensions = {
|
||||
columns = 85;
|
||||
lines = 30;
|
||||
};
|
||||
padding = {
|
||||
x = 20;
|
||||
y = 20;
|
||||
};
|
||||
opacity = 1.0;
|
||||
};
|
||||
scrolling.history = 10000;
|
||||
font = { size = 14.0; };
|
||||
key_bindings = [
|
||||
# Used for word completion in fish_user_key_bindings
|
||||
{
|
||||
key = "Return";
|
||||
mods = "Shift";
|
||||
chars = "\\x1F";
|
||||
}
|
||||
# Used for searching nixpkgs in fish_user_key_bindings
|
||||
{
|
||||
key = "N";
|
||||
mods = "Control|Shift";
|
||||
chars = "\\x11F";
|
||||
}
|
||||
{
|
||||
key = "H";
|
||||
mods = "Control|Shift";
|
||||
mode = "~Vi";
|
||||
action = "ToggleViMode";
|
||||
}
|
||||
{
|
||||
key = "Return";
|
||||
mode = "Vi";
|
||||
action = "ToggleViMode";
|
||||
}
|
||||
# Used to enable $ keybind in Vi mode
|
||||
{
|
||||
key = 5; # Scancode for key4
|
||||
mods = "Shift";
|
||||
mode = "Vi|~Search";
|
||||
action = "Last";
|
||||
}
|
||||
];
|
||||
colors = {
|
||||
primary = {
|
||||
background = config.theme.colors.base00;
|
||||
foreground = config.theme.colors.base05;
|
||||
};
|
||||
cursor = {
|
||||
text = "#1d2021";
|
||||
cursor = config.theme.colors.base05;
|
||||
};
|
||||
normal = {
|
||||
black = "#1d2021";
|
||||
red = config.theme.colors.base08;
|
||||
green = config.theme.colors.base0B;
|
||||
yellow = config.theme.colors.base0A;
|
||||
blue = config.theme.colors.base0D;
|
||||
magenta = config.theme.colors.base0E;
|
||||
cyan = config.theme.colors.base0C;
|
||||
white = config.theme.colors.base05;
|
||||
};
|
||||
bright = {
|
||||
black = config.theme.colors.base03;
|
||||
red = config.theme.colors.base09;
|
||||
green = config.theme.colors.base01;
|
||||
yellow = config.theme.colors.base02;
|
||||
blue = config.theme.colors.base04;
|
||||
magenta = config.theme.colors.base06;
|
||||
cyan = config.theme.colors.base0F;
|
||||
white = config.theme.colors.base07;
|
||||
};
|
||||
};
|
||||
draw_bold_text_with_bright_colors = false;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
15
modules/common/applications/default.nix
Normal file
15
modules/common/applications/default.nix
Normal file
@ -0,0 +1,15 @@
|
||||
{ ... }: {
|
||||
|
||||
imports = [
|
||||
./1password.nix
|
||||
./alacritty.nix
|
||||
./discord.nix
|
||||
./firefox.nix
|
||||
./kitty.nix
|
||||
./media.nix
|
||||
./obsidian.nix
|
||||
./qbittorrent.nix
|
||||
./nautilus.nix
|
||||
];
|
||||
|
||||
}
|
28
modules/common/applications/discord.nix
Normal file
28
modules/common/applications/discord.nix
Normal file
@ -0,0 +1,28 @@
|
||||
{ config, pkgs, lib, ... }: {
|
||||
|
||||
options = {
|
||||
discord = {
|
||||
enable = lib.mkEnableOption {
|
||||
description = "Enable Discord.";
|
||||
default = false;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkIf (config.gui.enable && config.discord.enable) {
|
||||
unfreePackages = [ "discord" ];
|
||||
home-manager.users.${config.user} = {
|
||||
home.packages = with pkgs; [ discord ];
|
||||
xdg.configFile."discord/settings.json".text = ''
|
||||
{
|
||||
"BACKGROUND_COLOR": "#202225",
|
||||
"IS_MAXIMIZED": false,
|
||||
"IS_MINIMIZED": false,
|
||||
"OPEN_ON_STARTUP": false,
|
||||
"MINIMIZE_TO_TRAY": false,
|
||||
"SKIP_HOST_UPDATE": true
|
||||
}
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
164
modules/common/applications/firefox.nix
Normal file
164
modules/common/applications/firefox.nix
Normal file
@ -0,0 +1,164 @@
|
||||
{ config, pkgs, lib, ... }:
|
||||
|
||||
{
|
||||
|
||||
options = {
|
||||
firefox = {
|
||||
enable = lib.mkEnableOption {
|
||||
description = "Enable Firefox.";
|
||||
default = false;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkIf (config.gui.enable && config.firefox.enable) {
|
||||
|
||||
unfreePackages = [
|
||||
(lib.mkIf config._1password.enable "onepassword-password-manager")
|
||||
"okta-browser-plugin"
|
||||
];
|
||||
|
||||
home-manager.users.${config.user} = {
|
||||
|
||||
programs.firefox = {
|
||||
enable = true;
|
||||
package =
|
||||
if pkgs.stdenv.isDarwin then pkgs.firefox-bin else pkgs.firefox;
|
||||
profiles.default = {
|
||||
id = 0;
|
||||
name = "default";
|
||||
isDefault = true;
|
||||
extensions = with pkgs.nur.repos.rycee.firefox-addons; [
|
||||
ublock-origin
|
||||
vimium
|
||||
multi-account-containers
|
||||
facebook-container
|
||||
temporary-containers
|
||||
(lib.mkIf config._1password.enable onepassword-password-manager)
|
||||
okta-browser-plugin
|
||||
sponsorblock
|
||||
reddit-enhancement-suite
|
||||
return-youtube-dislikes
|
||||
markdownload
|
||||
darkreader
|
||||
snowflake
|
||||
don-t-fuck-with-paste
|
||||
i-dont-care-about-cookies
|
||||
wappalyzer
|
||||
];
|
||||
settings = {
|
||||
"app.update.auto" = false;
|
||||
"browser.aboutConfig.showWarning" = false;
|
||||
"browser.warnOnQuit" = false;
|
||||
"browser.quitShortcut.disabled" =
|
||||
if pkgs.stdenv.isLinux then true else false;
|
||||
"browser.theme.dark-private-windows" = true;
|
||||
"browser.toolbars.bookmarks.visibility" = false;
|
||||
"browser.startup.page" = 3; # Restore previous session
|
||||
"browser.newtabpage.enabled" = false; # Make new tabs blank
|
||||
"trailhead.firstrun.didSeeAboutWelcome" =
|
||||
true; # Disable welcome splash
|
||||
"dom.forms.autocomplete.formautofill" = false; # Disable autofill
|
||||
"extensions.formautofill.creditCards.enabled" =
|
||||
false; # Disable credit cards
|
||||
"dom.payments.defaults.saveAddress" = false; # Disable address save
|
||||
"general.autoScroll" = true; # Drag middle-mouse to scroll
|
||||
"services.sync.prefs.sync.general.autoScroll" =
|
||||
false; # Prevent disabling autoscroll
|
||||
"extensions.pocket.enabled" = false;
|
||||
"toolkit.legacyUserProfileCustomizations.stylesheets" =
|
||||
true; # Allow userChrome.css
|
||||
"layout.css.color-mix.enabled" = true;
|
||||
"ui.systemUsesDarkTheme" =
|
||||
if config.theme.dark == true then 1 else 0;
|
||||
};
|
||||
userChrome = ''
|
||||
:root {
|
||||
--focus-outline-color: ${config.theme.colors.base04} !important;
|
||||
--toolbar-color: ${config.theme.colors.base07} !important;
|
||||
--tab-min-height: 30px !important;
|
||||
}
|
||||
/* Background of tab bar */
|
||||
.toolbar-items {
|
||||
background-color: ${config.theme.colors.base00} !important;
|
||||
}
|
||||
/* Extra tab bar sides on macOS */
|
||||
.titlebar-spacer {
|
||||
background-color: ${config.theme.colors.base00} !important;
|
||||
}
|
||||
.titlebar-buttonbox-container {
|
||||
background-color: ${config.theme.colors.base00} !important;
|
||||
}
|
||||
#tabbrowser-tabs {
|
||||
border-inline-start: 0 !important;
|
||||
}
|
||||
/* Private Browsing indicator on macOS */
|
||||
#private-browsing-indicator-with-label {
|
||||
background-color: ${config.theme.colors.base00} !important;
|
||||
margin-inline: 0 !important;
|
||||
padding-inline: 7px;
|
||||
}
|
||||
/* Tabs themselves */
|
||||
.tabbrowser-tab .tab-stack {
|
||||
border-radius: 5px 5px 0 0;
|
||||
overflow: hidden;
|
||||
background-color: ${config.theme.colors.base00};
|
||||
color: ${config.theme.colors.base06} !important;
|
||||
}
|
||||
.tab-content {
|
||||
border-bottom: 2px solid color-mix(in srgb, var(--identity-tab-color) 40%, transparent);
|
||||
border-radius: 5px 5px 0 0;
|
||||
background-color: ${config.theme.colors.base00};
|
||||
color: ${config.theme.colors.base06} !important;
|
||||
}
|
||||
.tab-content[selected=true] {
|
||||
border-bottom: 2px solid color-mix(in srgb, var(--identity-tab-color) 25%, transparent);
|
||||
background-color: ${config.theme.colors.base01} !important;
|
||||
color: ${config.theme.colors.base07} !important;
|
||||
}
|
||||
/* Below tab bar */
|
||||
#nav-bar {
|
||||
background: ${config.theme.colors.base01} !important;
|
||||
}
|
||||
/* URL bar in nav bar */
|
||||
#urlbar[focused=true] {
|
||||
color: ${config.theme.colors.base07} !important;
|
||||
background: ${config.theme.colors.base02} !important;
|
||||
caret-color: ${config.theme.colors.base05} !important;
|
||||
}
|
||||
#urlbar:not([focused=true]) {
|
||||
color: ${config.theme.colors.base04} !important;
|
||||
background: ${config.theme.colors.base02} !important;
|
||||
}
|
||||
#urlbar ::-moz-selection {
|
||||
color: ${config.theme.colors.base07} !important;
|
||||
background: ${config.theme.colors.base02} !important;
|
||||
}
|
||||
#urlbar-input-container {
|
||||
border: 1px solid ${config.theme.colors.base01} !important;
|
||||
}
|
||||
#urlbar-background {
|
||||
background: ${config.theme.colors.base01} !important;
|
||||
}
|
||||
/* Text in URL bar */
|
||||
#urlbar-input, #urlbar-scheme, .searchbar-textbox {
|
||||
color: ${config.theme.colors.base07} !important;
|
||||
}
|
||||
'';
|
||||
userContent = ''
|
||||
@-moz-document url-prefix(about:blank) {
|
||||
* {
|
||||
background-color:${config.theme.colors.base01} !important;
|
||||
}
|
||||
}
|
||||
'';
|
||||
|
||||
extraConfig = "";
|
||||
};
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
}
|
88
modules/common/applications/kitty.nix
Normal file
88
modules/common/applications/kitty.nix
Normal file
@ -0,0 +1,88 @@
|
||||
{ config, pkgs, lib, ... }: {
|
||||
|
||||
options = {
|
||||
kitty = {
|
||||
enable = lib.mkEnableOption {
|
||||
description = "Enable Kitty.";
|
||||
default = false;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkIf (config.gui.enable && config.kitty.enable) {
|
||||
home-manager.users.${config.user} = {
|
||||
# xsession.windowManager.i3.config.terminal = "kitty";
|
||||
# programs.rofi.terminal = "${pkgs.kitty}/bin/kitty";
|
||||
programs.kitty = {
|
||||
enable = true;
|
||||
environment = { };
|
||||
extraConfig = "";
|
||||
font.size = 14;
|
||||
keybindings = {
|
||||
"shift+enter" = "send_text all \\x1F";
|
||||
"super+f" = "toggle_fullscreen";
|
||||
};
|
||||
settings = {
|
||||
|
||||
# Colors (adapted from: https://github.com/kdrag0n/base16-kitty/blob/master/templates/default-256.mustache)
|
||||
background = config.theme.colors.base00;
|
||||
foreground = config.theme.colors.base05;
|
||||
selection_background = config.theme.colors.base05;
|
||||
selection_foreground = config.theme.colors.base00;
|
||||
url_color = config.theme.colors.base04;
|
||||
cursor = config.theme.colors.base05;
|
||||
active_border_color = config.theme.colors.base03;
|
||||
inactive_border_color = config.theme.colors.base01;
|
||||
active_tab_background = config.theme.colors.base00;
|
||||
active_tab_foreground = config.theme.colors.base05;
|
||||
inactive_tab_background = config.theme.colors.base01;
|
||||
inactive_tab_foreground = config.theme.colors.base04;
|
||||
tab_bar_background = config.theme.colors.base01;
|
||||
|
||||
# normal
|
||||
color0 = config.theme.colors.base00;
|
||||
color1 = config.theme.colors.base08;
|
||||
color2 = config.theme.colors.base0B;
|
||||
color3 = config.theme.colors.base0A;
|
||||
color4 = config.theme.colors.base0D;
|
||||
color5 = config.theme.colors.base0E;
|
||||
color6 = config.theme.colors.base0C;
|
||||
color7 = config.theme.colors.base05;
|
||||
|
||||
# bright
|
||||
color8 = config.theme.colors.base03;
|
||||
color9 = config.theme.colors.base08;
|
||||
color10 = config.theme.colors.base0B;
|
||||
color11 = config.theme.colors.base0A;
|
||||
color12 = config.theme.colors.base0D;
|
||||
color13 = config.theme.colors.base0E;
|
||||
color14 = config.theme.colors.base0C;
|
||||
color15 = config.theme.colors.base07;
|
||||
|
||||
# extended base16 colors
|
||||
color16 = config.theme.colors.base09;
|
||||
color17 = config.theme.colors.base0F;
|
||||
color18 = config.theme.colors.base01;
|
||||
color19 = config.theme.colors.base02;
|
||||
color20 = config.theme.colors.base04;
|
||||
color21 = config.theme.colors.base06;
|
||||
|
||||
# Scrollback
|
||||
scrolling_lines = 10000;
|
||||
scrollback_pager_history_size = 10; # MB
|
||||
scrollback_pager = ''
|
||||
${pkgs.neovim}/bin/nvim -c 'setlocal nonumber nolist showtabline=0 foldcolumn=0|Man!' -c "autocmd VimEnter * normal G" -'';
|
||||
|
||||
# Window
|
||||
window_padding_width = 6;
|
||||
|
||||
tab_bar_edge = "top";
|
||||
tab_bar_style = "slant";
|
||||
|
||||
# Audio
|
||||
enable_audio_bell = false;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
30
modules/common/applications/media.nix
Normal file
30
modules/common/applications/media.nix
Normal file
@ -0,0 +1,30 @@
|
||||
{ config, pkgs, lib, ... }: {
|
||||
|
||||
options = {
|
||||
media = {
|
||||
enable = lib.mkEnableOption {
|
||||
description = "Enable media programs.";
|
||||
default = false;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkIf (config.gui.enable && config.media.enable) {
|
||||
home-manager.users.${config.user} = {
|
||||
home.packages = with pkgs; [
|
||||
mpv # Video viewer
|
||||
sxiv # Image viewer
|
||||
mupdf # PDF viewer
|
||||
zathura # PDF viewer
|
||||
];
|
||||
|
||||
# Set default for opening PDFs
|
||||
xdg.mimeApps.defaultApplications."application/pdf" =
|
||||
[ "zathura.desktop" ];
|
||||
xdg.mimeApps.defaultApplications."image/*" = [ "sxiv.desktop" ];
|
||||
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
}
|
33
modules/common/applications/nautilus.nix
Normal file
33
modules/common/applications/nautilus.nix
Normal file
@ -0,0 +1,33 @@
|
||||
{ config, pkgs, lib, ... }: {
|
||||
|
||||
options = {
|
||||
nautilus = {
|
||||
enable = lib.mkEnableOption {
|
||||
description = "Enable Nautilus file manager.";
|
||||
default = false;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
# Install Nautilus file manager
|
||||
config = lib.mkIf (config.gui.enable && config.nautilus.enable) {
|
||||
home-manager.users.${config.user} = {
|
||||
home.packages = with pkgs; [
|
||||
gnome.nautilus
|
||||
gnome.sushi # Quick preview with spacebar
|
||||
];
|
||||
|
||||
# Set default for opening directories
|
||||
xdg.mimeApps.defaultApplications."inode/directory" =
|
||||
[ "nautilus.desktop" ];
|
||||
|
||||
programs.fish.functions = {
|
||||
qr = {
|
||||
body =
|
||||
"${pkgs.qrencode}/bin/qrencode $argv[1] -o /tmp/qr.png | ${pkgs.gnome.sushi}/bin/sushi /tmp/qr.png";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
}
|
19
modules/common/applications/obsidian.nix
Normal file
19
modules/common/applications/obsidian.nix
Normal file
@ -0,0 +1,19 @@
|
||||
{ config, pkgs, lib, ... }: {
|
||||
|
||||
options = {
|
||||
obsidian = {
|
||||
enable = lib.mkEnableOption {
|
||||
description = "Enable Obsidian.";
|
||||
default = false;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkIf (config.gui.enable && config.obsidian.enable) {
|
||||
unfreePackages = [ "obsidian" ];
|
||||
home-manager.users.${config.user} = {
|
||||
home.packages = with pkgs; [ obsidian ];
|
||||
};
|
||||
};
|
||||
|
||||
}
|
21
modules/common/applications/qbittorrent.nix
Normal file
21
modules/common/applications/qbittorrent.nix
Normal file
@ -0,0 +1,21 @@
|
||||
{ config, pkgs, lib, ... }: {
|
||||
|
||||
options = {
|
||||
qbittorrent = {
|
||||
enable = lib.mkEnableOption {
|
||||
description = "Enable qBittorrent.";
|
||||
default = false;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkIf (config.gui.enable && config.qbittorrent.enable) {
|
||||
|
||||
home-manager.users.${config.user} = {
|
||||
|
||||
home.packages = with pkgs; [ qbittorrent ];
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
}
|
107
modules/common/default.nix
Normal file
107
modules/common/default.nix
Normal file
@ -0,0 +1,107 @@
|
||||
{ config, lib, pkgs, ... }: {
|
||||
|
||||
imports =
|
||||
[ ./applications ./mail ./neovim ./programming ./repositories ./shell ];
|
||||
|
||||
options = {
|
||||
user = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
description = "Primary user of the system";
|
||||
};
|
||||
fullName = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
description = "Human readable name of the user";
|
||||
};
|
||||
userDirs = {
|
||||
# Required to prevent infinite recursion when referenced by himalaya
|
||||
download = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
description = "XDG directory for downloads";
|
||||
default =
|
||||
if pkgs.stdenv.isDarwin then "$HOME/Downloads" else "$HOME/downloads";
|
||||
};
|
||||
};
|
||||
identityFile = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
description = "Path to existing private key file.";
|
||||
default = "/etc/ssh/ssh_host_ed25519_key";
|
||||
};
|
||||
gui = {
|
||||
enable = lib.mkEnableOption {
|
||||
description = "Enable graphics.";
|
||||
default = false;
|
||||
};
|
||||
};
|
||||
theme = {
|
||||
colors = lib.mkOption {
|
||||
type = lib.types.attrs;
|
||||
description = "Base16 color scheme.";
|
||||
default = (import ../colorscheme/gruvbox).dark;
|
||||
};
|
||||
dark = lib.mkOption {
|
||||
type = lib.types.bool;
|
||||
description = "Enable dark mode.";
|
||||
default = true;
|
||||
};
|
||||
};
|
||||
|
||||
# colorscheme = lib.mkOption {
|
||||
# type = types.attrs;
|
||||
# description = "Base16 color scheme";
|
||||
# };
|
||||
homePath = lib.mkOption {
|
||||
type = lib.types.path;
|
||||
description = "Path of user's home directory.";
|
||||
default = builtins.toPath (if pkgs.stdenv.isDarwin then
|
||||
"/Users/${config.user}"
|
||||
else
|
||||
"/home/${config.user}");
|
||||
};
|
||||
|
||||
dotfilesPath = lib.mkOption {
|
||||
type = lib.types.path;
|
||||
description = "Path of dotfiles repository.";
|
||||
default = config.homePath + "/dev/personal/dotfiles";
|
||||
};
|
||||
dotfilesRepo = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
description = "Link to dotfiles repository.";
|
||||
};
|
||||
unfreePackages = lib.mkOption {
|
||||
type = lib.types.listOf lib.types.str;
|
||||
description = "List of unfree packages to allow.";
|
||||
default = [ ];
|
||||
};
|
||||
};
|
||||
|
||||
config = let stateVersion = "23.05";
|
||||
in {
|
||||
|
||||
# Enable features in Nix commands
|
||||
nix.extraOptions = ''
|
||||
experimental-features = nix-command flakes
|
||||
warn-dirty = false
|
||||
'';
|
||||
|
||||
# Basic common system packages for all devices
|
||||
environment.systemPackages = with pkgs; [ git vim wget curl ];
|
||||
|
||||
# Use the system-level nixpkgs instead of Home Manager's
|
||||
home-manager.useGlobalPkgs = true;
|
||||
|
||||
# Install packages to /etc/profiles instead of ~/.nix-profile, useful when
|
||||
# using multiple profiles for one user
|
||||
home-manager.useUserPackages = true;
|
||||
|
||||
# Allow specified unfree packages (identified elsewhere)
|
||||
# Retrieves package object based on string name
|
||||
nixpkgs.config.allowUnfreePredicate = pkg:
|
||||
builtins.elem (lib.getName pkg) config.unfreePackages;
|
||||
|
||||
# Pin a state version to prevent warnings
|
||||
home-manager.users.${config.user}.home.stateVersion = stateVersion;
|
||||
home-manager.users.root.home.stateVersion = stateVersion;
|
||||
|
||||
};
|
||||
|
||||
}
|
189
modules/common/mail/aerc.nix
Normal file
189
modules/common/mail/aerc.nix
Normal file
@ -0,0 +1,189 @@
|
||||
{ config, pkgs, lib, ... }: {
|
||||
|
||||
options.mail.aerc.enable = lib.mkEnableOption "Aerc email.";
|
||||
|
||||
config = lib.mkIf config.mail.aerc.enable {
|
||||
|
||||
home-manager.users.${config.user} = {
|
||||
|
||||
home.packages = with pkgs; [
|
||||
w3m # Render HTML
|
||||
dante # Socksify for rendering HTML
|
||||
];
|
||||
|
||||
programs.aerc = {
|
||||
enable = true;
|
||||
extraBinds = {
|
||||
# Binds are of the form <key sequence> = <command to run>
|
||||
# To use '=' in a key sequence, substitute it with "Eq": "<Ctrl+Eq>"
|
||||
# If you wish to bind #, you can wrap the key sequence in quotes: "#" = quit
|
||||
global = {
|
||||
"<C-p>" = ":prev-tab<Enter>";
|
||||
"<C-n>" = ":next-tab <Enter>";
|
||||
"<C-t>" = ":term<Enter>";
|
||||
"?" = ":help keys<Enter>";
|
||||
};
|
||||
|
||||
messages = {
|
||||
q = ":quit<Enter>";
|
||||
|
||||
j = ":next <Enter>";
|
||||
"<Down>" = ":next<Enter>";
|
||||
"<C-d>" = ":next 50%<Enter>";
|
||||
"<C-f>" = ":next 100%<Enter>";
|
||||
"<PgDn>" = ":next 100%<Enter>";
|
||||
|
||||
k = ":prev <Enter>";
|
||||
"<Up>" = ":prev<Enter>";
|
||||
"<C-u>" = ":prev 50%<Enter>";
|
||||
"<C-b>" = ":prev 100%<Enter>";
|
||||
"<PgUp>" = ":prev 100%<Enter>";
|
||||
g = ":select 0 <Enter>";
|
||||
G = ":select -1<Enter>";
|
||||
|
||||
J = ":next-folder <Enter>";
|
||||
K = ":prev-folder<Enter>";
|
||||
H = ":collapse-folder<Enter>";
|
||||
L = ":expand-folder<Enter>";
|
||||
|
||||
v = ":mark -t<Enter>";
|
||||
V = ":mark -v<Enter>";
|
||||
|
||||
T = ":toggle-threads<Enter>";
|
||||
|
||||
"<Enter>" = ":view<Enter>";
|
||||
d = ":prompt 'Really delete this message?' 'delete-message'<Enter>";
|
||||
D = ":move Trash<Enter>";
|
||||
A = ":archive flat<Enter>";
|
||||
|
||||
C = ":compose<Enter>";
|
||||
|
||||
rr = ":reply -a<Enter>";
|
||||
rq = ":reply -aq<Enter>";
|
||||
Rr = ":reply<Enter>";
|
||||
Rq = ":reply -q<Enter>";
|
||||
|
||||
c = ":cf<space>";
|
||||
"$" = ":term<space>";
|
||||
"!" = ":term<space>";
|
||||
"|" = ":pipe<space>";
|
||||
|
||||
"/" = ":search<space>";
|
||||
"\\" = ":filter <space>";
|
||||
n = ":next-result<Enter>";
|
||||
N = ":prev-result<Enter>";
|
||||
"<Esc>" = ":clear<Enter>";
|
||||
};
|
||||
|
||||
"messages:folder=Drafts" = { "<Enter>" = ":recall<Enter>"; };
|
||||
|
||||
view = {
|
||||
"/" = ":toggle-key-passthrough <Enter> /";
|
||||
q = ":close<Enter>";
|
||||
O = ":open<Enter>";
|
||||
S = ":save<space>";
|
||||
"|" = ":pipe<space>";
|
||||
D = ":move Trash<Enter>";
|
||||
A = ":archive flat<Enter>";
|
||||
|
||||
"<C-l>" = ":open-link <space>";
|
||||
|
||||
f = ":forward <Enter>";
|
||||
rr = ":reply -a<Enter>";
|
||||
rq = ":reply -aq<Enter>";
|
||||
Rr = ":reply<Enter>";
|
||||
Rq = ":reply -q<Enter>";
|
||||
|
||||
H = ":toggle-headers<Enter>";
|
||||
"<C-k>" = ":prev-part<Enter>";
|
||||
"<C-j>" = ":next-part<Enter>";
|
||||
J = ":next <Enter>";
|
||||
K = ":prev<Enter>";
|
||||
};
|
||||
|
||||
"view::passthrough" = {
|
||||
"$noinherit" = "true";
|
||||
"$ex" = "<C-x>";
|
||||
"<Esc>" = ":toggle-key-passthrough<Enter>";
|
||||
};
|
||||
|
||||
compose = {
|
||||
# Keybindings used when the embedded terminal is not selected in the compose
|
||||
# view
|
||||
"$noinherit" = "true";
|
||||
"$ex" = "<C-x>";
|
||||
"<C-k>" = ":prev-field<Enter>";
|
||||
"<C-j>" = ":next-field<Enter>";
|
||||
"<A-p>" = ":switch-account -p<Enter>";
|
||||
"<A-n>" = ":switch-account -n<Enter>";
|
||||
"<tab>" = ":next-field<Enter>";
|
||||
"<C-p>" = ":prev-tab<Enter>";
|
||||
"<C-n>" = ":next-tab<Enter>";
|
||||
};
|
||||
|
||||
"compose::editor" = {
|
||||
# Keybindings used when the embedded terminal is selected in the compose view
|
||||
"$noinherit" = "true";
|
||||
"$ex" = "<C-x>";
|
||||
"<C-k>" = ":prev-field<Enter>";
|
||||
"<C-j>" = ":next-field<Enter>";
|
||||
"<C-p>" = ":prev-tab<Enter>";
|
||||
"<C-n>" = ":next-tab<Enter>";
|
||||
};
|
||||
|
||||
"compose::review" = {
|
||||
# Keybindings used when reviewing a message to be sent
|
||||
y = ":send <Enter>";
|
||||
n = ":abort<Enter>";
|
||||
p = ":postpone<Enter>";
|
||||
q = ":choose -o d discard abort -o p postpone postpone<Enter>";
|
||||
e = ":edit<Enter>";
|
||||
a = ":attach<space>";
|
||||
d = ":detach<space>";
|
||||
};
|
||||
|
||||
terminal = {
|
||||
"$noinherit" = "true";
|
||||
"$ex" = "<C-x>";
|
||||
"<C-p>" = ":prev-tab<Enter>";
|
||||
"<C-n>" = ":next-tab<Enter>";
|
||||
};
|
||||
|
||||
};
|
||||
extraConfig = {
|
||||
general.unsafe-accounts-conf = true;
|
||||
viewer = { pager = "${pkgs.less}/bin/less -R"; };
|
||||
filters = {
|
||||
"text/plain" =
|
||||
"${pkgs.gawk}/bin/awk -f ${pkgs.aerc}/share/aerc/filters/colorize";
|
||||
"text/calendar" =
|
||||
"${pkgs.gawk}/bin/awk -f ${pkgs.aerc}/share/aerc/filters/calendar";
|
||||
"text/html" =
|
||||
"${pkgs.aerc}/share/aerc/filters/html"; # Requires w3m, dante
|
||||
# "text/html" =
|
||||
# "${pkgs.aerc}/share/aerc/filters/html | ${pkgs.aerc}/share/aerc/filters/colorize";
|
||||
# "text/*" =
|
||||
# ''${pkgs.bat}/bin/bat -fP --file-name="$AERC_FILENAME "'';
|
||||
"message/delivery-status" =
|
||||
"${pkgs.gawk}/bin/awk -f ${pkgs.aerc}/share/aerc/filters/colorize";
|
||||
"message/rfc822" =
|
||||
"${pkgs.gawk}/bin/awk -f ${pkgs.aerc}/share/aerc/filters/colorize";
|
||||
"application/x-sh" = "${pkgs.bat}/bin/bat -fP -l sh";
|
||||
"application/pdf" = "${pkgs.zathura}/bin/zathura -";
|
||||
};
|
||||
};
|
||||
};
|
||||
accounts.email.accounts.home.aerc = {
|
||||
enable = true;
|
||||
extraAccounts = {
|
||||
check-mail = "5m";
|
||||
check-mail-cmd = "${pkgs.isync}/bin/mbsync -a";
|
||||
};
|
||||
};
|
||||
|
||||
programs.fish.shellAbbrs = { ae = "aerc"; };
|
||||
|
||||
};
|
||||
|
||||
};
|
||||
}
|
84
modules/common/mail/default.nix
Normal file
84
modules/common/mail/default.nix
Normal file
@ -0,0 +1,84 @@
|
||||
{ config, pkgs, lib, ... }: {
|
||||
|
||||
imports = [ ./himalaya.nix ./aerc.nix ];
|
||||
|
||||
options = {
|
||||
mail.enable = lib.mkEnableOption "Mail service.";
|
||||
mail.user = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
description = "User name for the email address.";
|
||||
default = config.user;
|
||||
};
|
||||
mail.server = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
description = "Server name for the email address.";
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkIf config.mail.enable {
|
||||
|
||||
home-manager.users.${config.user} = {
|
||||
programs.mbsync = { enable = true; };
|
||||
services.mbsync = lib.mkIf pkgs.stdenv.isLinux {
|
||||
enable = true;
|
||||
frequency = "*:0/5";
|
||||
};
|
||||
accounts.email = {
|
||||
maildirBasePath = "${config.homePath}/mail";
|
||||
accounts = {
|
||||
home = let address = "${config.mail.user}@${config.mail.server}";
|
||||
in {
|
||||
userName = address;
|
||||
realName = config.fullName;
|
||||
primary = true;
|
||||
inherit address;
|
||||
aliases = map (user: "${user}@${config.mail.server}") [
|
||||
"me"
|
||||
"hey"
|
||||
"admin"
|
||||
];
|
||||
alot = { };
|
||||
flavor = "plain";
|
||||
folders = { };
|
||||
getmail = { };
|
||||
imap = {
|
||||
host = "imap.purelymail.com";
|
||||
port = 993;
|
||||
tls.enable = true;
|
||||
};
|
||||
imapnotify = {
|
||||
enable = false;
|
||||
boxes = [ ];
|
||||
onNotify = "";
|
||||
onNotifyPost = "";
|
||||
};
|
||||
maildir = { path = "main"; };
|
||||
mbsync = {
|
||||
enable = true;
|
||||
create = "maildir";
|
||||
expunge = "none";
|
||||
remove = "none";
|
||||
patterns = [ "*" ];
|
||||
extraConfig.channel = {
|
||||
CopyArrivalDate = "yes"; # Sync time of original message
|
||||
};
|
||||
};
|
||||
mu.enable = false;
|
||||
notmuch.enable = false;
|
||||
passwordCommand =
|
||||
"${pkgs.age}/bin/age --decrypt --identity ${config.identityFile} ${
|
||||
builtins.toString ../../private/mailpass.age
|
||||
}";
|
||||
smtp = {
|
||||
host = "smtp.purelymail.com";
|
||||
port = 465;
|
||||
tls.enable = true;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
};
|
||||
}
|
25
modules/common/mail/himalaya.nix
Normal file
25
modules/common/mail/himalaya.nix
Normal file
@ -0,0 +1,25 @@
|
||||
{ config, lib, ... }: {
|
||||
|
||||
options.mail.himalaya.enable = lib.mkEnableOption "Himalaya email.";
|
||||
|
||||
config = lib.mkIf config.mail.himalaya.enable {
|
||||
|
||||
home-manager.users.${config.user} = {
|
||||
|
||||
programs.himalaya = { enable = true; };
|
||||
accounts.email.accounts.home.himalaya = {
|
||||
enable = true;
|
||||
backend = "imap";
|
||||
sender = "smtp";
|
||||
settings = {
|
||||
downloads-dir = config.userDirs.download;
|
||||
smtp-insecure = true;
|
||||
};
|
||||
};
|
||||
|
||||
programs.fish.shellAbbrs = { hi = "himalaya"; };
|
||||
|
||||
};
|
||||
|
||||
};
|
||||
}
|
22
modules/common/neovim/config/bufferline.nix
Normal file
22
modules/common/neovim/config/bufferline.nix
Normal file
@ -0,0 +1,22 @@
|
||||
{ pkgs, ... }: {
|
||||
plugins = [
|
||||
pkgs.vimPlugins.bufferline-nvim
|
||||
pkgs.vimPlugins.vim-bbye # Better closing of buffers
|
||||
];
|
||||
setup.bufferline = {
|
||||
options = {
|
||||
diagnostics = "nvim_lsp";
|
||||
always_show_bufferline = false;
|
||||
separator_style = "slant";
|
||||
offsets = [{ filetype = "NvimTree"; }];
|
||||
};
|
||||
};
|
||||
lua = ''
|
||||
-- Move buffers
|
||||
vim.keymap.set("n", "L", ":BufferLineCycleNext<CR>", { silent = true })
|
||||
vim.keymap.set("n", "H", ":BufferLineCyclePrev<CR>", { silent = true })
|
||||
|
||||
-- Kill buffer
|
||||
vim.keymap.set("n", "<Leader>x", " :Bdelete<CR>", { silent = true })
|
||||
'';
|
||||
}
|
155
modules/common/neovim/config/completion.nix
Normal file
155
modules/common/neovim/config/completion.nix
Normal file
@ -0,0 +1,155 @@
|
||||
{ pkgs, dsl, ... }: {
|
||||
|
||||
plugins = [
|
||||
pkgs.vimPlugins.cmp-nvim-lsp
|
||||
pkgs.vimPlugins.cmp-buffer
|
||||
pkgs.vimPlugins.cmp-path
|
||||
pkgs.vimPlugins.cmp-cmdline
|
||||
pkgs.vimPlugins.cmp-nvim-lua
|
||||
pkgs.vimPlugins.luasnip
|
||||
pkgs.vimPlugins.cmp_luasnip
|
||||
pkgs.vimPlugins.cmp-rg
|
||||
pkgs.vimPlugins.friendly-snippets
|
||||
];
|
||||
|
||||
use.cmp.setup = dsl.callWith {
|
||||
|
||||
# Disable in telescope buffers
|
||||
enabled = dsl.rawLua ''
|
||||
function()
|
||||
if vim.bo.buftype == "prompt" then
|
||||
return false
|
||||
end
|
||||
return true
|
||||
end
|
||||
'';
|
||||
|
||||
snippet.expand = dsl.rawLua ''
|
||||
function(args)
|
||||
require("luasnip").lsp_expand(args.body)
|
||||
end
|
||||
'';
|
||||
|
||||
mapping = {
|
||||
"['<C-n>']" = dsl.rawLua
|
||||
"require('cmp').mapping.select_next_item({ behavior = require('cmp').SelectBehavior.Insert })";
|
||||
"['<C-p>']" = dsl.rawLua
|
||||
"require('cmp').mapping.select_prev_item({ behavior = require('cmp').SelectBehavior.Insert })";
|
||||
"['<Down>']" = dsl.rawLua
|
||||
"require('cmp').mapping.select_next_item({ behavior = require('cmp').SelectBehavior.Select })";
|
||||
"['<Up>']" = dsl.rawLua
|
||||
"require('cmp').mapping.select_prev_item({ behavior = require('cmp').SelectBehavior.Select })";
|
||||
"['<C-d>']" = dsl.rawLua "require('cmp').mapping.scroll_docs(-4)";
|
||||
"['<C-f>']" = dsl.rawLua "require('cmp').mapping.scroll_docs(4)";
|
||||
"['<C-e>']" = dsl.rawLua "require('cmp').mapping.abort()";
|
||||
"['<CR>']" = dsl.rawLua
|
||||
"require('cmp').mapping.confirm({ behavior = require('cmp').ConfirmBehavior.Replace, select = true, })";
|
||||
"['<C-r>']" = dsl.rawLua
|
||||
"require('cmp').mapping.confirm({ behavior = require('cmp').ConfirmBehavior.Replace, select = true, })";
|
||||
"['<Esc>']" = dsl.rawLua ''
|
||||
function(_)
|
||||
cmp.mapping({
|
||||
i = cmp.mapping.abort(),
|
||||
c = cmp.mapping.close(),
|
||||
})
|
||||
vim.cmd("stopinsert") --- Abort and leave insert mode
|
||||
end
|
||||
'';
|
||||
"['<C-l>']" = dsl.rawLua ''
|
||||
cmp.mapping(function(_)
|
||||
if require("luasnip").expand_or_jumpable() then
|
||||
require("luasnip").expand_or_jump()
|
||||
end
|
||||
end, { "i", "s" })
|
||||
'';
|
||||
};
|
||||
|
||||
sources = [
|
||||
{ name = "nvim_lua"; }
|
||||
{ name = "nvim_lsp"; }
|
||||
{ name = "luasnip"; }
|
||||
{ name = "path"; }
|
||||
{
|
||||
name = "buffer";
|
||||
keyword_length = 3;
|
||||
max_item_count = 10;
|
||||
}
|
||||
{
|
||||
name = "rg";
|
||||
keyword_length = 6;
|
||||
max_item_count = 10;
|
||||
option = { additional_arguments = "--ignore-case"; };
|
||||
}
|
||||
];
|
||||
|
||||
formatting = {
|
||||
fields = [ "kind" "abbr" "menu" ];
|
||||
format = dsl.rawLua ''
|
||||
function(entry, vim_item)
|
||||
local kind_icons = {
|
||||
Text = "",
|
||||
Method = "m",
|
||||
Function = "",
|
||||
Constructor = "",
|
||||
Field = "",
|
||||
Variable = "",
|
||||
Class = "",
|
||||
Interface = "",
|
||||
Module = "",
|
||||
Property = "",
|
||||
Unit = "",
|
||||
Value = "",
|
||||
Enum = "",
|
||||
Keyword = "",
|
||||
Snippet = "",
|
||||
Color = "",
|
||||
File = "",
|
||||
Reference = "",
|
||||
Folder = "",
|
||||
EnumMember = "",
|
||||
Constant = "",
|
||||
Struct = "",
|
||||
Event = "",
|
||||
Operator = "",
|
||||
TypeParameter = "",
|
||||
}
|
||||
vim_item.kind = string.format("%s", kind_icons[vim_item.kind])
|
||||
vim_item.menu = ({
|
||||
luasnip = "[Snippet]",
|
||||
buffer = "[Buffer]",
|
||||
path = "[Path]",
|
||||
rg = "[Grep]",
|
||||
nvim_lsp = "[LSP]",
|
||||
nvim_lua = "[Lua]",
|
||||
})[entry.source.name]
|
||||
return vim_item
|
||||
end
|
||||
'';
|
||||
};
|
||||
|
||||
experimental = {
|
||||
native_menu = false; # Use cmp menu instead of Vim menu
|
||||
ghost_text = true; # Show preview auto-completion
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
lua = ''
|
||||
-- Use buffer source for `/`
|
||||
require('cmp').setup.cmdline("/", {
|
||||
sources = {
|
||||
{ name = "buffer", keyword_length = 5 },
|
||||
},
|
||||
})
|
||||
|
||||
-- Use cmdline & path source for ':'
|
||||
require('cmp').setup.cmdline(":", {
|
||||
sources = require('cmp').config.sources({
|
||||
{ name = "path" },
|
||||
}, {
|
||||
{ name = "cmdline" },
|
||||
}),
|
||||
})
|
||||
'';
|
||||
|
||||
}
|
35
modules/common/neovim/config/gitsigns.lua
Normal file
35
modules/common/neovim/config/gitsigns.lua
Normal file
@ -0,0 +1,35 @@
|
||||
vim.keymap.set("", "<Space>", "<Nop>", { silent = true })
|
||||
vim.g.mapleader = " "
|
||||
vim.g.maplocalleader = " "
|
||||
|
||||
local gitsigns = require("gitsigns")
|
||||
vim.keymap.set("n", "<Leader>gB", gitsigns.blame_line)
|
||||
vim.keymap.set("n", "<Leader>gp", gitsigns.preview_hunk)
|
||||
vim.keymap.set("v", "<Leader>gp", gitsigns.preview_hunk)
|
||||
vim.keymap.set("n", "<Leader>gd", gitsigns.diffthis)
|
||||
vim.keymap.set("v", "<Leader>gd", gitsigns.diffthis)
|
||||
vim.keymap.set("n", "<Leader>rgf", gitsigns.reset_buffer)
|
||||
vim.keymap.set("v", "<Leader>hs", gitsigns.stage_hunk)
|
||||
vim.keymap.set("n", "<Leader>hr", gitsigns.reset_hunk)
|
||||
vim.keymap.set("v", "<Leader>hr", gitsigns.reset_hunk)
|
||||
|
||||
-- Navigation
|
||||
vim.keymap.set("n", "]g", function()
|
||||
if vim.wo.diff then
|
||||
return "]g"
|
||||
end
|
||||
vim.schedule(function()
|
||||
gitsigns.next_hunk()
|
||||
end)
|
||||
return "<Ignore>"
|
||||
end, { expr = true })
|
||||
|
||||
vim.keymap.set("n", "[g", function()
|
||||
if vim.wo.diff then
|
||||
return "[g"
|
||||
end
|
||||
vim.schedule(function()
|
||||
gitsigns.prev_hunk()
|
||||
end)
|
||||
return "<Ignore>"
|
||||
end, { expr = true })
|
5
modules/common/neovim/config/gitsigns.nix
Normal file
5
modules/common/neovim/config/gitsigns.nix
Normal file
@ -0,0 +1,5 @@
|
||||
{ pkgs, ... }: {
|
||||
plugins = [ pkgs.vimPlugins.gitsigns-nvim ];
|
||||
setup.gitsigns = { };
|
||||
lua = builtins.readFile ./gitsigns.lua;
|
||||
}
|
10
modules/common/neovim/config/lsp.lua
Normal file
10
modules/common/neovim/config/lsp.lua
Normal file
@ -0,0 +1,10 @@
|
||||
vim.keymap.set("n", "gd", vim.lsp.buf.definition)
|
||||
vim.keymap.set("n", "gT", vim.lsp.buf.type_definition)
|
||||
vim.keymap.set("n", "gi", vim.lsp.buf.implementation)
|
||||
vim.keymap.set("n", "gh", vim.lsp.buf.hover)
|
||||
-- vim.keymap.set("n", "gr", telescope.lsp_references)
|
||||
vim.keymap.set("n", "<Leader>R", vim.lsp.buf.rename)
|
||||
vim.keymap.set("n", "]e", vim.diagnostic.goto_next)
|
||||
vim.keymap.set("n", "[e", vim.diagnostic.goto_prev)
|
||||
vim.keymap.set("n", "<Leader>de", vim.diagnostic.open_float)
|
||||
vim.keymap.set("n", "<Leader>E", vim.lsp.buf.code_action)
|
66
modules/common/neovim/config/lsp.nix
Normal file
66
modules/common/neovim/config/lsp.nix
Normal file
@ -0,0 +1,66 @@
|
||||
{ pkgs, dsl, ... }: {
|
||||
|
||||
plugins = [
|
||||
pkgs.vimPlugins.nvim-lspconfig
|
||||
pkgs.vimPlugins.lsp-colors-nvim
|
||||
pkgs.vimPlugins.null-ls-nvim
|
||||
];
|
||||
|
||||
use.lspconfig.sumneko_lua.setup = dsl.callWith {
|
||||
settings = { Lua = { diagnostics = { globals = [ "vim" "hs" ]; }; }; };
|
||||
capabilities = dsl.rawLua "require('cmp_nvim_lsp').default_capabilities()";
|
||||
cmd = [ "${pkgs.sumneko-lua-language-server}/bin/lua-language-server" ];
|
||||
};
|
||||
|
||||
use.lspconfig.nil_ls.setup = dsl.callWith {
|
||||
cmd = [ "${pkgs.nil}/bin/nil" ];
|
||||
capabilities = dsl.rawLua "require('cmp_nvim_lsp').default_capabilities()";
|
||||
};
|
||||
|
||||
use.lspconfig.pyright.setup = dsl.callWith {
|
||||
cmd = [ "${pkgs.pyright}/bin/pyright-langserver" "--stdio" ];
|
||||
};
|
||||
|
||||
use.lspconfig.terraformls.setup =
|
||||
dsl.callWith { cmd = [ "${pkgs.terraform-ls}/bin/terraform-ls" "serve" ]; };
|
||||
|
||||
vim.api.nvim_create_augroup = dsl.callWith [ "LspFormatting" { } ];
|
||||
|
||||
lua = ''
|
||||
${builtins.readFile ./lsp.lua}
|
||||
|
||||
require("null-ls").setup({
|
||||
sources = {
|
||||
require("null-ls").builtins.formatting.stylua.with({ command = "${pkgs.stylua}/bin/stylua" }),
|
||||
require("null-ls").builtins.formatting.black.with({ command = "${pkgs.black}/bin/black" }),
|
||||
require("null-ls").builtins.diagnostics.flake8.with({ command = "${pkgs.python310Packages.flake8}/bin/flake8" }),
|
||||
require("null-ls").builtins.formatting.fish_indent.with({ command = "${pkgs.fish}/bin/fish_indent" }),
|
||||
require("null-ls").builtins.formatting.nixfmt.with({ command = "${pkgs.nixfmt}/bin/nixfmt" }),
|
||||
require("null-ls").builtins.formatting.rustfmt.with({ command = "${pkgs.rustfmt}/bin/rustfmt" }),
|
||||
require("null-ls").builtins.diagnostics.shellcheck.with({ command = "${pkgs.shellcheck}/bin/shellcheck" }),
|
||||
require("null-ls").builtins.formatting.shfmt.with({
|
||||
command = "${pkgs.shfmt}/bin/shfmt",
|
||||
extra_args = { "-i", "4", "-ci" },
|
||||
}),
|
||||
require("null-ls").builtins.formatting.terraform_fmt.with({
|
||||
command = "${pkgs.terraform}/bin/terraform",
|
||||
extra_filetypes = { "hcl" },
|
||||
}),
|
||||
},
|
||||
|
||||
on_attach = function(client, bufnr)
|
||||
if client.supports_method("textDocument/formatting") then
|
||||
vim.api.nvim_clear_autocmds({ group = augroup, buffer = bufnr })
|
||||
vim.api.nvim_create_autocmd("BufWritePre", {
|
||||
group = augroup,
|
||||
buffer = bufnr,
|
||||
callback = function()
|
||||
vim.lsp.buf.format({ bufnr = bufnr })
|
||||
end,
|
||||
})
|
||||
end
|
||||
end,
|
||||
})
|
||||
'';
|
||||
|
||||
}
|
70
modules/common/neovim/config/misc.nix
Normal file
70
modules/common/neovim/config/misc.nix
Normal file
@ -0,0 +1,70 @@
|
||||
{ pkgs, dsl, lib, ... }: {
|
||||
plugins = [
|
||||
pkgs.vimPlugins.vim-surround # Keybinds for surround characters
|
||||
pkgs.vimPlugins.vim-eunuch # File manipulation commands
|
||||
pkgs.vimPlugins.vim-fugitive # Git commands
|
||||
pkgs.vimPlugins.vim-repeat # Better repeat using .
|
||||
pkgs.vimPlugins.comment-nvim # Smart comment commands
|
||||
pkgs.vimPlugins.impatient-nvim # Faster load times
|
||||
pkgs.vimPlugins.glow-nvim # Markdown preview popup
|
||||
pkgs.vimPlugins.nvim-colorizer-lua # Hex color previews
|
||||
];
|
||||
|
||||
setup.Comment = { };
|
||||
setup.colorizer = { };
|
||||
|
||||
vim.o = {
|
||||
termguicolors = true; # Set to truecolor
|
||||
hidden = true; # Don't unload buffers when leaving them
|
||||
list = true; # Reveal whitespace with dashes
|
||||
expandtab = true; # Tabs into spaces
|
||||
shiftwidth = 4; # Amount to shift with > key
|
||||
softtabstop = 4; # Amount to shift with <TAB> key
|
||||
ignorecase = true; # Ignore case when searching
|
||||
smartcase = true; # Check case when using capitals in search
|
||||
infercase = true; # Don't match cases when completing suggestions
|
||||
incsearch = true; # Search while typing
|
||||
visualbell = true; # No sounds
|
||||
scrolljump = 1; # Number of lines to scroll
|
||||
scrolloff = 3; # Margin of lines to see while scrolling
|
||||
splitright = true; # Vertical splits on the right side
|
||||
splitbelow = true; # Horizontal splits on the bottom side
|
||||
pastetoggle = "<F3>"; # Use F3 to enter raw paste mode
|
||||
clipboard = "unnamedplus"; # Uses system clipboard for yanking
|
||||
updatetime = 300; # Faster diagnostics
|
||||
mouse = "nv"; # Mouse interaction / scrolling
|
||||
inccommand = "split"; # Live preview search and replace
|
||||
};
|
||||
|
||||
vim.wo = {
|
||||
number = true; # Show line numbers
|
||||
relativenumber = true; # Relative numbers instead of absolute
|
||||
};
|
||||
|
||||
# Better backup, swap and undo storage
|
||||
vim.o.backup = true; # Easier to recover and more secure
|
||||
vim.bo.swapfile = false; # Instead of swaps, create backups
|
||||
vim.bo.undofile = true; # Keeps undos after quit
|
||||
vim.o.backupdir = dsl.rawLua ''vim.fn.stdpath("cache") .. "/backup"'';
|
||||
|
||||
# Required for nvim-cmp completion
|
||||
vim.opt.completeopt = [ "menu" "menuone" "noselect" ];
|
||||
|
||||
lua = lib.mkBefore ''
|
||||
require("impatient")
|
||||
${builtins.readFile ../lua/keybinds.lua};
|
||||
${builtins.readFile ../lua/settings.lua};
|
||||
'';
|
||||
|
||||
vimscript = ''
|
||||
" Remember last position when reopening file
|
||||
au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$") | exe "normal! g`\"" | endif
|
||||
|
||||
" LaTeX options
|
||||
au FileType tex inoremap ;bf \textbf{}<Esc>i
|
||||
au BufWritePost *.tex silent! execute "!pdflatex -output-directory=%:p:h % >/dev/null 2>&1" | redraw!
|
||||
|
||||
" Flash highlight when yanking
|
||||
au TextYankPost * silent! lua vim.highlight.on_yank { timeout = 250 }
|
||||
'';
|
||||
}
|
9
modules/common/neovim/config/statusline.nix
Normal file
9
modules/common/neovim/config/statusline.nix
Normal file
@ -0,0 +1,9 @@
|
||||
{ pkgs, ... }: {
|
||||
plugins = [ pkgs.vimPlugins.lualine-nvim ];
|
||||
setup.lualine = {
|
||||
options = {
|
||||
theme = "gruvbox";
|
||||
icons_enabled = true;
|
||||
};
|
||||
};
|
||||
}
|
52
modules/common/neovim/config/syntax.nix
Normal file
52
modules/common/neovim/config/syntax.nix
Normal file
@ -0,0 +1,52 @@
|
||||
{ pkgs, ... }: {
|
||||
|
||||
plugins = [
|
||||
(pkgs.vimPlugins.nvim-treesitter.withPlugins (plugins:
|
||||
with pkgs.tree-sitter-grammars; [
|
||||
tree-sitter-hcl
|
||||
tree-sitter-python
|
||||
tree-sitter-lua
|
||||
tree-sitter-nix
|
||||
tree-sitter-fish
|
||||
tree-sitter-toml
|
||||
tree-sitter-yaml
|
||||
tree-sitter-json
|
||||
]))
|
||||
pkgs.vimPlugins.vim-matchup # Better % jumping in languages
|
||||
pkgs.vimPlugins.nginx-vim
|
||||
pkgs.vimPlugins.vim-helm
|
||||
pkgs.vimPlugins.vim-puppet
|
||||
];
|
||||
|
||||
setup."nvim-treesitter.configs" = {
|
||||
highlight = { enable = true; };
|
||||
indent = { enable = true; };
|
||||
|
||||
textobjects = {
|
||||
select = {
|
||||
enable = true;
|
||||
lookahead = true; # Jump forward automatically
|
||||
|
||||
keymaps = {
|
||||
"['af']" = "@function.outer";
|
||||
"['if']" = "@function.inner";
|
||||
"['ac']" = "@class.outer";
|
||||
"['ic']" = "@class.inner";
|
||||
"['al']" = "@loop.outer";
|
||||
"['il']" = "@loop.inner";
|
||||
"['aa']" = "@call.outer";
|
||||
"['ia']" = "@call.inner";
|
||||
"['ar']" = "@parameter.outer";
|
||||
"['ir']" = "@parameter.inner";
|
||||
"['aC']" = "@comment.outer";
|
||||
"['iC']" = "@comment.outer";
|
||||
"['a/']" = "@comment.outer";
|
||||
"['i/']" = "@comment.outer";
|
||||
"['a;']" = "@statement.outer";
|
||||
"['i;']" = "@statement.outer";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
}
|
69
modules/common/neovim/config/telescope.lua
Normal file
69
modules/common/neovim/config/telescope.lua
Normal file
@ -0,0 +1,69 @@
|
||||
local telescope = require("telescope.builtin")
|
||||
vim.keymap.set("n", "<Leader>k", telescope.keymaps)
|
||||
vim.keymap.set("n", "<Leader>/", telescope.live_grep)
|
||||
vim.keymap.set("n", "<Leader>ff", telescope.find_files)
|
||||
vim.keymap.set("n", "<Leader>fp", telescope.git_files)
|
||||
vim.keymap.set("n", "<Leader>fw", telescope.grep_string)
|
||||
vim.keymap.set("n", "<Leader>b", telescope.buffers)
|
||||
vim.keymap.set("n", "<Leader>hh", telescope.help_tags)
|
||||
vim.keymap.set("n", "<Leader>fr", telescope.oldfiles)
|
||||
vim.keymap.set("n", "<Leader>cc", telescope.commands)
|
||||
vim.keymap.set("n", "<Leader>gc", telescope.git_commits)
|
||||
vim.keymap.set("n", "<Leader>gf", telescope.git_bcommits)
|
||||
vim.keymap.set("n", "<Leader>gb", telescope.git_branches)
|
||||
vim.keymap.set("n", "<Leader>gs", telescope.git_status)
|
||||
vim.keymap.set("n", "<Leader>s", telescope.current_buffer_fuzzy_find)
|
||||
|
||||
vim.keymap.set("n", "<Leader>N", function()
|
||||
local opts = {
|
||||
prompt_title = "Search Notes",
|
||||
cwd = "$NOTES_PATH",
|
||||
}
|
||||
telescope.live_grep(opts)
|
||||
end)
|
||||
|
||||
vim.keymap.set("n", "<Leader>fN", function()
|
||||
local opts = {
|
||||
prompt_title = "Find Notes",
|
||||
cwd = "$NOTES_PATH",
|
||||
}
|
||||
telescope.find_files(opts)
|
||||
end)
|
||||
|
||||
vim.keymap.set("n", "<Leader>cr", function()
|
||||
local opts = require("telescope.themes").get_ivy({
|
||||
layout_config = {
|
||||
bottom_pane = {
|
||||
height = 15,
|
||||
},
|
||||
},
|
||||
})
|
||||
telescope.command_history(opts)
|
||||
end)
|
||||
|
||||
-- Zoxide
|
||||
vim.keymap.set("n", "<Leader>fz", require("telescope").extensions.zoxide.list)
|
||||
|
||||
-- Project
|
||||
require("telescope").load_extension("project")
|
||||
vim.keymap.set("n", "<C-p>", function()
|
||||
local opts = require("telescope.themes").get_ivy({
|
||||
layout_config = {
|
||||
bottom_pane = {
|
||||
height = 10,
|
||||
},
|
||||
},
|
||||
})
|
||||
require("telescope").extensions.project.project(opts)
|
||||
end)
|
||||
|
||||
-- File browser
|
||||
require("telescope").load_extension("file_browser")
|
||||
vim.keymap.set("n", "<Leader>fa", require("telescope").extensions.file_browser.file_browser)
|
||||
vim.keymap.set("n", "<Leader>fD", function()
|
||||
local opts = {
|
||||
prompt_title = "Find Downloads",
|
||||
cwd = "~/downloads",
|
||||
}
|
||||
require("telescope").extensions.file_browser.file_browser(opts)
|
||||
end)
|
34
modules/common/neovim/config/telescope.nix
Normal file
34
modules/common/neovim/config/telescope.nix
Normal file
@ -0,0 +1,34 @@
|
||||
{ pkgs, dsl, ... }: {
|
||||
|
||||
plugins = [
|
||||
pkgs.vimPlugins.telescope-nvim
|
||||
pkgs.vimPlugins.telescope-project-nvim
|
||||
pkgs.vimPlugins.telescope-fzy-native-nvim
|
||||
pkgs.vimPlugins.telescope-file-browser-nvim
|
||||
pkgs.vimPlugins.telescope-zoxide
|
||||
];
|
||||
|
||||
setup.telescope = {
|
||||
defaults = {
|
||||
mappings = {
|
||||
i = {
|
||||
"['<esc>']" = dsl.rawLua "require('telescope.actions').close";
|
||||
"['<C-h>']" = "which_key";
|
||||
};
|
||||
};
|
||||
};
|
||||
pickers = {
|
||||
find_files = { theme = "ivy"; };
|
||||
oldfiles = { theme = "ivy"; };
|
||||
buffers = { theme = "dropdown"; };
|
||||
};
|
||||
extensions = {
|
||||
fzy_native = { };
|
||||
zoxide = { };
|
||||
project = { base_dirs = [ "~/dev" ]; };
|
||||
};
|
||||
};
|
||||
|
||||
lua = builtins.readFile ./telescope.lua;
|
||||
|
||||
}
|
40
modules/common/neovim/config/toggleterm.lua
Normal file
40
modules/common/neovim/config/toggleterm.lua
Normal file
@ -0,0 +1,40 @@
|
||||
vim.keymap.set("t", "<A-CR>", "<C-\\><C-n>") --- Exit terminal mode
|
||||
|
||||
-- Only set these keymaps for toggleterm
|
||||
vim.api.nvim_create_autocmd("TermOpen", {
|
||||
pattern = "term://*toggleterm#*",
|
||||
callback = function()
|
||||
-- vim.keymap.set("t", "<Esc>", "<C-\\><C-n>") --- Exit terminal mode
|
||||
vim.keymap.set("t", "<C-h>", "<C-\\><C-n><C-w>h")
|
||||
vim.keymap.set("t", "<C-j>", "<C-\\><C-n><C-w>j")
|
||||
vim.keymap.set("t", "<C-k>", "<C-\\><C-n><C-w>k")
|
||||
vim.keymap.set("t", "<C-l>", "<C-\\><C-n><C-w>l")
|
||||
end,
|
||||
})
|
||||
|
||||
local terminal = require("toggleterm.terminal").Terminal
|
||||
|
||||
local basicterminal = terminal:new()
|
||||
function TERM_TOGGLE()
|
||||
basicterminal:toggle()
|
||||
end
|
||||
|
||||
local nixpkgs = terminal:new({ cmd = "nix repl '<nixpkgs>'" })
|
||||
function NIXPKGS_TOGGLE()
|
||||
nixpkgs:toggle()
|
||||
end
|
||||
|
||||
local gitwatch = terminal:new({ cmd = "fish --interactive --init-command 'gh run watch'" })
|
||||
function GITWATCH_TOGGLE()
|
||||
gitwatch:toggle()
|
||||
end
|
||||
|
||||
local k9s = terminal:new({ cmd = "k9s" })
|
||||
function K9S_TOGGLE()
|
||||
k9s:toggle()
|
||||
end
|
||||
|
||||
vim.keymap.set("n", "<Leader>t", TERM_TOGGLE)
|
||||
vim.keymap.set("n", "<Leader>P", NIXPKGS_TOGGLE)
|
||||
vim.keymap.set("n", "<Leader>gw", GITWATCH_TOGGLE)
|
||||
vim.keymap.set("n", "<Leader>9", K9S_TOGGLE)
|
13
modules/common/neovim/config/toggleterm.nix
Normal file
13
modules/common/neovim/config/toggleterm.nix
Normal file
@ -0,0 +1,13 @@
|
||||
{ pkgs, dsl, ... }: {
|
||||
|
||||
plugins = [ pkgs.vimPlugins.toggleterm-nvim ];
|
||||
|
||||
use.toggleterm.setup = dsl.callWith {
|
||||
open_mapping = dsl.rawLua "[[<c-\\>]]";
|
||||
hide_numbers = true;
|
||||
direction = "float";
|
||||
};
|
||||
|
||||
lua = builtins.readFile ./toggleterm.lua;
|
||||
|
||||
}
|
77
modules/common/neovim/config/tree.nix
Normal file
77
modules/common/neovim/config/tree.nix
Normal file
@ -0,0 +1,77 @@
|
||||
{ pkgs, dsl, ... }: {
|
||||
|
||||
plugins = [ pkgs.vimPlugins.nvim-tree-lua pkgs.vimPlugins.nvim-web-devicons ];
|
||||
|
||||
# Disable netrw eagerly
|
||||
# https://github.com/kyazdani42/nvim-tree.lua/commit/fb8735e96cecf004fbefb086ce85371d003c5129
|
||||
vim.g = {
|
||||
loaded = 1;
|
||||
loaded_netrwPlugin = 1;
|
||||
};
|
||||
|
||||
setup.nvim-tree = {
|
||||
disable_netrw = true;
|
||||
hijack_netrw = true;
|
||||
update_focused_file = {
|
||||
enable = true;
|
||||
update_cwd = true;
|
||||
ignore_list = { };
|
||||
};
|
||||
diagnostics = {
|
||||
enable = true;
|
||||
icons = {
|
||||
hint = "";
|
||||
info = "";
|
||||
warning = "";
|
||||
error = "";
|
||||
};
|
||||
};
|
||||
renderer = {
|
||||
icons = {
|
||||
glyphs = {
|
||||
git = {
|
||||
unstaged = "~";
|
||||
staged = "+";
|
||||
unmerged = "";
|
||||
renamed = "➜";
|
||||
deleted = "";
|
||||
untracked = "?";
|
||||
ignored = "◌";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
view = {
|
||||
width = 30;
|
||||
hide_root_folder = false;
|
||||
side = "left";
|
||||
mappings = {
|
||||
custom_only = false;
|
||||
list = [
|
||||
{
|
||||
key = [ "l" "<CR>" "o" ];
|
||||
cb = dsl.rawLua
|
||||
"require('nvim-tree.config').nvim_tree_callback('edit')";
|
||||
}
|
||||
{
|
||||
key = "h";
|
||||
cb = dsl.rawLua
|
||||
"require('nvim-tree.config').nvim_tree_callback('close_node')";
|
||||
}
|
||||
{
|
||||
key = "v";
|
||||
cb = dsl.rawLua
|
||||
"require('nvim-tree.config').nvim_tree_callback('vsplit')";
|
||||
}
|
||||
];
|
||||
};
|
||||
number = false;
|
||||
relativenumber = false;
|
||||
};
|
||||
};
|
||||
|
||||
lua = ''
|
||||
vim.keymap.set("n", "<Leader>e", ":NvimTreeFindFileToggle<CR>", { silent = true })
|
||||
'';
|
||||
|
||||
}
|
44
modules/common/neovim/default.nix
Normal file
44
modules/common/neovim/default.nix
Normal file
@ -0,0 +1,44 @@
|
||||
{ config, pkgs, lib, ... }:
|
||||
|
||||
let
|
||||
|
||||
neovim = import ./package {
|
||||
inherit pkgs;
|
||||
colors = import config.theme.colors.neovimConfig { inherit pkgs; };
|
||||
};
|
||||
|
||||
in {
|
||||
|
||||
options.neovim.enable = lib.mkEnableOption "Neovim.";
|
||||
|
||||
config = lib.mkIf config.neovim.enable {
|
||||
home-manager.users.${config.user} =
|
||||
|
||||
{
|
||||
|
||||
home.packages = [ neovim ];
|
||||
|
||||
programs.git.extraConfig.core.editor = "nvim";
|
||||
home.sessionVariables = {
|
||||
EDITOR = "nvim";
|
||||
MANPAGER = "nvim +Man!";
|
||||
};
|
||||
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'";
|
||||
};
|
||||
};
|
||||
programs.kitty.settings.scrollback_pager = lib.mkForce ''
|
||||
${neovim}/bin/nvim -c 'setlocal nonumber nolist showtabline=0 foldcolumn=0|Man!' -c "autocmd VimEnter * normal G" -'';
|
||||
|
||||
};
|
||||
|
||||
# # Used for icons in Vim
|
||||
# fonts.fonts = with pkgs; [ nerdfonts ];
|
||||
|
||||
};
|
||||
|
||||
}
|
4
modules/common/neovim/init.lua
Normal file
4
modules/common/neovim/init.lua
Normal file
@ -0,0 +1,4 @@
|
||||
require("packer_init")
|
||||
require("settings")
|
||||
require("keybinds")
|
||||
require("background")
|
78
modules/common/neovim/lua/keybinds.lua
Normal file
78
modules/common/neovim/lua/keybinds.lua
Normal file
@ -0,0 +1,78 @@
|
||||
-- ===========================================================================
|
||||
-- Key Mapping
|
||||
-- ===========================================================================
|
||||
|
||||
-- Function to cut down config boilerplate
|
||||
local key = function(mode, key_sequence, action, params)
|
||||
params = params or {}
|
||||
vim.keymap.set(mode, key_sequence, action, params)
|
||||
end
|
||||
|
||||
-- Remap space as leader key
|
||||
key("", "<Space>", "<Nop>", { silent = true })
|
||||
vim.g.mapleader = " "
|
||||
vim.g.maplocalleader = " "
|
||||
|
||||
-- Keep selection when changing indentation
|
||||
key("v", "<", "<gv")
|
||||
key("v", ">", ">gv")
|
||||
|
||||
-- Clear search register
|
||||
key("n", "<CR>", ":noh<CR><CR>", { silent = true })
|
||||
|
||||
-- Shuffle lines around
|
||||
key("n", "<A-j>", ":m .+1<CR>==")
|
||||
key("n", "<A-k>", ":m .-2<CR>==")
|
||||
key("v", "<A-j>", ":m '>+1<CR>gv=gv")
|
||||
key("v", "<A-k>", ":m '<-2<CR>gv=gv")
|
||||
|
||||
-- Better window navigation
|
||||
key("n", "<C-h>", "<C-w>h")
|
||||
key("n", "<C-j>", "<C-w>j")
|
||||
key("n", "<C-k>", "<C-w>k")
|
||||
key("n", "<C-l>", "<C-w>l")
|
||||
|
||||
-- File commands
|
||||
key("n", "<Leader>q", ":quit<CR>")
|
||||
key("n", "<Leader>Q", ":quitall<CR>")
|
||||
key("n", "<Leader>fs", ":write<CR>")
|
||||
key("n", "<Leader>fd", ":lcd %:p:h<CR>", { silent = true })
|
||||
key("n", "<Leader>fu", ":lcd ..<CR>", { silent = true })
|
||||
key("n", "<Leader><Tab>", ":b#<CR>", { silent = true })
|
||||
key("n", "<Leader>gr", ":!gh repo view -w<CR><CR>", { silent = true })
|
||||
key("n", "<Leader>tt", [[<Cmd>exe 'edit $NOTES_PATH/journal/'.strftime("%Y-%m-%d_%a").'.md'<CR>]])
|
||||
key("n", "<Leader>jj", ":!journal<CR>:e<CR>")
|
||||
|
||||
-- Window commands
|
||||
key("n", "<Leader>wv", ":vsplit<CR>")
|
||||
key("n", "<Leader>wh", ":split<CR>")
|
||||
key("n", "<Leader>wm", ":only<CR>")
|
||||
|
||||
-- Vimrc editing
|
||||
key("n", "<Leader>rr", ":luafile $HOME/.config/nvim/init.lua<CR>")
|
||||
key("n", "<Leader>rp", ":luafile $HOME/.config/nvim/init.lua<CR>:PackerInstall<CR>:")
|
||||
key("n", "<Leader>rc", ":luafile $HOME/.config/nvim/init.lua<CR>:PackerCompile<CR>")
|
||||
|
||||
-- Keep cursor in place
|
||||
key("n", "n", "nzz")
|
||||
key("n", "N", "Nzz")
|
||||
key("n", "J", "mzJ`z") --- Mark and jump back to it
|
||||
|
||||
-- Add undo breakpoints
|
||||
key("i", ",", ",<C-g>u")
|
||||
key("i", ".", ".<C-g>u")
|
||||
key("i", "!", "!<C-g>u")
|
||||
key("i", "?", "?<C-g>u")
|
||||
|
||||
-- Resize with arrows
|
||||
key("n", "<C-Up>", ":resize +2<CR>", { silent = true })
|
||||
key("n", "<C-Down>", ":resize -2<CR>", { silent = true })
|
||||
key("n", "<C-Left>", ":vertical resize -2<CR>", { silent = true })
|
||||
key("n", "<C-Right>", ":vertical resize +2<CR>", { silent = true })
|
||||
|
||||
-- Other
|
||||
key("n", "<A-CR>", ":noh<CR>", { silent = true }) --- Clear search in VimWiki
|
||||
key("n", "Y", "y$") --- Copy to end of line
|
||||
key("v", "<C-r>", "y<Esc>:%s/<C-r>+//gc<left><left><left>") --- Substitute selected
|
||||
key("v", "D", "y'>gp") --- Duplicate selected
|
||||
key("x", "<Leader>p", '"_dP') --- Paste but keep register
|
164
modules/common/neovim/lua/packer/completion.lua
Normal file
164
modules/common/neovim/lua/packer/completion.lua
Normal file
@ -0,0 +1,164 @@
|
||||
-- =======================================================================
|
||||
-- Completion System
|
||||
-- =======================================================================
|
||||
|
||||
local M = {}
|
||||
|
||||
M.packer = function(use)
|
||||
-- Completion sources
|
||||
use("hrsh7th/cmp-nvim-lsp") --- Language server completion plugin
|
||||
use("hrsh7th/cmp-buffer") --- Generic text completion
|
||||
use("hrsh7th/cmp-path") --- Local file completion
|
||||
use("hrsh7th/cmp-cmdline") --- Command line completion
|
||||
use("hrsh7th/cmp-nvim-lua") --- Nvim lua api completion
|
||||
use("saadparwaiz1/cmp_luasnip") --- Luasnip completion
|
||||
use("lukas-reineke/cmp-rg") --- Ripgrep completion
|
||||
use("rafamadriz/friendly-snippets") -- Lots of pre-generated snippets
|
||||
|
||||
-- Completion engine
|
||||
use({
|
||||
"hrsh7th/nvim-cmp",
|
||||
requires = { "L3MON4D3/LuaSnip" },
|
||||
config = function()
|
||||
local cmp = require("cmp")
|
||||
|
||||
local kind_icons = {
|
||||
Text = "",
|
||||
Method = "m",
|
||||
Function = "",
|
||||
Constructor = "",
|
||||
Field = "",
|
||||
Variable = "",
|
||||
Class = "",
|
||||
Interface = "",
|
||||
Module = "",
|
||||
Property = "",
|
||||
Unit = "",
|
||||
Value = "",
|
||||
Enum = "",
|
||||
Keyword = "",
|
||||
Snippet = "",
|
||||
Color = "",
|
||||
File = "",
|
||||
Reference = "",
|
||||
Folder = "",
|
||||
EnumMember = "",
|
||||
Constant = "",
|
||||
Struct = "",
|
||||
Event = "",
|
||||
Operator = "",
|
||||
TypeParameter = "",
|
||||
}
|
||||
|
||||
cmp.setup({
|
||||
|
||||
-- Only enable on non-prompt buffers
|
||||
-- So don't use in telescope
|
||||
enabled = function()
|
||||
if vim.bo.buftype == "prompt" then
|
||||
return false
|
||||
end
|
||||
return true
|
||||
end,
|
||||
|
||||
-- Setup snippet completion
|
||||
snippet = {
|
||||
expand = function(args)
|
||||
require("luasnip").lsp_expand(args.body)
|
||||
end,
|
||||
},
|
||||
|
||||
-- Setup completion keybinds
|
||||
mapping = {
|
||||
["<C-n>"] = cmp.mapping(cmp.mapping.select_next_item(), { "i", "c" }),
|
||||
["<C-p>"] = cmp.mapping(cmp.mapping.select_prev_item(), { "i", "c" }),
|
||||
["<C-d>"] = cmp.mapping(cmp.mapping.scroll_docs(-4), { "i", "c" }),
|
||||
["<C-f>"] = cmp.mapping(cmp.mapping.scroll_docs(4), { "i", "c" }),
|
||||
["<C-e>"] = cmp.mapping(cmp.mapping.abort(), { "i", "c" }),
|
||||
["<Esc>"] = function(_)
|
||||
cmp.mapping({
|
||||
i = cmp.mapping.abort(),
|
||||
c = cmp.mapping.close(),
|
||||
})
|
||||
vim.cmd("stopinsert") --- Abort and leave insert mode
|
||||
end,
|
||||
["<CR>"] = cmp.mapping.confirm({
|
||||
behavior = cmp.ConfirmBehavior.Insert,
|
||||
select = true,
|
||||
}),
|
||||
["<C-r>"] = cmp.mapping.confirm({
|
||||
behavior = cmp.ConfirmBehavior.Replace,
|
||||
select = true,
|
||||
}),
|
||||
["<C-l>"] = cmp.mapping(function(_)
|
||||
if require("luasnip").expand_or_jumpable() then
|
||||
require("luasnip").expand_or_jump()
|
||||
end
|
||||
end, { "i", "s" }),
|
||||
},
|
||||
|
||||
-- Setup completion engines
|
||||
sources = {
|
||||
{ name = "nvim_lua" },
|
||||
{ name = "nvim_lsp" },
|
||||
{ name = "luasnip" },
|
||||
{ name = "path" },
|
||||
{ name = "buffer", keyword_length = 3, max_item_count = 10 },
|
||||
{
|
||||
name = "rg",
|
||||
keyword_length = 6,
|
||||
max_item_count = 10,
|
||||
option = { additional_arguments = "--ignore-case" },
|
||||
},
|
||||
},
|
||||
|
||||
-- Visual presentation
|
||||
formatting = {
|
||||
fields = { "kind", "abbr", "menu" },
|
||||
format = function(entry, vim_item)
|
||||
vim_item.kind = string.format("%s", kind_icons[vim_item.kind])
|
||||
vim_item.menu = ({
|
||||
luasnip = "[Snippet]",
|
||||
buffer = "[Buffer]",
|
||||
path = "[Path]",
|
||||
rg = "[Grep]",
|
||||
nvim_lsp = "[LSP]",
|
||||
nvim_lua = "[Lua]",
|
||||
})[entry.source.name]
|
||||
return vim_item
|
||||
end,
|
||||
},
|
||||
|
||||
-- Docs
|
||||
-- window = {
|
||||
-- completion = cmp.config.window.bordered(),
|
||||
-- documentation = cmp.config.window.bordered(),
|
||||
-- },
|
||||
|
||||
-- Extra features
|
||||
experimental = {
|
||||
native_menu = false, --- Use cmp menu instead of Vim menu
|
||||
ghost_text = true, --- Show preview auto-completion
|
||||
},
|
||||
})
|
||||
|
||||
-- Use buffer source for `/`
|
||||
cmp.setup.cmdline("/", {
|
||||
sources = {
|
||||
{ name = "buffer", keyword_length = 5 },
|
||||
},
|
||||
})
|
||||
|
||||
-- Use cmdline & path source for ':'
|
||||
cmp.setup.cmdline(":", {
|
||||
sources = cmp.config.sources({
|
||||
{ name = "path" },
|
||||
}, {
|
||||
{ name = "cmdline" },
|
||||
}),
|
||||
})
|
||||
end,
|
||||
})
|
||||
end
|
||||
|
||||
return M
|
153
modules/common/neovim/lua/packer/lsp.lua
Normal file
153
modules/common/neovim/lua/packer/lsp.lua
Normal file
@ -0,0 +1,153 @@
|
||||
-- =======================================================================
|
||||
-- Language Server
|
||||
-- =======================================================================
|
||||
|
||||
local M = {}
|
||||
|
||||
M.packer = function(use)
|
||||
-- Language server engine
|
||||
use({
|
||||
"neovim/nvim-lspconfig",
|
||||
requires = { "hrsh7th/cmp-nvim-lsp" },
|
||||
config = function()
|
||||
local function on_path(program)
|
||||
return vim.fn.executable(program) == 1
|
||||
end
|
||||
|
||||
local capabilities = require("cmp_nvim_lsp").default_capabilities()
|
||||
if on_path("lua-language-server") then
|
||||
require("lspconfig").sumneko_lua.setup({
|
||||
capabilities = capabilities,
|
||||
-- Turn off errors for vim global variable
|
||||
settings = {
|
||||
Lua = {
|
||||
diagnostics = {
|
||||
globals = { "vim", "hs" },
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
end
|
||||
if on_path("rust-analyzer") then
|
||||
require("lspconfig").rust_analyzer.setup({ capabilities = capabilities })
|
||||
end
|
||||
if on_path("tflint") then
|
||||
require("lspconfig").tflint.setup({ capabilities = capabilities })
|
||||
end
|
||||
if on_path("terraform-ls") then
|
||||
require("lspconfig").terraformls.setup({ capabilities = capabilities })
|
||||
end
|
||||
if on_path("pyright") then
|
||||
require("lspconfig").pyright.setup({
|
||||
on_attach = function()
|
||||
-- set keymaps (requires 0.7.0)
|
||||
-- vim.keymap.set("n", "", "", {buffer=0})
|
||||
end,
|
||||
capabilities = capabilities,
|
||||
})
|
||||
end
|
||||
if on_path("nil") then
|
||||
require("lspconfig").nil_ls.setup({ capabilities = capabilities })
|
||||
end
|
||||
|
||||
vim.keymap.set("n", "gd", vim.lsp.buf.definition)
|
||||
vim.keymap.set("n", "gT", vim.lsp.buf.type_definition)
|
||||
vim.keymap.set("n", "gi", vim.lsp.buf.implementation)
|
||||
vim.keymap.set("n", "gh", vim.lsp.buf.hover)
|
||||
-- vim.keymap.set("n", "gr", telescope.lsp_references)
|
||||
vim.keymap.set("n", "<Leader>R", vim.lsp.buf.rename)
|
||||
vim.keymap.set("n", "]e", vim.diagnostic.goto_next)
|
||||
vim.keymap.set("n", "[e", vim.diagnostic.goto_prev)
|
||||
vim.keymap.set("n", "<Leader>de", vim.diagnostic.open_float)
|
||||
vim.keymap.set("n", "<Leader>E", vim.lsp.buf.code_action)
|
||||
end,
|
||||
})
|
||||
|
||||
-- Pretty highlights
|
||||
use("folke/lsp-colors.nvim")
|
||||
|
||||
-- Linting
|
||||
use({
|
||||
"jose-elias-alvarez/null-ls.nvim",
|
||||
branch = "main",
|
||||
requires = {
|
||||
"nvim-lua/plenary.nvim",
|
||||
"neovim/nvim-lspconfig",
|
||||
},
|
||||
config = function()
|
||||
local function on_path(program)
|
||||
return vim.fn.executable(program) == 1
|
||||
end
|
||||
|
||||
local augroup = vim.api.nvim_create_augroup("LspFormatting", {})
|
||||
require("null-ls").setup({
|
||||
sources = {
|
||||
require("null-ls").builtins.formatting.stylua.with({
|
||||
condition = function()
|
||||
return on_path("stylua")
|
||||
end,
|
||||
}),
|
||||
require("null-ls").builtins.formatting.black.with({
|
||||
condition = function()
|
||||
return on_path("black")
|
||||
end,
|
||||
}),
|
||||
require("null-ls").builtins.diagnostics.flake8.with({
|
||||
condition = function()
|
||||
return on_path("flake8")
|
||||
end,
|
||||
}),
|
||||
require("null-ls").builtins.formatting.fish_indent.with({
|
||||
condition = function()
|
||||
return on_path("fish_indent")
|
||||
end,
|
||||
}),
|
||||
require("null-ls").builtins.formatting.nixfmt.with({
|
||||
condition = function()
|
||||
return on_path("nixfmt")
|
||||
end,
|
||||
}),
|
||||
require("null-ls").builtins.formatting.rustfmt.with({
|
||||
condition = function()
|
||||
return on_path("rustfmt")
|
||||
end,
|
||||
}),
|
||||
require("null-ls").builtins.diagnostics.shellcheck.with({
|
||||
condition = function()
|
||||
return on_path("shellcheck")
|
||||
end,
|
||||
}),
|
||||
require("null-ls").builtins.formatting.shfmt.with({
|
||||
extra_args = { "-i", "4", "-ci" },
|
||||
condition = function()
|
||||
return on_path("shfmt")
|
||||
end,
|
||||
}),
|
||||
require("null-ls").builtins.formatting.terraform_fmt.with({
|
||||
condition = function()
|
||||
return on_path("terraform")
|
||||
end,
|
||||
}),
|
||||
-- require("null-ls").builtins.diagnostics.luacheck,
|
||||
-- require("null-ls").builtins.diagnostics.markdownlint,
|
||||
-- require("null-ls").builtins.diagnostics.pylint,
|
||||
},
|
||||
-- Format on save
|
||||
on_attach = function(client, bufnr)
|
||||
if client.supports_method("textDocument/formatting") then
|
||||
vim.api.nvim_clear_autocmds({ group = augroup, buffer = bufnr })
|
||||
vim.api.nvim_create_autocmd("BufWritePre", {
|
||||
group = augroup,
|
||||
buffer = bufnr,
|
||||
callback = function()
|
||||
vim.lsp.buf.format({ bufnr = bufnr })
|
||||
end,
|
||||
})
|
||||
end
|
||||
end,
|
||||
})
|
||||
end,
|
||||
})
|
||||
end
|
||||
|
||||
return M
|
67
modules/common/neovim/lua/packer/misc.lua
Normal file
67
modules/common/neovim/lua/packer/misc.lua
Normal file
@ -0,0 +1,67 @@
|
||||
local M = {}
|
||||
|
||||
M.packer = function(use)
|
||||
-- Important tweaks
|
||||
use("tpope/vim-surround") --- Manipulate parentheses
|
||||
|
||||
-- Convenience tweaks
|
||||
use("tpope/vim-eunuch") --- File manipulation in Vim
|
||||
use("tpope/vim-vinegar") --- Fixes netrw file explorer
|
||||
use("tpope/vim-fugitive") --- Git commands and syntax
|
||||
use("tpope/vim-repeat") --- Actually repeat using .
|
||||
|
||||
-- Use gc or gcc to add comments
|
||||
use({
|
||||
"numToStr/Comment.nvim",
|
||||
config = function()
|
||||
require("Comment").setup()
|
||||
end,
|
||||
})
|
||||
|
||||
-- Alignment tool
|
||||
use({
|
||||
"godlygeek/tabular",
|
||||
config = function()
|
||||
vim.keymap.set("", "<Leader>ta", ":Tabularize /")
|
||||
vim.keymap.set("", "<Leader>t#", ":Tabularize /#<CR>")
|
||||
vim.keymap.set("", "<Leader>tl", ":Tabularize /---<CR>")
|
||||
end,
|
||||
})
|
||||
|
||||
-- Markdown renderer / wiki notes
|
||||
-- use("vimwiki/vimwiki")
|
||||
use({
|
||||
"jakewvincent/mkdnflow.nvim",
|
||||
config = function()
|
||||
require("mkdnflow").setup({
|
||||
modules = {
|
||||
bib = false,
|
||||
conceal = true,
|
||||
folds = false,
|
||||
},
|
||||
perspective = {
|
||||
priority = "current",
|
||||
fallback = "first",
|
||||
nvim_wd_heel = false, -- Don't change working dir
|
||||
},
|
||||
links = {
|
||||
style = "markdown",
|
||||
conceal = true,
|
||||
},
|
||||
wrap = true,
|
||||
to_do = {
|
||||
symbols = { " ", "-", "x" },
|
||||
},
|
||||
})
|
||||
vim.api.nvim_create_autocmd("FileType", {
|
||||
pattern = "markdown",
|
||||
callback = function()
|
||||
vim.o.autowriteall = true -- Save in new buffer
|
||||
vim.o.wrapmargin = 79 -- Wrap text automatically
|
||||
end,
|
||||
})
|
||||
end,
|
||||
})
|
||||
end
|
||||
|
||||
return M
|
13
modules/common/neovim/lua/packer/speed.lua
Normal file
13
modules/common/neovim/lua/packer/speed.lua
Normal file
@ -0,0 +1,13 @@
|
||||
local M = {}
|
||||
|
||||
M.packer = function(use)
|
||||
-- Startup speed hacks
|
||||
use({
|
||||
"lewis6991/impatient.nvim",
|
||||
config = function()
|
||||
require("impatient")
|
||||
end,
|
||||
})
|
||||
end
|
||||
|
||||
return M
|
72
modules/common/neovim/lua/packer/syntax.lua
Normal file
72
modules/common/neovim/lua/packer/syntax.lua
Normal file
@ -0,0 +1,72 @@
|
||||
-- =======================================================================
|
||||
-- Syntax
|
||||
-- =======================================================================
|
||||
|
||||
local M = {}
|
||||
|
||||
M.packer = function(use)
|
||||
-- Syntax engine
|
||||
use({
|
||||
"nvim-treesitter/nvim-treesitter",
|
||||
commit = "9ada5f70f98d51e9e3e76018e783b39fd1cd28f7",
|
||||
run = ":TSUpdate",
|
||||
config = function()
|
||||
require("nvim-treesitter.configs").setup({
|
||||
ensure_installed = {
|
||||
"hcl",
|
||||
"python",
|
||||
"lua",
|
||||
"nix",
|
||||
"fish",
|
||||
"toml",
|
||||
"yaml",
|
||||
"json",
|
||||
},
|
||||
auto_install = true,
|
||||
highlight = { enable = true },
|
||||
indent = { enable = true },
|
||||
})
|
||||
end,
|
||||
})
|
||||
|
||||
-- Syntax-aware Textobjects
|
||||
use({
|
||||
"nvim-treesitter/nvim-treesitter-textobjects",
|
||||
requires = { "nvim-treesitter/nvim-treesitter" },
|
||||
config = function()
|
||||
require("nvim-treesitter.configs").setup({
|
||||
textobjects = {
|
||||
select = {
|
||||
enable = true,
|
||||
lookahead = true, -- Jump forward automatically
|
||||
keymaps = {
|
||||
["af"] = "@function.outer",
|
||||
["if"] = "@function.inner",
|
||||
["ac"] = "@class.outer",
|
||||
["ic"] = "@class.inner",
|
||||
["al"] = "@loop.outer",
|
||||
["il"] = "@loop.inner",
|
||||
["aa"] = "@call.outer",
|
||||
["ia"] = "@call.inner",
|
||||
["ar"] = "@parameter.outer",
|
||||
["ir"] = "@parameter.inner",
|
||||
["aC"] = "@comment.outer",
|
||||
["iC"] = "@comment.outer",
|
||||
["a/"] = "@comment.outer",
|
||||
["i/"] = "@comment.outer",
|
||||
["a;"] = "@statement.outer",
|
||||
["i;"] = "@statement.outer",
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
end,
|
||||
})
|
||||
|
||||
-- Additional syntax sources
|
||||
use("chr4/nginx.vim") --- Nginx syntax
|
||||
use("towolf/vim-helm") --- Helm syntax
|
||||
use("rodjek/vim-puppet") --- Puppet syntax
|
||||
end
|
||||
|
||||
return M
|
139
modules/common/neovim/lua/packer/telescope.lua
Normal file
139
modules/common/neovim/lua/packer/telescope.lua
Normal file
@ -0,0 +1,139 @@
|
||||
-- =======================================================================
|
||||
-- Fuzzy Launcher
|
||||
-- =======================================================================
|
||||
|
||||
local M = {}
|
||||
|
||||
M.packer = function(use)
|
||||
use({
|
||||
"nvim-telescope/telescope.nvim",
|
||||
branch = "master",
|
||||
requires = { "nvim-lua/plenary.nvim" },
|
||||
config = function()
|
||||
-- Telescope: quit instantly with escape
|
||||
local actions = require("telescope.actions")
|
||||
require("telescope").setup({
|
||||
defaults = {
|
||||
mappings = {
|
||||
i = {
|
||||
["<esc>"] = actions.close,
|
||||
["<C-h>"] = "which_key",
|
||||
},
|
||||
},
|
||||
},
|
||||
pickers = {
|
||||
find_files = { theme = "ivy" },
|
||||
oldfiles = { theme = "ivy" },
|
||||
buffers = { theme = "dropdown" },
|
||||
},
|
||||
extensions = {
|
||||
fzy_native = {},
|
||||
zoxide = {},
|
||||
project = {
|
||||
base_dirs = { "~/dev" },
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
local telescope = require("telescope.builtin")
|
||||
|
||||
vim.keymap.set("n", "<Leader>k", telescope.keymaps)
|
||||
vim.keymap.set("n", "<Leader>/", telescope.live_grep)
|
||||
vim.keymap.set("n", "<Leader>ff", telescope.find_files)
|
||||
vim.keymap.set("n", "<Leader>fp", telescope.git_files)
|
||||
vim.keymap.set("n", "<Leader>fw", telescope.grep_string)
|
||||
vim.keymap.set("n", "<Leader>b", telescope.buffers)
|
||||
vim.keymap.set("n", "<Leader>hh", telescope.help_tags)
|
||||
vim.keymap.set("n", "<Leader>fr", telescope.oldfiles)
|
||||
vim.keymap.set("n", "<Leader>cc", telescope.commands)
|
||||
vim.keymap.set("n", "<Leader>gc", telescope.git_commits)
|
||||
vim.keymap.set("n", "<Leader>gf", telescope.git_bcommits)
|
||||
vim.keymap.set("n", "<Leader>gb", telescope.git_branches)
|
||||
vim.keymap.set("n", "<Leader>gs", telescope.git_status)
|
||||
vim.keymap.set("n", "<Leader>s", telescope.current_buffer_fuzzy_find)
|
||||
|
||||
vim.keymap.set("n", "<Leader>N", function()
|
||||
local opts = {
|
||||
prompt_title = "Search Notes",
|
||||
cwd = "$NOTES_PATH",
|
||||
}
|
||||
telescope.live_grep(opts)
|
||||
end)
|
||||
|
||||
vim.keymap.set("n", "<Leader>fN", function()
|
||||
local opts = {
|
||||
prompt_title = "Find Notes",
|
||||
cwd = "$NOTES_PATH",
|
||||
}
|
||||
telescope.find_files(opts)
|
||||
end)
|
||||
|
||||
vim.keymap.set("n", "<Leader>cr", function()
|
||||
local opts = require("telescope.themes").get_ivy({
|
||||
layout_config = {
|
||||
bottom_pane = {
|
||||
height = 15,
|
||||
},
|
||||
},
|
||||
})
|
||||
telescope.command_history(opts)
|
||||
end)
|
||||
end,
|
||||
})
|
||||
|
||||
-- Faster sorting
|
||||
use("nvim-telescope/telescope-fzy-native.nvim")
|
||||
|
||||
-- Jump around tmux sessions
|
||||
-- use("camgraff/telescope-tmux.nvim")
|
||||
|
||||
-- Jump directories
|
||||
use({
|
||||
"jvgrootveld/telescope-zoxide",
|
||||
requires = { "nvim-lua/popup.nvim", "nvim-telescope/telescope.nvim" },
|
||||
config = function()
|
||||
vim.keymap.set("n", "<Leader>fz", require("telescope").extensions.zoxide.list)
|
||||
end,
|
||||
})
|
||||
|
||||
-- Jump projects
|
||||
use({
|
||||
"nvim-telescope/telescope-project.nvim",
|
||||
requires = { "nvim-telescope/telescope.nvim" },
|
||||
config = function()
|
||||
require("telescope").load_extension("project")
|
||||
|
||||
vim.keymap.set("n", "<C-p>", function()
|
||||
local opts = require("telescope.themes").get_ivy({
|
||||
layout_config = {
|
||||
bottom_pane = {
|
||||
height = 10,
|
||||
},
|
||||
},
|
||||
})
|
||||
require("telescope").extensions.project.project(opts)
|
||||
end)
|
||||
end,
|
||||
})
|
||||
|
||||
-- File browser
|
||||
use({
|
||||
"nvim-telescope/telescope-file-browser.nvim",
|
||||
requires = { "nvim-telescope/telescope.nvim" },
|
||||
config = function()
|
||||
require("telescope").load_extension("file_browser")
|
||||
|
||||
vim.keymap.set("n", "<Leader>fa", require("telescope").extensions.file_browser.file_browser)
|
||||
|
||||
vim.keymap.set("n", "<Leader>fD", function()
|
||||
local opts = {
|
||||
prompt_title = "Find Downloads",
|
||||
cwd = "~/downloads",
|
||||
}
|
||||
require("telescope").extensions.file_browser.file_browser(opts)
|
||||
end)
|
||||
end,
|
||||
})
|
||||
end
|
||||
|
||||
return M
|
79
modules/common/neovim/lua/packer/toggleterm.lua
Normal file
79
modules/common/neovim/lua/packer/toggleterm.lua
Normal file
@ -0,0 +1,79 @@
|
||||
local M = {}
|
||||
|
||||
M.packer = function(use)
|
||||
use({
|
||||
"akinsho/toggleterm.nvim",
|
||||
tag = "v2.1.0",
|
||||
config = function()
|
||||
require("toggleterm").setup({
|
||||
open_mapping = [[<c-\>]],
|
||||
hide_numbers = true,
|
||||
direction = "float",
|
||||
})
|
||||
|
||||
vim.keymap.set("t", "<A-CR>", "<C-\\><C-n>") --- Exit terminal mode
|
||||
|
||||
-- Only set these keymaps for toggleterm
|
||||
vim.api.nvim_create_autocmd("TermOpen", {
|
||||
pattern = "term://*toggleterm#*",
|
||||
callback = function()
|
||||
-- vim.keymap.set("t", "<Esc>", "<C-\\><C-n>") --- Exit terminal mode
|
||||
vim.keymap.set("t", "<C-h>", "<C-\\><C-n><C-w>h")
|
||||
vim.keymap.set("t", "<C-j>", "<C-\\><C-n><C-w>j")
|
||||
vim.keymap.set("t", "<C-k>", "<C-\\><C-n><C-w>k")
|
||||
vim.keymap.set("t", "<C-l>", "<C-\\><C-n><C-w>l")
|
||||
end,
|
||||
})
|
||||
|
||||
local terminal = require("toggleterm.terminal").Terminal
|
||||
|
||||
local basicterminal = terminal:new()
|
||||
function TERM_TOGGLE()
|
||||
basicterminal:toggle()
|
||||
end
|
||||
|
||||
local nixpkgs = terminal:new({ cmd = "nix repl '<nixpkgs>'" })
|
||||
function NIXPKGS_TOGGLE()
|
||||
nixpkgs:toggle()
|
||||
end
|
||||
|
||||
local gitwatch = terminal:new({ cmd = "fish --interactive --init-command 'gh run watch'" })
|
||||
function GITWATCH_TOGGLE()
|
||||
gitwatch:toggle()
|
||||
end
|
||||
|
||||
local k9s = terminal:new({ cmd = "k9s" })
|
||||
function K9S_TOGGLE()
|
||||
k9s:toggle()
|
||||
end
|
||||
|
||||
vim.keymap.set("n", "<Leader>t", TERM_TOGGLE)
|
||||
vim.keymap.set("n", "<Leader>P", NIXPKGS_TOGGLE)
|
||||
vim.keymap.set("n", "<Leader>gw", GITWATCH_TOGGLE)
|
||||
vim.keymap.set("n", "<Leader>9", K9S_TOGGLE)
|
||||
end,
|
||||
})
|
||||
|
||||
-- Connect to telescope
|
||||
-- use({
|
||||
-- "https://git.sr.ht/~havi/telescope-toggleterm.nvim",
|
||||
-- event = "TermOpen",
|
||||
-- requires = {
|
||||
-- "akinsho/nvim-toggleterm.lua",
|
||||
-- "nvim-telescope/telescope.nvim",
|
||||
-- "nvim-lua/popup.nvim",
|
||||
-- "nvim-lua/plenary.nvim",
|
||||
-- },
|
||||
-- config = function()
|
||||
-- require("telescope").load_extension("toggleterm")
|
||||
-- require("telescope-toggleterm").setup({
|
||||
-- telescope_mappings = {
|
||||
-- -- <ctrl-c> : kill the terminal buffer (default) .
|
||||
-- ["<C-c>"] = require("telescope-toggleterm").actions.exit_terminal,
|
||||
-- },
|
||||
-- })
|
||||
-- end,
|
||||
-- })
|
||||
end
|
||||
|
||||
return M
|
164
modules/common/neovim/lua/packer/visuals.lua
Normal file
164
modules/common/neovim/lua/packer/visuals.lua
Normal file
@ -0,0 +1,164 @@
|
||||
local M = {}
|
||||
|
||||
M.packer = function(use)
|
||||
-- Git next to line numbers
|
||||
use({
|
||||
"lewis6991/gitsigns.nvim",
|
||||
branch = "main",
|
||||
requires = { "nvim-lua/plenary.nvim" },
|
||||
config = function()
|
||||
local gitsigns = require("gitsigns")
|
||||
gitsigns.setup()
|
||||
vim.keymap.set("n", "<Leader>gB", gitsigns.blame_line)
|
||||
vim.keymap.set("n", "<Leader>gp", gitsigns.preview_hunk)
|
||||
vim.keymap.set("v", "<Leader>gp", gitsigns.preview_hunk)
|
||||
vim.keymap.set("n", "<Leader>gd", gitsigns.diffthis)
|
||||
vim.keymap.set("v", "<Leader>gd", gitsigns.diffthis)
|
||||
vim.keymap.set("n", "<Leader>rgf", gitsigns.reset_buffer)
|
||||
vim.keymap.set("v", "<Leader>hs", gitsigns.stage_hunk)
|
||||
vim.keymap.set("v", "<Leader>hr", gitsigns.reset_hunk)
|
||||
vim.keymap.set("v", "<Leader>hr", gitsigns.reset_hunk)
|
||||
|
||||
-- Navigation
|
||||
vim.keymap.set("n", "]g", function()
|
||||
if vim.wo.diff then
|
||||
return "]g"
|
||||
end
|
||||
vim.schedule(function()
|
||||
gitsigns.next_hunk()
|
||||
end)
|
||||
return "<Ignore>"
|
||||
end, { expr = true })
|
||||
|
||||
vim.keymap.set("n", "[g", function()
|
||||
if vim.wo.diff then
|
||||
return "[g"
|
||||
end
|
||||
vim.schedule(function()
|
||||
gitsigns.prev_hunk()
|
||||
end)
|
||||
return "<Ignore>"
|
||||
end, { expr = true })
|
||||
end,
|
||||
})
|
||||
|
||||
-- Status bar
|
||||
use({
|
||||
"hoob3rt/lualine.nvim",
|
||||
requires = { "kyazdani42/nvim-web-devicons", opt = true },
|
||||
config = function()
|
||||
require("lualine").setup({
|
||||
options = {
|
||||
theme = "gruvbox",
|
||||
icons_enabled = true,
|
||||
},
|
||||
})
|
||||
end,
|
||||
})
|
||||
|
||||
-- Buffer line ("tabs")
|
||||
use({
|
||||
"akinsho/bufferline.nvim",
|
||||
tag = "v2.4.0",
|
||||
requires = { "kyazdani42/nvim-web-devicons", "moll/vim-bbye" },
|
||||
config = function()
|
||||
require("bufferline").setup({
|
||||
options = {
|
||||
diagnostics = "nvim_lsp",
|
||||
always_show_bufferline = false,
|
||||
separator_style = "slant",
|
||||
offsets = { { filetype = "NvimTree" } },
|
||||
},
|
||||
})
|
||||
-- Move buffers
|
||||
vim.keymap.set("n", "L", ":BufferLineCycleNext<CR>", { silent = true })
|
||||
vim.keymap.set("n", "H", ":BufferLineCyclePrev<CR>", { silent = true })
|
||||
|
||||
-- Kill buffer
|
||||
vim.keymap.set("n", "<Leader>x", " :Bdelete<CR>", { silent = true })
|
||||
|
||||
-- Shift buffers
|
||||
-- vim.keymap.set("n", "<C-L>", ":BufferLineMoveNext<CR>")
|
||||
-- vim.keymap.set("i", "<C-L>", "<Esc>:BufferLineMoveNext<CR>i")
|
||||
-- vim.keymap.set("n", "<C-H>", ":BufferLineMovePrev<CR>")
|
||||
-- vim.keymap.set("i", "<C-H>", "<Esc>:BufferLineMovePrev<CR>i")
|
||||
end,
|
||||
})
|
||||
|
||||
-- File explorer
|
||||
use({
|
||||
"kyazdani42/nvim-tree.lua",
|
||||
requires = { "kyazdani42/nvim-web-devicons" },
|
||||
config = function()
|
||||
require("nvim-tree").setup({
|
||||
disable_netrw = true,
|
||||
hijack_netrw = true,
|
||||
update_focused_file = {
|
||||
enable = true,
|
||||
update_cwd = true,
|
||||
ignore_list = {},
|
||||
},
|
||||
diagnostics = {
|
||||
enable = true,
|
||||
icons = {
|
||||
hint = "",
|
||||
info = "",
|
||||
warning = "",
|
||||
error = "",
|
||||
},
|
||||
},
|
||||
renderer = {
|
||||
icons = {
|
||||
glyphs = {
|
||||
git = {
|
||||
unstaged = "~",
|
||||
staged = "+",
|
||||
unmerged = "",
|
||||
renamed = "➜",
|
||||
deleted = "",
|
||||
untracked = "?",
|
||||
ignored = "◌",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
view = {
|
||||
width = 30,
|
||||
hide_root_folder = false,
|
||||
side = "left",
|
||||
mappings = {
|
||||
custom_only = false,
|
||||
list = {
|
||||
{
|
||||
key = { "l", "<CR>", "o" },
|
||||
cb = require("nvim-tree.config").nvim_tree_callback("edit"),
|
||||
},
|
||||
{ key = "h", cb = require("nvim-tree.config").nvim_tree_callback("close_node") },
|
||||
{ key = "v", cb = require("nvim-tree.config").nvim_tree_callback("vsplit") },
|
||||
},
|
||||
},
|
||||
number = false,
|
||||
relativenumber = false,
|
||||
},
|
||||
})
|
||||
vim.keymap.set("n", "<Leader>e", ":NvimTreeFindFileToggle<CR>", { silent = true })
|
||||
|
||||
-- https://github.com/kyazdani42/nvim-tree.lua/commit/fb8735e96cecf004fbefb086ce85371d003c5129
|
||||
vim.g.loaded = 1
|
||||
vim.g.loaded_netrwPlugin = 1
|
||||
end,
|
||||
})
|
||||
|
||||
-- Markdown pretty view
|
||||
use("ellisonleao/glow.nvim")
|
||||
|
||||
-- Hex color previews
|
||||
use({
|
||||
"norcalli/nvim-colorizer.lua",
|
||||
config = function()
|
||||
require("colorizer").setup()
|
||||
end,
|
||||
})
|
||||
end
|
||||
|
||||
return M
|
34
modules/common/neovim/lua/packer_init.lua
Normal file
34
modules/common/neovim/lua/packer_init.lua
Normal file
@ -0,0 +1,34 @@
|
||||
-- Bootstrap the Packer plugin manager
|
||||
local fn = vim.fn
|
||||
local install_path = fn.stdpath("data") .. "/site/pack/packer/start/packer.nvim"
|
||||
if fn.empty(fn.glob(install_path)) > 0 then
|
||||
PACKER_BOOTSTRAP = fn.system({
|
||||
"git",
|
||||
"clone",
|
||||
"--depth",
|
||||
"1",
|
||||
"https://github.com/wbthomason/packer.nvim",
|
||||
install_path,
|
||||
})
|
||||
end
|
||||
|
||||
require("packer").startup(function(use)
|
||||
-- Maintain plugin manager
|
||||
use("wbthomason/packer.nvim")
|
||||
|
||||
-- Include other files initialized by packer
|
||||
require("packer.speed").packer(use)
|
||||
require("packer.misc").packer(use)
|
||||
require("packer.colors").packer(use)
|
||||
require("packer.visuals").packer(use)
|
||||
require("packer.lsp").packer(use)
|
||||
require("packer.completion").packer(use)
|
||||
require("packer.syntax").packer(use)
|
||||
require("packer.telescope").packer(use)
|
||||
require("packer.toggleterm").packer(use)
|
||||
|
||||
-- Auto-install after bootstrapping
|
||||
if PACKER_BOOTSTRAP then
|
||||
require("packer").sync()
|
||||
end
|
||||
end)
|
17
modules/common/neovim/lua/settings.lua
Normal file
17
modules/common/neovim/lua/settings.lua
Normal file
@ -0,0 +1,17 @@
|
||||
-- ===========================================================================
|
||||
-- Settings
|
||||
-- ===========================================================================
|
||||
|
||||
vim.filetype.add({
|
||||
pattern = {
|
||||
[".*%.tfvars"] = "hcl",
|
||||
[".*%.tf"] = "hcl",
|
||||
},
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd("FileType", {
|
||||
pattern = "*.eml",
|
||||
callback = function()
|
||||
vim.o.wrapmargin = 79 -- Wrap text automatically
|
||||
end,
|
||||
})
|
46
modules/common/neovim/package/default.nix
Normal file
46
modules/common/neovim/package/default.nix
Normal file
@ -0,0 +1,46 @@
|
||||
# { inputs, globals, extraConfig ? [ ], ... }:
|
||||
#
|
||||
# let
|
||||
#
|
||||
# pkgs = import inputs.nixpkgs {
|
||||
# system = inputs.system;
|
||||
# overlays = [
|
||||
# (import ./modules/neovim/plugins-overlay.nix inputs)
|
||||
# inputs.nix2vim.overlay
|
||||
# ];
|
||||
# };
|
||||
#
|
||||
# in pkgs.neovimBuilder {
|
||||
# package = pkgs.neovim-unwrapped;
|
||||
# imports = [
|
||||
# ./modules/common/neovim/plugins/bufferline.nix
|
||||
# ./modules/common/neovim/plugins/completion.nix
|
||||
# ./modules/common/neovim/plugins/gitsigns.nix
|
||||
# ./modules/common/neovim/plugins/lsp.nix
|
||||
# ./modules/common/neovim/plugins/misc.nix
|
||||
# ./modules/common/neovim/plugins/statusline.nix
|
||||
# ./modules/common/neovim/plugins/syntax.nix
|
||||
# ./modules/common/neovim/plugins/telescope.nix
|
||||
# ./modules/common/neovim/plugins/toggleterm.nix
|
||||
# ./modules/common/neovim/plugins/tree.nix
|
||||
# ] ++ extraConfig;
|
||||
# }
|
||||
|
||||
{ pkgs, colors ? { }, ... }:
|
||||
|
||||
pkgs.neovimBuilder {
|
||||
package = pkgs.neovim-unwrapped;
|
||||
imports = [
|
||||
../config/bufferline.nix
|
||||
../config/completion.nix
|
||||
../config/gitsigns.nix
|
||||
../config/lsp.nix
|
||||
../config/misc.nix
|
||||
../config/statusline.nix
|
||||
../config/syntax.nix
|
||||
../config/telescope.nix
|
||||
../config/toggleterm.nix
|
||||
../config/tree.nix
|
||||
colors
|
||||
];
|
||||
}
|
12
modules/common/programming/default.nix
Normal file
12
modules/common/programming/default.nix
Normal file
@ -0,0 +1,12 @@
|
||||
{ config, pkgs, lib, ... }: {
|
||||
|
||||
imports = [
|
||||
./haskell.nix
|
||||
./kubernetes.nix
|
||||
./lua.nix
|
||||
./nix.nix
|
||||
./python.nix
|
||||
./terraform.nix
|
||||
];
|
||||
|
||||
}
|
14
modules/common/programming/haskell.nix
Normal file
14
modules/common/programming/haskell.nix
Normal file
@ -0,0 +1,14 @@
|
||||
{ config, pkgs, lib, ... }: {
|
||||
|
||||
options.haskell.enable = lib.mkEnableOption "Haskell programming language.";
|
||||
|
||||
config = lib.mkIf config.haskell.enable {
|
||||
|
||||
# Binary Cache for Haskell.nix
|
||||
nix.settings.trusted-public-keys =
|
||||
[ "hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ=" ];
|
||||
nix.settings.substituters = [ "https://cache.iog.io" ];
|
||||
|
||||
};
|
||||
|
||||
}
|
145
modules/common/programming/kubernetes.nix
Normal file
145
modules/common/programming/kubernetes.nix
Normal file
@ -0,0 +1,145 @@
|
||||
{ config, pkgs, lib, ... }: {
|
||||
|
||||
options.kubernetes.enable = lib.mkEnableOption "Kubernetes tools.";
|
||||
|
||||
config = lib.mkIf config.kubernetes.enable {
|
||||
home-manager.users.${config.user} = {
|
||||
|
||||
home.packages = with pkgs; [
|
||||
kubectl # Basic Kubernetes queries
|
||||
kubernetes-helm # Helm CLI
|
||||
fluxcd # Bootstrap clusters with Flux
|
||||
kustomize # Kustomize CLI (for Flux)
|
||||
];
|
||||
|
||||
programs.fish.shellAbbrs = {
|
||||
k = "kubectl";
|
||||
pods = "kubectl get pods -A";
|
||||
nodes = "kubectl get nodes";
|
||||
deploys = "kubectl get deployments -A";
|
||||
dash = "kube-dashboard";
|
||||
ks = "k9s";
|
||||
};
|
||||
|
||||
# Terminal Kubernetes UI
|
||||
programs.k9s = {
|
||||
enable = true;
|
||||
# settings = { k9s = { headless = true; }; };
|
||||
skin = {
|
||||
k9s = {
|
||||
body = {
|
||||
fgColor = config.theme.colors.base06;
|
||||
bgColor = config.theme.colors.base00;
|
||||
logoColor = config.theme.colors.base02; # *blue ?
|
||||
};
|
||||
# Search bar
|
||||
prompt = {
|
||||
fgColor = config.theme.colors.base06;
|
||||
bgColor = config.theme.colors.base00;
|
||||
suggestColor = config.theme.colors.base03;
|
||||
};
|
||||
# Header left side
|
||||
info = {
|
||||
fgColor = config.theme.colors.base04;
|
||||
sectionColor = config.theme.colors.base05;
|
||||
};
|
||||
dialog = {
|
||||
fgColor = config.theme.colors.base06;
|
||||
bgColor = config.theme.colors.base00;
|
||||
buttonFgColor = config.theme.colors.base06;
|
||||
buttonBgColor = config.theme.colors.base0E;
|
||||
buttonFocusFgColor = config.theme.colors.base07;
|
||||
buttonFocusBgColor = config.theme.colors.base02; # *cyan
|
||||
labelFgColor = config.theme.colors.base09;
|
||||
fieldFgColor = config.theme.colors.base06;
|
||||
};
|
||||
frame = {
|
||||
border = {
|
||||
fgColor = config.theme.colors.base01;
|
||||
focusColor = config.theme.colors.base06;
|
||||
};
|
||||
menu = {
|
||||
fgColor = config.theme.colors.base06;
|
||||
keyColor = config.theme.colors.base0E; # *magenta
|
||||
numKeyColor = config.theme.colors.base0E; # *magenta
|
||||
};
|
||||
crumbs = {
|
||||
fgColor = config.theme.colors.base06;
|
||||
bgColor = config.theme.colors.base01;
|
||||
activeColor = config.theme.colors.base03;
|
||||
};
|
||||
status = {
|
||||
newColor = config.theme.colors.base04; # *cyan
|
||||
modifyColor = config.theme.colors.base0D; # *blue
|
||||
addColor = config.theme.colors.base0B; # *green
|
||||
errorColor = config.theme.colors.base08; # *red
|
||||
highlightColor = config.theme.colors.base09; # *orange
|
||||
killColor = config.theme.colors.base03; # *comment
|
||||
completedColor = config.theme.colors.base03; # *comment
|
||||
};
|
||||
title = {
|
||||
fgColor = config.theme.colors.base06;
|
||||
bgColor = config.theme.colors.base00;
|
||||
highlightColor = config.theme.colors.base09; # *orange
|
||||
counterColor = config.theme.colors.base0D; # *blue
|
||||
filterColor = config.theme.colors.base0E; # *magenta
|
||||
};
|
||||
};
|
||||
views = {
|
||||
charts = {
|
||||
bgColor = config.theme.colors.base00;
|
||||
defaultDialColors =
|
||||
[ config.theme.colors.base0D config.theme.colors.base08 ];
|
||||
# - *blue
|
||||
# - *red
|
||||
defaultChartColors =
|
||||
[ config.theme.colors.base0D config.theme.colors.base08 ];
|
||||
# - *blue
|
||||
# - *red
|
||||
};
|
||||
table = {
|
||||
# List of resources
|
||||
fgColor = config.theme.colors.base06;
|
||||
bgColor = config.theme.colors.base00;
|
||||
|
||||
# Row selection
|
||||
cursorFgColor = config.theme.colors.base07;
|
||||
cursorBgColor = config.theme.colors.base01;
|
||||
|
||||
# Header row
|
||||
header = {
|
||||
fgColor = config.theme.colors.base0D;
|
||||
bgColor = config.theme.colors.base00;
|
||||
sorterColor = config.theme.colors.base0A; # *selection
|
||||
};
|
||||
};
|
||||
xray = {
|
||||
fgColor = config.theme.colors.base06;
|
||||
bgColor = config.theme.colors.base00;
|
||||
cursorColor = config.theme.colors.base06;
|
||||
graphicColor = config.theme.colors.base0D;
|
||||
showIcons = false;
|
||||
};
|
||||
yaml = {
|
||||
keyColor = config.theme.colors.base0D;
|
||||
colonColor = config.theme.colors.base04;
|
||||
fgColor = config.theme.colors.base03;
|
||||
};
|
||||
logs = {
|
||||
fgColor = config.theme.colors.base06;
|
||||
bgColor = config.theme.colors.base00;
|
||||
indicator = {
|
||||
fgColor = config.theme.colors.base06;
|
||||
bgColor = config.theme.colors.base00;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
}
|
12
modules/common/programming/lua.nix
Normal file
12
modules/common/programming/lua.nix
Normal file
@ -0,0 +1,12 @@
|
||||
{ config, pkgs, lib, ... }: {
|
||||
|
||||
options.lua.enable = lib.mkEnableOption "Lua programming language.";
|
||||
|
||||
config = lib.mkIf config.lua.enable {
|
||||
home-manager.users.${config.user}.home.packages = with pkgs; [
|
||||
stylua # Lua formatter
|
||||
sumneko-lua-language-server # Lua LSP
|
||||
];
|
||||
};
|
||||
|
||||
}
|
18
modules/common/programming/nix.nix
Normal file
18
modules/common/programming/nix.nix
Normal file
@ -0,0 +1,18 @@
|
||||
{ config, pkgs, lib, ... }: {
|
||||
|
||||
options.nixlang.enable = lib.mkEnableOption "Nix programming language.";
|
||||
|
||||
config = lib.mkIf config.nixlang.enable {
|
||||
|
||||
home-manager.users.${config.user} = {
|
||||
|
||||
home.packages = with pkgs; [
|
||||
nixfmt # Nix file formatter
|
||||
nil # Nix language server
|
||||
];
|
||||
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
}
|
22
modules/common/programming/python.nix
Normal file
22
modules/common/programming/python.nix
Normal file
@ -0,0 +1,22 @@
|
||||
{ config, pkgs, lib, ... }: {
|
||||
|
||||
options.python.enable = lib.mkEnableOption "Python programming language.";
|
||||
|
||||
config = lib.mkIf config.python.enable {
|
||||
|
||||
home-manager.users.${config.user} = {
|
||||
|
||||
home.packages = with pkgs; [
|
||||
# python310 # Standard Python interpreter
|
||||
nodePackages.pyright # Python language server
|
||||
black # Python formatter
|
||||
python310Packages.flake8 # Python linter
|
||||
];
|
||||
|
||||
programs.fish.shellAbbrs = { py = "python3"; };
|
||||
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
}
|
22
modules/common/programming/terraform.nix
Normal file
22
modules/common/programming/terraform.nix
Normal file
@ -0,0 +1,22 @@
|
||||
{ config, pkgs, lib, ... }: {
|
||||
|
||||
options.terraform.enable = lib.mkEnableOption "Terraform tools.";
|
||||
|
||||
config = lib.mkIf config.terraform.enable {
|
||||
|
||||
home-manager.users.${config.user} = {
|
||||
programs.fish.shellAbbrs = {
|
||||
# Terraform
|
||||
te = "terraform";
|
||||
};
|
||||
home.packages = with pkgs; [
|
||||
terraform # Terraform executable
|
||||
terraform-ls # Language server
|
||||
tflint # Linter
|
||||
];
|
||||
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
}
|
5
modules/common/repositories/default.nix
Normal file
5
modules/common/repositories/default.nix
Normal file
@ -0,0 +1,5 @@
|
||||
{ ... }: {
|
||||
|
||||
imports = [ ./dotfiles.nix ./notes.nix ];
|
||||
|
||||
}
|
30
modules/common/repositories/dotfiles.nix
Normal file
30
modules/common/repositories/dotfiles.nix
Normal file
@ -0,0 +1,30 @@
|
||||
{ config, pkgs, lib, ... }: {
|
||||
|
||||
options.dotfiles.enable = lib.mkEnableOption "Clone dotfiles.";
|
||||
|
||||
config = lib.mkIf config.dotfiles.enable {
|
||||
|
||||
home-manager.users.${config.user} = {
|
||||
|
||||
home.activation = {
|
||||
|
||||
# Always clone dotfiles repository if it doesn't exist
|
||||
cloneDotfiles =
|
||||
config.home-manager.users.${config.user}.lib.dag.entryAfter
|
||||
[ "writeBoundary" ] ''
|
||||
if [ ! -d "${config.dotfilesPath}" ]; then
|
||||
$DRY_RUN_CMD mkdir --parents $VERBOSE_ARG $(dirname "${config.dotfilesPath}")
|
||||
$DRY_RUN_CMD ${pkgs.git}/bin/git clone ${config.dotfilesRepo} "${config.dotfilesPath}"
|
||||
fi
|
||||
'';
|
||||
|
||||
};
|
||||
|
||||
# Set a variable for dotfiles repo, not necessary but convenient
|
||||
home.sessionVariables.DOTS = config.dotfilesPath;
|
||||
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
}
|
11
modules/common/repositories/notes.nix
Normal file
11
modules/common/repositories/notes.nix
Normal file
@ -0,0 +1,11 @@
|
||||
{ config, ... }: {
|
||||
|
||||
home-manager.users.${config.user} = {
|
||||
|
||||
home.sessionVariables = {
|
||||
NOTES_PATH = "${config.homePath}/dev/personal/notes/content";
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
}
|
55
modules/common/shell/bash/scripts/ocr.sh
Executable file
55
modules/common/shell/bash/scripts/ocr.sh
Executable file
@ -0,0 +1,55 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Yoinked from https://github.com/JJGO/dotfiles
|
||||
# Adapted from https://github.com/sdushantha/bin
|
||||
|
||||
set -x
|
||||
TEXT_FILE="/tmp/ocr.txt"
|
||||
IMAGE_FILE="/tmp/ocr.png"
|
||||
|
||||
function notify-send() {
|
||||
/usr/bin/osascript -e "display notification \"$2\" with title \"OCR\""
|
||||
}
|
||||
|
||||
PATH="/usr/local/bin/:$PATH"
|
||||
|
||||
# Take screenshot by selecting the area
|
||||
/usr/sbin/screencapture -i "$IMAGE_FILE"
|
||||
|
||||
# Get the exit code of the previous command.
|
||||
# So in this case, it is the screenshot command. If it did not exit with an
|
||||
# exit code 0, then it means the user canceled the process of taking a
|
||||
# screenshot by doing something like pressing the escape key
|
||||
STATUS=$?
|
||||
|
||||
# If the user pressed the escape key or did something to terminate the proccess
|
||||
# taking a screenshot, then just exit
|
||||
[ $STATUS -ne 0 ] && exit 1
|
||||
|
||||
# Do the magic (∩^o^)⊃━☆゚.*・。゚
|
||||
# Notice how I have removing the extension .txt from the file path. This is
|
||||
# because tesseract adds .txt to the given file path anyways. So if we were to
|
||||
# specify /tmp/ocr.txt as the file path, tesseract would out the text to
|
||||
# /tmp/ocr.txt.txt
|
||||
tesseract "$IMAGE_FILE" "${TEXT_FILE//\.txt/}"
|
||||
|
||||
# Check if the text was detected by checking number
|
||||
# of lines in the file
|
||||
LINES=$(wc -l <$TEXT_FILE)
|
||||
if [ "$LINES" -eq 0 ]; then
|
||||
notify-send "ocr" "no text was detected"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Copy text to clipboard
|
||||
# xclip -selection clip < "$TEXT_FILE"
|
||||
/usr/bin/pbcopy <"$TEXT_FILE"
|
||||
|
||||
# Send a notification with the text that was grabbed using OCR
|
||||
notify-send "ocr" "$(cat $TEXT_FILE)"
|
||||
|
||||
# Clean up
|
||||
# "Always leave the area better than you found it"
|
||||
# - My first grade teacher
|
||||
rm "$TEXT_FILE"
|
||||
rm "$IMAGE_FILE"
|
15
modules/common/shell/charm.nix
Normal file
15
modules/common/shell/charm.nix
Normal file
@ -0,0 +1,15 @@
|
||||
{ config, pkgs, lib, ... }: {
|
||||
|
||||
options.charm.enable = lib.mkEnableOption "Charm utilities.";
|
||||
|
||||
config.home-manager.users.${config.user} = lib.mkIf config.charm.enable {
|
||||
|
||||
home.packages = with pkgs; [
|
||||
glow # Markdown previews
|
||||
skate # Key-value store
|
||||
charm # Manage account and filesystem
|
||||
];
|
||||
|
||||
};
|
||||
|
||||
}
|
13
modules/common/shell/default.nix
Normal file
13
modules/common/shell/default.nix
Normal file
@ -0,0 +1,13 @@
|
||||
{ ... }: {
|
||||
imports = [
|
||||
./charm.nix
|
||||
./direnv.nix
|
||||
./fish
|
||||
./fzf.nix
|
||||
./git.nix
|
||||
./github.nix
|
||||
./nixpkgs.nix
|
||||
./starship.nix
|
||||
./utilities.nix
|
||||
];
|
||||
}
|
9
modules/common/shell/direnv.nix
Normal file
9
modules/common/shell/direnv.nix
Normal file
@ -0,0 +1,9 @@
|
||||
{ config, ... }: {
|
||||
|
||||
home-manager.users.${config.user}.programs.direnv = {
|
||||
enable = true;
|
||||
nix-direnv.enable = true;
|
||||
config = { whitelist = { prefix = [ config.dotfilesPath ]; }; };
|
||||
};
|
||||
|
||||
}
|
131
modules/common/shell/fish/default.nix
Normal file
131
modules/common/shell/fish/default.nix
Normal file
@ -0,0 +1,131 @@
|
||||
{ config, pkgs, lib, ... }: {
|
||||
|
||||
users.users.${config.user}.shell = pkgs.fish;
|
||||
programs.fish.enable =
|
||||
true; # Needed for LightDM to remember username (TODO: fix)
|
||||
|
||||
home-manager.users.${config.user} = {
|
||||
|
||||
# Packages used in abbreviations and aliases
|
||||
home.packages = with pkgs; [ curl exa ];
|
||||
|
||||
programs.fish = {
|
||||
enable = true;
|
||||
shellAliases = { ls = "exa"; };
|
||||
functions = {
|
||||
commandline-git-commits = {
|
||||
description = "Insert commit into commandline";
|
||||
body = builtins.readFile ./functions/commandline-git-commits.fish;
|
||||
};
|
||||
copy = {
|
||||
description = "Copy file contents into clipboard";
|
||||
body = "cat $argv | pbcopy"; # Need to fix for non-macOS
|
||||
};
|
||||
edit = {
|
||||
description = "Open a file in Vim";
|
||||
body = builtins.readFile ./functions/edit.fish;
|
||||
};
|
||||
envs = {
|
||||
description = "Evaluate a bash-like environment variables file";
|
||||
body = ''set -gx (cat $argv | tr "=" " " | string split ' ')'';
|
||||
};
|
||||
fcd = {
|
||||
description = "Jump to directory";
|
||||
argumentNames = "directory";
|
||||
body = builtins.readFile ./functions/fcd.fish;
|
||||
};
|
||||
fish_user_key_bindings = {
|
||||
body = builtins.readFile ./functions/fish_user_key_bindings.fish;
|
||||
};
|
||||
ip = { body = builtins.readFile ./functions/ip.fish; };
|
||||
json = {
|
||||
description = "Tidy up JSON using jq";
|
||||
body = "pbpaste | jq '.' | pbcopy"; # Need to fix for non-macOS
|
||||
};
|
||||
note = {
|
||||
description = "Edit or create a note";
|
||||
argumentNames = "filename";
|
||||
body = builtins.readFile ./functions/note.fish;
|
||||
};
|
||||
recent = {
|
||||
description = "Open a recent file in Vim";
|
||||
body = builtins.readFile ./functions/recent.fish;
|
||||
};
|
||||
search-and-edit = {
|
||||
description = "Search and open the relevant file in Vim";
|
||||
body = builtins.readFile ./functions/search-and-edit.fish;
|
||||
};
|
||||
syncnotes = {
|
||||
description = "Full git commit on notes";
|
||||
body = builtins.readFile ./functions/syncnotes.fish;
|
||||
};
|
||||
};
|
||||
interactiveShellInit = ''
|
||||
fish_vi_key_bindings
|
||||
bind yy fish_clipboard_copy
|
||||
bind Y fish_clipboard_copy
|
||||
bind -M visual y fish_clipboard_copy
|
||||
bind -M default p fish_clipboard_paste
|
||||
set -g fish_vi_force_cursor
|
||||
set -g fish_cursor_default block
|
||||
set -g fish_cursor_insert line
|
||||
set -g fish_cursor_visual block
|
||||
set -g fish_cursor_replace_one underscore
|
||||
'';
|
||||
loginShellInit = "";
|
||||
shellAliases = { };
|
||||
shellAbbrs = {
|
||||
|
||||
# Directory aliases
|
||||
l = "ls -lh";
|
||||
lh = "ls -lh";
|
||||
ll = "ls -alhF";
|
||||
la = "ls -a";
|
||||
c = "cd";
|
||||
"-" = "cd -";
|
||||
mkd = "mkdir -pv";
|
||||
|
||||
# System
|
||||
s = "sudo";
|
||||
sc = "systemctl";
|
||||
scs = "systemctl status";
|
||||
m = "make";
|
||||
|
||||
# Vim (overwritten by Neovim)
|
||||
v = "vim";
|
||||
vl = "vim -c 'normal! `0'";
|
||||
|
||||
# Notes
|
||||
sn = "syncnotes";
|
||||
|
||||
# Fun CLI Tools
|
||||
weather = "curl wttr.in/$WEATHER_CITY";
|
||||
moon = "curl wttr.in/Moon";
|
||||
|
||||
# Cheat Sheets
|
||||
ssl =
|
||||
"openssl req -new -newkey rsa:2048 -nodes -keyout server.key -out server.csr";
|
||||
fingerprint = "ssh-keyscan myhost.com | ssh-keygen -lf -";
|
||||
publickey = "ssh-keygen -y -f ~/.ssh/id_rsa > ~/.ssh/id_rsa.pub";
|
||||
forloop = "for i in (seq 1 100)";
|
||||
|
||||
# Docker
|
||||
dc = "$DOTS/bin/docker_cleanup";
|
||||
dr = "docker run --rm -it";
|
||||
db = "docker build . -t";
|
||||
|
||||
# Rust
|
||||
ca = "cargo";
|
||||
|
||||
};
|
||||
shellInit = "";
|
||||
};
|
||||
|
||||
home.sessionVariables.fish_greeting = "";
|
||||
|
||||
programs.starship.enableFishIntegration = true;
|
||||
programs.zoxide.enableFishIntegration = true;
|
||||
programs.fzf.enableFishIntegration = true;
|
||||
|
||||
};
|
||||
}
|
@ -0,0 +1,6 @@
|
||||
set commit (git-commits)
|
||||
if [ $commit ]
|
||||
commandline -i "$commit"
|
||||
else
|
||||
commandline -i HEAD
|
||||
end
|
4
modules/common/shell/fish/functions/edit.fish
Normal file
4
modules/common/shell/fish/functions/edit.fish
Normal file
@ -0,0 +1,4 @@
|
||||
set vimfile (fzf)
|
||||
and set vimfile (echo $vimfile | tr -d '\r')
|
||||
and commandline -r "vim $vimfile"
|
||||
and commandline -f execute
|
10
modules/common/shell/fish/functions/fcd.fish
Normal file
10
modules/common/shell/fish/functions/fcd.fish
Normal file
@ -0,0 +1,10 @@
|
||||
if test -z $directory
|
||||
set directory "$HOME"
|
||||
end
|
||||
if ! test -d $directory
|
||||
echo "Directory not found: $directory"
|
||||
return 1
|
||||
end
|
||||
set jump (fd -t d . $directory | fzf)
|
||||
and cd $jump $argv
|
||||
and commandline -f execute
|
@ -0,0 +1,20 @@
|
||||
bind -M insert \co edit
|
||||
bind -M default \co edit
|
||||
bind -M insert \cs search-and-edit
|
||||
bind -M default \cs search-and-edit
|
||||
bind -M insert \ca 'cd ~; and edit; and commandline -a "; cd -"; commandline -f execute'
|
||||
bind -M default \ca 'cd ~; and edit; and commandline -a "; cd -"; commandline -f execute'
|
||||
bind -M insert \ce recent
|
||||
bind -M default \ce recent
|
||||
bind -M default \cg commandline-git-commits
|
||||
bind -M insert \cg 'commandline -i (git rev-parse --show-toplevel 2>/dev/null || echo ".")'
|
||||
bind -M insert \cf fcd
|
||||
bind -M default \cf fcd
|
||||
bind -M insert \cp projects
|
||||
bind -M default \cp projects
|
||||
bind -M insert \x1F accept-autosuggestion
|
||||
bind -M default \x1F accept-autosuggestion
|
||||
bind -M insert \cn 'commandline -r "nix run nixpkgs#"'
|
||||
bind -M default \cn 'commandline -r "nix run nixpkgs#"'
|
||||
bind -M insert \x11F nix-fzf
|
||||
bind -M default \x11F nix-fzf
|
122
modules/common/shell/fish/functions/fish_vi_cursor.fish
Normal file
122
modules/common/shell/fish/functions/fish_vi_cursor.fish
Normal file
@ -0,0 +1,122 @@
|
||||
#!/usr/local/bin/fish
|
||||
|
||||
function fish_vi_cursor -d 'Set cursor shape for different vi modes'
|
||||
# If we're not interactive, there is effectively no bind mode.
|
||||
if not status is-interactive
|
||||
return
|
||||
end
|
||||
|
||||
# This is hard to test in expect, since the exact sequences depend on the environment.
|
||||
# Instead disable it.
|
||||
if set -q FISH_UNIT_TESTS_RUNNING
|
||||
return
|
||||
end
|
||||
|
||||
# If this variable is set, skip all checks
|
||||
if not set -q fish_vi_force_cursor
|
||||
|
||||
# Emacs Makes All Cursors Suck
|
||||
if set -q INSIDE_EMACS
|
||||
return
|
||||
end
|
||||
|
||||
# vte-based terms set $TERM = xterm*, but only gained support in 2015.
|
||||
# From https://bugzilla.gnome.org/show_bug.cgi?id=720821, it appears it was version 0.40.0
|
||||
if set -q VTE_VERSION
|
||||
and test "$VTE_VERSION" -lt 4000 2>/dev/null
|
||||
return
|
||||
end
|
||||
|
||||
# Similarly, genuine XTerm can do it since v280.
|
||||
if set -q XTERM_VERSION
|
||||
and not test (string replace -r "XTerm\((\d+)\)" '$1' -- "$XTERM_VERSION") -ge 280 2>/dev/null
|
||||
return
|
||||
end
|
||||
|
||||
# We need one of these terms.
|
||||
# It would be lovely if we could rely on terminfo, but:
|
||||
# - The "Ss" entry isn't a thing in macOS' old and crusty terminfo
|
||||
# - It is set for xterm, and everyone and their dog claims to be xterm
|
||||
#
|
||||
# So we just don't care about $TERM, unless it is one of the few terminals that actually have their own entry.
|
||||
#
|
||||
# Note: Previous versions also checked $TMUX, and made sure that then $TERM was screen* or tmux*.
|
||||
# We don't care, since we *cannot* handle term-in-a-terms 100% correctly.
|
||||
if not set -q KONSOLE_PROFILE_NAME
|
||||
and not test -n "$KONSOLE_VERSION" -a "$KONSOLE_VERSION" -ge 200400 # konsole, but new.
|
||||
and not set -q ITERM_PROFILE
|
||||
and not set -q VTE_VERSION # which version is already checked above
|
||||
and not set -q WT_PROFILE_ID
|
||||
and not set -q XTERM_VERSION
|
||||
and not string match -rq '^st(-.*)$' -- $TERM
|
||||
and not string match -q 'xterm-kitty*' -- $TERM
|
||||
and not string match -q 'rxvt*' -- $TERM
|
||||
and not string match -q 'alacritty*' -- $TERM
|
||||
return
|
||||
end
|
||||
|
||||
# HACK: Explicitly disable on ITERM because of #3696, which is weirdness with multi-line prompts.
|
||||
# --force-iterm is now deprecated; set $fish_vi_force_cursor instead
|
||||
if contains -- $argv[1] --force-iterm
|
||||
set -e argv[1]
|
||||
else if set -q ITERM_PROFILE
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
set -l terminal $argv[1]
|
||||
set -q terminal[1]
|
||||
or set terminal auto
|
||||
|
||||
set -l function
|
||||
switch "$terminal"
|
||||
case auto
|
||||
# Nowadays, konsole does not set $KONSOLE_PROFILE_NAME anymore,
|
||||
# and it uses the xterm sequences.
|
||||
if set -q KONSOLE_PROFILE_NAME
|
||||
set function __fish_cursor_konsole
|
||||
else if set -q ITERM_PROFILE
|
||||
set function __fish_cursor_1337
|
||||
else
|
||||
set function __fish_cursor_xterm
|
||||
end
|
||||
case konsole
|
||||
set function __fish_cursor_konsole
|
||||
case xterm
|
||||
set function __fish_cursor_xterm
|
||||
end
|
||||
|
||||
set -l tmux_prefix
|
||||
set -l tmux_postfix
|
||||
if set -q TMUX
|
||||
set tmux_prefix echo -ne "'\ePtmux;\e'"
|
||||
set tmux_postfix echo -ne "'\e\\\\'"
|
||||
end
|
||||
|
||||
set -q fish_cursor_unknown
|
||||
or set -g fish_cursor_unknown block blink
|
||||
|
||||
echo "
|
||||
function fish_vi_cursor_handle --on-variable fish_bind_mode --on-event fish_postexec --on-event fish_focus_in
|
||||
set -l varname fish_cursor_\$fish_bind_mode
|
||||
if not set -q \$varname
|
||||
set varname fish_cursor_unknown
|
||||
end
|
||||
$tmux_prefix
|
||||
$function \$\$varname
|
||||
$tmux_postfix
|
||||
end
|
||||
" | source
|
||||
|
||||
echo "
|
||||
function fish_vi_cursor_handle_preexec --on-event fish_preexec
|
||||
set -l varname fish_cursor_default
|
||||
if not set -q \$varname
|
||||
set varname fish_cursor_unknown
|
||||
end
|
||||
$tmux_prefix
|
||||
$function \$\$varname
|
||||
$tmux_postfix
|
||||
end
|
||||
" | source
|
||||
end
|
14
modules/common/shell/fish/functions/git-add-fuzzy.fish
Normal file
14
modules/common/shell/fish/functions/git-add-fuzzy.fish
Normal file
@ -0,0 +1,14 @@
|
||||
set gitfile (git status -s \
|
||||
| fzf \
|
||||
--height 50% \
|
||||
-m \
|
||||
--preview-window right:70% \
|
||||
--layout reverse \
|
||||
--preview 'set -l IFS; set gd (git diff --color=always (echo {} | awk \'{$1=$1};1\' | cut -d" " -f2)); if test "$gd"; echo "$gd"; else; bat --color=always (echo {} | awk \'{$1=$1};1\' | cut -d" " -f2); end')
|
||||
and for gf in $gitfile
|
||||
set gf (echo $gf \
|
||||
| awk '{$1=$1};1' \
|
||||
| cut -d' ' -f2 \
|
||||
)
|
||||
and git add $gf
|
||||
end
|
8
modules/common/shell/fish/functions/git-commits.fish
Normal file
8
modules/common/shell/fish/functions/git-commits.fish
Normal file
@ -0,0 +1,8 @@
|
||||
set commitline (git log \
|
||||
--pretty="format:%C(auto)%ar %h%d %s" \
|
||||
| fzf \
|
||||
--height 50% \
|
||||
--preview 'git show --color=always (echo {} | cut -d" " -f4)' \
|
||||
)
|
||||
and set commit (echo $commitline | cut -d" " -f4)
|
||||
and echo $commit
|
10
modules/common/shell/fish/functions/git-fuzzy-branch.fish
Normal file
10
modules/common/shell/fish/functions/git-fuzzy-branch.fish
Normal file
@ -0,0 +1,10 @@
|
||||
set -l current (git rev-parse --abbrev-ref HEAD | tr -d '\n')
|
||||
set -l branch (git branch \
|
||||
--format "%(refname:short)" \
|
||||
| fzf \
|
||||
--height 50% \
|
||||
--header="On $current, $header" \
|
||||
--preview-window right:70% \
|
||||
--preview 'git log {} --color=always --pretty="format:%C(auto)%ar %h%d %s"' \
|
||||
)
|
||||
and echo $branch
|
14
modules/common/shell/fish/functions/git-history.fish
Normal file
14
modules/common/shell/fish/functions/git-history.fish
Normal file
@ -0,0 +1,14 @@
|
||||
if not count $argv >/dev/null
|
||||
echo "Must provide filename."
|
||||
return 1
|
||||
end
|
||||
set commitline ( git log \
|
||||
--follow \
|
||||
--pretty="format:%C(auto)%ar %h%d %s" \
|
||||
-- ./$argv \
|
||||
| fzf \
|
||||
--height 100% \
|
||||
--preview "git diff --color=always (echo {} | cut -d' ' -f4)^1..(echo {} | cut -d' ' -f4) -- ./$argv" \
|
||||
)
|
||||
and set commit (echo $commitline | cut -d" " -f4)
|
||||
and echo $commit
|
@ -0,0 +1,4 @@
|
||||
set -l branch (git branch 2>/dev/null | grep '^\*' | colrm 1 2)
|
||||
and set -l command "git push --set-upstream origin $branch"
|
||||
and commandline -r $command
|
||||
and commandline -f execute
|
6
modules/common/shell/fish/functions/git-show-fuzzy.fish
Normal file
6
modules/common/shell/fish/functions/git-show-fuzzy.fish
Normal file
@ -0,0 +1,6 @@
|
||||
set commitline (git log \
|
||||
--pretty="format:%C(auto)%ar %h%d %s" \
|
||||
| fzf \
|
||||
)
|
||||
and set commit (echo $commitline | cut -d" " -f4 )
|
||||
and git show $commit
|
37
modules/common/shell/fish/functions/git.fish
Normal file
37
modules/common/shell/fish/functions/git.fish
Normal file
@ -0,0 +1,37 @@
|
||||
if contains f $argv
|
||||
switch $argv[1]
|
||||
case checkout
|
||||
git-checkout-fuzzy
|
||||
case add
|
||||
git-add-fuzzy
|
||||
case show
|
||||
git-show-fuzzy
|
||||
case merge
|
||||
git-merge-fuzzy
|
||||
case branch
|
||||
if test "$argv[2]" = -d
|
||||
git-delete-fuzzy
|
||||
else if test "$argv[2]" = -D
|
||||
git-force-delete-fuzzy
|
||||
else
|
||||
echo "Not a fuzzy option."
|
||||
return 1
|
||||
end
|
||||
case reset
|
||||
set commit (git-commits)
|
||||
and if test "$argv[2]" = --hard
|
||||
git reset --hard $commit
|
||||
else
|
||||
git reset $commit
|
||||
end
|
||||
case "*"
|
||||
echo "No fuzzy option."
|
||||
return 1
|
||||
end
|
||||
else
|
||||
if count $argv >/dev/null
|
||||
command git $argv
|
||||
else
|
||||
command git status -sb
|
||||
end
|
||||
end
|
5
modules/common/shell/fish/functions/ip.fish
Normal file
5
modules/common/shell/fish/functions/ip.fish
Normal file
@ -0,0 +1,5 @@
|
||||
if count $argv >/dev/null
|
||||
curl ipinfo.io/$argv
|
||||
else
|
||||
curl checkip.amazonaws.com
|
||||
end
|
8
modules/common/shell/fish/functions/note.fish
Normal file
8
modules/common/shell/fish/functions/note.fish
Normal file
@ -0,0 +1,8 @@
|
||||
if test -n "$filename"
|
||||
vim $NOTES_PATH/$filename.md
|
||||
else
|
||||
set file (ls $NOTES_PATH | fzf)
|
||||
if [ $status -eq 0 ]
|
||||
vim $NOTES_PATH/$file
|
||||
end
|
||||
end
|
4
modules/common/shell/fish/functions/recent.fish
Normal file
4
modules/common/shell/fish/functions/recent.fish
Normal file
@ -0,0 +1,4 @@
|
||||
set vimfile (fd -t f --exec /usr/bin/stat -f "%m%t%N" | sort -nr | cut -f2 | fzf)
|
||||
and set vimfile (echo $vimfile | tr -d '\r')
|
||||
and commandline -r "vim $vimfile"
|
||||
and commandline -f execute
|
21
modules/common/shell/fish/functions/search-and-edit.fish
Normal file
21
modules/common/shell/fish/functions/search-and-edit.fish
Normal file
@ -0,0 +1,21 @@
|
||||
set vimfile ( \
|
||||
rg \
|
||||
--color=always \
|
||||
--line-number \
|
||||
--no-heading \
|
||||
--smart-case \
|
||||
--iglob "!/Library/**" \
|
||||
--iglob "!/System/**" \
|
||||
--iglob "!Users/$HOME/Library/*" \
|
||||
".*" \
|
||||
| fzf --ansi \
|
||||
--height "80%" \
|
||||
--color "hl:-1:underline,hl+:-1:underline:reverse" \
|
||||
--delimiter : \
|
||||
--preview 'bat --color=always {1} --highlight-line {2}' \
|
||||
--preview-window 'up,60%,border-bottom,+{2}+3/3,~3'
|
||||
)
|
||||
and set line_number (echo $vimfile | tr -d '\r' | cut -d':' -f2)
|
||||
and set vimfile (echo $vimfile | tr -d '\r' | cut -d':' -f1)
|
||||
and commandline -r "vim +$line_number $vimfile"
|
||||
and commandline -f execute
|
7
modules/common/shell/fish/functions/syncnotes.fish
Normal file
7
modules/common/shell/fish/functions/syncnotes.fish
Normal file
@ -0,0 +1,7 @@
|
||||
set current_dir $PWD
|
||||
cd $NOTES_PATH
|
||||
git pull
|
||||
git add -A
|
||||
git commit -m autosync
|
||||
git push
|
||||
cd $current_dir
|
9
modules/common/shell/fish/functions/uncommitted.fish
Normal file
9
modules/common/shell/fish/functions/uncommitted.fish
Normal file
@ -0,0 +1,9 @@
|
||||
echo "Searching git repos..." >&2
|
||||
find "$HOME/dev" -type d -name '.git' | while read dir
|
||||
set fullPath (dirname "$dir")
|
||||
set relativePath (echo "$fullPath" | cut -d'/' -f5-)
|
||||
if test -n (echo (git -C "$fullPath" status -s))
|
||||
echo "$relativePath"
|
||||
git -C "$fullPath" status -s
|
||||
end
|
||||
end
|
41
modules/common/shell/fzf.nix
Normal file
41
modules/common/shell/fzf.nix
Normal file
@ -0,0 +1,41 @@
|
||||
{ config, ... }: {
|
||||
|
||||
home-manager.users.${config.user} = {
|
||||
|
||||
programs.fzf.enable = true;
|
||||
|
||||
programs.fish = {
|
||||
functions = {
|
||||
projects = {
|
||||
description = "Jump to a project";
|
||||
body = ''
|
||||
set projdir ( \
|
||||
fd \
|
||||
--search-path $HOME/dev \
|
||||
--type directory \
|
||||
--hidden \
|
||||
"^.git\$" \
|
||||
| xargs dirname \
|
||||
| fzf \
|
||||
--delimiter '/' \
|
||||
--with-nth 6.. \
|
||||
)
|
||||
and cd $projdir
|
||||
and commandline -f execute
|
||||
'';
|
||||
};
|
||||
};
|
||||
shellAbbrs = { lsf = "ls -lh | fzf"; };
|
||||
};
|
||||
|
||||
# Global fzf configuration
|
||||
home.sessionVariables = let fzfCommand = "fd --type file";
|
||||
in {
|
||||
FZF_DEFAULT_COMMAND = fzfCommand;
|
||||
FZF_CTRL_T_COMMAND = fzfCommand;
|
||||
FZF_DEFAULT_OPTS = "-m --height 50% --border";
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
}
|
129
modules/common/shell/git.nix
Normal file
129
modules/common/shell/git.nix
Normal file
@ -0,0 +1,129 @@
|
||||
{ config, pkgs, lib, ... }:
|
||||
|
||||
let home-packages = config.home-manager.users.${config.user}.home.packages;
|
||||
|
||||
in {
|
||||
|
||||
options = {
|
||||
gitName = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
description = "Name to use for git commits";
|
||||
};
|
||||
gitEmail = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
description = "Email to use for git commits";
|
||||
};
|
||||
};
|
||||
|
||||
config = {
|
||||
|
||||
home-manager.users.root.programs.git = {
|
||||
enable = true;
|
||||
extraConfig.safe.directory = config.dotfilesPath;
|
||||
};
|
||||
|
||||
home-manager.users.${config.user} = {
|
||||
programs.git = {
|
||||
enable = true;
|
||||
userName = config.gitName;
|
||||
userEmail = config.gitEmail;
|
||||
extraConfig = {
|
||||
pager = { branch = "false"; };
|
||||
safe = { directory = config.dotfilesPath; };
|
||||
pull = { ff = "only"; };
|
||||
init = { defaultBranch = "master"; };
|
||||
};
|
||||
ignores = [ ".direnv/**" "result" ];
|
||||
};
|
||||
|
||||
programs.fish.shellAbbrs = {
|
||||
g = "git";
|
||||
gs = "git status";
|
||||
gd = "git diff";
|
||||
gds = "git diff --staged";
|
||||
gdp = "git diff HEAD^";
|
||||
ga = "git add";
|
||||
gaa = "git add -A";
|
||||
gac = "git commit -am";
|
||||
gc = "git commit -m";
|
||||
gca = "git commit --amend --no-edit";
|
||||
gcae = "git commit --amend";
|
||||
gu = "git pull";
|
||||
gp = "git push";
|
||||
gpp = "git-push-upstream";
|
||||
gl = "git log --graph --decorate --oneline -20";
|
||||
gll = "git log --graph --decorate --oneline";
|
||||
gco = "git checkout";
|
||||
gcom = ''
|
||||
git switch (git symbolic-ref refs/remotes/origin/HEAD | cut -d"/" -f4)'';
|
||||
gcob = "git switch -c";
|
||||
gb = "git branch";
|
||||
gbd = "git branch -d";
|
||||
gbD = "git branch -D";
|
||||
gr = "git reset";
|
||||
grh = "git reset --hard";
|
||||
gm = "git merge";
|
||||
gcp = "git cherry-pick";
|
||||
cdg = "cd (git rev-parse --show-toplevel)";
|
||||
};
|
||||
|
||||
# Required for fish commands
|
||||
home.packages = with pkgs; [ fish fzf bat ];
|
||||
|
||||
programs.fish.functions = lib.mkIf (builtins.elem pkgs.fzf home-packages
|
||||
&& builtins.elem pkgs.bat home-packages) {
|
||||
git = { body = builtins.readFile ./fish/functions/git.fish; };
|
||||
git-add-fuzzy = {
|
||||
body = builtins.readFile ./fish/functions/git-add-fuzzy.fish;
|
||||
};
|
||||
git-fuzzy-branch = {
|
||||
argumentNames = "header";
|
||||
body = builtins.readFile ./fish/functions/git-fuzzy-branch.fish;
|
||||
};
|
||||
git-checkout-fuzzy = {
|
||||
body = ''
|
||||
set branch (git-fuzzy-branch "checkout branch...")
|
||||
and git checkout $branch
|
||||
'';
|
||||
};
|
||||
git-delete-fuzzy = {
|
||||
body = ''
|
||||
set branch (git-fuzzy-branch "delete branch...")
|
||||
and git branch -d $branch
|
||||
'';
|
||||
};
|
||||
git-force-delete-fuzzy = {
|
||||
body = ''
|
||||
set branch (git-fuzzy-branch "force delete branch...")
|
||||
and git branch -D $branch
|
||||
'';
|
||||
};
|
||||
git-merge-fuzzy = {
|
||||
body = ''
|
||||
set branch (git-fuzzy-branch "merge from...")
|
||||
and git merge $branch
|
||||
'';
|
||||
};
|
||||
git-show-fuzzy = {
|
||||
body = builtins.readFile ./fish/functions/git-show-fuzzy.fish;
|
||||
};
|
||||
git-commits = {
|
||||
body = builtins.readFile ./fish/functions/git-commits.fish;
|
||||
};
|
||||
git-history = {
|
||||
body = builtins.readFile ./fish/functions/git-history.fish;
|
||||
};
|
||||
git-push-upstream = {
|
||||
description = "Create upstream branch";
|
||||
body = builtins.readFile ./fish/functions/git-push-upstream.fish;
|
||||
};
|
||||
uncommitted = {
|
||||
description = "Find uncommitted git repos";
|
||||
body = builtins.readFile ./fish/functions/uncommitted.fish;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
}
|
77
modules/common/shell/github.nix
Normal file
77
modules/common/shell/github.nix
Normal file
@ -0,0 +1,77 @@
|
||||
{ config, pkgs, lib, ... }: {
|
||||
|
||||
home-manager.users.${config.user} = {
|
||||
|
||||
programs.gh =
|
||||
lib.mkIf config.home-manager.users.${config.user}.programs.git.enable {
|
||||
enable = true;
|
||||
enableGitCredentialHelper = true;
|
||||
settings.git_protocol = "https";
|
||||
};
|
||||
|
||||
programs.fish =
|
||||
lib.mkIf config.home-manager.users.${config.user}.programs.gh.enable {
|
||||
shellAbbrs = {
|
||||
ghr = "gh repo view -w";
|
||||
gha =
|
||||
"gh run list | head -1 | awk '{ print $(NF-2) }' | xargs gh run view";
|
||||
grw = "gh run watch";
|
||||
grf = "gh run view --log-failed";
|
||||
grl = "gh run view --log";
|
||||
ghpr = "gh pr create && sleep 3 && gh run watch";
|
||||
};
|
||||
functions = {
|
||||
repos = {
|
||||
description = "Clone GitHub repositories";
|
||||
argumentNames = "organization";
|
||||
body = ''
|
||||
set directory (gh-repos $organization)
|
||||
and cd $directory
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
home.packages = [
|
||||
(pkgs.writeShellScriptBin "gh-repos" ''
|
||||
case $1 in
|
||||
t2) organization="take-two" ;;
|
||||
d2c) organization="take-two-t2gp" ;;
|
||||
t2gp) organization="take-two-t2gp" ;;
|
||||
pd) organization="private-division" ;;
|
||||
dots) organization="playdots" ;;
|
||||
*) organization="nmasur" ;;
|
||||
esac
|
||||
|
||||
selected=$(gh repo list "$organization" \
|
||||
--limit 50 \
|
||||
--no-archived \
|
||||
--json=name,description,isPrivate,updatedAt,primaryLanguage \
|
||||
| jq -r '.[] | .name + "," + if .description == "" then "-" else .description |= gsub(","; " ") | .description end + "," + .updatedAt + "," + .primaryLanguage.name' \
|
||||
| (echo "REPO,DESCRIPTION,UPDATED,LANGUAGE"; cat -) \
|
||||
| column -s , -t \
|
||||
| fzf \
|
||||
--header-lines=1 \
|
||||
--layout=reverse \
|
||||
--bind "ctrl-o:execute:gh repo view -w ''${organization}/{1}" \
|
||||
--bind "shift-up:preview-half-page-up" \
|
||||
--bind "shift-down:preview-half-page-down" \
|
||||
--preview "GH_FORCE_TTY=49% gh repo view ''${organization}/{1} | glow -" \
|
||||
--preview-window up
|
||||
)
|
||||
[ -n "''${selected}" ] && {
|
||||
directory="$HOME/dev/work"
|
||||
if [ $organization = "nmasur" ]; then directory="$HOME/dev/personal"; fi
|
||||
repo=$(echo "''${selected}" | awk '{print $1}')
|
||||
repo_full="''${organization}/''${repo}"
|
||||
if [ ! -d "''${directory}/''${repo}" ]; then
|
||||
gh repo clone "$repo_full" "''${directory}/''${repo}"
|
||||
fi
|
||||
echo "''${directory}/''${repo}"
|
||||
}
|
||||
'')
|
||||
];
|
||||
|
||||
};
|
||||
|
||||
}
|
72
modules/common/shell/nixpkgs.nix
Normal file
72
modules/common/shell/nixpkgs.nix
Normal file
@ -0,0 +1,72 @@
|
||||
{ config, pkgs, lib, ... }: {
|
||||
home-manager.users.${config.user} = {
|
||||
|
||||
programs.fish = {
|
||||
shellAbbrs = {
|
||||
n = "nix";
|
||||
ns = "nix-shell -p";
|
||||
nsf = "nix-shell --run fish -p";
|
||||
nsr = "nix-shell-run";
|
||||
nps = "nix repl '<nixpkgs>'";
|
||||
nixo = "man configuration.nix";
|
||||
nixh = "man home-configuration.nix";
|
||||
nr = "rebuild-nixos";
|
||||
nro = "rebuild-nixos offline";
|
||||
hm = "rebuild-home";
|
||||
};
|
||||
functions = {
|
||||
nix-shell-run = {
|
||||
body = ''
|
||||
set program $argv[1]
|
||||
if test (count $argv) -ge 2
|
||||
commandline -r "nix run nixpkgs#$program -- $argv[2..-1]"
|
||||
else
|
||||
commandline -r "nix run nixpkgs#$program"
|
||||
end
|
||||
commandline -f execute
|
||||
'';
|
||||
};
|
||||
nix-fzf = {
|
||||
body = ''
|
||||
commandline -i (nix-instantiate --eval --json \
|
||||
-E 'builtins.attrNames (import <nixpkgs> {})' \
|
||||
| jq '.[]' -r | fzf)
|
||||
commandline -f repaint
|
||||
'';
|
||||
};
|
||||
rebuild-nixos = {
|
||||
body = ''
|
||||
if test "$argv[1]" = "offline"
|
||||
set option "--option substitute false"
|
||||
end
|
||||
git -C ${config.dotfilesPath} add --intent-to-add --all
|
||||
commandline -r "doas nixos-rebuild switch $option --flake ${config.dotfilesPath}#${config.networking.hostName}"
|
||||
commandline --function execute
|
||||
'';
|
||||
};
|
||||
rebuild-home = {
|
||||
body = ''
|
||||
git -C ${config.dotfilesPath} add --intent-to-add --all
|
||||
commandline -r "${pkgs.home-manager}/bin/home-manager switch --flake ${config.dotfilesPath}#${config.networking.hostName}";
|
||||
commandline --function execute
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
# Provides "command-not-found" options
|
||||
programs.nix-index = {
|
||||
enable = true;
|
||||
enableFishIntegration = true;
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
nix = {
|
||||
|
||||
# Set channel to flake packages, used for nix-shell commands
|
||||
nixPath = [ "nixpkgs=${pkgs.path}" ];
|
||||
|
||||
};
|
||||
|
||||
}
|
63
modules/common/shell/starship.nix
Normal file
63
modules/common/shell/starship.nix
Normal file
@ -0,0 +1,63 @@
|
||||
{ config, lib, ... }: {
|
||||
|
||||
home-manager.users.${config.user}.programs.starship = {
|
||||
enable = true;
|
||||
settings = {
|
||||
add_newline = false; # Don't print new line at the start of the prompt
|
||||
format = lib.concatStrings [
|
||||
"$directory"
|
||||
"$git_branch"
|
||||
"$git_commit"
|
||||
"$git_status"
|
||||
"$hostname"
|
||||
"$cmd_duration"
|
||||
"$character"
|
||||
];
|
||||
right_format = "$nix_shell";
|
||||
character = {
|
||||
success_symbol = "[❯](bold green)";
|
||||
error_symbol = "[❯](bold red)";
|
||||
vicmd_symbol = "[❮](bold green)";
|
||||
};
|
||||
cmd_duration = {
|
||||
min_time = 5000;
|
||||
show_notifications = true;
|
||||
min_time_to_notify = 30000;
|
||||
format = "[$duration]($style) ";
|
||||
};
|
||||
directory = {
|
||||
truncate_to_repo = true;
|
||||
truncation_length = 100;
|
||||
};
|
||||
git_branch = { format = "[$symbol$branch]($style)"; };
|
||||
git_commit = {
|
||||
format = "( @ [$hash]($style) )";
|
||||
only_detached = false;
|
||||
};
|
||||
git_status = {
|
||||
format = "([$all_status$ahead_behind]($style) )";
|
||||
conflicted = "=";
|
||||
ahead = "⇡";
|
||||
behind = "⇣";
|
||||
diverged = "⇕";
|
||||
untracked = "⋄";
|
||||
stashed = "⩮";
|
||||
modified = "∽";
|
||||
staged = "+";
|
||||
renamed = "»";
|
||||
deleted = "✘";
|
||||
style = "red";
|
||||
};
|
||||
hostname = {
|
||||
ssh_only = true;
|
||||
format = "on [$hostname](bold red) ";
|
||||
};
|
||||
nix_shell = {
|
||||
format = "[$symbol $name]($style)";
|
||||
symbol = "❄️";
|
||||
};
|
||||
python = { format = "[\${version}\\(\${virtualenv}\\)]($style)"; };
|
||||
};
|
||||
};
|
||||
|
||||
}
|
82
modules/common/shell/utilities.nix
Normal file
82
modules/common/shell/utilities.nix
Normal file
@ -0,0 +1,82 @@
|
||||
{ config, pkgs, ... }:
|
||||
|
||||
let
|
||||
|
||||
ignorePatterns = ''
|
||||
!.env*
|
||||
!.github/
|
||||
!.gitignore
|
||||
!*.tfvars
|
||||
.terraform/
|
||||
.target/
|
||||
/Library/'';
|
||||
|
||||
in {
|
||||
|
||||
config = {
|
||||
|
||||
home-manager.users.${config.user} = {
|
||||
|
||||
# Fix: age won't build
|
||||
nixpkgs.overlays = [
|
||||
(final: prev: {
|
||||
age = prev.age.overrideAttrs (old: {
|
||||
src = prev.fetchFromGitHub {
|
||||
owner = "FiloSottile";
|
||||
repo = "age";
|
||||
rev = "7354aa0d08a06eac42c635670a55f858bd23c943";
|
||||
sha256 = "H80mNTgZmExDMgubONIXP7jmLBvNMVqXee6NiZJhPFY=";
|
||||
};
|
||||
});
|
||||
})
|
||||
];
|
||||
|
||||
home.packages = with pkgs; [
|
||||
unzip # Extract zips
|
||||
rsync # Copy folders
|
||||
ripgrep # grep
|
||||
fd # find
|
||||
sd # sed
|
||||
jq # JSON manipulation
|
||||
tealdeer # Cheatsheets
|
||||
tree # View directory hierarchy
|
||||
htop # Show system processes
|
||||
glow # Pretty markdown previews
|
||||
qrencode # Generate qr codes
|
||||
vimv-rs # Batch rename files
|
||||
dig # DNS lookup
|
||||
lf # File viewer
|
||||
inetutils # Includes telnet, whois
|
||||
age # Encryption
|
||||
];
|
||||
|
||||
programs.zoxide.enable = true; # Shortcut jump command
|
||||
|
||||
home.file = {
|
||||
".rgignore".text = ignorePatterns;
|
||||
".fdignore".text = ignorePatterns;
|
||||
".digrc".text = "+noall +answer"; # Cleaner dig commands
|
||||
};
|
||||
|
||||
programs.bat = {
|
||||
enable = true; # cat replacement
|
||||
config = { theme = config.theme.colors.batTheme; };
|
||||
};
|
||||
|
||||
programs.fish.shellAbbrs = {
|
||||
cat = "bat"; # Swap cat with bat
|
||||
};
|
||||
|
||||
programs.fish.functions = {
|
||||
ping = {
|
||||
description = "Improved ping";
|
||||
argumentNames = "target";
|
||||
body = "${pkgs.prettyping}/bin/prettyping --nolegend $target";
|
||||
};
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
}
|
Reference in New Issue
Block a user