home: create 'modules/home' folder

Consolidating all modules under the same path, to clear out the
top-level directory.
This commit is contained in:
Bruno BELANYI 2023-11-09 13:43:55 +00:00
parent c856933803
commit 65a8f7c481
119 changed files with 2 additions and 2 deletions

View file

@ -0,0 +1,26 @@
{ config, lib, ... }:
let
cfg = config.my.home.aliases;
in
{
options.my.home.aliases = with lib; {
enable = my.mkDisableOption "shell aliases configuration";
};
config = lib.mkIf cfg.enable {
home = {
shellAliases = {
# I like pretty colors
diff = "diff --color=auto";
grep = "grep --color=auto";
egrep = "egrep --color=auto";
fgrep = "fgrep --color=auto";
ls = "ls --color=auto";
# Well-known ls aliases
l = "ls -alh";
ll = "ls -l";
};
};
};
}

View file

@ -0,0 +1,31 @@
{ config, lib, ... }:
let
cfg = config.my.home.atuin;
in
{
options.my.home.atuin = with lib; {
enable = my.mkDisableOption "atuin configuration";
};
config = lib.mkIf cfg.enable {
programs.atuin = {
enable = true;
flags = [
# I *despise* this hijacking of the up key, even though I use Ctrl-p
"--disable-up-arrow"
];
settings = {
# The package is managed by Nix
update_check = false;
# I don't care for the fancy display
style = "compact";
# Get closer to fzf's fuzzy search
search_mode = "skim";
# Show long command lines at the bottom
show_preview = true;
};
};
};
}

View file

@ -0,0 +1,18 @@
{ config, lib, ... }:
let
cfg = config.my.home.bat;
in
{
options.my.home.bat = with lib; {
enable = my.mkDisableOption "bat configuration";
};
config.programs.bat = lib.mkIf cfg.enable {
enable = true;
config = {
theme = "gruvbox-dark";
pager = with config.home.sessionVariables; "${PAGER} ${LESS}";
};
};
}

View file

@ -0,0 +1,27 @@
{ config, lib, ... }:
let
cfg = config.my.home.bitwarden;
in
{
options.my.home.bitwarden = with lib; {
enable = my.mkDisableOption "bitwarden configuration";
pinentry = mkOption {
type = types.str;
default = "tty";
example = "gtk2";
description = "Which pinentry interface to use";
};
};
config = lib.mkIf cfg.enable {
programs.rbw = {
enable = true;
settings = {
email = lib.my.mkMailAddress "bruno" "belanyi.fr";
inherit (cfg) pinentry;
};
};
};
}

View file

@ -0,0 +1,19 @@
{ config, lib, ... }:
let
cfg = config.my.home.bluetooth;
in
{
options.my.home.bluetooth = with lib; {
enable = mkEnableOption "bluetooth configuration";
};
config = lib.mkIf cfg.enable {
services.blueman-applet = {
enable = true;
};
services.mpris-proxy = {
enable = true;
};
};
}

View file

@ -0,0 +1,15 @@
{ config, lib, pkgs, ... }:
let
cfg = config.my.home.calibre;
in
{
options.my.home.calibre = with lib; {
enable = mkEnableOption "calibre configuration";
};
config = lib.mkIf cfg.enable {
home.packages = with pkgs; [
calibre
];
};
}

View file

@ -0,0 +1,15 @@
{ config, lib, pkgs, ... }:
let
cfg = config.my.home.comma;
in
{
options.my.home.comma = with lib; {
enable = my.mkDisableOption "comma configuration";
};
config = lib.mkIf cfg.enable {
home.packages = with pkgs; [
ambroisie.comma
];
};
}

56
modules/home/default.nix Normal file
View file

@ -0,0 +1,56 @@
{ ... }:
{
imports = [
./aliases
./atuin
./bat
./bitwarden
./bluetooth
./calibre
./comma
./dircolors
./direnv
./discord
./documentation
./feh
./firefox
./flameshot
./fzf
./gammastep
./gdb
./git
./gpg
./gtk
./htop
./jq
./mail
./mpv
./nix
./nix-index
./nixpkgs
./nm-applet
./packages
./pager
./power-alert
./secrets
./ssh
./terminal
./tmux
./udiskie
./vim
./wm
./x
./xdg
./zathura
./zsh
];
# First sane reproducible version
home.stateVersion = "20.09";
# Who am I?
home.username = "ambroisie";
# Start services automatically
systemd.user.startServices = "sd-switch";
}

View file

@ -0,0 +1,15 @@
{ config, lib, ... }:
let
cfg = config.my.home.dircolors;
in
{
options.my.home.dircolors = with lib; {
enable = my.mkDisableOption "dircolors configuration";
};
config = lib.mkIf cfg.enable {
programs.dircolors = {
enable = true;
};
};
}

View file

@ -0,0 +1,46 @@
{ config, lib, ... }:
let
cfg = config.my.home.direnv;
in
{
options.my.home.direnv = with lib; {
enable = my.mkDisableOption "direnv configuration";
defaultFlake = mkOption {
type = types.str;
default = "pkgs";
example = "nixpkgs";
description = ''
Which flake from the registry should be used for
<command>use pkgs</command> by default.
'';
};
};
config = lib.mkIf cfg.enable {
programs.direnv = {
enable = true;
nix-direnv = {
# A better `use_nix`
enable = true;
};
};
xdg.configFile =
let
libDir = ./lib;
contents = builtins.readDir libDir;
names = lib.attrNames contents;
files = lib.filter (name: contents.${name} == "regular") names;
linkLibFile = name:
lib.nameValuePair
"direnv/lib/${name}"
{ source = libDir + "/${name}"; };
in
lib.my.genAttrs' files linkLibFile;
home.sessionVariables = {
DIRENV_DEFAULT_FLAKE = cfg.defaultFlake;
};
};
}

View file

