move home configs to root
This commit is contained in:
2
home/Makefile
Normal file
2
home/Makefile
Normal file
@@ -0,0 +1,2 @@
|
||||
switch:
|
||||
home-manager switch
|
||||
BIN
home/assets/profile-pictures/jokke.png
Normal file
BIN
home/assets/profile-pictures/jokke.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.1 KiB |
BIN
home/assets/profile-pictures/moco.png
Normal file
BIN
home/assets/profile-pictures/moco.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 5.9 KiB |
423
home/common/default.nix
Normal file
423
home/common/default.nix
Normal file
@@ -0,0 +1,423 @@
|
||||
{ config, lib, pkgs, ... }:
|
||||
{
|
||||
nixpkgs.config.allowUnfree = true;
|
||||
imports = [ ../gnome ../custom-programs ./neovim ];
|
||||
|
||||
# This value determines the Home Manager release that your configuration is
|
||||
# compatible with. This helps avoid breakage when a new Home Manager release
|
||||
# introduces backwards incompatible changes.
|
||||
#
|
||||
# You should not change this value, even if you update Home Manager. If you do
|
||||
# want to update the value, then make sure to first check the Home Manager
|
||||
# release notes.
|
||||
home.stateVersion = "23.11"; # Please read the comment before changing.
|
||||
|
||||
home.packages = with pkgs; [
|
||||
htop
|
||||
gnupg
|
||||
yubioath-flutter
|
||||
yubikey-manager
|
||||
gcc
|
||||
sqlite
|
||||
nerdfonts
|
||||
noto-fonts
|
||||
noto-fonts-cjk-sans
|
||||
noto-fonts-color-emoji
|
||||
google-fonts
|
||||
mosh
|
||||
docker-compose
|
||||
signal-desktop
|
||||
cargo
|
||||
blanket
|
||||
wl-clipboard
|
||||
gnumeric
|
||||
gh
|
||||
neovim-remote
|
||||
flameshot
|
||||
supersonic
|
||||
crystal
|
||||
shards
|
||||
moreutils
|
||||
keymapp
|
||||
gnumake
|
||||
tig
|
||||
jq
|
||||
yt-dlp
|
||||
ffmpeg
|
||||
otp
|
||||
manix
|
||||
(writeShellScriptBin "fd" ''
|
||||
${fd}/bin/fd -H "$@"
|
||||
'')
|
||||
rpi-imager
|
||||
picocom
|
||||
imagemagick
|
||||
ghostscript
|
||||
inkscape
|
||||
jless
|
||||
qmapshack
|
||||
scribus
|
||||
dnscontrol
|
||||
protonmail-bridge
|
||||
hydroxide
|
||||
protonmail-desktop
|
||||
tutanota-desktop
|
||||
imapsync
|
||||
nixfmt-rfc-style
|
||||
];
|
||||
|
||||
programs = {
|
||||
nh = {
|
||||
enable = true;
|
||||
flake = "/etc/nixos";
|
||||
};
|
||||
home-manager.enable = true;
|
||||
bat = {
|
||||
enable = true;
|
||||
extraPackages = with pkgs.bat-extras; [ batdiff batwatch ];
|
||||
config = {
|
||||
pager = "less -FR";
|
||||
};
|
||||
};
|
||||
direnv = {
|
||||
enable = true;
|
||||
nix-direnv.enable = true;
|
||||
enableZshIntegration = true;
|
||||
};
|
||||
mpv = {
|
||||
enable = true;
|
||||
config = {
|
||||
hwdec = "auto-safe";
|
||||
vo = "gpu";
|
||||
profile = "gpu-hq";
|
||||
gpu-context = "wayland";
|
||||
};
|
||||
};
|
||||
fb-client = {
|
||||
enable = true;
|
||||
pastebin = "https://p.jokke.space";
|
||||
clipboard_cmd = "${pkgs.wl-copy-both}/bin/wl-copy";
|
||||
};
|
||||
kitty = {
|
||||
enable = true;
|
||||
font = {
|
||||
package = pkgs.nerdfonts;
|
||||
name = "IosevkaTerm NFM";
|
||||
size = 12;
|
||||
};
|
||||
shellIntegration.enableZshIntegration = true;
|
||||
themeFile = "Tomorrow_Night";
|
||||
settings = {
|
||||
hide_window_decorations = true;
|
||||
enabled_layouts = "splits,stack";
|
||||
};
|
||||
keybindings = {
|
||||
"kitty_mod+q" = "";
|
||||
"kitty_mod+w" = "";
|
||||
"kitty_mod+t" = "new_tab_with_cwd";
|
||||
"kitty_mod+tab" = "next_tab";
|
||||
"kitty_mod+enter" = "launch --location=hsplit --cwd=current";
|
||||
"kitty_mod+space" = "launch --location=vsplit --cwd=current";
|
||||
"kitty_mod+h" = "neighboring_window left";
|
||||
"kitty_mod+l" = "neighboring_window right";
|
||||
"kitty_mod+k" = "neighboring_window up";
|
||||
"kitty_mod+j" = "neighboring_window down";
|
||||
"kitty_mod+1" = "goto_tab 1";
|
||||
"kitty_mod+2" = "goto_tab 2";
|
||||
"kitty_mod+3" = "goto_tab 3";
|
||||
"kitty_mod+4" = "goto_tab 4";
|
||||
"kitty_mod+5" = "goto_tab 5";
|
||||
"kitty_mod+6" = "goto_tab 6";
|
||||
"kitty_mod+7" = "goto_tab 7";
|
||||
"kitty_mod+8" = "goto_tab 8";
|
||||
"kitty_mod+9" = "goto_tab 9";
|
||||
"kitty_mod+0" = "goto_tab 10";
|
||||
"kitty_mod+f" = "toggle_layout stack";
|
||||
"kitty_mod+/" = "show_scrollback";
|
||||
"ctrl+alt+h" = "move_window left";
|
||||
"ctrl+alt+l" = "move_window right";
|
||||
"ctrl+alt+k" = "move_window up";
|
||||
"ctrl+alt+j" = "move_window down";
|
||||
"ctrl+alt+enter" = "layout_action rotate";
|
||||
};
|
||||
};
|
||||
vivaldi.enable = true;
|
||||
git = {
|
||||
enable = true;
|
||||
aliases = {
|
||||
st = "status";
|
||||
co = "checkout";
|
||||
b = "branch";
|
||||
};
|
||||
extraConfig = {
|
||||
pull = {
|
||||
rebase = "true";
|
||||
};
|
||||
push = {
|
||||
autoSetupRemote = true;
|
||||
};
|
||||
init = {
|
||||
defaultBranch = "main";
|
||||
};
|
||||
user = {
|
||||
name = "Joakim Repomaa";
|
||||
signingKey = "F0AF1CE34733B22317A8937D05557F53CD3C6458";
|
||||
};
|
||||
commit.gpgSign = true;
|
||||
};
|
||||
};
|
||||
gpg = {
|
||||
enable = true;
|
||||
};
|
||||
zsh = {
|
||||
enable = true;
|
||||
enableVteIntegration = true;
|
||||
cdpath = [
|
||||
"${config.xdg.configHome}/home-manager"
|
||||
];
|
||||
defaultKeymap = "viins";
|
||||
dirHashes = {
|
||||
hm = "${config.xdg.configHome}/home-manager";
|
||||
};
|
||||
history = {
|
||||
path = "${config.home.homeDirectory}/.cache/zsh/history";
|
||||
save = 100000;
|
||||
size = 100000;
|
||||
};
|
||||
initExtra = ''
|
||||
. "${config.xdg.configHome}/zsh/init"
|
||||
'';
|
||||
};
|
||||
lazygit = {
|
||||
enable = true;
|
||||
settings = {
|
||||
gui = {
|
||||
nerdFontsVersion = "3";
|
||||
};
|
||||
git = {
|
||||
showUntrackedFiles = "all";
|
||||
branchLogCmd = "git log {{branchName}} --first-parent --color=always --pretty=format:'%Cgreen%h%Creset %Cblue%aN%Creset %C(cyan)%<(14)%ar%Creset %s' --abbrev-commit";
|
||||
};
|
||||
os = {
|
||||
edit = "$EDITOR {{filename}}";
|
||||
editAtLine = "$EDITOR +{{line}} {{filename}}";
|
||||
editAtLineAndWait = "$EDITOR --remote-wait +{{line}} {{filename}}";
|
||||
};
|
||||
customCommands = [
|
||||
{
|
||||
key = "<c-p>";
|
||||
context = "global";
|
||||
command = ''
|
||||
git push --force-with-lease --set-upstream origin "{{.SelectedLocalBranch.Name}}" &&
|
||||
gh pr create --title "{{.SelectedLocalBranch.Name}}" --fill ||
|
||||
(git log --reverse --no-merges --pretty='- %s' master..HEAD | gh pr edit --body-file -);
|
||||
gh pr view --web
|
||||
'';
|
||||
}
|
||||
];
|
||||
};
|
||||
};
|
||||
obs-studio.enable = true;
|
||||
ssh = {
|
||||
enable = true;
|
||||
controlMaster = "auto";
|
||||
controlPersist = "1h";
|
||||
matchBlocks = {
|
||||
"*" = {
|
||||
extraOptions = {
|
||||
ControlPath = "${config.home.homeDirectory}/.ssh/masters-control/%r@%h:%p";
|
||||
};
|
||||
setEnv = {
|
||||
TERM = "screen-256color";
|
||||
};
|
||||
};
|
||||
"apu" = {
|
||||
hostname = "10.10.0.1";
|
||||
user = "root";
|
||||
};
|
||||
};
|
||||
};
|
||||
spotify-player = {
|
||||
enable = true;
|
||||
settings = {
|
||||
enable_streaming = "Always";
|
||||
theme = "tomorrow_night";
|
||||
copy_command = "wl-copy";
|
||||
};
|
||||
themes = [
|
||||
{
|
||||
name = "tomorrow_night";
|
||||
palette = {
|
||||
background = "#1d1f21";
|
||||
foreground = "#c5c8c6";
|
||||
black = "#000000";
|
||||
red = "#cc6666";
|
||||
green = "#b5bd68";
|
||||
yellow = "#f0c674";
|
||||
blue = "#81a2be";
|
||||
magenta = "#b294bb";
|
||||
cyan = "#8abeb7";
|
||||
white = "#ffffff";
|
||||
bright_black = "#000000";
|
||||
bright_red = "#cc6666";
|
||||
bright_green = "#b5bd68";
|
||||
bright_yellow = "#f0c674";
|
||||
bright_blue = "#81a2be";
|
||||
bright_magenta = "#b294bb";
|
||||
bright_cyan = "#8abeb7";
|
||||
bright_white = "#ffffff";
|
||||
};
|
||||
component_style = {
|
||||
playback_metadata = { fg = "#8abeb7"; };
|
||||
playback_progress_bar = { bg = "#1d1f21"; fg = "#c5c8c6"; };
|
||||
};
|
||||
}
|
||||
];
|
||||
};
|
||||
neovide = {
|
||||
enable = true;
|
||||
settings = {
|
||||
font = {
|
||||
normal = [ "IosevkaTerm NFM" ];
|
||||
size = 12.0;
|
||||
};
|
||||
fork = true;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
gnome = {
|
||||
keyboard.sources = [ "us+altgr-intl" ];
|
||||
keybindings = {
|
||||
builtin = {
|
||||
screenshot-window = [ ];
|
||||
show-screenshot-ui = [ ];
|
||||
};
|
||||
custom = [
|
||||
{
|
||||
binding = "Print";
|
||||
command = "flameshot gui";
|
||||
name = "Flameshot";
|
||||
}
|
||||
{
|
||||
binding = "<Alt>Print";
|
||||
command = "kooha";
|
||||
name = "Kooha";
|
||||
}
|
||||
];
|
||||
};
|
||||
power = {
|
||||
powerButton = "hibernate";
|
||||
};
|
||||
extensions = {
|
||||
paperwm = {
|
||||
enable = true;
|
||||
winprops = [
|
||||
{ wm_class = "vivaldi-stable"; preferredWidth = "67%"; }
|
||||
{ wm_class = "yubioath-flutter"; scratch_layer = true; }
|
||||
{ wm_class = "signal"; scratch_layer = true; }
|
||||
{ wm_class = "Slack"; scratch_layer = true; }
|
||||
{ wm_class = "Supersonic"; scratch_layer = true; }
|
||||
{ wm_class = "io.github.seadve.Kooha"; scratch_layer = true; }
|
||||
{ wm_class = "/.*/"; preferredWidth = "33"; }
|
||||
];
|
||||
keybindings = {
|
||||
move-down = [ "<Control><Super>Down" "<Shift><Super>j" ];
|
||||
move-left = [ "<Control><Super>Left" "<Shift><Super>h" ];
|
||||
move-right = [ "<Control><Super>Right" "<Shift><Super>l" ];
|
||||
move-up = [ "<Control><Super>Up" "<Shift><Super>k" ];
|
||||
switch-down = [ "<Super>Down" "<Super>j" ];
|
||||
switch-left = [ "<Super>Left" "<Super>h" ];
|
||||
switch-right = [ "<Super>Right" "<Super>l" ];
|
||||
switch-up = [ "<Super>Up" "<Super>k" ];
|
||||
};
|
||||
};
|
||||
freon = {
|
||||
enable = true;
|
||||
};
|
||||
};
|
||||
nightLight.enable = true;
|
||||
};
|
||||
|
||||
fonts.fontconfig = {
|
||||
enable = true;
|
||||
defaultFonts = {
|
||||
emoji = [ "Noto Color Emoji" ];
|
||||
monospace = [ "IosevkaTerm NFM" ];
|
||||
};
|
||||
};
|
||||
|
||||
targets.genericLinux.enable = true;
|
||||
xdg.mime.enable = true;
|
||||
|
||||
xdg = {
|
||||
enable = true;
|
||||
configFile = {
|
||||
tmux.source = dotfiles/tmux;
|
||||
zsh.source = dotfiles/zsh;
|
||||
"fd/ignore".text = ''
|
||||
/.git/
|
||||
'';
|
||||
"vivaldi/NativeMessagingHosts/ff2mpv.json".text = builtins.toJSON {
|
||||
name = "ff2mpv";
|
||||
description = "ff2mpv's external manifest";
|
||||
path = "${pkgs.ff2mpv-rust}/bin/ff2mpv-rust";
|
||||
type = "stdio";
|
||||
allowed_origins = [
|
||||
"chrome-extension://ephjcajbkgplkjmelpglennepbpmdpjg/"
|
||||
];
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
# Home Manager can also manage your environment variables through
|
||||
# 'home.sessionVariables'. If you don't want to manage your shell through Home
|
||||
# Manager then you have to manually source 'hm-session-vars.sh' located at
|
||||
# either
|
||||
#
|
||||
# ~/.nix-profile/etc/profile.d/hm-session-vars.sh
|
||||
#
|
||||
# or
|
||||
#
|
||||
# ~/.local/state/nix/profiles/profile/etc/profile.d/hm-session-vars.sh
|
||||
#
|
||||
# or
|
||||
#
|
||||
# /etc/profiles/per-user/jokke/etc/profile.d/hm-session-vars.sh
|
||||
#
|
||||
systemd.user.sessionVariables = {
|
||||
NIXOS_OZONE_WL = 1;
|
||||
NVIM_LISTEN_ADDRESS = "$XDG_RUNTIME_DIR/nvimsocket";
|
||||
PAGER = "bat --paging=always --style=plain";
|
||||
MANPAGER = "sh -c 'col -bx | bat -l man -p'";
|
||||
MANROFFOPT = "-c";
|
||||
DO_NOT_TRACK = 1;
|
||||
};
|
||||
|
||||
home.shellAliases = {
|
||||
_ = "sudo";
|
||||
icr = "crystal i";
|
||||
hm = "home-manager";
|
||||
chat = "ssh root@ipv4.jokke.space pkill mosh; mosh weechat@ipv4.jokke.space";
|
||||
wget = " wget --content-disposition";
|
||||
pj = "jq | bat -l json";
|
||||
ls = "ls --color=auto";
|
||||
};
|
||||
|
||||
services.gpg-agent = with pkgs; {
|
||||
enable = true;
|
||||
enableSshSupport = true;
|
||||
pinentryPackage = pinentry-gnome3;
|
||||
};
|
||||
|
||||
programs.gpg.scdaemonSettings = {
|
||||
disable-ccid = true;
|
||||
};
|
||||
|
||||
xdg.configFile."autostart/gnome-keyring-ssh.desktop".text = lib.strings.concatLines [
|
||||
(builtins.readFile "${pkgs.gnome-keyring}/etc/xdg/autostart/gnome-keyring-ssh.desktop")
|
||||
"X-GNOME-Autostart-enabled=false"
|
||||
];
|
||||
|
||||
gnome.automaticTimeZone = true;
|
||||
}
|
||||
69
home/common/dotfiles/tmux/tmux.conf
Normal file
69
home/common/dotfiles/tmux/tmux.conf
Normal file
@@ -0,0 +1,69 @@
|
||||
# vim: ft=tmux
|
||||
# original from bl1nk
|
||||
# Styles
|
||||
setw -g mode-style "fg=yellow,bg=default,bright"
|
||||
setw -g window-status-style "fg=default,bg=default,dim"
|
||||
setw -g window-status-current-style "fg=yellow,bg=default,dim"
|
||||
set -g message-style "fg=red,bg=default,bright"
|
||||
set -g status-style "fg=default,bg=black,bright"
|
||||
set -g pane-active-border-style "fg=blue,bg=black"
|
||||
set -g allow-passthrough 1
|
||||
set-option -g set-titles on
|
||||
set-option -g focus-events on
|
||||
# set set-titles-string "#{session_name}"
|
||||
|
||||
# Options
|
||||
set -g bell-action any
|
||||
set -g history-limit 50000
|
||||
set -g status on
|
||||
#set -g status-keys vi
|
||||
#set -g status-utf8 on
|
||||
set -g set-titles on
|
||||
|
||||
set -g default-terminal "tmux-256color"
|
||||
set -as terminal-features ",foot*:RGB,alacritty*:RGB,gnome*:RGB"
|
||||
set -g set-titles-string "tmux:#I [ #W ]"
|
||||
set -g base-index 1
|
||||
set -g pane-base-index 1
|
||||
set -g @plugin 'base16-project/base16-tmux'
|
||||
|
||||
set -g update-environment "DISPLAY SSH_ASKPASS SSH_AGENT_PID SSH_CONNECTION WINDOWID XAUTHORITY BASE16_SHELL"
|
||||
|
||||
set -g status-left-length 30
|
||||
set -g status-left '[#[fg=white]#S]#[fg=black,bright] #[default]'
|
||||
set -sg escape-time 0
|
||||
|
||||
#setw -g utf8 on
|
||||
setw -g automatic-rename on
|
||||
setw -g clock-mode-style 24
|
||||
#setw -g mode-keys vi
|
||||
setw -g mouse on
|
||||
|
||||
bind-key q confirm kill-pane
|
||||
bind-key Q confirm kill-session
|
||||
bind-key Tab next-window
|
||||
|
||||
bind-key > switchc -n
|
||||
bind-key > switchc -p
|
||||
|
||||
bind-key C-n new-window -c "#{pane_current_path}"
|
||||
bind-key C-t new-window -c "#{pane_current_path}" "~/bin/share-tty $(tmux display -p '#S')"
|
||||
|
||||
bind-key u run tmux-url-select
|
||||
|
||||
bind-key o split-window -h -c '#{pane_current_path}'
|
||||
bind-key u split-window -v -c '#{pane_current_path}'
|
||||
bind-key C-o split-window -h -c '#{pane_current_path}'
|
||||
bind-key C-u split-window -v -c '#{pane_current_path}'
|
||||
|
||||
bind-key -r C-h select-pane -L
|
||||
bind-key -r C-j select-pane -D
|
||||
bind-key -r C-k select-pane -U
|
||||
bind-key -r C-l select-pane -R
|
||||
|
||||
bind-key f resize-pane -Z
|
||||
bind-key r source-file ~/.config/tmux/tmux.conf
|
||||
|
||||
bind-key -T copy-mode-vi MouseDragEnd1Pane send-keys -X copy-pipe-and-cancel "xclip -i"
|
||||
bind -T root MouseDown2Pane select-pane -t =\; run -b "xclip -o | tmux load-buffer - && tmux paste-buffer -s ' '"
|
||||
run '~/.tmux/plugins/tpm/tpm'
|
||||
1953
home/common/dotfiles/zsh/.zcompdump
Normal file
1953
home/common/dotfiles/zsh/.zcompdump
Normal file
File diff suppressed because it is too large
Load Diff
30
home/common/dotfiles/zsh/completion
Normal file
30
home/common/dotfiles/zsh/completion
Normal file
@@ -0,0 +1,30 @@
|
||||
#!/bin/zsh
|
||||
# The following lines were added by compinstall
|
||||
|
||||
zstyle ':completion:*' completer _expand _complete _ignored _approximate
|
||||
zstyle ':completion:*' completions 1
|
||||
zstyle ':completion:*' expand prefix
|
||||
zstyle ':completion:*' format '%BCompleting %d%b'
|
||||
zstyle ':completion:*' glob 1
|
||||
zstyle ':completion:*' group-name ''
|
||||
zstyle ':completion:*' ignore-parents parent pwd
|
||||
zstyle ':completion:*' insert-unambiguous true
|
||||
zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS}
|
||||
zstyle ':completion:*' list-prompt %SAt %p: Hit TAB for more, or the character to insert%s
|
||||
zstyle ':completion:*' list-suffixes true
|
||||
zstyle ':completion:*' matcher-list '' 'm:{[:lower:][:upper:]}={[:upper:][:lower:]}' 'r:|[._-]=** r:|=**' 'l:|=* r:|=*'
|
||||
zstyle ':completion:*' max-errors 1
|
||||
zstyle ':completion:*' menu select=3
|
||||
zstyle ':completion:*' original true
|
||||
zstyle ':completion:*' preserve-prefix '//[^/]##/'
|
||||
zstyle ':completion:*' prompt 'Did you mean...'
|
||||
zstyle ':completion:*' select-prompt %SScrolling active: current selection at %p%s
|
||||
zstyle ':completion:*' squeeze-slashes true
|
||||
zstyle ':completion:*' substitute 1
|
||||
zstyle ':completion:*' verbose true
|
||||
zstyle ':completion:*' word true
|
||||
zstyle :compinstall filename "$ZDOTDIR/completion"
|
||||
|
||||
autoload -Uz compinit
|
||||
compinit
|
||||
# End of lines added by compinstall
|
||||
64
home/common/dotfiles/zsh/functions
Normal file
64
home/common/dotfiles/zsh/functions
Normal file
@@ -0,0 +1,64 @@
|
||||
#!/usr/bin/zsh
|
||||
|
||||
scratch () {
|
||||
nvim -c ":set ft=$1" $(mktemp)
|
||||
}
|
||||
|
||||
tsessions() {
|
||||
tmux list-sessions -F '#{session_name} #{?session_attached,,not_attached}' | \
|
||||
awk '/not_attached/{print $1}'
|
||||
}
|
||||
|
||||
tkill() {
|
||||
tsessions | fzf | xargs tmux kill-session -t
|
||||
}
|
||||
|
||||
tswitch() {
|
||||
tsessions | fzf | xargs tmux switch-client -t
|
||||
}
|
||||
|
||||
tnew() {
|
||||
tmux new -d -s "$@"
|
||||
tmux switch-client -t $1
|
||||
}
|
||||
|
||||
asciirec() {
|
||||
local tempfile=$(mktemp /tmp/asciirec.XXXXX.asciinema.json)
|
||||
asciinema rec "$tempfile"
|
||||
fb "$tempfile"
|
||||
rm "$tempfile"
|
||||
}
|
||||
|
||||
fbs() {
|
||||
local url=$1
|
||||
local time=${2-5}
|
||||
|
||||
fb <<-HTML | rev | cut -c 2- | rev | xclip
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="refresh" content="${time}; url=${url}" />
|
||||
</head>
|
||||
<body>
|
||||
<h3>Redirect</h3>
|
||||
<p>Redirecting you to <a href="${url}">${url}</a></p>
|
||||
</body>
|
||||
</html>
|
||||
HTML
|
||||
|
||||
xclip -o
|
||||
}
|
||||
|
||||
qrshow() {
|
||||
local url=$1
|
||||
[[ -z "$url" ]] && read url
|
||||
qrencode -o - "$url" | feh -
|
||||
}
|
||||
|
||||
envy() {
|
||||
env $(cat .env | sed '/^\s*#/d') "$@"
|
||||
}
|
||||
|
||||
add-hash() {
|
||||
hash -d "$@=$PWD"
|
||||
echo "hash -d '$@=$PWD'" >> "$ZDOTDIR/hashes"
|
||||
}
|
||||
79
home/common/dotfiles/zsh/init
Normal file
79
home/common/dotfiles/zsh/init
Normal file
@@ -0,0 +1,79 @@
|
||||
#!/bin/zsh
|
||||
|
||||
# History {{{
|
||||
HISTFILE="$XDG_CACHE_HOME/zsh/history"
|
||||
HISTSIZE=100000
|
||||
SAVEHIST=100000
|
||||
setopt hist_ignore_dups
|
||||
setopt hist_ignore_space
|
||||
setopt share_history
|
||||
setopt autopushd
|
||||
|
||||
mkdir -p $(dirname "$HISTFILE")
|
||||
# }}}
|
||||
|
||||
# Various options {{{
|
||||
setopt autocd extendedglob nomatch notify histfindnodups
|
||||
unsetopt beep
|
||||
setopt interactive_comments
|
||||
# }}}
|
||||
|
||||
# Vim mode
|
||||
bindkey -v
|
||||
|
||||
# Keybindings {{{
|
||||
bindkey '^?' backward-delete-char
|
||||
bindkey '^h' backward-delete-char
|
||||
bindkey '^w' backward-kill-word
|
||||
bindkey '^r' history-incremental-pattern-search-backward
|
||||
bindkey '^k' history-beginning-search-backward
|
||||
bindkey '^j' history-beginning-search-forward
|
||||
bindkey '^p' push-input
|
||||
bindkey '^ ' fzf-cd-widget
|
||||
# }}}
|
||||
|
||||
# Prompt {{{
|
||||
autoload -Uz vcs_info
|
||||
precmd_functions+=( vcs_info )
|
||||
setopt prompt_subst
|
||||
PROMPT="%#$([ -n "$IN_NIX_SHELL" ] && echo '%F{blue}ns%f') %1~%(0?..%F{red})>%f "
|
||||
RPROMPT=\$vcs_info_msg_0_
|
||||
zstyle ':vcs_info:git:*' check-for-changes true
|
||||
zstyle ':vcs_info:git:*' formats '<%b> [%u%c]'
|
||||
# }}}
|
||||
|
||||
# Safe rm {{{
|
||||
alias rm='rm -I '
|
||||
setopt rm_star_silent
|
||||
# }}}
|
||||
|
||||
for file in completion functions; do
|
||||
[ -f "$XDG_CONFIG_HOME/zsh/$file" ] || touch "$XDG_CONFIG_HOME/zsh/$file"
|
||||
. "$XDG_CONFIG_HOME/zsh/$file"
|
||||
done
|
||||
|
||||
# GPG Agent {{{
|
||||
export GPG_TTY=$(tty)
|
||||
gpg-connect-agent updatestartuptty /bye >/dev/null
|
||||
# }}}
|
||||
|
||||
# Base16 {{{
|
||||
export BASE16_SHELL="$HOME/.config/base16-shell/"
|
||||
[ -n "$PS1" ] && \
|
||||
[ -s "$BASE16_SHELL/profile_helper.sh" ] && \
|
||||
eval "$("$BASE16_SHELL/profile_helper.sh")"
|
||||
# }}}
|
||||
|
||||
|
||||
# NVM {{{
|
||||
#if [ -f /usr/share/nvm/init-nvm.sh ]; then
|
||||
# source /usr/share/nvm/init-nvm.sh
|
||||
#fi
|
||||
# }}}
|
||||
|
||||
# ENVS {{{
|
||||
#eval "$(rbenv init -)"
|
||||
#. /usr/share/nvm/nvm.sh
|
||||
# }}}
|
||||
|
||||
# vim: set foldmethod=marker
|
||||
433
home/common/neovim/default.nix
Normal file
433
home/common/neovim/default.nix
Normal file
@@ -0,0 +1,433 @@
|
||||
{ pkgs, lib, ... }:
|
||||
{
|
||||
imports = [ ../../modules/neovim ];
|
||||
|
||||
programs.neovim =
|
||||
let
|
||||
toLua = lib.generators.toLua { };
|
||||
luaMap = rhs: { rhs = rhs; lua = true; options = { silent = true; }; };
|
||||
in
|
||||
{
|
||||
enable = true;
|
||||
defaultEditor = true;
|
||||
options = {
|
||||
number = true;
|
||||
expandtab = true;
|
||||
tabstop = 2;
|
||||
shiftwidth = 2;
|
||||
softtabstop = 2;
|
||||
signcolumn = "yes";
|
||||
modeline = true;
|
||||
hidden = true;
|
||||
listchars = "tab:▸ ,trail:·";
|
||||
list = true;
|
||||
undofile = true;
|
||||
winblend = 30;
|
||||
};
|
||||
withTreesitterPlugins = p: [
|
||||
p.lua
|
||||
p.vim
|
||||
p.vimdoc
|
||||
p.nix
|
||||
p.query
|
||||
p.make
|
||||
];
|
||||
formatters = [
|
||||
{
|
||||
filetypes = [ "nix" ];
|
||||
globs = [ "*.nix" ];
|
||||
exe = "${pkgs.nixpkgs-fmt}/bin/nixpkgs-fmt";
|
||||
stdin = true;
|
||||
}
|
||||
{
|
||||
filetypes = [ "lua" ];
|
||||
globs = [ "*.lua" ];
|
||||
exe = "${pkgs.stylua}/bin/stylua";
|
||||
args = _: [ "-" ];
|
||||
stdin = true;
|
||||
}
|
||||
{
|
||||
filetypes = [ "crystal" ];
|
||||
globs = [ "*.cr" ];
|
||||
exe = "${pkgs.crystal}/bin/crystal";
|
||||
args = file: [ "tool" "format" ];
|
||||
stdin = false;
|
||||
}
|
||||
];
|
||||
autoCommands = [
|
||||
{
|
||||
event = "FileType";
|
||||
pattern = [ "lua" ];
|
||||
command = "setlocal expandtab";
|
||||
}
|
||||
{
|
||||
event = "FileType";
|
||||
pattern = [
|
||||
"makefile"
|
||||
];
|
||||
command = "setlocal shiftwidth=4 tabstop=4 softtabstop=4 noexpandtab";
|
||||
}
|
||||
{
|
||||
event = "FileType";
|
||||
pattern = [ "gitcommit" "gitrebase" "gitconfig" ];
|
||||
command = "set bufhidden=delete";
|
||||
}
|
||||
{
|
||||
event = "BufWinEnter";
|
||||
pattern = "*";
|
||||
command = "if line2byte(line('$')) > 1000000 | syntax clear | endif";
|
||||
}
|
||||
];
|
||||
signs = {
|
||||
error = "";
|
||||
warning = "";
|
||||
hint = "";
|
||||
info = "";
|
||||
};
|
||||
env = {
|
||||
GIT_EDITOR = "nvr -cc split --remote-wait";
|
||||
EDITOR = "nvr -cc close --remote-wait";
|
||||
};
|
||||
leader = " ";
|
||||
mappings = {
|
||||
normal = {
|
||||
"<C-h>" = "<C-w>h";
|
||||
"<C-j>" = "<C-w>j";
|
||||
"<C-k>" = "<C-w>k";
|
||||
"<C-l>" = "<c-w>l";
|
||||
"n" = "n";
|
||||
};
|
||||
visual = {
|
||||
"<tab>" = ">gv^";
|
||||
"<s-tab>" = "<gv^";
|
||||
};
|
||||
};
|
||||
snippets = {
|
||||
snippets = ./snippets;
|
||||
luasnippets = ./luasnippets;
|
||||
};
|
||||
plug = with pkgs.vimPlugins; [
|
||||
vimpeccable
|
||||
vim-crystal
|
||||
{
|
||||
plugin = telescope-nvim;
|
||||
dependencies = [ plenary-nvim telescope-file-browser-nvim commander-nvim telescope-ui-select-nvim ];
|
||||
config =
|
||||
let
|
||||
commands = [
|
||||
{ cmd = "<cmd>!rails db:migrate<cr>"; desc = "Run rails migrations"; }
|
||||
{ cmd = "<cmd>!yarn codegen --no-watch<cr>"; desc = "Run yarn codegen"; }
|
||||
{ cmd = "<cmd>!rails translations:update<cr>"; desc = "Update i18n translations"; }
|
||||
{ cmd = "<cmd>!deploy staging-v6 -t $(git branch --show-current)<cr>"; desc = "Deploy to staging"; }
|
||||
{ cmd = "<cmd>!db-restore -d db-prod-inc<cr>"; desc = "Restore db from prod-inc"; }
|
||||
];
|
||||
mappings = { i = { "<c-h>" = "which_key"; }; };
|
||||
in
|
||||
''
|
||||
local telescope = require('telescope')
|
||||
local commander = require('commander')
|
||||
|
||||
commander.add(${toLua commands})
|
||||
telescope.load_extension('commander')
|
||||
telescope.load_extension('ui-select')
|
||||
|
||||
telescope.setup({
|
||||
defaults = { mappings = ${toLua mappings}, winblend = 30; },
|
||||
pickers = {
|
||||
find_files = {
|
||||
find_command = { "${pkgs.fd}/bin/fd", "-H", "--type=file", "--type=symlink" }
|
||||
},
|
||||
},
|
||||
extensions = {
|
||||
file_browser = {
|
||||
hidden = true
|
||||
},
|
||||
}
|
||||
})
|
||||
'';
|
||||
mappings = {
|
||||
normal = (
|
||||
lib.attrsets.mapAttrs
|
||||
(key: value: luaMap "require('telescope.builtin').${value}")
|
||||
{
|
||||
"<leader>f" = "find_files";
|
||||
"<leader>r" = "live_grep";
|
||||
"<leader>b" = "buffers";
|
||||
"<leader>h" = "help_tags";
|
||||
"<leader>o" = "oldfiles";
|
||||
"<leader>s" = "git_status";
|
||||
"<leader>/" = "current_buffer_fuzzy_find";
|
||||
"<leader>c" = "git_branches";
|
||||
}
|
||||
) // (
|
||||
lib.attrsets.mapAttrs
|
||||
(key: value: luaMap "require('telescope').extensions.${value}")
|
||||
{
|
||||
"<leader>n" = "file_browser.file_browser";
|
||||
"<leader>:" = "commander.filter";
|
||||
}
|
||||
);
|
||||
};
|
||||
}
|
||||
{
|
||||
plugin = base16-nvim;
|
||||
config = ''
|
||||
vim.opt.termguicolors = true
|
||||
vim.cmd('colorscheme base16-tomorrow-night')
|
||||
'';
|
||||
}
|
||||
{ plugin = octo-nvim; config = "require('octo').setup()"; }
|
||||
{
|
||||
plugin = gitsigns-nvim;
|
||||
dependencies = [ plenary-nvim ];
|
||||
config = ''
|
||||
require('gitsigns').setup(${toLua {
|
||||
current_line_blame = true;
|
||||
}})
|
||||
'';
|
||||
}
|
||||
{ plugin = windline-nvim; config = "require('wlsample.airline')"; }
|
||||
{
|
||||
plugin = luasnip;
|
||||
config = ''
|
||||
require('luasnip.loaders.from_snipmate').lazy_load()
|
||||
require('luasnip.loaders.from_lua').lazy_load()
|
||||
local luasnip = require('luasnip')
|
||||
luasnip.setup({ updateevents = 'TextChanged,TextChangedI' })
|
||||
'';
|
||||
mappings =
|
||||
let
|
||||
mapping = rhs: luaMap "function() ${rhs} end";
|
||||
mappings = {
|
||||
"<c-n>" = mapping "luasnip.jump(1)";
|
||||
"<c-p>" = mapping "luasnip.jump(-1)";
|
||||
"<c-e>" = mapping "if luasnip.choice_active() then luasnip.change_choice(1) end";
|
||||
};
|
||||
in
|
||||
{
|
||||
insert = mappings;
|
||||
select = mappings;
|
||||
};
|
||||
}
|
||||
{ plugin = vim-abolish; }
|
||||
{ plugin = NrrwRgn; }
|
||||
{
|
||||
plugin = trouble-nvim;
|
||||
dependencies = [ nvim-web-devicons ];
|
||||
mappings =
|
||||
let
|
||||
mapping = rhs: luaMap "function() require('trouble').${rhs} end";
|
||||
in
|
||||
{
|
||||
normal = {
|
||||
"<leader>xx" = mapping "open()";
|
||||
"<leader>xd" = mapping "open('document_diagnostics')";
|
||||
"<leader>xl" = mapping "open('loclist')";
|
||||
"gR" = mapping "open('lsp_references')";
|
||||
};
|
||||
};
|
||||
}
|
||||
{ plugin = twilight-nvim; }
|
||||
{ plugin = which-key-nvim; }
|
||||
{ plugin = zen-mode-nvim; }
|
||||
{
|
||||
plugin = diffview-nvim;
|
||||
config =
|
||||
let
|
||||
config = {
|
||||
default = {
|
||||
layout = "diff2_vertical";
|
||||
};
|
||||
merge_tool = {
|
||||
layout = "diff3_vertical";
|
||||
};
|
||||
file_history = {
|
||||
layout = "diff2_vertical";
|
||||
};
|
||||
};
|
||||
in
|
||||
''
|
||||
require('diffview').setup(${toLua config})
|
||||
'';
|
||||
}
|
||||
{
|
||||
plugin = toggleterm-nvim;
|
||||
dependencies = [ plenary-nvim pkgs.lazygit ];
|
||||
config = ''
|
||||
local Terminal = require('toggleterm.terminal').Terminal
|
||||
local lazygit = Terminal:new({
|
||||
cmd = "${pkgs.lazygit}/bin/lazygit",
|
||||
dir = "git_dir",
|
||||
direction = "float",
|
||||
hidden = true,
|
||||
on_open = function (term)
|
||||
vim.cmd('startinsert!')
|
||||
vim.api.nvim_buf_set_keymap(term.bufnr, 'n', 'q', '<cmd>close<cr>', { noremap = true, silent = true })
|
||||
end,
|
||||
on_close = function (term)
|
||||
vim.cmd('startinsert!')
|
||||
end,
|
||||
})
|
||||
'';
|
||||
mappings = {
|
||||
normal = {
|
||||
"<leader>g" = luaMap "function () lazygit:toggle() end";
|
||||
};
|
||||
};
|
||||
}
|
||||
{
|
||||
plugin = copilot-cmp;
|
||||
dependencies = [{
|
||||
plugin = copilot-lua;
|
||||
config = ''
|
||||
require('copilot').setup({
|
||||
suggestion = { enabled = false },
|
||||
panel = { enajkbled = false },
|
||||
copilot_node_command = '${pkgs.nodejs}/bin/node',
|
||||
})
|
||||
'';
|
||||
}];
|
||||
config = ''
|
||||
require('copilot_cmp').setup()
|
||||
'';
|
||||
}
|
||||
{
|
||||
plugin = gen-nvim;
|
||||
config =
|
||||
let
|
||||
config = {
|
||||
model = "llama3";
|
||||
};
|
||||
in
|
||||
''
|
||||
require('gen').setup(${toLua config})
|
||||
'';
|
||||
}
|
||||
{
|
||||
plugin = bufferline-nvim;
|
||||
config =
|
||||
let
|
||||
options = {
|
||||
hover = {
|
||||
enabled = true;
|
||||
delay = 200;
|
||||
reveal = [ "close" ];
|
||||
};
|
||||
};
|
||||
in
|
||||
''
|
||||
require('bufferline').setup({ options = ${toLua options} })
|
||||
'';
|
||||
dependencies = [{
|
||||
plugin = nvim-web-devicons;
|
||||
}];
|
||||
}
|
||||
];
|
||||
lsp = {
|
||||
servers = with pkgs; [
|
||||
{
|
||||
name = "lua_ls";
|
||||
config = {
|
||||
settings = {
|
||||
Lua = {
|
||||
diagnostics = {
|
||||
globals = [ "vim" ];
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
package = lua-language-server;
|
||||
}
|
||||
{
|
||||
name = "yamlls";
|
||||
config = {
|
||||
settings = {
|
||||
redhat = { telemetry = { enabled = false; }; };
|
||||
yaml = {
|
||||
schemas = {
|
||||
"https://json.schemastore.org/github-workflow" = ".github/workflows/*.yml";
|
||||
"https://json.schemastore.org/prettierrc" = ".prettierrc";
|
||||
"https://json.schemastore.org/prettierrc.yml" = ".prettierrc.yml";
|
||||
"https://json.schemastore.org/prettierrc.yaml" = ".prettierrc.yaml";
|
||||
"https://json.schemastore.org/prettier.config.yml" = "prettier.config.yml";
|
||||
"https://json.schemastore.org/prettier.config.yaml" = "prettier.config.yaml";
|
||||
"https://schema.jokke.space/caddy.json" = [ "*caddy*.yml" "*caddy*.yaml" ];
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
package = yaml-language-server;
|
||||
}
|
||||
{
|
||||
name = "tailwindcss";
|
||||
config = {
|
||||
settings = {
|
||||
tailwindCSS = {
|
||||
classAttributes = [ "class" "className" ];
|
||||
};
|
||||
};
|
||||
};
|
||||
package = tailwindcss-language-server;
|
||||
}
|
||||
{
|
||||
name = "ts_ls";
|
||||
package = nodePackages.typescript-language-server;
|
||||
config = {
|
||||
single_file_support = false;
|
||||
};
|
||||
rootPattern = [ "package.json" ];
|
||||
}
|
||||
{ name = "eslint"; package = vscode-langservers-extracted; }
|
||||
{ name = "nixd"; package = nixd; }
|
||||
{
|
||||
name = "bashls";
|
||||
package = nodePackages.bash-language-server.overrideAttrs (oldAttrs: {
|
||||
buildDependencies = [ shellcheck ];
|
||||
afterInstall = ''
|
||||
wrapProgram "$out/bin/bash-language-server" --prefix PATH : "${shellcheck}/bin"
|
||||
'';
|
||||
});
|
||||
}
|
||||
{
|
||||
name = "crystalline";
|
||||
package = crystalline;
|
||||
}
|
||||
{
|
||||
name = "rust_analyzer";
|
||||
package = rust-analyzer;
|
||||
}
|
||||
];
|
||||
mappings = {
|
||||
buf = {
|
||||
declaration = "gD";
|
||||
definition = "gd";
|
||||
hover = "K";
|
||||
implementation = "gi";
|
||||
type_definition = "<leader>D";
|
||||
rename = "<leader>rn";
|
||||
code_action = "<leader>ca";
|
||||
};
|
||||
diagnostic = {
|
||||
show_line_diagnostics = "<leader>e";
|
||||
goto_prev = "[d";
|
||||
goto_next = "]d";
|
||||
set_loclist = "<leader>q";
|
||||
};
|
||||
};
|
||||
};
|
||||
extraLuaConfig = ''
|
||||
local function close_all_other_buffers(opts)
|
||||
local current_buf = vim.api.nvim_get_current_buf()
|
||||
local buffers = vim.api.nvim_list_bufs()
|
||||
|
||||
for _, buf in ipairs(buffers) do
|
||||
if buf ~= current_buf and vim.api.nvim_buf_is_loaded(buf) then
|
||||
vim.api.nvim_buf_delete(buf, { force = opts.bang })
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
vim.api.nvim_create_user_command('CloseOtherBuffers', close_all_other_buffers, { bang = true })
|
||||
'';
|
||||
};
|
||||
}
|
||||
46
home/common/neovim/formatters.lua
Normal file
46
home/common/neovim/formatters.lua
Normal file
@@ -0,0 +1,46 @@
|
||||
local Formatters = {}
|
||||
|
||||
Formatters.setup = function()
|
||||
local formatter = require('formatter')
|
||||
local util = require('formatter.util')
|
||||
|
||||
local js = {
|
||||
function ()
|
||||
return {
|
||||
exe = "npx",
|
||||
args = {"prettier", "--stdin-filepath", util.escape_path(util.get_current_buffer_file_name())},
|
||||
stdin = true,
|
||||
}
|
||||
end
|
||||
}
|
||||
|
||||
local ruby = {
|
||||
function ()
|
||||
return {
|
||||
exe = "bundle",
|
||||
args = {"exec", "rufo", "-x", "--filename", util.escape_path(util.get_current_buffer_file_name())},
|
||||
stdin = true,
|
||||
}
|
||||
end
|
||||
}
|
||||
|
||||
formatter.setup {
|
||||
filetype = {
|
||||
javascript = js,
|
||||
typescript = js,
|
||||
javascriptreact = js,
|
||||
typescriptreact = js,
|
||||
svelte = js,
|
||||
ruby = ruby,
|
||||
haml = ruby,
|
||||
}
|
||||
}
|
||||
|
||||
vim.api.nvim_create_autocmd("BufWritePost", {
|
||||
pattern = { "*.js", "*.ts", "*.jsx", "*.tsx", "*.svelte", "*.rb", "*.haml", "Gemfile", "*.rake" },
|
||||
command = "FormatWrite",
|
||||
group = vim.api.nvim_create_augroup("FormatAutogroup", { clear = true }),
|
||||
})
|
||||
end
|
||||
|
||||
Formatters.setup()
|
||||
83
home/common/neovim/luasnippets/typescriptreact.lua
Normal file
83
home/common/neovim/luasnippets/typescriptreact.lua
Normal file
@@ -0,0 +1,83 @@
|
||||
local ls = require("luasnip")
|
||||
local fmt = require("luasnip.extras.fmt").fmt
|
||||
local s = ls.snippet
|
||||
local sn = ls.snippet_node
|
||||
local i = ls.insert_node
|
||||
local f = ls.function_node
|
||||
local d = ls.dynamic_node
|
||||
|
||||
return {
|
||||
s(
|
||||
{ trig = "fc", desc = "React.FC" },
|
||||
fmt(
|
||||
[[
|
||||
import React from "react"
|
||||
|
||||
interface {props_name} {{
|
||||
{prop_types}
|
||||
}}
|
||||
|
||||
const {component_name}: React.FC<{props_name}> = ({props}) => {{
|
||||
return (
|
||||
{markup}
|
||||
)
|
||||
}}
|
||||
|
||||
export default {component_name}
|
||||
]],
|
||||
{
|
||||
props_name = i(3, "Props"),
|
||||
prop_types = i(2),
|
||||
component_name = d(1, function()
|
||||
local filename = vim.api.nvim_buf_get_name(0)
|
||||
local component_name
|
||||
|
||||
if filename == "index.tsx" then
|
||||
component_name = vim.fs.basename(vim.fs.dirname(filename))
|
||||
else
|
||||
component_name = vim.fs.basename(filename):match("(.+)%.tsx")
|
||||
end
|
||||
|
||||
return sn(nil, i(1, component_name))
|
||||
end),
|
||||
props = f(function(prop_types)
|
||||
local props = {}
|
||||
|
||||
for _, prop in ipairs(prop_types[1]) do
|
||||
local parts = vim.split(prop, ":", { plain = true, trimempty = true })
|
||||
local name = parts[1]
|
||||
if name then
|
||||
table.insert(props, vim.trim(name))
|
||||
end
|
||||
end
|
||||
|
||||
return "{ " .. table.concat(props, ", ") .. " }"
|
||||
end, { 2 }),
|
||||
markup = i(0),
|
||||
},
|
||||
{
|
||||
repeat_duplicates = true,
|
||||
}
|
||||
)
|
||||
),
|
||||
s(
|
||||
{ trig = "t", desc = "<tag>" },
|
||||
fmt(
|
||||
[[
|
||||
<{tag}>
|
||||
{children}
|
||||
</{closing_tag}>
|
||||
]],
|
||||
{
|
||||
tag = i(1, "div"),
|
||||
closing_tag = f(function(tag)
|
||||
return vim.split(tag[1][1], " ")[1]
|
||||
end, { 1 }),
|
||||
children = i(0),
|
||||
},
|
||||
{
|
||||
repeat_duplicates = true,
|
||||
}
|
||||
)
|
||||
),
|
||||
}
|
||||
33
home/common/neovim/snippets/ruby.snippets
Normal file
33
home/common/neovim/snippets/ruby.snippets
Normal file
@@ -0,0 +1,33 @@
|
||||
snippet if ruby if statement
|
||||
if $1
|
||||
$0
|
||||
end
|
||||
|
||||
snippet qt graphql query test
|
||||
require "test_helper"
|
||||
|
||||
module Graphql
|
||||
module Queries
|
||||
class $1Test < ActionDispatch::IntegrationTest
|
||||
setup do
|
||||
@user = users(:tobias)
|
||||
rack_login(@user)
|
||||
end
|
||||
|
||||
test "Query$1" do
|
||||
run_query("Query$1") do |json, msg|
|
||||
$0
|
||||
end
|
||||
end
|
||||
|
||||
test "Query$1 without $2 permissions" do
|
||||
@user.permission.update!($2: 0)
|
||||
|
||||
run_query("Query$1") do |json, msg|
|
||||
assert false
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
1
home/common/neovim/snippets/typescriptreact.snippets
Normal file
1
home/common/neovim/snippets/typescriptreact.snippets
Normal file
@@ -0,0 +1 @@
|
||||
|
||||
10
home/custom-programs/default.nix
Normal file
10
home/custom-programs/default.nix
Normal file
@@ -0,0 +1,10 @@
|
||||
{ ... }:
|
||||
let
|
||||
inherit (builtins) attrNames filter readDir;
|
||||
dirs =
|
||||
let files = readDir ./.;
|
||||
in filter (name: files."${name}" == "directory") (attrNames files);
|
||||
in
|
||||
{
|
||||
imports = map (dir: ./${dir}) dirs;
|
||||
}
|
||||
30
home/custom-programs/fb-client/default.nix
Normal file
30
home/custom-programs/fb-client/default.nix
Normal file
@@ -0,0 +1,30 @@
|
||||
{ pkgs, config, lib, ... }:
|
||||
let
|
||||
cfg = config.programs.fb-client;
|
||||
in
|
||||
{
|
||||
options.programs.fb-client = let inherit (lib) mkEnableOption mkOption types; in {
|
||||
enable = mkEnableOption { };
|
||||
pastebin = mkOption {
|
||||
type = types.str;
|
||||
default = "https://paste.xinu.at";
|
||||
};
|
||||
clipboard_cmd = mkOption {
|
||||
type = types.pathInStore;
|
||||
default = "${pkgs.wl-clipboard}/bin/wl-copy";
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
home.packages = [ pkgs.fb-client ];
|
||||
xdg = {
|
||||
configFile = {
|
||||
"fb-client/config".text = ''
|
||||
pastebin="${cfg.pastebin}"
|
||||
apikey_file="${config.xdg.dataHome}/fb-client/apikey"
|
||||
clipboard_cmd="${cfg.clipboard_cmd}"
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
13
home/default.nix
Normal file
13
home/default.nix
Normal file
@@ -0,0 +1,13 @@
|
||||
{ ksoloti-pr, inputs, ... }:
|
||||
{
|
||||
home-manager = {
|
||||
users = {
|
||||
jokke = import ./jokke;
|
||||
moco = import ./moco;
|
||||
};
|
||||
extraSpecialArgs = { inherit ksoloti-pr inputs; };
|
||||
sharedModules = [ (import ./common) ];
|
||||
useUserPackages = true;
|
||||
useGlobalPkgs = true;
|
||||
};
|
||||
}
|
||||
123
home/gnome/default.nix
Normal file
123
home/gnome/default.nix
Normal file
@@ -0,0 +1,123 @@
|
||||
{ config, lib, ... }:
|
||||
let
|
||||
cfg = config.gnome;
|
||||
in
|
||||
{
|
||||
imports = [ ./extensions ];
|
||||
|
||||
options.gnome = with lib.types; {
|
||||
profilePicture = lib.mkOption {
|
||||
type = nullOr path;
|
||||
default = null;
|
||||
};
|
||||
keyboard = {
|
||||
sources = lib.mkOption {
|
||||
type = listOf str;
|
||||
default = [ "us" ];
|
||||
};
|
||||
};
|
||||
keybindings = {
|
||||
builtin = lib.mkOption {
|
||||
type = attrsOf (listOf str);
|
||||
default = { };
|
||||
};
|
||||
custom = lib.mkOption {
|
||||
type = listOf (submodule {
|
||||
options = {
|
||||
binding = lib.mkOption { type = str; };
|
||||
command = lib.mkOption { type = str; };
|
||||
name = lib.mkOption { type = str; };
|
||||
};
|
||||
});
|
||||
default = [ ];
|
||||
};
|
||||
};
|
||||
scalingFactor = lib.mkOption {
|
||||
type = numbers.positive;
|
||||
default = 1;
|
||||
};
|
||||
power = {
|
||||
powerButton = lib.mkOption {
|
||||
type = enum [ "suspend" "interactive" "hibernate" "nothing" ];
|
||||
default = "interactive";
|
||||
};
|
||||
};
|
||||
nightLight = {
|
||||
enable = lib.mkEnableOption { };
|
||||
temperature = lib.mkOption {
|
||||
type = ints.between 1700 4700;
|
||||
default = 2700;
|
||||
};
|
||||
schedule = lib.mkOption {
|
||||
type = nullOr (submodule {
|
||||
options = {
|
||||
from = lib.mkOption {
|
||||
type = numbers.between 0 23.99;
|
||||
default = 20.0;
|
||||
};
|
||||
to = lib.mkOption {
|
||||
type = numbers.between 0 23.99;
|
||||
default = 8.0;
|
||||
};
|
||||
};
|
||||
});
|
||||
default = null;
|
||||
};
|
||||
};
|
||||
calendar = {
|
||||
showWeekNumbers = lib.mkEnableOption { };
|
||||
};
|
||||
automaticTimeZone = lib.mkEnableOption { };
|
||||
};
|
||||
|
||||
config = {
|
||||
dconf.settings = with lib.hm.gvariant; {
|
||||
"org/gnome/shell/keybindings" = cfg.keybindings.builtin;
|
||||
"org/gnome/settings-daemon/plugins/media-keys" = {
|
||||
custom-keybindings = (
|
||||
lib.lists.imap0
|
||||
(i: _: "/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom${toString i}/")
|
||||
cfg.keybindings.custom
|
||||
);
|
||||
};
|
||||
"org/gnome/desktop/input-sources" = {
|
||||
sources = map (source: mkTuple [ "xkb" source ]) cfg.keyboard.sources;
|
||||
};
|
||||
"org/gnome/mutter" = {
|
||||
experimental-features = [ "scale-monitor-framebuffer" ];
|
||||
};
|
||||
"org/gnome/settings-daemon/plugins/xsettings" = {
|
||||
overrides = [ (mkTuple [ "GdkWindowScalingFactor" cfg.scalingFactor ]) ];
|
||||
};
|
||||
"org/gnome/desktop/interface" = {
|
||||
scaling-factor = cfg.scalingFactor;
|
||||
};
|
||||
"org/gnome/settings-daemon/plugins/power" = {
|
||||
"power-button-action" = cfg.power.powerButton;
|
||||
};
|
||||
"org/gnome/settings-daemon/plugins/color" = with cfg.nightLight; {
|
||||
night-light-enabled = enable;
|
||||
night-light-temperature = temperature;
|
||||
night-light-schedule-automatic = isNull schedule;
|
||||
night-light-schedule-from = lib.mkIf (!isNull schedule) schedule.from;
|
||||
night-light-schedule-to = lib.mkIf (!isNull schedule) schedule.to;
|
||||
};
|
||||
"org/gnome/desktop/calendar" = {
|
||||
show-weekdate = cfg.calendar.showWeekNumbers;
|
||||
};
|
||||
"org/gnome/desktop/datetime" = {
|
||||
automatic-timezone = cfg.automaticTimeZone;
|
||||
};
|
||||
} // (
|
||||
builtins.listToAttrs (
|
||||
lib.lists.imap0
|
||||
(i: keybinding: {
|
||||
name = "org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom${toString i}";
|
||||
value = keybinding;
|
||||
})
|
||||
cfg.keybindings.custom
|
||||
)
|
||||
);
|
||||
home.file.".face".source = lib.mkIf (!isNull cfg.profilePicture) cfg.profilePicture;
|
||||
};
|
||||
}
|
||||
10
home/gnome/extensions/default.nix
Normal file
10
home/gnome/extensions/default.nix
Normal file
@@ -0,0 +1,10 @@
|
||||
{ ... }:
|
||||
let
|
||||
inherit (builtins) attrNames filter readDir;
|
||||
dirs =
|
||||
let files = readDir ./.;
|
||||
in filter (name: files."${name}" == "directory") (attrNames files);
|
||||
in
|
||||
{
|
||||
imports = map (dir: ./${dir}) dirs;
|
||||
}
|
||||
24
home/gnome/extensions/freon/default.nix
Normal file
24
home/gnome/extensions/freon/default.nix
Normal file
@@ -0,0 +1,24 @@
|
||||
{ config, pkgs, lib, ... }:
|
||||
let
|
||||
cfg = config.gnome.extensions.freon;
|
||||
in
|
||||
{
|
||||
options.gnome.extensions = with lib.types; {
|
||||
freon = {
|
||||
enable = lib.mkEnableOption { };
|
||||
package = lib.mkOption {
|
||||
type = package;
|
||||
default = pkgs.gnomeExtensions.freon;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
dconf.settings = {
|
||||
"org/gnome/shell".enabled-extensions = [
|
||||
cfg.package.extensionUuid
|
||||
];
|
||||
};
|
||||
home.packages = [ cfg.package ];
|
||||
};
|
||||
}
|
||||
48
home/gnome/extensions/paperwm/default.nix
Normal file
48
home/gnome/extensions/paperwm/default.nix
Normal file
@@ -0,0 +1,48 @@
|
||||
{ config, pkgs, lib, ... }:
|
||||
let
|
||||
cfg = config.gnome.extensions;
|
||||
in
|
||||
{
|
||||
options.gnome.extensions = with lib.types; {
|
||||
paperwm = {
|
||||
enable = lib.mkEnableOption { };
|
||||
package = lib.mkOption {
|
||||
type = package;
|
||||
default = pkgs.gnomeExtensions.paperwm;
|
||||
};
|
||||
cycle-height-steps = lib.mkOption { type = listOf numbers.nonnegative; default = [ 0.33 0.5 0.67 1.0 ]; };
|
||||
cycle-width-steps = lib.mkOption { type = listOf numbers.nonnegative; default = [ 0.33 0.5 0.67 1.0 ]; };
|
||||
horizontal-margin = lib.mkOption { type = ints.unsigned; default = 5; };
|
||||
vertical-margin = lib.mkOption { type = ints.unsigned; default = 5; };
|
||||
window-gap = lib.mkOption { type = ints.unsigned; default = 5; };
|
||||
winprops = lib.mkOption {
|
||||
type = listOf (submodule {
|
||||
options = {
|
||||
wm_class = lib.mkOption { type = str; default = ""; };
|
||||
title = lib.mkOption { type = str; default = ""; };
|
||||
scratch_layer = lib.mkEnableOption { };
|
||||
preferredWidth = lib.mkOption { type = nullOr str; default = null; };
|
||||
};
|
||||
});
|
||||
default = [ ];
|
||||
};
|
||||
keybindings = lib.mkOption {
|
||||
type = attrsOf (listOf str);
|
||||
default = { };
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.paperwm.enable {
|
||||
home.packages = [ cfg.paperwm.package ];
|
||||
dconf.settings = {
|
||||
"org/gnome/shell".enabled-extensions =
|
||||
lib.mkIf cfg.paperwm.enable [ cfg.paperwm.package.extensionUuid ];
|
||||
"org/gnome/shell/extensions/paperwm" = with cfg.paperwm; lib.mkIf cfg.paperwm.enable {
|
||||
inherit cycle-height-steps cycle-width-steps horizontal-margin vertical-margin window-gap;
|
||||
winprops = map (props: builtins.toJSON props) winprops;
|
||||
};
|
||||
"org/gnome/shell/extensions/paperwm/keybindings" = lib.mkIf cfg.paperwm.enable cfg.paperwm.keybindings;
|
||||
};
|
||||
};
|
||||
}
|
||||
101
home/jokke/default.nix
Normal file
101
home/jokke/default.nix
Normal file
@@ -0,0 +1,101 @@
|
||||
{ pkgs, ksoloti-pr, ... }:
|
||||
{
|
||||
config = {
|
||||
# Home Manager needs a bit of information about you and the paths it should
|
||||
# manage.
|
||||
home.username = "jokke";
|
||||
home.homeDirectory = "/home/jokke";
|
||||
home.packages = with pkgs; [
|
||||
ffmpeg
|
||||
mediainfo
|
||||
git-lfs
|
||||
telegram-desktop
|
||||
shards
|
||||
deno
|
||||
virt-manager
|
||||
gimp
|
||||
lftp
|
||||
inkscape
|
||||
wineWowPackages.waylandFull
|
||||
reaper
|
||||
ksoloti-pr.ksoloti
|
||||
calibre
|
||||
jellyfin-media-player
|
||||
darktable
|
||||
openscad
|
||||
shutter
|
||||
];
|
||||
|
||||
gnome.profilePicture = ../assets/profile-pictures/jokke.png;
|
||||
|
||||
programs.neovim = {
|
||||
extraPackages = with pkgs; [
|
||||
nodePackages.graphql-language-service-cli
|
||||
];
|
||||
withTreesitterPlugins = p: [
|
||||
p.typescript
|
||||
p.svelte
|
||||
p.prisma
|
||||
p.graphql
|
||||
];
|
||||
formatters = [
|
||||
{
|
||||
filetypes = [ "typescript" "typescriptreact" "svelte" ];
|
||||
globs = [ "*.ts" "*.tsx" "*.svelte" ];
|
||||
exe = "npx";
|
||||
args = file: [ "prettier" "--stdin-filepath" file ];
|
||||
stdin = true;
|
||||
}
|
||||
{
|
||||
filetypes = [ "prisma" ];
|
||||
globs = [ "*.prisma" ];
|
||||
exe = "${pkgs.nodePackages.prisma}/bin/prisma";
|
||||
args = file: [ "format" "--schema" ];
|
||||
stdin = false;
|
||||
}
|
||||
];
|
||||
lsp.servers = with pkgs; [
|
||||
{
|
||||
name = "svelte";
|
||||
package = nodePackages.svelte-language-server;
|
||||
}
|
||||
{
|
||||
name = "denols";
|
||||
package = deno;
|
||||
rootPattern = [ "deno.json" ];
|
||||
}
|
||||
{
|
||||
name = "prismals";
|
||||
package = nodePackages."@prisma/language-server";
|
||||
rootPattern = [ "package.json" "deno.json" ];
|
||||
}
|
||||
{
|
||||
name = "graphql";
|
||||
package = nodePackages.graphql-language-service-cli;
|
||||
config = {
|
||||
filetypes = [ "typescript" "typescriptreact" "graphql" "svelte" ];
|
||||
};
|
||||
}
|
||||
];
|
||||
};
|
||||
|
||||
programs.ssh.matchBlocks = {
|
||||
"alderaan" = {
|
||||
hostname = "alderaan.space";
|
||||
user = "root";
|
||||
};
|
||||
"base.alderaan" = {
|
||||
hostname = "base.alderaan.space";
|
||||
user = "luke";
|
||||
};
|
||||
"jokke.space" = {
|
||||
user = "root";
|
||||
};
|
||||
};
|
||||
|
||||
programs.git.extraConfig.user.email = "joakim@repomaa.com";
|
||||
services.syncthing = {
|
||||
enable = true;
|
||||
};
|
||||
};
|
||||
}
|
||||
201
home/moco/default.nix
Normal file
201
home/moco/default.nix
Normal file
@@ -0,0 +1,201 @@
|
||||
{ pkgs, ... }:
|
||||
let
|
||||
homeDirectory = "/home/moco";
|
||||
in
|
||||
{
|
||||
# Home Manager needs a bit of information about you and the paths it should
|
||||
# manage.
|
||||
home = {
|
||||
username = "moco";
|
||||
inherit homeDirectory;
|
||||
packages = with pkgs; [
|
||||
(slack.overrideAttrs (oldAttrs: {
|
||||
fixupPhase = ''
|
||||
sed -i -e 's/,"WebRTCPipeWireCapturer"/,"LebRTCPipeWireCapturer"/' $out/lib/slack/resources/app.asar
|
||||
|
||||
rm $out/bin/slack
|
||||
makeWrapper $out/lib/slack/slack $out/bin/slack \
|
||||
--prefix XDG_DATA_DIRS : $GSETTINGS_SCHEMAS_PATH \
|
||||
--suffix PATH : ${lib.makeBinPath [ xdg-utils ]} \
|
||||
--add-flags "--ozone-platform-hint=auto --enable-features=WaylandWindowDecorations,WebRTCPipeWireCapturer"
|
||||
'';
|
||||
}))
|
||||
kooha
|
||||
gnome-pomodoro
|
||||
mitmproxy
|
||||
(writeShellScriptBin "moco-admin-pw" ''
|
||||
password=$(op item get fkj74ou6jfex7a6gcinac6o5oe --reveal --fields label=Kennwort)
|
||||
otp=$(ykman oath accounts code -s 'MOCO:Admin')
|
||||
echo "''${password}''${otp}" | wl-copy -n
|
||||
'')
|
||||
(writeShellScriptBin "moco-reto-otp" ''
|
||||
ykman oath accounts code -s 'MOCO Reto' | wl-copy -n
|
||||
'')
|
||||
];
|
||||
};
|
||||
|
||||
gnome = {
|
||||
profilePicture = ../assets/profile-pictures/moco.png;
|
||||
calendar.showWeekNumbers = true;
|
||||
extensions.paperwm.winprops = [
|
||||
{ wm_class = "gnome-pomodoro"; scratch_layer = true; }
|
||||
];
|
||||
};
|
||||
|
||||
programs.poetry = {
|
||||
enable = true;
|
||||
settings = {
|
||||
virtualenvs = {
|
||||
create = true;
|
||||
inProject = true;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
programs.zsh = {
|
||||
cdpath = [
|
||||
"${homeDirectory}/Code/mocoapp"
|
||||
"${homeDirectory}/Code/mocoapp-promo"
|
||||
"${homeDirectory}/Code/mocoapp-llama"
|
||||
];
|
||||
dirHashes = {
|
||||
moco = "${homeDirectory}/Code/mocoapp";
|
||||
promo = "${homeDirectory}/Code/mocoapp-promo";
|
||||
llama = "${homeDirectory}/Code/mocoapp-llama";
|
||||
};
|
||||
};
|
||||
|
||||
programs.git.extraConfig.user.email = "joakim.repomaa@mocoapp.com";
|
||||
|
||||
programs.neovim = {
|
||||
withTreesitterPlugins = p: [
|
||||
p.ruby
|
||||
p.javascript
|
||||
p.typescript
|
||||
p.graphql
|
||||
];
|
||||
formatters = [
|
||||
{
|
||||
filetypes = [ "ruby" ];
|
||||
globs = [ "*.rb" "Gemfile" "*.rake" ];
|
||||
exe = "bundle";
|
||||
args = file: [ "exec" "rufo" "-x" "--filename" file ];
|
||||
stdin = true;
|
||||
}
|
||||
{
|
||||
filetypes = [ "javascript" "typescript" "javascriptreact" "typescriptreact" ];
|
||||
globs = [ "*.js" "*.jsx" "*.ts" "*.tsx" ];
|
||||
exe = "npx";
|
||||
args = file: [ "prettier" "--stdin-filepath" file ];
|
||||
stdin = true;
|
||||
}
|
||||
];
|
||||
lsp.servers = with pkgs; [
|
||||
{
|
||||
name = "ruby_lsp";
|
||||
config = {
|
||||
init_options = {
|
||||
formatter = "auto";
|
||||
};
|
||||
};
|
||||
package = ruby-lsp;
|
||||
}
|
||||
{
|
||||
name = "graphql";
|
||||
package = nodePackages.graphql-language-service-cli;
|
||||
}
|
||||
];
|
||||
};
|
||||
|
||||
programs.ssh.matchBlocks =
|
||||
let
|
||||
aliases = [ "moco" "mocoapp" "mocoapp.com" ];
|
||||
matcher = subdomains:
|
||||
builtins.concatStringsSep " " (
|
||||
map
|
||||
(alias: builtins.concatStringsSep " " (
|
||||
map (subdomain: "*.${subdomain}.${alias} ${subdomain}.${alias}") subdomains
|
||||
))
|
||||
aliases);
|
||||
in
|
||||
{
|
||||
"console.*.moco" = {
|
||||
extraOptions = {
|
||||
RequestTTY = "force";
|
||||
RemoteCommand = "./rails-console.sh";
|
||||
};
|
||||
};
|
||||
|
||||
"${matcher ["reto" "reto.intern"]}" = {
|
||||
hostname = "reto.intern.mocoapp.com";
|
||||
user = "jokke";
|
||||
};
|
||||
|
||||
"${matcher ["web"]}" = {
|
||||
hostname = "mocoapp.com";
|
||||
};
|
||||
"${matcher ["prod-inc"]}" = {
|
||||
hostname = "prod-inc.mocoapp.com";
|
||||
};
|
||||
"${matcher ["prod"]}" = {
|
||||
hostname = "web02.mocoapp";
|
||||
};
|
||||
"${matcher ["pfg" "primeforcegroup"]}" = {
|
||||
hostname = "primeforcegroup.mocoapp.com";
|
||||
};
|
||||
"${matcher ["crafft"]}" = {
|
||||
hostname = "crafft.mocoapp.com";
|
||||
};
|
||||
"${matcher ["bd" "businessdecision"]}" = {
|
||||
hostname = "businessdecision.mocoapp.com";
|
||||
};
|
||||
"${matcher ["festland"]}" = {
|
||||
hostname = "festland.mocoapp.com";
|
||||
};
|
||||
"${matcher ["oi" "one-inside"]}" = {
|
||||
hostname = "one-inside.mocoapp.com";
|
||||
};
|
||||
"${matcher ["se" "scope-engineering"]}" = {
|
||||
hostname = "scope-engineering.mocoapp.com";
|
||||
};
|
||||
"${matcher ["cpc" "cpc-ag"]}" = {
|
||||
hostname = "cpc-ag.mocoapp.com";
|
||||
};
|
||||
"${matcher ["weareact3"]}" = {
|
||||
hostname = "weareact3.mocoapp.com";
|
||||
};
|
||||
"${matcher ["avenit"]}" = {
|
||||
hostname = "avenit.mocoapp.com";
|
||||
};
|
||||
"${matcher ["staging"]}" = {
|
||||
hostname = "staging.mocoapp.com";
|
||||
};
|
||||
"${matcher ["staging-v2"]}" = {
|
||||
hostname = "staging-v2.mocoapp.com";
|
||||
};
|
||||
"${matcher ["staging-v3"]}" = {
|
||||
hostname = "staging-v3.mocoapp.com";
|
||||
};
|
||||
"${matcher ["staging-v4"]}" = {
|
||||
hostname = "staging-v4.mocoapp.com";
|
||||
};
|
||||
"${matcher ["staging-v5"]}" = {
|
||||
hostname = "staging-v5.mocoapp.com";
|
||||
};
|
||||
"${matcher ["staging-v6"]}" = {
|
||||
hostname = "staging-v6.mocoapp.com";
|
||||
};
|
||||
"${matcher ["prod-db" "production-db"]}" = {
|
||||
hostname = "production-db.mocoapp";
|
||||
};
|
||||
"${matcher ["pdf-renderer"]}" = {
|
||||
hostname = "mocoapp-pdf-renderer01.mocoapp.com";
|
||||
};
|
||||
"*.moco *.mocoapp *.mocoapp.com" = {
|
||||
forwardAgent = true;
|
||||
};
|
||||
"*.moco !reto.moco *.mocoapp.com !reto.mocoapp.com" = {
|
||||
user = "butler";
|
||||
};
|
||||
};
|
||||
}
|
||||
392
home/modules/neovim/default.nix
Normal file
392
home/modules/neovim/default.nix
Normal file
@@ -0,0 +1,392 @@
|
||||
{ config, pkgs, lib, ... }:
|
||||
let
|
||||
cfg = config.programs.neovim;
|
||||
toLua = lib.generators.toLua { };
|
||||
buildPluginConfig = p:
|
||||
let
|
||||
pluginConfig = if builtins.hasAttr "plugin" p then p else { plugin = p; };
|
||||
name = pluginConfig.plugin.name;
|
||||
|
||||
config = if (builtins.isNull pluginConfig.config or null) then "" else pluginConfig.config;
|
||||
mappings = if (builtins.isNull pluginConfig.mappings or null) then "" else generateMappings pluginConfig.mappings;
|
||||
mergedConfig = config + mappings;
|
||||
in
|
||||
[
|
||||
{
|
||||
plugin = pluginConfig.plugin;
|
||||
config = lib.modules.mkIf (mergedConfig != "") ''
|
||||
Plugins[${toLua name}] = {}
|
||||
Plugins[${toLua name}].setup = function()
|
||||
${lib.strings.concatMapStrings
|
||||
(line: if line == "" then "" else " ${line}\n")
|
||||
(lib.strings.splitString "\n" mergedConfig)
|
||||
|
||||
}
|
||||
end
|
||||
|
||||
Plugins[${toLua name}].setup()
|
||||
'';
|
||||
type = "lua";
|
||||
}
|
||||
] ++ (
|
||||
lib.lists.concatMap buildPluginConfig pluginConfig.dependencies or [ ]
|
||||
);
|
||||
|
||||
lspPluginConfig = with pkgs.vimPlugins; {
|
||||
plugin = nvim-lspconfig;
|
||||
dependencies = [
|
||||
nvim-cmp
|
||||
cmp-nvim-lsp
|
||||
cmp_luasnip
|
||||
luasnip
|
||||
];
|
||||
|
||||
config = (builtins.readFile ./lsp-config.lua) + ''
|
||||
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
||||
capabilities.workspace.didChangeWatchedFiles.dynamicRegistration = true
|
||||
local lspconfig = require('lspconfig')
|
||||
local util = require('lspconfig.util')
|
||||
|
||||
local on_attach = function (client, bufnr)
|
||||
local function buf_set_option(...) vim.api.nvim_buf_set_option(bufnr, ...) end
|
||||
local map = function (lhs, rhs)
|
||||
print('set mapping ' .. lhs)
|
||||
end
|
||||
|
||||
-- Enable completion triggered by <c-x><c-o>
|
||||
buf_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc')
|
||||
|
||||
-- Mappings.
|
||||
-- See `:help vim.lsp.*` for documentation on any of the below functions
|
||||
|
||||
${lib.strings.concatLines (lib.attrsets.mapAttrsToList (name: value: ''
|
||||
local buf_${name} = vim.lsp.buf[${toLua name}]
|
||||
if buf_${name} then
|
||||
vim.keymap.set('n', ${toLua value}, buf_${name}, { buffer = bufnr })
|
||||
end
|
||||
''
|
||||
) cfg.lsp.mappings.buf)}
|
||||
${lib.strings.concatLines (lib.attrsets.mapAttrsToList (name: value: ''
|
||||
local diagnostic_${name} = vim.lsp.buf[${toLua name}]
|
||||
if diagnostic_${name} then
|
||||
vim.keymap.set('n', ${toLua value}, diagnostic_${name}, { buffer = bufnr })
|
||||
end
|
||||
'') cfg.lsp.mappings.diagnostic)}
|
||||
end
|
||||
|
||||
vim.env.PATH = ${toLua (lib.makeBinPath (map (s: s.package) (builtins.filter (s: builtins.hasAttr "package" s) cfg.lsp.servers)) + ":")} .. vim.env.PATH
|
||||
local servers = ${toLua (map (
|
||||
{ name, config ? {}, rootPattern ? null, ... }: {
|
||||
inherit name;
|
||||
config = config // (if (builtins.isNull rootPattern) then {} else { inherit rootPattern; });
|
||||
}
|
||||
) cfg.lsp.servers)}
|
||||
|
||||
for _, server in ipairs(servers) do
|
||||
local server_config = server.config
|
||||
server_config.on_attach = on_attach
|
||||
server_config.capabilities = capabilities
|
||||
server_config.flags = {
|
||||
debounce_text_changes = 150
|
||||
}
|
||||
|
||||
if server_config.rootPattern then
|
||||
server_config.root_dir = util.root_pattern(
|
||||
unpack(server_config.rootPattern)
|
||||
)
|
||||
end
|
||||
|
||||
lspconfig[server.name].setup(server_config)
|
||||
end
|
||||
'';
|
||||
|
||||
};
|
||||
|
||||
treesitterPluginConfig = with pkgs.vimPlugins; {
|
||||
plugin = nvim-treesitter.withPlugins cfg.withTreesitterPlugins;
|
||||
config = ''
|
||||
require('nvim-treesitter.configs').setup(${toLua {
|
||||
highlight = {
|
||||
enable = true;
|
||||
additional_vim_regex_highlighting = false;
|
||||
};
|
||||
}});
|
||||
'';
|
||||
};
|
||||
|
||||
formatterPluginConfig = with pkgs.vimPlugins; {
|
||||
plugin = formatter-nvim;
|
||||
config = ''
|
||||
local formatter = require('formatter')
|
||||
local util = require('formatter.util')
|
||||
|
||||
formatter.setup({
|
||||
filetype = {
|
||||
${lib.strings.concatMapStringsSep ",\n " ({ exe, args, stdin, no_append, filetypes, ... }:
|
||||
lib.strings.concatMapStringsSep ",\n " (filetype: ''
|
||||
[${toLua filetype}] = {
|
||||
function ()
|
||||
return {
|
||||
exe = ${toLua exe},
|
||||
args = {
|
||||
${lib.strings.concatMapStringsSep ",\n " (arg:
|
||||
if arg == "<<FILE>>"
|
||||
then "util.escape_path(util.get_current_buffer_file_path())"
|
||||
else toLua arg
|
||||
) (args "<<FILE>>")}
|
||||
},
|
||||
stdin = ${toLua stdin},
|
||||
no_append = ${toLua no_append},
|
||||
}
|
||||
end
|
||||
}
|
||||
'') filetypes
|
||||
) cfg.formatters}
|
||||
}
|
||||
})
|
||||
${generateAutoCommand {
|
||||
event = "BufWritePost";
|
||||
pattern = lib.lists.concatMap ({ globs, ... }: globs) cfg.formatters;
|
||||
command = "FormatWrite";
|
||||
group = "FormatAutogroup";
|
||||
}}
|
||||
'';
|
||||
};
|
||||
|
||||
customTypes = let inherit (lib) mkOption mkEnableOption types; in {
|
||||
mapping = types.submodule {
|
||||
options = {
|
||||
rhs = mkOption { type = types.str; };
|
||||
lua = mkEnableOption { };
|
||||
options = mkOption {
|
||||
type = types.nullOr (
|
||||
types.submodule {
|
||||
options = {
|
||||
buffer = mkOption { type = types.nullOr (types.either types.int types.bool); default = null; };
|
||||
nowait = mkOption { type = types.nullOr types.bool; default = null; };
|
||||
silent = mkOption { type = types.nullOr types.bool; default = null; };
|
||||
expr = mkOption { type = types.nullOr types.bool; default = null; };
|
||||
script = mkOption { type = types.nullOr types.bool; default = null; };
|
||||
unique = mkOption { type = types.nullOr types.bool; default = null; };
|
||||
replace_keycodes = mkOption { type = types.nullOr types.bool; default = null; };
|
||||
};
|
||||
}
|
||||
);
|
||||
default = { };
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
modeMappings = types.attrsOf (types.either types.str customTypes.mapping);
|
||||
|
||||
mappings = types.submodule {
|
||||
options = {
|
||||
normal = mkOption { type = customTypes.modeMappings; default = { }; };
|
||||
insert = mkOption { type = customTypes.modeMappings; default = { }; };
|
||||
visual = mkOption { type = customTypes.modeMappings; default = { }; };
|
||||
command = mkOption { type = customTypes.modeMappings; default = { }; };
|
||||
select = mkOption { type = customTypes.modeMappings; default = { }; };
|
||||
};
|
||||
};
|
||||
|
||||
plugin = types.either types.package (types.submodule {
|
||||
options = {
|
||||
plugin = mkOption { type = types.package; };
|
||||
dependencies = mkOption {
|
||||
type = types.listOf customTypes.plugin;
|
||||
default = [ ];
|
||||
};
|
||||
mappings = mkOption { type = customTypes.mappings; default = { }; };
|
||||
config = mkOption { type = types.nullOr types.str; default = null; };
|
||||
};
|
||||
});
|
||||
|
||||
autoCommand = types.submodule {
|
||||
options = {
|
||||
event = mkOption { type = types.either types.str (types.listOf types.str); };
|
||||
pattern = mkOption { type = types.either types.str (types.listOf types.str); };
|
||||
command = mkOption { type = types.str; };
|
||||
};
|
||||
};
|
||||
|
||||
lspServer = types.submodule {
|
||||
options = {
|
||||
name = mkOption { type = types.str; };
|
||||
config = mkOption { type = types.attrs; default = { }; };
|
||||
package = mkOption { type = types.nullOr types.package; default = null; };
|
||||
rootPattern = mkOption { type = types.nullOr (types.listOf types.str); default = null; };
|
||||
};
|
||||
};
|
||||
|
||||
formatter = types.submodule {
|
||||
options = {
|
||||
filetypes = mkOption { type = types.listOf types.str; };
|
||||
globs = mkOption { type = types.listOf types.str; };
|
||||
exe = mkOption { type = types.either types.path types.str; };
|
||||
args = mkOption { type = types.functionTo (types.listOf types.str); default = _: [ ]; };
|
||||
stdin = mkEnableOption { };
|
||||
no_append = mkEnableOption { };
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
generateMappings = mappings: lib.strings.concatLines (
|
||||
lib.attrsets.mapAttrsToList
|
||||
(mode: modeMappings:
|
||||
lib.strings.concatLines (
|
||||
lib.attrsets.mapAttrsToList
|
||||
(name: value:
|
||||
|
||||
let
|
||||
mapping = { lhs = name; lua = false; options = { }; } // (if builtins.isString value then { rhs = value; } else value);
|
||||
args = [
|
||||
(toLua (builtins.substring 0 1 mode))
|
||||
(toLua mapping.lhs)
|
||||
(if mapping.lua then mapping.rhs else toLua mapping.rhs)
|
||||
(
|
||||
toLua (
|
||||
builtins.listToAttrs (
|
||||
builtins.filter ({ value, ... }: !isNull (value)) (lib.attrsets.attrsToList mapping.options)
|
||||
)
|
||||
)
|
||||
)
|
||||
];
|
||||
in
|
||||
"vim.keymap.set(${lib.strings.concatStringsSep ", " args})"
|
||||
)
|
||||
modeMappings
|
||||
)
|
||||
)
|
||||
mappings
|
||||
);
|
||||
|
||||
generateAutoCommand = { event, pattern, command, group ? null }: ''
|
||||
vim.api.nvim_create_autocmd(${toLua event}, {
|
||||
pattern = ${toLua pattern},
|
||||
command = ${toLua command},
|
||||
group = ${if isNull group then toLua group else ''
|
||||
vim.api.nvim_create_augroup(${toLua group}, { clear = true })
|
||||
''},
|
||||
})
|
||||
'';
|
||||
|
||||
generateAutoCommands = autoCommands: lib.strings.concatLines (
|
||||
map generateAutoCommand autoCommands
|
||||
);
|
||||
|
||||
generateSignDefinitions = signs: lib.strings.concatLines (
|
||||
lib.attrsets.mapAttrsToList
|
||||
(name: value:
|
||||
let
|
||||
hl = "DiagnosticSign${lib.strings.toUpper (builtins.substring 0 1 name)}${builtins.substring 1 (-1) name}";
|
||||
in
|
||||
"vim.fn.sign_define(${toLua hl}, ${toLua { text = value; texthl = hl; numhl = ""; }})"
|
||||
)
|
||||
signs
|
||||
);
|
||||
in
|
||||
{
|
||||
options.programs.neovim =
|
||||
let
|
||||
inherit (lib) mkOption types;
|
||||
in
|
||||
{
|
||||
mappings = mkOption { type = customTypes.mappings; default = { }; };
|
||||
plug = mkOption {
|
||||
type = types.listOf customTypes.plugin;
|
||||
default = [ ];
|
||||
};
|
||||
leader = mkOption { type = types.str; default = "\\"; };
|
||||
options = mkOption {
|
||||
type = types.attrs;
|
||||
default = { };
|
||||
};
|
||||
snippets = mkOption {
|
||||
type = types.attrsOf types.path;
|
||||
default = { };
|
||||
};
|
||||
autoCommands = mkOption {
|
||||
type = types.listOf customTypes.autoCommand;
|
||||
default = [ ];
|
||||
};
|
||||
env = mkOption {
|
||||
type = types.attrsOf types.str;
|
||||
default = { };
|
||||
};
|
||||
signs = {
|
||||
error = mkOption { type = types.str; default = ""; };
|
||||
warning = mkOption { type = types.str; default = ""; };
|
||||
info = mkOption { type = types.str; default = ""; };
|
||||
hint = mkOption { type = types.str; default = ""; };
|
||||
};
|
||||
lsp = {
|
||||
servers = mkOption {
|
||||
type = types.listOf customTypes.lspServer;
|
||||
default = [ ];
|
||||
};
|
||||
mappings = {
|
||||
buf = mkOption { type = types.attrsOf types.str; default = { }; };
|
||||
diagnostic = mkOption { type = types.attrsOf types.str; default = { }; };
|
||||
};
|
||||
};
|
||||
withTreesitterPlugins = mkOption {
|
||||
type = types.functionTo (types.listOf types.package);
|
||||
default = _: [ ];
|
||||
};
|
||||
formatters = mkOption {
|
||||
type = types.listOf customTypes.formatter;
|
||||
default = [ ];
|
||||
};
|
||||
};
|
||||
|
||||
config = {
|
||||
programs.neovim = {
|
||||
extraLuaConfig = lib.strings.concatLines [
|
||||
"local Plugins = {}"
|
||||
(generateMappings cfg.mappings)
|
||||
(generateAutoCommands cfg.autoCommands)
|
||||
(lib.strings.concatLines (lib.attrsets.mapAttrsToList (name: value: "vim.env.${name} = ${toLua value}") cfg.env))
|
||||
(lib.strings.concatLines (lib.attrsets.mapAttrsToList (name: value: "vim.opt.${name} = ${toLua value}") cfg.options))
|
||||
(generateSignDefinitions cfg.signs)
|
||||
"vim.g.mapleader = ${toLua cfg.leader}"
|
||||
''
|
||||
local undodir = ${toLua (
|
||||
if builtins.hasAttr "undodir" cfg.options
|
||||
then cfg.options.undodir
|
||||
else "${config.xdg.cacheHome}/nvim/undo"
|
||||
)}
|
||||
vim.opt.undodir = undodir
|
||||
vim.fn.mkdir(undodir, 'p')
|
||||
''
|
||||
];
|
||||
plugins = lib.lists.concatMap buildPluginConfig (
|
||||
cfg.plug ++ [
|
||||
lspPluginConfig
|
||||
treesitterPluginConfig
|
||||
formatterPluginConfig
|
||||
]
|
||||
);
|
||||
vimAlias = lib.mkForce false;
|
||||
vimdiffAlias = lib.mkForce false;
|
||||
};
|
||||
|
||||
xdg.configFile = (
|
||||
lib.attrsets.mapAttrs'
|
||||
(name: value: {
|
||||
name = "nvim/${name}";
|
||||
value = { source = value; };
|
||||
})
|
||||
cfg.snippets
|
||||
);
|
||||
|
||||
home.shellAliases =
|
||||
let
|
||||
nvim = ''nvim --listen "$XDG_RUNTIME_DIR/nvimsocket"'';
|
||||
in
|
||||
{
|
||||
inherit nvim;
|
||||
vim = nvim;
|
||||
vimdiff = "${nvim} -d";
|
||||
};
|
||||
};
|
||||
}
|
||||
89
home/modules/neovim/lsp-config.lua
Normal file
89
home/modules/neovim/lsp-config.lua
Normal file
@@ -0,0 +1,89 @@
|
||||
local Lsp = {}
|
||||
|
||||
Lsp.setup = function()
|
||||
local luasnip = require("luasnip")
|
||||
local cmp = require("cmp")
|
||||
|
||||
local has_words_before = function()
|
||||
if vim.api.nvim_buf_get_option(0, "buftype") == "prompt" then
|
||||
return false
|
||||
end
|
||||
local line, col = unpack(vim.api.nvim_win_get_cursor(0))
|
||||
return col ~= 0 and vim.api.nvim_buf_get_text(0, line - 1, 0, line - 1, col, {})[1]:match("^%s*$") == nil
|
||||
end
|
||||
|
||||
cmp.setup({
|
||||
snippet = {
|
||||
expand = function(args)
|
||||
luasnip.lsp_expand(args.body)
|
||||
end,
|
||||
},
|
||||
window = {
|
||||
completion = cmp.config.window.bordered(),
|
||||
documentation = cmp.config.window.bordered(),
|
||||
},
|
||||
mapping = {
|
||||
["<C-p>"] = function()
|
||||
if luasnip.jumpable(-1) then
|
||||
luasnip.jump(-1)
|
||||
else
|
||||
cmp.mapping.select_prev_item()
|
||||
end
|
||||
end,
|
||||
["<C-n>"] = function()
|
||||
if luasnip.expand_or_jumpable() then
|
||||
luasnip.expand_or_jump()
|
||||
else
|
||||
cmp.mapping.select_next_item()
|
||||
end
|
||||
end,
|
||||
["<C-d>"] = cmp.mapping.scroll_docs(-4),
|
||||
["<C-f>"] = cmp.mapping.scroll_docs(4),
|
||||
["<C-Space>"] = cmp.mapping.complete(),
|
||||
["<C-e>"] = cmp.mapping.close(),
|
||||
["<CR>"] = cmp.mapping.confirm({
|
||||
behavior = cmp.ConfirmBehavior.Replace,
|
||||
select = true,
|
||||
}),
|
||||
["<Tab>"] = function(fallback)
|
||||
if cmp.visible() and has_words_before() then
|
||||
cmp.select_next_item()
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end,
|
||||
["<S-Tab>"] = function(fallback)
|
||||
if cmp.visible() and has_words_before() then
|
||||
cmp.select_prev_item()
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end,
|
||||
},
|
||||
sources = {
|
||||
{ name = "copilot", group_index = 2 },
|
||||
{ name = "nvim_lsp", group_index = 2 },
|
||||
{ name = "luasnip", group_index = 2 },
|
||||
},
|
||||
})
|
||||
|
||||
vim.o.completeopt = "menuone,noselect"
|
||||
vim.o.updatetime = 250
|
||||
vim.cmd([[autocmd CursorHold,CursorHoldI * lua vim.diagnostic.open_float(nil, {focus=false})]])
|
||||
vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with(vim.lsp.diagnostic.on_publish_diagnostics, {
|
||||
virtual_text = {
|
||||
source = "if_many",
|
||||
},
|
||||
})
|
||||
|
||||
vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, { border = "rounded" })
|
||||
|
||||
vim.lsp.handlers["textDocument/signatureHelp"] =
|
||||
vim.lsp.with(vim.lsp.handlers.signature_help, { border = "rounded" })
|
||||
|
||||
vim.diagnostic.config({
|
||||
float = { border = "rounded", zindex = 1 },
|
||||
})
|
||||
end
|
||||
|
||||
Lsp.setup()
|
||||
Reference in New Issue
Block a user