@ -0,0 +1,69 @@
#shellcheck shell=bash
use_pkgs() {
if ! has nix; then
# shellcheck disable=2016
log_error 'use_pkgs: `nix` is not in PATH'
return 1
fi
# Use user-provided default value, or fallback to nixpkgs
local DEFAULT_FLAKE="${DIRENV_DEFAULT_FLAKE:-nixpkgs}"
# Additional args that should be forwarded to `nix`
local args=()
# Allow changing the default flake through a command line switch
while true; do
case "$1" in
-b|--broken)
args+=(--impure)
export NIXPKGS_ALLOW_BROKEN=1
shift
;;
-f|--flake)
DEFAULT_FLAKE="$2"
shift 2
;;
-i|--impure)
args+=(--impure)
shift
;;
-s|--insecure)
args+=(--impure)
export NIXPKGS_ALLOW_INSECURE=1
shift
;;
-u|--unfree)
args+=(--impure)
export NIXPKGS_ALLOW_UNFREE=1
shift
;;
--)
shift
break
;;
*)
break
;;
esac
done
# Allow specifying a full installable, or just a package name and use the default flake
local packages=()
for pkg; do
if [[ $pkg =~ .*#.* ]]; then
packages+=("$pkg")
else
packages+=("$DEFAULT_FLAKE#$pkg")
fi
done
# shellcheck disable=2154
direnv_load nix shell "${args[@]}" "${packages[@]}" --command "$direnv" dump
# Clean-up after ourselves (assumes the user does not set them before us)
unset NIXPKGS_ALLOW_BROKEN
unset NIXPKGS_ALLOW_INSECURE
unset NIXPKGS_ALLOW_UNFREE
}

View file

@ -0,0 +1,22 @@
#shellcheck shell=bash
layout_postgres() {
if ! has postgres || ! has initdb; then
# shellcheck disable=2016
log_error 'layout_postgres: `postgres` and `initdb` are not in PATH'
return 1
fi
# shellcheck disable=2155
export PGDATA="$(direnv_layout_dir)/postgres"
export PGHOST="$PGDATA"
if [[ ! -d "$PGDATA" ]]; then
initdb
cat >> "$PGDATA/postgresql.conf" << EOF
listen_addresses = ''
unix_socket_directories = '$PGHOST'
EOF
echo "CREATE DATABASE $USER;" | postgres --single -E postgres
fi
}

View file

@ -0,0 +1,25 @@
#shellcheck shell=bash
layout_poetry() {
if ! has poetry; then
# shellcheck disable=2016
log_error 'layout_poetry: `poetry` is not in PATH'
return 1
fi
if [[ ! -f pyproject.toml ]]; then
# shellcheck disable=2016
log_error 'layout_poetry: no pyproject.toml found. Use `poetry new` or `poetry init` to create one first'
return 1
fi
# create venv if it doesn't exist
poetry run true
# shellcheck disable=2155
export VIRTUAL_ENV=$(poetry env info --path)
export POETRY_ACTIVE=1
PATH_add "$VIRTUAL_ENV/bin"
watch_file pyproject.toml
watch_file poetry.lock
}

View file

@ -0,0 +1,23 @@
{ config, lib, pkgs, ... }:
let
cfg = config.my.home.discord;
jsonFormat = pkgs.formats.json { };
in
{
options.my.home.discord = with lib; {
enable = mkEnableOption "discord configuration";
};
config = lib.mkIf cfg.enable {
home.packages = with pkgs; [
discord
];
xdg.configFile."discord/settings.json".source =
jsonFormat.generate "discord.json" {
# Do not keep me from using the app just to force an update
SKIP_HOST_UPDATE = true;
};
};
}

View file

@ -0,0 +1,17 @@
{ config, lib, ... }:
let
cfg = config.my.home.documentation;
in
{
options.my.home.documentation = with lib; {
enable = my.mkDisableOption "documentation integration";
};
# Add documentation for user packages
config.programs.man = {
enable = cfg.enable;
generateCaches = true; # Enables the use of `apropos` etc...
};
config.programs.info.enable = cfg.enable;
}

View file

@ -0,0 +1,13 @@
{ config, lib, ... }:
let
cfg = config.my.home.feh;
in
{
options.my.home.feh = with lib; {
enable = mkEnableOption "feh configuration";
};
config.programs.feh = lib.mkIf cfg.enable {
enable = true;
};
}

View file

@ -0,0 +1,80 @@
{ config, lib, pkgs, ... }:
let
cfg = config.my.home.firefox;
in
{
imports = [
./tridactyl
];
options.my.home.firefox = with lib; {
enable = mkEnableOption "firefox configuration";
tridactyl = {
enable = mkOption {
type = types.bool;
description = "tridactyl configuration";
example = false;
default = config.my.home.firefox.enable;
};
};
ff2mpv = {
enable = mkOption {
type = types.bool;
description = "ff2mpv configuration";
example = false;
default = config.my.home.mpv.enable;
};
};
};
config.programs.firefox = lib.mkIf cfg.enable {
enable = true;
package = pkgs.firefox.override {
nativeMessagingHosts = ([ ]
++ lib.optional cfg.tridactyl.enable pkgs.tridactyl-native
# Watch videos using mpv
++ lib.optional cfg.ff2mpv.enable pkgs.ambroisie.ff2mpv-go
);
};
profiles = {
default = {
id = 0;
settings = {
"browser.bookmarks.showMobileBookmarks" = true; # Mobile bookmarks
"browser.download.useDownloadDir" = false; # Ask for download location
"browser.in-content.dark-mode" = true; # Dark mode
"browser.newtabpage.activity-stream.feeds.section.topstories" = false; # Disable top stories
"browser.newtabpage.activity-stream.feeds.sections" = false;
"browser.newtabpage.activity-stream.feeds.system.topstories" = false; # Disable top stories
"browser.newtabpage.activity-stream.section.highlights.includePocket" = false; # Disable pocket
"extensions.pocket.enabled" = false; # Disable pocket
"media.eme.enabled" = true; # Enable DRM
"media.gmp-widevinecdm.enabled" = true; # Enable DRM
"media.gmp-widevinecdm.visible" = true; # Enable DRM
"signon.autofillForms" = false; # Disable built-in form-filling
"signon.rememberSignons" = false; # Disable built-in password manager
"ui.systemUsesDarkTheme" = true; # Dark mode
};
extensions = with pkgs.nur.repos.rycee.firefox-addons; ([
bitwarden
consent-o-matic
form-history-control
reddit-comment-collapser
reddit-enhancement-suite
refined-github
sponsorblock
ublock-origin
]
++ lib.optional (cfg.tridactyl.enable) tridactyl
++ lib.optional (cfg.ff2mpv.enable) ff2mpv
);
};
};
};
}

View file

@ -0,0 +1,28 @@
{ config, lib, pkgs, ... }:
let
cfg = config.my.home.firefox.tridactyl;
term = config.my.home.terminal.program;
vimCommandLine = {
alacritty = ''-e "vim" "%f" "+normal!%lGzv%c|"'';
# Termite wants the whole command in a single argument...
termite = ''-e "vim %f '+normal!%lGzv%c|'"'';
};
in
{
config = lib.mkIf cfg.enable {
xdg.configFile."tridactyl/tridactylrc".source = pkgs.substituteAll {
src = ./tridactylrc;
editorcmd = lib.concatStringsSep " " [
# Use my configured terminal
term
# Make it easy to pick out with a window class name
"--class tridactyl_editor"
# Open vim with the cursor in the correct position
vimCommandLine.${term}
];
};
};
}

View file

@ -0,0 +1,82 @@
" Shamelessly taken from bovine3dom's example configuration file from the docs
" Basics {{{
" Use dark color scheme
colorscheme dark
" Make tridactyl open Vim in my prefered terminal
set editorcmd @editorcmd@
" Remove editor file after use
alias editor_rm composite editor | jsb -p tri.native.run(`rm -f '${JS_ARG[0]}'`)
bind --mode=insert <C-i> editor_rm
bind --mode=input <C-i> editor_rm
" }}}
" Binds {{{
" Reddit et al. {{{
" Toggle comments on Reddit, Hacker News, Lobste.rs
bind ;c hint -Jc [class*="expand"],[class*="togg"],[class="comment_folder"]
" Make `gu` take me back to subreddit from comments
bindurl reddit.com gu urlparent 3
" Only hint search results on Google
bindurl www.google.com f hint -Jc #search div:not(.action-menu) > a
bindurl www.google.com F hint -Jbc #search div:not(.action-menu) > a
" Only hint search results on DuckDuckGo
bindurl ^https://duckduckgo.com f hint -Jc [data-testid="result-title-a"]
bindurl ^https://duckduckgo.com F hint -Jbc [data-testid="result-title-a"]
" Only hint item pages on Hacker News
bindurl news.ycombinator.com ;f hint -Jc .age > a
bindurl news.ycombinator.com ;F hint -Jtc .age > a
" }}}
" Better bindings {{{
" Handy multiwindow binds
bind gd tabdetach
bind gD composite tabduplicate; tabdetach
" Duplicate a tab without detaching window
bind <Space>d tabduplicate
" Make yy use canonical links on the few websites that support them
bind yy clipboard yankcanon
" }}}
" Search {{{
" Case insensitive only if fully lowercase
set findcase smart
" Search forward/backward
bind / fillcmdline find
bind ? fillcmdline find -?
" Go to next/previous match
bind n findnext 1
bind N findnext -1
" Because :nohls never works
bind <Space><Space> nohlsearch
" Use browser's native find when using Ctrl-F
unbind <C-f>
" }}}
" }}}
" Redirections {{{
" Always redirect Reddit to the old site
autocmd DocStart ^http(s?)://www.reddit.com js tri.excmds.urlmodify("-t", "www", "old")
" Use a better Twitter front-end
autocmd DocStart ^http(s?)://twitter.com js tri.excmds.urlmodify("-t", "twitter.com", "nitter.net")
" }}}
" Disabled websites {{{
blacklistadd netflix.com
blacklistadd primevideo.com
blacklistadd jellyfin.belanyi.fr
" }}}
" vim: set filetype=vim foldmethod=marker:

View file

@ -0,0 +1,13 @@
{ config, lib, ... }:
let
cfg = config.my.home.flameshot;
in
{
options.my.home.flameshot = with lib; {
enable = mkEnableOption "flameshot configuration";
};
config.services.flameshot = lib.mkIf cfg.enable {
enable = true;
};
}

View file

@ -0,0 +1,15 @@
{ config, lib, ... }:
let
cfg = config.my.home.fzf;
in
{
options.my.home.fzf = with lib; {
enable = my.mkDisableOption "fzf configuration";
};
config = lib.mkIf cfg.enable {
programs.fzf = {
enable = true;
};
};
}

View file

@ -0,0 +1,44 @@
{ config, lib, ... }:
let
cfg = config.my.home.gammastep;
mkTempOption = with lib; description: default: mkOption {
inherit description default;
type = types.int;
example = 1000;
};
mkTimeOption = with lib; description: default: mkOption {
inherit description default;
type = types.str;
example = "12:00-14:00";
};
in
{
options.my.home.gammastep = with lib; {
enable = mkEnableOption "gammastep configuration";
temperature = {
day = mkTempOption "Colour temperature to use during the day" 6500;
night = mkTempOption "Colour temperature to use during the night" 2000;
};
times = {
dawn = mkTimeOption "Dawn time" "6:00-7:30";
dusk = mkTimeOption "Dusk time" "18:30-20:00";
};
};
config.services.gammastep = lib.mkIf cfg.enable {
enable = true;
tray = true;
dawnTime = cfg.times.dawn;
duskTime = cfg.times.dusk;
temperature = {
inherit (cfg.temperature) day night;
};
};
}

View file

@ -0,0 +1,38 @@
{ config, lib, pkgs, ... }:
let
cfg = config.my.home.gdb;
in
{
options.my.home.gdb = with lib; {
enable = my.mkDisableOption "gdb configuration";
rr = {
enable = my.mkDisableOption "rr configuration";
package = mkOption {
type = types.package;
default = pkgs.rr;
defaultText = literalExample "pkgs.rr";
description = ''
Package providing rr
'';
};
};
};
config = lib.mkIf cfg.enable (lib.mkMerge [
{
home.packages = with pkgs; [
gdb
];
xdg.configFile."gdb/gdbinit".source = ./gdbinit;
}
(lib.mkIf cfg.rr.enable {
home.packages = [
cfg.rr.package
];
})
]);
}

24
modules/home/gdb/gdbinit Normal file
View file

@ -0,0 +1,24 @@
# Keep a history of all commands in each directory
set history save on
# Enable those pretty-printers
enable pretty-printer
# Pretty formatting of structures
set print pretty on
# Show derived type based on VTable
set print object on
# Show static members
set print static-members on
# Show VTable
set print vtbl on
# Demangle types
set print demangle on
# Read python scrips in the load path
set auto-load python-scripts
# Allow autoloading project-local .gdbinit files
add-auto-load-safe-path ~/git/
# Allow autoloading from the Nix store
add-auto-load-safe-path /nix/store

View file

@ -0,0 +1,34 @@
# C/C++ binary files
*.so
*.o
*.a
*.out
# Python files
env/
__pycache__/
*.py[cod]
.mypy_cache/
.dmypy.json
dmypy.json
# Build system files
compile_commands.json
# Debugger files
.gdb_history
# LSP cache
.clangd/
# Swap and backup files
*~
~.swp
# Direnv files
.envrc
.direnv/
# Project-local neovim configuration files
.nvim.lua
.nvimrc

View file

@ -0,0 +1,196 @@
{ config, pkgs, lib, ... }:
let
cfg = config.my.home.git;
inherit (lib.my) mkMailAddress;
in
{
options.my.home.git = with lib; {
enable = my.mkDisableOption "git configuration";
};
config.home.packages = with pkgs; lib.mkIf cfg.enable [
git-absorb
git-revise
tig
];
config.programs.git = lib.mkIf cfg.enable {
enable = true;
# Who am I?
userEmail = mkMailAddress "bruno" "belanyi.fr";
userName = "Bruno BELANYI";
# I want the full experience
package = pkgs.gitFull;
aliases = {
git = "!git";
lol = "log --graph --decorate --pretty=oneline --abbrev-commit --topo-order";
lola = "lol --all";
assume = "update-index --assume-unchanged";
unassume = "update-index --no-assume-unchanged";
assumed = "!git ls-files -v | grep ^h | cut -c 3-";
pick = "log -p -G";
push-new = "!git push -u origin "
+ ''"$(git branch | grep '^* ' | cut -f2- -d' ')"'';
root = "git rev-parse --show-toplevel";
};
lfs.enable = true;
delta = {
enable = true;
options = {
features = "diff-highlight decorations";
# Less jarring style for `diff-highlight` emulation
diff-highlight = {
minus-style = "red";
minus-non-emph-style = "red";
minus-emph-style = "bold red 52";
plus-style = "green";
plus-non-emph-style = "green";
plus-emph-style = "bold green 22";
whitespace-error-style = "reverse red";
};
# Personal preference for easier reading
decorations = {
commit-style = "raw"; # Do not recolor meta information
keep-plus-minus-markers = true;
paging = "always";
};
};
};
# There's more
extraConfig = {
# Makes it a bit more readable
blame = {
coloring = "repeatedLines";
markIgnoredLines = true;
markUnblamables = true;
};
# I want `pull --rebase` as a default
branch = {
autosetubrebase = "always";
};
# Shiny colors
color = {
branch = "auto";
diff = "auto";
interactive = "auto";
status = "auto";
ui = "auto";
};
# Pretty much the usual diff colors
"color.diff" = {
commit = "yellow";
frag = "cyan";
meta = "yellow";
new = "green";
old = "red";
whitespace = "red reverse";
};
commit = {
# Show my changes when writing the message
verbose = true;
};
diff = {
# Usually leads to better results
algorithm = "patience";
};
fetch = {
# I don't want hanging references
prune = true;
pruneTags = true;
};
init = {
defaultBranch = "main";
};
# Local configuration, not-versioned
include = {
path = "config.local";
};
merge = {
conflictStyle = "zdiff3";
};
pull = {
# Avoid useless merge commits
rebase = true;
};
push = {
# Just yell at me instead of trying to be smart
default = "simple";
};
rebase = {
# Why isn't it the default?...
autoSquash = true;
autoStash = true;
};
url = {
"git@git.belanyi.fr:" = {
insteadOf = "https://git.belanyi.fr/";
};
"git@github.com:" = {
insteadOf = "https://github.com/";
};
"git@gitlab.com:" = {
insteadOf = "https://gitlab.com/";
};
};
};
# Multiple identities
includes = [
{
condition = "gitdir:~/git/EPITA/";
contents = {
user = {
name = "Bruno BELANYI";
email = mkMailAddress "bruno.belanyi" "epita.fr";
};
};
}
{
condition = "gitdir:~/git/work/";
contents = {
user = {
name = "Bruno BELANYI";
email = mkMailAddress "ambroisie" "google.com";
};
};
}
];
ignores =
let
inherit (builtins) readFile;
inherit (lib) filter hasPrefix splitString;
readLines = file: splitString "\n" (readFile file);
removeComments = filter (line: line != "" && !(hasPrefix "#" line));
getPaths = file: removeComments (readLines file);
in
getPaths ./default.ignore;
};
}

View file

@ -0,0 +1,36 @@
{ config, lib, ... }:
let
cfg = config.my.home.gpg;
in
{
options.my.home.gpg = with lib; {
enable = my.mkDisableOption "gpg configuration";
pinentry = mkOption {
type = types.str;
default = "tty";
example = "gtk2";
description = "Which pinentry interface to use";
};
};
config = lib.mkIf cfg.enable {
programs.gpg = {
enable = true;
};
services.gpg-agent = {
enable = true;
enableSshSupport = true; # One agent to rule them all
pinentryFlavor = cfg.pinentry;
extraConfig = ''
allow-loopback-pinentry
'';
};
home.shellAliases = {
# Sometime `gpg-agent` errors out...
reset-agent = "gpg-connect-agent updatestartuptty /bye";
};
};
}

View file

@ -0,0 +1,33 @@
{ config, lib, pkgs, ... }:
let
cfg = config.my.home.gtk;
in
{
options.my.home.gtk = with lib; {
enable = mkEnableOption "GTK configuration";
};
config.gtk = lib.mkIf cfg.enable {
enable = true;
font = {
package = pkgs.dejavu_fonts;
name = "DejaVu Sans";
};
gtk2 = {
# That sweet, sweet clean home that I am always aiming for...
configLocation = "${config.xdg.configHome}/gtk-2.0/gtkrc";
};
iconTheme = {
package = pkgs.gnome.gnome-themes-extra;
name = "Adwaita";
};
theme = {
package = pkgs.gnome.gnome-themes-extra;
name = "Adwaita";
};
};
}

View file

@ -0,0 +1,13 @@
{ config, lib, ... }:
let
cfg = config.my.home.htop;
in
{
options.my.home.htop = with lib; {
enable = my.mkDisableOption "htop configuration";
};
config.programs.htop = lib.mkIf cfg.enable {
enable = true;
};
}

View file

@ -0,0 +1,22 @@
{ config, lib, ... }:
let
cfg = config.my.home.jq;
in
{
options.my.home.jq = with lib; {
enable = my.mkDisableOption "jq configuration";
};
config.programs.jq = lib.mkIf cfg.enable {
enable = true;
colors = {
null = "1;30";
false = "0;37";
true = "0;37";
numbers = "0;37";
strings = "0;32";
arrays = "1;39";
objects = "1;39";
};
};
}

View file

@ -0,0 +1,94 @@
{ config, lib, pkgs, ... }:
let
cfg = config.my.home.mail;
inherit (lib.my) mkMailAddress;
mkConfig = { domain, address, passName, aliases ? [ ], primary ? false }: {
realName = lib.mkDefault "Bruno BELANYI";
userName = lib.mkDefault (mkMailAddress address domain);
passwordCommand =
lib.mkDefault [ (lib.getExe pkgs.ambroisie.rbw-pass) "Mail" passName ];
address = mkMailAddress address domain;
aliases = builtins.map (lib.flip mkMailAddress domain) aliases;
inherit primary;
himalaya = {
enable = cfg.himalaya.enable;
# FIXME: try to actually configure it at some point
backend = "imap";
sender = "smtp";
};
msmtp = {
enable = cfg.msmtp.enable;
};
};
migaduConfig = {
imap = {
host = "imap.migadu.com";
port = 993;
tls = {
enable = true;
};
};
smtp = {
host = "smtp.migadu.com";
port = 465;
tls = {
enable = true;
};
};
};
gmailConfig = {
flavor = "gmail.com";
folders = {
drafts = "[Gmail]/Drafts";
sent = "[Gmail]/Sent Mail";
trash = "[Gmail]/Trash";
};
};
office365Config = {
flavor = "outlook.office365.com";
};
in
{
config.accounts.email.accounts = {
personal = lib.mkMerge [
# Common configuraton
(mkConfig {
domain = "belanyi.fr";
address = "bruno";
passName = "Migadu";
aliases = [ "admin" "postmaster" ];
primary = true; # This is my primary email
})
migaduConfig
];
gmail = lib.mkMerge [
# Common configuraton
(mkConfig {
domain = "gmail.com";
address = "brunobelanyi";
passName = "GMail";
})
gmailConfig
];
epita = lib.mkMerge [
# Common configuration
(mkConfig {
domain = "epita.fr";
address = "bruno.belanyi";
passName = "EPITA";
})
office365Config
];
};
}

View file

@ -0,0 +1,31 @@
{ config, lib, ... }:
let
cfg = config.my.home.mail;
mkRelatedOption = desc: lib.mkEnableOption desc // { default = cfg.enable; };
in
{
imports = [
./accounts
./himalaya
./msmtp
];
options.my.home.mail = with lib; {
enable = my.mkDisableOption "email configuration";
himalaya = {
enable = mkEnableOption "himalaya configuration";
};
msmtp = {
enable = mkRelatedOption "msmtp configuration";
};
};
config = {
accounts.email = {
maildirBasePath = "mail";
};
};
}

View file

@ -0,0 +1,23 @@
{ config, lib, pkgs, ... }:
let
cfg = config.my.home.mail.himalaya;
in
{
config.programs.himalaya = lib.mkIf cfg.enable {
enable = true;
settings = {
notify-cmd =
let
notify-send = lib.getExe pkgs.libnotify;
in
pkgs.writeScript "mail-notifier" ''
SENDER="$1"
SUBJECT="$2"
${notify-send} \
-c himalaya \
-- "$(printf 'Received email from %s\n\n%s' "$SENDER" "$SUBJECT")"
'';
};
};
}

View file

@ -0,0 +1,9 @@
{ config, lib, ... }:
let
cfg = config.my.home.mail.msmtp;
in
{
config.programs.msmtp = lib.mkIf cfg.enable {
enable = true;
};
}

View file

@ -0,0 +1,19 @@
{ config, lib, pkgs, ... }:
let
cfg = config.my.home.mpv;
in
{
options.my.home.mpv = with lib; {
enable = mkEnableOption "mpv configuration";
};
config = lib.mkIf cfg.enable {
programs.mpv = {
enable = true;
scripts = [
pkgs.mpvScripts.mpris # Allow controlling using media keys
];
};
};
}

View file

@ -0,0 +1,13 @@
{ config, lib, ... }:
let
cfg = config.my.home.nix-index;
in
{
options.my.home.nix-index = with lib; {
enable = my.mkDisableOption "nix-index configuration";
};
config.programs.nix-index = lib.mkIf cfg.enable {
enable = true;
};
}

View file

@ -0,0 +1,82 @@
# Nix related settings
{ config, inputs, lib, pkgs, ... }:
let
cfg = config.my.home.nix;
channels = lib.my.merge [
{
# Allow me to use my custom package using `nix run self#pkg`
self = inputs.self;
# Add NUR to run some packages that are only present there
nur = inputs.nur;
# Use pinned nixpkgs when using `nix run pkgs#<whatever>`
pkgs = inputs.nixpkgs;
}
(lib.optionalAttrs cfg.overrideNixpkgs {
# ... And with `nix run nixpkgs#<whatever>`
nixpkgs = inputs.nixpkgs;
})
];
in
{
options.my.home.nix = with lib; {
enable = my.mkDisableOption "nix configuration";
linkInputs = my.mkDisableOption "link inputs to `$XDG_CONFIG_HOME/nix/inputs`";
addToRegistry = my.mkDisableOption "add inputs and self to registry";
addToNixPath = my.mkDisableOption "add inputs and self to nix path";
overrideNixpkgs = my.mkDisableOption "point nixpkgs to pinned system version";
};
config = lib.mkIf cfg.enable (lib.mkMerge [
{
assertions = [
{
assertion = cfg.addToNixPath -> cfg.linkInputs;
message = ''
enabling `my.home.nix.addToNixPath` needs to have
`my.home.nix.linkInputs = true`
'';
}
];
}
{
nix = {
package = lib.mkDefault pkgs.nix; # NixOS module sets it unconditionally
settings = {
experimental-features = [ "nix-command" "flakes" ];
};
};
}
(lib.mkIf cfg.addToRegistry {
nix.registry =
let
makeEntry = v: { flake = v; };
makeEntries = lib.mapAttrs (lib.const makeEntry);
in
makeEntries channels;
})
(lib.mkIf cfg.linkInputs {
xdg.configFile =
let
makeLink = n: v: {
name = "nix/inputs/${n}";
value = { source = v.outPath; };
};
makeLinks = lib.mapAttrs' makeLink;
in
makeLinks channels;
})
(lib.mkIf cfg.addToNixPath {
home.sessionVariables.NIX_PATH = "${config.xdg.configHome}/nix/inputs\${NIX_PATH:+:$NIX_PATH}";
})
]);
}

View file

@ -0,0 +1,20 @@
{ config, lib, pkgs, ... }:
let
cfg = config.my.home.nixpkgs;
in
{
options.my.home.nixpkgs = with lib; {
enable = mkEnableOption "nixpkgs configuration";
};
config = lib.mkIf cfg.enable {
home.packages = with pkgs; [
nixpkgs-review
];
home.sessionVariables = {
GITHUB_TOKEN = ''$(cat "${config.age.secrets."github/token".path}")'';
GITHUB_API_TOKEN = ''$(cat "${config.age.secrets."github/token".path}")'';
};
};
}

View file

@ -0,0 +1,13 @@
{ config, lib, ... }:
let
cfg = config.my.home.nm-applet;
in
{
options.my.home.nm-applet = with lib; {
enable = mkEnableOption "network-manager-applet configuration";
};
config.services.network-manager-applet = lib.mkIf cfg.enable {
enable = true;
};
}

View file

@ -0,0 +1,26 @@
{ config, lib, pkgs, ... }:
let
cfg = config.my.home.packages;
in
{
options.my.home.packages = with lib; {
enable = my.mkDisableOption "user packages";
additionalPackages = mkOption {
type = with types; listOf package;
default = [ ];
example = literalExample ''
with pkgs; [
quasselClient
]
'';
};
};
config.home.packages = with pkgs; lib.mkIf cfg.enable ([
fd
file
mosh
ripgrep
] ++ cfg.additionalPackages);
}

View file

@ -0,0 +1,21 @@
{ config, lib, ... }:
let
cfg = config.my.home.pager;
in
{
options.my.home.pager = with lib; {
enable = my.mkDisableOption "pager configuration";
};
config = lib.mkIf cfg.enable {
home.sessionVariables = {
# My default pager
PAGER = "less";
# Clear the screen on start and exit
LESS = "-R -+X -c";
# Better XDG compliance
LESSHISTFILE = "${config.xdg.dataHome}/less/history";
};
};
}

View file

@ -0,0 +1,15 @@
{ config, lib, ... }:
let
cfg = config.my.home.power-alert;
in
{
options.my.home.power-alert = with lib; {
enable = mkEnableOption "power-alert configuration";
};
config = lib.mkIf cfg.enable {
services.poweralertd = {
enable = true;
};
};
}

View file

@ -0,0 +1,25 @@
{ config, inputs, lib, options, ... }:
{
imports = [
inputs.agenix.homeManagerModules.age
];
config.age = {
secrets =
let
toName = lib.removeSuffix ".age";
toSecret = name: { ... }: {
file = ./. + "/${name}";
};
convertSecrets = n: v: lib.nameValuePair (toName n) (toSecret n v);
secrets = import ./secrets.nix;
in
lib.mapAttrs' convertSecrets secrets;
# Add my usual agenix key to the defaults
identityPaths = options.age.identityPaths.default ++ [
"${config.home.homeDirectory}/.ssh/agenix"
];
};
}

Binary file not shown.

View file

@ -0,0 +1,9 @@
# Common secrets
let
keys = import ../../keys;
all = builtins.attrValues keys.users;
in
{
"github/token.age".publicKeys = all;
}

View file

@ -0,0 +1,54 @@
{ config, lib, ... }:
let
cfg = config.my.home.ssh;
in
{
options.my.home.ssh = with lib; {
enable = my.mkDisableOption "ssh configuration";
};
config.programs.ssh = lib.mkIf cfg.enable {
enable = true;
includes = [
# Local configuration, not-versioned
"config.local"
];
matchBlocks = {
"github.com" = {
hostname = "github.com";
identityFile = "~/.ssh/shared_rsa";
user = "git";
};
"gitlab.com" = {
hostname = "gitlab.com";
identityFile = "~/.ssh/shared_rsa";
user = "git";
};
"git.sr.ht" = {
hostname = "git.sr.ht";
identityFile = "~/.ssh/shared_rsa";
user = "git";
};
"git.belanyi.fr" = {
hostname = "git.belanyi.fr";
identityFile = "~/.ssh/shared_rsa";
user = "git";
};
porthos = {
hostname = "91.121.177.163";
identityFile = "~/.ssh/shared_rsa";
user = "ambroisie";
};
};
extraConfig = ''
AddKeysToAgent yes
'';
};
}

View file

@ -0,0 +1,52 @@
{ config, lib, ... }:
let
cfg = config.my.home.terminal;
in
{
config = lib.mkIf (cfg.program == "alacritty") {
programs.alacritty = {
enable = true;
settings = {
font = {
size = 5.5;
};
colors = {
primary = {
background = cfg.colors.background;
foreground = cfg.colors.foreground;
bright_foreground = cfg.colors.foregroundBold;
};
cursor = {
cursor = cfg.colors.cursor;
};
normal = {
black = cfg.colors.black;
red = cfg.colors.red;
green = cfg.colors.green;
yellow = cfg.colors.yellow;
blue = cfg.colors.blue;
magenta = cfg.colors.magenta;
cyan = cfg.colors.cyan;
white = cfg.colors.white;
};
bright = {
black = cfg.colors.blackBold;
red = cfg.colors.redBold;
green = cfg.colors.greenBold;
yellow = cfg.colors.yellowBold;
blue = cfg.colors.blueBold;
magenta = cfg.colors.magentaBold;
cyan = cfg.colors.cyanBold;
white = cfg.colors.whiteBold;
};
};
};
};
};
}

View file

@ -0,0 +1,62 @@
{ config, lib, ... }:
let
mkColorOption = with lib; description: default: mkOption {
inherit description default;
example = "#abcdef";
type = types.strMatching "#[0-9a-f]{6}";
};
cfg = config.my.home.terminal;
in
{
imports = [
./alacritty
./termite
];
options.my.home = with lib; {
terminal = {
program = mkOption {
type = with types; nullOr (enum [ "alacritty" "termite" ]);
default = null;
example = "termite";
description = "Which terminal to use for home session";
};
colors = {
background = mkColorOption "Background color" "#161616";
foreground = mkColorOption "Foreground color" "#ffffff";
foregroundBold = mkColorOption "Foreground bold color" "#ffffff";
cursor = mkColorOption "Cursor color" "#ffffff";
black = mkColorOption "Black" "#222222";
blackBold = mkColorOption "Black bold" "#666666";
red = mkColorOption "Red" "#e84f4f";
redBold = mkColorOption "Red bold" "#d23d3d";
green = mkColorOption "Green" "#b7ce42";
greenBold = mkColorOption "Green bold" "#bde077";
yellow = mkColorOption "Yellow" "#fea63c";
yellowBold = mkColorOption "Yellow bold" "#ffe863";
blue = mkColorOption "Blue" "#66aabb";
blueBold = mkColorOption "Blue bold" "#aaccbb";
magenta = mkColorOption "Magenta" "#b7416e";
magentaBold = mkColorOption "Magenta bold" "#e16a98";
cyan = mkColorOption "Cyan" "#6d878d";
cyanBold = mkColorOption "Cyan bold" "#42717b";
white = mkColorOption "White" "#dddddd";
whiteBold = mkColorOption "White bold" "#cccccc";
};
};
};
config.home.sessionVariables = lib.mkIf (cfg.program != null) {
TERMINAL = cfg.program;
};
}

View file

@ -0,0 +1,53 @@
{ config, lib, pkgs, ... }:
let
cfg = config.my.home.terminal;
in
{
config = lib.mkIf (cfg.program == "termite") {
programs.termite = {
enable = true;
# Niceties
browser = "${pkgs.xdg-utils}/bin/xdg-open";
clickableUrl = true;
dynamicTitle = true;
fullscreen = false;
mouseAutohide = true;
urgentOnBell = true;
# Look and feel
allowBold = true;
audibleBell = false;
cursorBlink = "system";
font = "Monospace 9";
scrollbar = "off";
# Colors
backgroundColor = cfg.colors.background;
cursorColor = cfg.colors.cursor;
foregroundColor = cfg.colors.foreground;
foregroundBoldColor = cfg.colors.foregroundBold;
colorsExtra = with cfg.colors; ''
# Normal colors
color0 = ${black}
color1 = ${red}
color2 = ${green}
color3 = ${yellow}
color4 = ${blue}
color5 = ${magenta}
color6 = ${cyan}
color7 = ${white}
# Bold colors
color8 = ${blackBold}
color9 = ${redBold}
color10 = ${greenBold}
color11 = ${yellowBold}
color12 = ${blueBold}
color13 = ${magentaBold}
color14 = ${cyanBold}
color15 = ${whiteBold}
'';
};
};
}

View file

@ -0,0 +1,101 @@
{ config, lib, pkgs, ... }:
let
cfg = config.my.home.tmux;
hasGUI = lib.any lib.id [
config.my.home.x.enable
(config.my.home.wm.windowManager != null)
];
in
{
options.my.home.tmux = with lib; {
enable = my.mkDisableOption "tmux terminal multiplexer";
enablePassthrough = mkEnableOption "tmux DCS passthrough sequence";
trueColorTerminals = mkOption {
type = with types; listOf str;
default = lib.my.nullableToList config.my.home.terminal.program;
defaultText = ''
`[ config.my.home.terminal.program ]` if it is non-null, otherwise an
empty list.
'';
example = [ "xterm-256color" ];
description = ''
$TERM values which should be considered to always support 24-bit color.
'';
};
};
config.programs.tmux = lib.mkIf cfg.enable {
enable = true;
keyMode = "vi"; # Home-row keys and other niceties
clock24 = true; # I'm one of those heathens
escapeTime = 0; # Let vim do its thing instead
historyLimit = 50000; # Bigger buffer
terminal = "tmux-256color"; # I want accurate termcap info
plugins = with pkgs.tmuxPlugins; [
# Open high-lighted files in copy mode
open
# Better pane management
pain-control
# Better session management
sessionist
{
# X clipboard integration
plugin = yank;
extraConfig = ''
# Use 'clipboard' because of misbehaving apps (e.g: firefox)
set -g @yank_selection_mouse 'clipboard'
# Stay in copy mode after yanking
set -g @yank_action 'copy-pipe'
'';
}
{
# Show when prefix has been pressed
plugin = prefix-highlight;
extraConfig = ''
# Also show when I'm in copy or sync mode
set -g @prefix_highlight_show_copy_mode 'on'
set -g @prefix_highlight_show_sync_mode 'on'
# Show prefix mode in status bar
set -g status-right '#{prefix_highlight} %a %Y-%m-%d %H:%M'
'';
}
];
extraConfig = ''
# Better vim mode
bind-key -T copy-mode-vi 'v' send -X begin-selection
${
lib.optionalString
(!hasGUI)
"bind-key -T copy-mode-vi 'y' send -X copy-selection"
}
# Block selection in vim mode
bind-key -Tcopy-mode-vi 'C-v' send -X begin-selection \; send -X rectangle-toggle
# Allow any application to send OSC52 escapes to set the clipboard
set -s set-clipboard on
# Longer session names in status bar
set -g status-left-length 16
${
lib.optionalString cfg.enablePassthrough ''
# Allow any application to use the tmux DCS for passthrough
set -g allow-passthrough on
''
}
# Force 24-bit color for each relevant $TERM
${
let
mkTcFlag = term: ''set -as terminal-features ",${term}:RGB"'';
in
lib.concatMapStringsSep "\n" mkTcFlag cfg.trueColorTerminals
}
'';
};
}

View file

@ -0,0 +1,13 @@
{ config, lib, ... }:
let
cfg = config.my.home.udiskie;
in
{
options.my.home.udiskie = with lib; {
enable = mkEnableOption "udiskie configuration";
};
config.services.udiskie = lib.mkIf cfg.enable {
enable = true;
};
}

View file

@ -0,0 +1,9 @@
" Create the `b:undo_ftplugin` variable if it doesn't exist
call ftplugined#check_undo_ft()
" Use a small indentation value on beancount files
setlocal shiftwidth=2
let b:undo_ftplugin.='|setlocal shiftwidth<'
" Have automatic padding of transactions so that decimal is on 52nd column
let g:beancount_separator_col=52

View file

@ -0,0 +1,6 @@
" Create the `b:undo_ftplugin` variable if it doesn't exist
call ftplugined#check_undo_ft()
" Use 2 spaces indentation inside CMake files
setlocal shiftwidth=2
let b:undo_ftplugin.='|setlocal shiftwidth<'

View file

@ -0,0 +1,6 @@
" Create the `b:undo_ftplugin` variable if it doesn't exist
call ftplugined#check_undo_ft()
" Don't highlight trailing whitespace in fugitive windows
let b:better_whitespace_enabled=0
let b:undo_ftplugin.='|unlet! b:better_whitespace_enabled'

View file

@ -0,0 +1,10 @@
" Create the `b:undo_ftplugin` variable if it doesn't exist
call ftplugined#check_undo_ft()
" Enable spell checking on commit messages
setlocal spell
let b:undo_ftplugin.='|setlocal spell<'
" Change max length of a line to 72 for this buffer
setlocal colorcolumn=72
let b:undo_ftplugin.='|setlocal colorcolumn<'

View file

@ -0,0 +1,6 @@
" Create the `b:undo_ftplugin` variable if it doesn't exist
call ftplugined#check_undo_ft()
" Git configuration files should use tabs to indent
setlocal noexpandtab
let b:undo_ftplugin.='|setlocal noexpandtab<'

View file

@ -0,0 +1,10 @@
" Create the `b:undo_ftplugin` variable if it doesn't exist
call ftplugined#check_undo_ft()
" Use a small indentation value on Haskell files
setlocal shiftwidth=2
let b:undo_ftplugin.='|setlocal shiftwidth<'
" Change max length of a line to 100 for this buffer to match official guidelines
setlocal colorcolumn=100
let b:undo_ftplugin.='|setlocal colorcolumn<'

View file

@ -0,0 +1,6 @@
" Create the `b:undo_ftplugin` variable if it doesn't exist
call ftplugined#check_undo_ft()
" Don't highlight trailing whitespace in help windows
let b:better_whitespace_enabled=0
let b:undo_ftplugin.='|unlet! b:better_whitespace_enabled'

View file

@ -0,0 +1,6 @@
" Create the `b:undo_ftplugin` variable if it doesn't exist
call ftplugined#check_undo_ft()
" Change max length of a line to 72 to follow the netiquette
setlocal colorcolumn=72
let b:undo_ftplugin.='|setlocal colorcolumn<'

View file

@ -0,0 +1,6 @@
" Create the `b:undo_ftplugin` variable if it doesn't exist
call ftplugined#check_undo_ft()
" Makefiles should use tabs to indent
setlocal noexpandtab
let b:undo_ftplugin.='|setlocal noexpandtab<'

View file

@ -0,0 +1,10 @@
" Create the `b:undo_ftplugin` variable if it doesn't exist
call ftplugined#check_undo_ft()
" Use a small indentation value on Pandoc files
setlocal shiftwidth=2
let b:undo_ftplugin.='|setlocal shiftwidth<'
" Use my usual text width
setlocal textwidth=80
let b:undo_ftplugin.='|setlocal textwidth<'

View file

@ -0,0 +1,6 @@
" Create the `b:undo_ftplugin` variable if it doesn't exist
call ftplugined#check_undo_ft()
" Don't show Netrw in buffer list
setlocal bufhidden=delete
let b:undo_ftplugin='|setlocal bufhidden<'

View file

@ -0,0 +1,6 @@
" Create the `b:undo_ftplugin` variable if it doesn't exist
call ftplugined#check_undo_ft()
" Use a small indentation value on Nix files
setlocal shiftwidth=2
let b:undo_ftplugin.='|setlocal shiftwidth<'

View file

@ -0,0 +1,6 @@
" Create the `b:undo_ftplugin` variable if it doesn't exist
call ftplugined#check_undo_ft()
" Change max length of a line to 88 for this buffer to match black's settings
setlocal colorcolumn=88
let b:undo_ftplugin.='|setlocal colorcolumn<'

View file

@ -0,0 +1,6 @@
" Create the `b:undo_ftplugin` variable if it doesn't exist
call ftplugined#check_undo_ft()
" Change max length of a line to 99 for this buffer to match official guidelines
setlocal colorcolumn=99
let b:undo_ftplugin.='|setlocal colorcolumn<'

View file

@ -0,0 +1,6 @@
" Create the `b:undo_ftplugin` variable if it doesn't exist
call ftplugined#check_undo_ft()
" Use 2 spaces indentation inside TeX files
setlocal shiftwidth=2
let b:undo_ftplugin.='|setlocal shiftwidth<'

View file

@ -0,0 +1,6 @@
" Create the `b:undo_ftplugin` variable if it doesn't exist
call ftplugined#check_undo_ft()
" Use a small indentation value on tiger files
setlocal shiftwidth=2
let b:undo_ftplugin.='|setlocal shiftwidth<'

View file

@ -0,0 +1,6 @@
" Create the `b:undo_ftplugin` variable if it doesn't exist
call ftplugined#check_undo_ft()
" Use a small indentation value on YAML files
setlocal shiftwidth=2
let b:undo_ftplugin.='|setlocal shiftwidth<'

View file

@ -0,0 +1,10 @@
local wk = require("which-key")
local keys = {
name = "Comment/uncomment",
c = "Current line",
u = "Uncomment the current and adjacent commented lines",
["gc"] = "Uncomment the current and adjacent commented lines",
}
wk.register(keys, { prefix = "gc" })

View file

@ -0,0 +1,7 @@
local wk = require("which-key")
local keys = {
["<leader>"] = { "<cmd>nohls<CR>", "Clear search highlight" },
}
wk.register(keys, { prefix = "<leader>" })

View file

@ -0,0 +1,15 @@
local wk = require("which-key")
local telescope_builtin = require("telescope.builtin")
local keys = {
f = {
name = "Fuzzy finder",
b = { telescope_builtin.buffers, "Open buffers" },
f = { telescope_builtin.git_files, "Git tracked files" },
F = { telescope_builtin.find_files, "Files" },
g = { telescope_builtin.live_grep, "Grep string" },
G = { telescope_builtin.grep_string, "Grep string under cursor" },
},
}
wk.register(keys, { prefix = "<leader>" })

View file

@ -0,0 +1,30 @@
local wk = require("which-key")
local motions = {
["]m"] = "Next method start",
["]M"] = "Next method end",
["]S"] = "Next statement start",
["]]"] = "Next class start",
["]["] = "Next class end",
["[m"] = "Previous method start",
["[M"] = "Previous method end",
["[S"] = "Previous statement start",
["[["] = "Previous class start",
["[]"] = "Previous class end",
}
local objects = {
["aa"] = "a parameter",
["ia"] = "inner parameter",
["ab"] = "a block",
["ib"] = "inner block",
["ac"] = "a class",
["ic"] = "inner class",
["af"] = "a function",
["if"] = "inner function",
["ak"] = "a comment",
["aS"] = "a statement",
}
wk.register(motions, { mode = "n" })
wk.register(objects, { mode = "o" })

View file

@ -0,0 +1,128 @@
local wk = require("which-key")
local lsp = require("ambroisie.lsp")
local keys = {
-- Edition and navigation mappins
["["] = {
name = "Previous",
["<space>"] = "Insert blank line above",
["<C-L>"] = "Previous location list file",
["<C-Q>"] = "Previous quickfix list file",
["<C-T>"] = "Previous tag in preview window",
a = "Previous argument",
A = "First argument",
b = "Previous buffer",
B = "First buffer",
e = "Exchange previous line",
f = "Previous file in directory",
l = "Previous location list entry",
L = "First Location list entry",
n = "Previous conflict marker/diff hunk",
p = "Paste line above",
P = "Paste line above",
q = "Previous quickfix list entry",
Q = "First quickfix list entry",
t = "Previous matching tag",
T = "First matching tag",
z = "Previous fold",
-- Encoding
C = "C string encode",
u = "URL encode",
x = "XML encode",
y = "C string encode",
-- Custom
d = { lsp.goto_prev_diagnostic, "Previous diagnostic" },
},
["]"] = {
name = "Next",
["<space>"] = "Insert blank line below",
["<C-L>"] = "Next location list file",
["<C-Q>"] = "Next quickfix list file",
["<C-T>"] = "Next tag in preview window",
a = "Next argument",
A = "Last argument",
b = "Next buffer",
B = "Last buffer",
e = "Exchange next line",
f = "Next file in directory",
l = "Next location list entry",
L = "Last Location list entry",
n = "Next conflict marker/diff hunk",
p = "Paste line below",
P = "Paste line below",
q = "Next quickfix list entry",
Q = "Last quickfix list entry",
t = "Next matching tag",
T = "Last matching tag",
z = "Next fold",
-- Decoding
C = "C string decode",
u = "URL decode",
x = "XML decode",
y = "C string decode",
-- Custom
d = { lsp.goto_next_diagnostic, "Next diagnostic" },
},
-- Option mappings
["[o"] = {
name = "Enable option",
b = "Light background",
c = "Cursor line",
d = "Diff",
f = { "<cmd>FormatEnable<CR>", "LSP Formatting" },
h = "Search high-lighting",
i = "Case insensitive search",
l = "List mode",
n = "Line numbers",
r = "Relative line numbers",
p = { "<cmd>lwindow<CR>", "Location list" },
q = { "<cmd>cwindow<CR>", "Quickfix list" },
u = "Cursor column",
v = "Virtual editing",
w = "Text wrapping",
x = "Cursor line and column",
z = "Spell checking",
},
["]o"] = {
name = "Option off",
b = "Light background",
c = "Cursor line",
d = "Diff",
f = { "<cmd>FormatDisable<CR>", "LSP Formatting" },
h = "Search high-lighting",
i = "Case insensitive search",
l = "List mode",
n = "Line numbers",
p = { "<cmd>lclose<CR>", "Location list" },
q = { "<cmd>cclose<CR>", "Quickfix list" },
r = "Relative line numbers",
u = "Cursor column",
v = "Virtual editing",
w = "Text wrapping",
x = "Cursor line and column",
z = "Spell checking",
},
["yo"] = {
name = "Option toggle",
b = "Light background",
c = "Cursor line",
d = "Diff",
f = { "<cmd>FormatToggle<CR>", "LSP Formatting" },
h = "Search high-lighting",
i = "Case insensitive search",
l = "List mode",
n = "Line numbers",
p = { "<Plug>(qf_loc_toggle)", "Location list" },
q = { "<Plug>(qf_qf_toggle)", "Quickfix list" },
r = "Relative line numbers",
u = "Cursor column",
v = "Virtual editing",
w = "Text wrapping",
x = "Cursor line and column",
z = "Spell checking",
},
}
wk.register(keys)

View file

@ -0,0 +1,6 @@
" Create the `b:undo_ftplugin` variable if it doesn't exist
function! ftplugined#check_undo_ft()
if !exists("b:undo_ftplugin")
let b:undo_ftplugin=''
endif
endfunction

View file

@ -0,0 +1,114 @@
{ config, pkgs, lib, ... }:
let
cfg = config.my.home.vim;
configFiles =
let
toSource = directory: { source = ./. + "/${directory}"; };
configureDirectory =
name: lib.nameValuePair "nvim/${name}" (toSource name);
linkDirectories =
dirs: builtins.listToAttrs (map configureDirectory dirs);
in
linkDirectories [
"after"
"autoload"
"ftdetect"
"lua"
"plugin"
];
in
{
options.my.home.vim = with lib; {
enable = my.mkDisableOption "vim configuration";
};
config.programs.neovim = lib.mkIf cfg.enable {
enable = true;
# This is the best editor
defaultEditor = true;
# All the aliases
viAlias = true;
vimAlias = true;
vimdiffAlias = true;
plugins = with pkgs.vimPlugins; [
# Theming
gruvbox-nvim # Nice dark theme
lualine-nvim # A lua-based status line
lualine-lsp-progress # Show progress for LSP servers
# tpope essentials
vim-commentary # Easy comments
vim-eunuch # UNIX integrations
vim-fugitive # A 'git' wrapper
vim-git # Sane git syntax files
vim-repeat # Enanche '.' for plugins
vim-rsi # Readline mappings
vim-unimpaired # Some ex command mappings
vim-vinegar # Better netrw
# Languages
rust-vim
vim-beancount
vim-jsonnet
vim-nix
vim-toml
# General enhancements
vim-qf # Better quick-fix list
nvim-osc52 # Send clipboard data through terminal escape for SSH
# Other wrappers
git-messenger-vim # A simple blame window
# LSP and linting
nvim-lspconfig # Easy LSP configuration
lsp-format-nvim # Simplified formatting configuration
lsp_lines-nvim # Show diagnostics *over* regions
none-ls-nvim # LSP integration for linters and formatters
nvim-treesitter.withAllGrammars # Better highlighting
nvim-treesitter-textobjects # More textobjects
nvim-ts-context-commentstring # Comment string in nested language blocks
plenary-nvim # 'null-ls', 'telescope' dependency
# Completion
luasnip # Snippet manager compatible with LSP
friendly-snippets # LSP snippets collection
nvim-cmp # Completion engine
cmp-async-path # More responsive path completion
cmp-buffer # Words from open buffers
cmp-nvim-lsp # LSP suggestions
cmp-nvim-lua # NeoVim lua API
cmp-under-comparator # Sort items that start with '_' lower
cmp_luasnip # Snippet suggestions from LuaSnip
# UX improvements
dressing-nvim # Integrate native UI hooks with Telescope etc...
gitsigns-nvim # Fast git UI integration
nvim-surround # Deal with pairs, now in Lua
telescope-fzf-native-nvim # Use 'fzf' fuzzy matching algorithm
telescope-lsp-handlers-nvim # Use 'telescope' for various LSP actions
telescope-nvim # Fuzzy finder interface
which-key-nvim # Show available mappings
];
extraConfig = builtins.readFile ./init.vim;
# Linters, formatters, etc...
extraPackages = with pkgs; [
# C/C++
clang-tools
# Nix
nixpkgs-fmt
# Shell
shellcheck
shfmt
];
};
config.xdg.configFile = lib.mkIf cfg.enable configFiles;
}

View file

@ -0,0 +1,6 @@
-- Use Automake filetype for `local.am` files, explicit `set` to force override
vim.filetype.add({
filename = {
["local.am"] = "automake",
},
})

View file

@ -0,0 +1,6 @@
-- Use bash filetype for `.envrc` files
vim.filetype.add({
filename = {
[".envrc"] = "bash",
},
})

View file

@ -0,0 +1,6 @@
-- Kbuild is just a Makefile under a different name
vim.filetype.add({
filename = {
["Kbuild"] = "make",
},
})

View file

@ -0,0 +1,6 @@
-- Mconfig is just Kconfig
vim.filetype.add({
filename = {
["Mconfig"] = "kconfig",
},
})

View file

@ -0,0 +1,7 @@
-- Use Tiger filetype for programs and header files
vim.filetype.add({
extension = {
tig = "tiger",
tih = "tiger",
},
})

View file

@ -0,0 +1,6 @@
-- Use LaTeX filetype for TikZ files
vim.filetype.add({
extension = {
tikz = "tex",
},
})

111
modules/home/vim/init.vim Normal file
View file

@ -0,0 +1,111 @@
" Basic configuraion {{{
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Use UTF-8
set encoding=utf-8
set fileencodings=utf-8
" Allow unsaved buffers when switching windows
set hidden
" Allow command completion in command-line
set wildmenu
" Enable syntax high-lighting and file-type specific plugins
syntax on
filetype plugin indent on
" Map leader to space (needs the noremap trick to avoid moving the cursor)
nnoremap <Space> <Nop>
let mapleader=" "
" Map localleader to '!' (if I want to filter text, I use visual mode)
let maplocalleader="!"
" }}}
" Indentation configuration {{{
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Use space by default
set expandtab
" Indent and align to 4 spaces by default
set shiftwidth=4
" -1 means the same as shiftwidth
set softtabstop=-1
" Always indent by multiples of shiftwidth
set shiftround
" You shouldn't change the default tab width of 8 characters
set tabstop=8
" }}}
" File parameters {{{
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Disable backups, we have source control for that
set nobackup
" Disable swapfiles too
set noswapfile
" }}}
" UI and UX parameters {{{
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Set the minimal amount of lignes under and above the cursor for context
set scrolloff=5
" Always show status line
set laststatus=2
" Enable Doxygen highlighting
let g:load_doxygen_syntax=1
" Make backspace behave as expected
set backspace=eol,indent,start
" Use the visual bell instead of beeping
set visualbell
" Disable bell completely by resetting the visual bell's escape sequence
set t_vb=
" Color the 80th column
set colorcolumn=80
" Show whitespace
set list
" Show a tab as an arrow, trailing spaces as ¤, non-breaking spaces as dots
set listchars=tab:>,trail,nbsp
" Use patience diff
set diffopt+=algorithm:patience
" Align similar lines in each hunk
set diffopt+=linematch:50
" Don't redraw when executing macros
set lazyredraw
" Timeout quickly on shortcuts, I can't wait two seconds to delete in visual
set timeoutlen=500
" Timeout quickly for CursorHold events (and also swap file)
set updatetime=250
" Disable all mouse integrations
set mouse=
" Set dark mode by default
set background=dark
" 24 bit colors
set termguicolors
" Use my preferred colorscheme
colorscheme gruvbox
" }}}
" Search parameters {{{
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Enable search high-lighting while the search is on-going
set hlsearch
" Ignore case on search
set ignorecase
" Ignore case unless there is an uppercase letter in the pattern
set smartcase
" }}}
" Project-local settings {{{
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Securely read `.nvim.lua` or `.nvimrc`.
set exrc
" }}}
" vim: foldmethod=marker

View file

@ -0,0 +1,118 @@
local M = {}
-- Simplified LSP formatting configuration
local lsp_format = require("lsp-format")
--- Move to the next/previous diagnostic, automatically showing the diagnostics
--- float if necessary.
--- @param forward whether to go forward or backwards
local function goto_diagnostic(forward)
vim.validate({
forward = { forward, "boolean" },
})
local opts = {
float = false,
}
-- Only show floating diagnostics if they are otherwise not displayed
local config = vim.diagnostic.config()
if not (config.virtual_text or config.virtual_lines) then
opts.float = true
end
if forward then
vim.diagnostic.goto_next(opts)
else
vim.diagnostic.goto_prev(opts)
end
end
--- Move to the next diagnostic, automatically showing the diagnostics float if
--- necessary.
M.goto_next_diagnostic = function()
goto_diagnostic(true)
end
--- Move to the previous diagnostic, automatically showing the diagnostics float
--- if necessary.
M.goto_prev_diagnostic = function()
goto_diagnostic(false)
end
--- shared LSP configuration callback
--- @param client native client configuration
--- @param bufnr int? buffer number of the attched client
M.on_attach = function(client, bufnr)
-- Format on save
lsp_format.on_attach(client, bufnr)
-- Mappings
local wk = require("which-key")
local function list_workspace_folders()
local utils = require("ambroisie.utils")
utils.dump(vim.lsp.buf.list_workspace_folders())
end
local function cycle_diagnostics_display()
-- Cycle from:
-- * nothing displayed
-- * single diagnostic at the end of the line (`virtual_text`)
-- * full diagnostics using virtual text (`virtual_lines`)
local text = vim.diagnostic.config().virtual_text
local lines = vim.diagnostic.config().virtual_lines
-- Text -> Lines transition
if text then
text = false
lines = true
-- Lines -> Nothing transition
elseif lines then
text = false
lines = false
-- Nothing -> Text transition
else
text = true
lines = false
end
vim.diagnostic.config({
virtual_text = text,
virtual_lines = lines,
})
end
local function show_buffer_diagnostics()
vim.diagnostic.open_float(nil, { scope = "buffer" })
end
local keys = {
K = { vim.lsp.buf.hover, "Show symbol information" },
["<C-k>"] = { vim.lsp.buf.signature_help, "Show signature information" },
["gd"] = { vim.lsp.buf.definition, "Go to definition" },
["gD"] = { vim.lsp.buf.declaration, "Go to declaration" },
["gi"] = { vim.lsp.buf.implementation, "Go to implementation" },
["gr"] = { vim.lsp.buf.references, "List all references" },
["<leader>c"] = {
name = "Code",
a = { vim.lsp.buf.code_action, "Code actions" },
d = { cycle_diagnostics_display, "Cycle diagnostics display" },
D = { show_buffer_diagnostics, "Show buffer diagnostics" },
r = { vim.lsp.buf.rename, "Rename symbol" },
s = { vim.lsp.buf.signature_help, "Show signature" },
t = { vim.lsp.buf.type_definition, "Go to type definition" },
w = {
name = "Workspace",
a = { vim.lsp.buf.add_workspace_folder, "Add folder to workspace" },
l = { list_workspace_folders, "List folders in workspace" },
r = { vim.lsp.buf.remove_workspace_folder, "Remove folder from workspace" },
},
},
}
wk.register(keys, { buffer = bufnr })
end
return M

View file

@ -0,0 +1,57 @@
local M = {}
--- pretty print lua object
--- @param obj any object to pretty print
M.dump = function(obj)
print(vim.inspect(obj))
end
--- checks if a given command is executable
--- @param cmd string? command to check
--- @return boolean executable
M.is_executable = function(cmd)
return cmd and vim.fn.executable(cmd) == 1
end
--- return a function that checks if a given command is executable
--- @param cmd string? command to check
--- @return fun(cmd: string): boolean executable
M.is_executable_condition = function(cmd)
return function()
return M.is_executable(cmd)
end
end
--- whether or not we are currently in an SSH connection
--- @return boolean ssh connection
M.is_ssh = function()
local variables = {
"SSH_CONNECTION",
"SSH_CLIENT",
"SSH_TTY",
}
for _, var in ipairs(variables) do
if string.len(os.getenv(var) or "") ~= 0 then
return true
end
end
return false
end
--- list all active LSP clients for current buffer
--- @param bufnr int? buffer number
--- @return table all active LSP client names
M.list_lsp_clients = function(bufnr)
local clients = vim.lsp.buf_get_clients(bufnr)
local names = {}
for _, client in ipairs(clients) do
table.insert(names, client.name)
end
return names
end
return M

View file

@ -0,0 +1,9 @@
local abbreviations = {
-- A few things that are hard to write in ASCII
["(R)"] = "©",
["(TM)"] = "",
}
for text, result in pairs(abbreviations) do
vim.cmd.abbreviate(text, result)
end

View file

@ -0,0 +1,23 @@
-- Show lines numbers
vim.opt.number = true
local numbertoggle = vim.api.nvim_create_augroup("numbertoggle", { clear = true })
-- Toggle numbers between relative and absolute when changing buffers
vim.api.nvim_create_autocmd({ "BufEnter", "FocusGained", "InsertLeave", "WinEnter" }, {
pattern = "*",
group = numbertoggle,
command = "if &nu | setlocal rnu | endif",
})
vim.api.nvim_create_autocmd({ "BufLeave", "FocusLost", "InsertEnter", "WinLeave" }, {
pattern = "*",
group = numbertoggle,
command = "if &nu | setlocal nornu | endif",
})
-- Never show the sign column in a terminal buffer
vim.api.nvim_create_autocmd({ "TermOpen" }, {
pattern = "*",
group = numbertoggle,
command = "setlocal nonu nornu",
})

View file

@ -0,0 +1,62 @@
-- Show completion menu in all cases, and don't select anything
vim.opt.completeopt = { "menu", "menuone", "noselect" }
local cmp = require("cmp")
local cmp_under_comparator = require("cmp-under-comparator")
local luasnip = require("luasnip")
cmp.setup({
snippet = {
expand = function(args)
luasnip.lsp_expand(args.body)
end,
},
mapping = {
["<Tab>"] = function(fallback)
if luasnip.expand_or_jumpable() then
luasnip.expand_or_jump()
else
fallback()
end
end,
["<S-Tab>"] = function(fallback)
if luasnip.jumpable(-1) then
luasnip.jump(-1)
else
fallback()
end
end,
["<C-n>"] = cmp.mapping(cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Insert }), { "i", "c" }),
["<C-p>"] = cmp.mapping(cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Insert }), { "i", "c" }),
["<C-d>"] = cmp.mapping.scroll_docs(-5),
["<C-f>"] = cmp.mapping.scroll_docs(5),
["<C-y>"] = cmp.mapping.confirm({ behavior = cmp.ConfirmBehavior.Insert, select = false }),
["<C-e>"] = cmp.mapping.abort(),
},
view = {
entries = "native",
},
sources = {
{ name = "async_path", priority_weight = 110 },
{ name = "nvim_lsp", priority_weight = 100 },
{ name = "nvim_lua", priority_weight = 90 },
{ name = "luasnip", priority_weight = 80 },
{ name = "buffer", max_item_count = 5, priority_weight = 50 },
},
sorting = {
priority_weight = 100,
comparators = {
cmp.config.compare.offset,
cmp.config.compare.exact,
cmp.config.compare.score,
cmp_under_comparator.under,
cmp.config.compare.kind,
cmp.config.compare.sort_text,
cmp.config.compare.length,
cmp.config.compare.order,
},
},
experimental = {
ghost_text = true,
},
})

View file

@ -0,0 +1,6 @@
local dressing = require("dressing")
dressing.setup({
-- Use a relative prompt size
prefer_width = 0.4,
})

View file

@ -0,0 +1,5 @@
-- Intercept all fold commands
-- stylua: ignore
vim.g.fastfold_fold_command_suffixes = {
"x", "X", "a", "A", "o", "O", "c", "C", "r", "R", "m", "M", "i", "n", "N",
}

View file

@ -0,0 +1,3 @@
local lsp_format = require("lsp-format")
lsp_format.setup({})

View file

@ -0,0 +1,58 @@
local gitsigns = require("gitsigns")
local wk = require("which-key")
gitsigns.setup({
current_line_blame_opts = {
-- Show the blame quickly
delay = 100,
},
})
local keys = {
-- Navigation
["[c"] = { "&diff ? '[c' : '<cmd>Gitsigns prev_hunk<CR>'", "Previous hunk/diff", expr = true },
["]c"] = { "&diff ? ']c' : '<cmd>Gitsigns next_hunk<CR>'", "Next hunk/diff", expr = true },
-- Commands
["<leader>g"] = {
name = "Git",
-- Actions
b = { gitsigns.toggle_current_line_blame, "Toggle blame virtual text" },
d = { gitsigns.diffthis, "Diff buffer" },
-- stylua: ignore
D = { function() gitsigns.diffthis("~") end, "Diff buffer against last commit" },
g = { "<cmd>Git<CR>", "Git status" },
h = { gitsigns.toggle_deleted, "Show deleted hunks" },
L = { "<cmd>:sp<CR><C-w>T:Gllog --follow -- %:p<CR>", "Current buffer log" },
m = { "<Plug>(git-messenger)", "Current line blame" },
p = { gitsigns.preview_hunk, "Preview hunk" },
r = { gitsigns.reset_hunk, "Restore hunk" },
R = { gitsigns.reset_buffer, "Restore buffer" },
s = { gitsigns.stage_hunk, "Stage hunk" },
S = { gitsigns.stage_buffer, "Stage buffer" },
u = { gitsigns.undo_stage_hunk, "Undo stage hunk" },
["["] = { gitsigns.prev_hunk, "Previous hunk" },
["]"] = { gitsigns.next_hunk, "Next hunk" },
},
}
local objects = {
["ih"] = { gitsigns.select_hunk, "Git hunk" },
}
local visual = {
["ih"] = { gitsigns.select_hunk, "Git hunk" },
-- Only the actual command can make use of the visual selection...
["<leader>g"] = {
name = "Git",
p = { ":Gitsigns preview_hunk<CR>", "Preview selection" },
r = { ":Gitsigns reset_hunk<CR>", "Restore selection" },
s = { ":Gitsigns stage_hunk<CR>", "Stage selection" },
u = { ":Gitsigns undo_stage_hunk<CR>", "Undo stage selection" },
},
}
wk.register(keys, { buffer = bufnr })
wk.register(objects, { buffer = bufnr, mode = "o" })
wk.register(visual, { buffer = bufnr, mode = "x" })

View file

@ -0,0 +1,3 @@
local lsp_lines = require("lsp_lines")
lsp_lines.setup()

View file

@ -0,0 +1,61 @@
local lspconfig = require("lspconfig")
local lsp = require("ambroisie.lsp")
local utils = require("ambroisie.utils")
-- Diagnostics
vim.diagnostic.config({
-- Disable virtual test next to affected regions
virtual_text = false,
-- Also disable virtual diagnostics under the affected regions
virtual_lines = false,
-- Show diagnostics signs
signs = true,
-- Underline offending regions
underline = true,
-- Do not bother me in the middle of insertion
update_in_insert = false,
-- Show highest severity first
severity_sort = true,
})
-- Inform servers we are able to do completion, snippets, etc...
local capabilities = require("cmp_nvim_lsp").default_capabilities()
-- C/C++
if utils.is_executable("clangd") then
lspconfig.clangd.setup({
capabilities = capabilities,
on_attach = lsp.on_attach,
})
end
-- Nix
if utils.is_executable("nil") then
lspconfig.nil_ls.setup({
capabilities = capabilities,
on_attach = lsp.on_attach,
})
end
if utils.is_executable("rnix-lsp") then
lspconfig.rnix.setup({
capabilities = capabilities,
on_attach = lsp.on_attach,
})
end
-- Python
if utils.is_executable("pyright") then
lspconfig.pyright.setup({
capabilities = capabilities,
on_attach = lsp.on_attach,
})
end
-- Rust
if utils.is_executable("rust-analyzer") then
lspconfig.rust_analyzer.setup({
capabilities = capabilities,
on_attach = lsp.on_attach,
})
end

View file

@ -0,0 +1,61 @@
local lualine = require("lualine")
local utils = require("ambroisie.utils")
local function list_spell_languages()
if not vim.opt.spell:get() then
return ""
end
return table.concat(vim.opt.spelllang:get(), ", ")
end
local function list_lsp_clients()
local client_names = utils.list_lsp_clients()
if #client_names == 0 then
return ""
end
return "[ " .. table.concat(client_names, " ") .. " ]"
end
lualine.setup({
options = {
icons_enabled = false,
section_separators = "",
component_separators = "|",
},
sections = {
lualine_a = {
{ "mode" },
},
lualine_b = {
{ "FugitiveHead" },
{ "filename", symbols = { readonly = "🔒" } },
},
lualine_c = {
{ list_spell_languages },
{ "lsp_progress" },
},
lualine_x = {
{ list_lsp_clients },
{
"diagnostics",
-- Only use the diagnostics API
sources = { "nvim_diagnostic" },
},
},
lualine_y = {
{ "fileformat" },
{ "encoding" },
{ "filetype" },
},
lualine_z = {
"location",
},
},
extensions = {
"fugitive",
"quickfix",
},
})

View file

@ -0,0 +1 @@
require("luasnip.loaders.from_vscode").lazy_load()

View file

@ -0,0 +1,138 @@
local null_ls = require("null-ls")
local lsp = require("ambroisie.lsp")
local utils = require("ambroisie.utils")
null_ls.setup({
on_attach = lsp.on_attach,
})
-- Bazel
null_ls.register({
null_ls.builtins.diagnostics.buildifier.with({
-- Only used if available
condition = utils.is_executable_condition("buildifier"),
}),
null_ls.builtins.formatting.buildifier.with({
-- Only used if available
condition = utils.is_executable_condition("buildifier"),
}),
})
-- C, C++
null_ls.register({
null_ls.builtins.formatting.clang_format.with({
-- Only used if available, but prefer clangd formatting if available
condition = function()
return utils.is_executable("clang-format") and not utils.is_executable("clangd")
end,
}),
})
-- Haskell
null_ls.register({
null_ls.builtins.formatting.brittany.with({
-- Only used if available
condition = utils.is_executable_condition("brittany"),
}),
})
-- Nix
null_ls.register({
null_ls.builtins.formatting.nixpkgs_fmt.with({
-- Only used if available, but prefer rnix if available
condition = function()
return utils.is_executable("nixpkgs-fmt")
and not utils.is_executable("rnix-lsp")
and not utils.is_executable("nil")
end,
}),
})
-- Python
null_ls.register({
null_ls.builtins.diagnostics.flake8.with({
-- Only used if available, but prefer pflake8 if available
condition = function()
return utils.is_executable("flake8") and not utils.is_executable("pflake8")
end,
}),
null_ls.builtins.diagnostics.pyproject_flake8.with({
-- Only used if available
condition = utils.is_executable_condition("pflake8"),
}),
null_ls.builtins.diagnostics.mypy.with({
-- Only used if available
condition = utils.is_executable_condition("mypy"),
}),
null_ls.builtins.diagnostics.pylint.with({
-- Only used if available
condition = utils.is_executable_condition("pylint"),
}),
null_ls.builtins.formatting.black.with({
extra_args = { "--fast" },
-- Only used if available
condition = utils.is_executable_condition("black"),
}),
null_ls.builtins.formatting.isort.with({
-- Only used if available
condition = utils.is_executable_condition("isort"),
}),
})
-- Shell (non-POSIX)
null_ls.register({
null_ls.builtins.code_actions.shellcheck.with({
-- Restrict to bash and zsh
filetypes = { "bash", "zsh" },
-- Only used if available
condition = utils.is_executable_condition("shellcheck"),
}),
null_ls.builtins.diagnostics.shellcheck.with({
-- Show error code in message
diagnostics_format = "[#{c}] #{m}",
-- Require explicit empty string test, use bash dialect
extra_args = { "-s", "bash", "-o", "avoid-nullary-conditions" },
-- Restrict to bash and zsh
filetypes = { "bash", "zsh" },
-- Only used if available
condition = utils.is_executable_condition("shellcheck"),
}),
null_ls.builtins.formatting.shfmt.with({
-- Indent with 4 spaces, simplify the code, indent switch cases,
-- add space after redirection, use bash dialect
extra_args = { "-i", "4", "-s", "-ci", "-sr", "-ln", "bash" },
-- Restrict to bash and zsh
filetypes = { "bash", "zsh" },
-- Only used if available
condition = utils.is_executable_condition("shfmt"),
}),
})
-- Shell (POSIX)
null_ls.register({
null_ls.builtins.code_actions.shellcheck.with({
-- Restrict to POSIX sh
filetypes = { "sh" },
-- Only used if available
condition = utils.is_executable_condition("shellcheck"),
}),
null_ls.builtins.diagnostics.shellcheck.with({
-- Show error code in message
diagnostics_format = "[#{c}] #{m}",
-- Require explicit empty string test
extra_args = { "-o", "avoid-nullary-conditions" },
-- Restrict to POSIX sh
filetypes = { "sh" },
-- Only used if available
condition = utils.is_executable_condition("shellcheck"),
}),
null_ls.builtins.formatting.shfmt.with({
-- Indent with 4 spaces, simplify the code, indent switch cases,
-- add space after redirection, use POSIX
extra_args = { "-i", "4", "-s", "-ci", "-sr", "-ln", "posix" },
-- Restrict to POSIX sh
filetypes = { "sh" },
-- Only used if available
condition = utils.is_executable_condition("shfmt"),
}),
})

View file

@ -0,0 +1,17 @@
if not require("ambroisie.utils").is_ssh() then
return
end
local function copy(lines, _)
require("osc52").copy(table.concat(lines, "\n"))
end
local function paste()
return { vim.fn.split(vim.fn.getreg(""), "\n"), vim.fn.getregtype("") }
end
vim.g.clipboard = {
name = "osc52",
copy = { ["+"] = copy, ["*"] = copy },
paste = { ["+"] = paste, ["*"] = paste },
}

View file

@ -0,0 +1,3 @@
require("nvim-surround").setup({
-- No configuration at the moment
})

View file

@ -0,0 +1,24 @@
local telescope = require("telescope")
telescope.setup({
defaults = {
mappings = {
i = {
["<C-h>"] = "which_key",
-- I want the normal readline mappings rather than scrolling
["<C-u>"] = false,
},
},
},
extensions = {
fzf = {
fuzzy = true,
override_generic_sorter = true,
override_file_sorter = true,
case_mode = "smart_case",
},
},
})
telescope.load_extension("fzf")
telescope.load_extension("lsp_handlers")

View file

@ -0,0 +1,56 @@
local ts_config = require("nvim-treesitter.configs")
ts_config.setup({
highlight = {
enable = true,
-- Avoid duplicate highlighting
additional_vim_regex_highlighting = false,
},
indent = {
enable = true,
},
context_commentstring = {
enable = true,
},
textobjects = {
select = {
enable = true,
-- Jump to matching text objects
lookahead = true,
keymaps = {
["aa"] = "@parameter.outer",
["ia"] = "@parameter.inner",
["ab"] = "@block.outer",
["ib"] = "@block.inner",
["ac"] = "@class.outer",
["ic"] = "@class.inner",
["af"] = "@function.outer",
["if"] = "@function.inner",
["ak"] = "@comment.outer",
["aS"] = "@statement.outer",
},
},
move = {
enable = true,
-- Add to jump list
set_jumps = true,
goto_next_start = {
["]m"] = "@function.outer",
["]S"] = "@statement.outer",
["]]"] = "@class.outer",
},
goto_next_end = {
["]M"] = "@function.outer",
["]["] = "@class.outer",
},
goto_previous_start = {
["[m"] = "@function.outer",
["[S"] = "@statement.outer",
["[["] = "@class.outer",
},
goto_previous_end = {
["[M"] = "@function.outer",
["[]"] = "@class.outer",
},
},
},
})

Some files were not shown because too many files have changed in this diff Show more