feat: markdown to html script

- add binary: md2html
- nvf: add snack nvim
This commit is contained in:
danny 2025-09-18 21:44:57 +08:00
parent 16da0a0a4d
commit d7cf0baf67
10 changed files with 246 additions and 199 deletions

View file

@ -123,10 +123,12 @@
inputs.nixpkgs.follows = "nixpkgs"; inputs.nixpkgs.follows = "nixpkgs";
}; };
# ===== Nvim Plugins ===== #
marks-nvim = { marks-nvim = {
url = "github:chentoast/marks.nvim"; url = "github:chentoast/marks.nvim";
flake = false; flake = false;
}; };
# ======================== #
}; };
outputs = outputs =

View file

@ -15,6 +15,6 @@
../user/vscode.nix ../user/vscode.nix
../user/yazi.nix ../user/yazi.nix
../user/zellij.nix ../user/zellij.nix
../user/nvf.nix ../user/nvf
]; ];
} }

23
home/scripts/md2html.nix Normal file
View file

@ -0,0 +1,23 @@
{ pkgs, ... }:
let
cssStyle = pkgs.fetchurl {
url = "https://raw.githubusercontent.com/xz/new.css/refs/heads/master/new.css";
hash = "sha256-Xd3AMZOeThsrupQusSLjqv3hbNmcpeTms0ieI9nyxOk=";
};
in
pkgs.writeShellScriptBin "md2html" ''
set -e
INPUT="$1"
shift
BASENAME="''\${INPUT%.*}"
HTML_TEMP="''\${BASENAME}.html"
PDF_OUTPUT="''\${BASENAME}.pdf"
${pkgs.pandoc}/bin/pandoc "$INPUT" -s \
--to=html5 --embed-resources \
--css=${cssStyle} -o "$HTML_TEMP" "$@"
echo "generated: $HTML_TEMP"
''

View file

@ -1,9 +1,7 @@
{ {
pkgs, pkgs,
lib, lib,
osConfig,
inputs, inputs,
system,
... ...
}: }:
let let
@ -25,6 +23,10 @@ let
}; };
in in
{ {
imports = [
./plugins/snacks-nvim
];
programs.nvf = { programs.nvf = {
enable = true; enable = true;
settings = { settings = {
@ -87,68 +89,6 @@ in
}; };
keymaps = [ keymaps = [
# === Files === #
# Explorer
{
key = "<leader>e";
mode = [ "n" ];
action = ":Neotree toggle<CR>";
silent = true;
desc = "Toggle file explorer";
}
# === Fzf lua === #
{
key = "<Leader><Space>";
silent = true;
mode = [ "n" ];
action = ":FzfLua files<CR>";
nowait = true;
unique = true;
desc = "Find file";
}
{
key = "<Leader>/";
mode = [ "n" ];
action = ":FzfLua live_grep<CR>";
nowait = true;
unique = true;
desc = "Live grep";
}
# Lsp symbol document
{
key = "<Leader>ss";
silent = true;
mode = [ "n" ];
action = ":FzfLua lsp_document_symbols<CR>";
nowait = true;
unique = true;
desc = "Find symbols (document)";
}
# Lsp symbol workspace
{
key = "<Leader>sS";
silent = true;
mode = [ "n" ];
action = ":FzfLua lsp_workspace_symbols<CR>";
unique = true;
nowait = true;
desc = "Find symbols (workspace)";
}
# Registers
{
key = ''""'';
mode = [ "n" ];
action = ":FzfLua registers<CR>";
desc = "Registers";
}
# Marks
{
key = "''";
mode = [ "n" ];
action = ":FzfLua marks<CR>";
desc = "Marks";
}
# === Buffer === # # === Buffer === #
{ {
key = "<Leader>bo"; key = "<Leader>bo";
@ -181,34 +121,6 @@ in
action = "<C-d>"; action = "<C-d>";
desc = "Shift left"; desc = "Shift left";
} }
{
key = "gd";
mode = [ "n" ];
action = ":FzfLua lsp_definitions<CR>";
nowait = true;
desc = "Go to definition";
}
{
key = "gD";
mode = [ "n" ];
action = ":FzfLua lsp_declarations<CR>";
nowait = true;
desc = "Go to declaration";
}
{
key = "gi";
mode = [ "n" ];
action = ":FzfLua lsp_implementations<CR>";
nowait = true;
desc = "Go to implementation";
}
{
key = "gr";
mode = [ "n" ];
action = ":FzfLua lsp_references<CR>";
nowait = true;
desc = "List references";
}
{ {
key = "<Leader>n"; key = "<Leader>n";
mode = [ "n" ]; mode = [ "n" ];
@ -496,12 +408,6 @@ in
visuals = { visuals = {
nvim-web-devicons.enable = true; nvim-web-devicons.enable = true;
nvim-cursorline.enable = true; nvim-cursorline.enable = true;
cinnamon-nvim = {
enable = true;
setupOpts.keymaps = {
basic = true;
};
};
fidget-nvim = { fidget-nvim = {
enable = true; enable = true;
setupOpts.notification = { setupOpts.notification = {
@ -705,7 +611,15 @@ in
snippets.luasnip = { snippets.luasnip = {
enable = true; enable = true;
providers = [ "blink-cmp" ]; providers = [
"friendly-snippets"
"blink-cmp"
"base16"
"lsp-signature-nvim"
"snacks-nvim"
"render-markdown-nvim"
"cmp-path"
];
setupOpts.enable_autosnippets = true; setupOpts.enable_autosnippets = true;
}; };
@ -715,7 +629,7 @@ in
filetree = { filetree = {
neo-tree = { neo-tree = {
enable = true; enable = false;
setupOpts = { setupOpts = {
window = { window = {
position = "right"; position = "right";
@ -754,86 +668,6 @@ in
whichKey.enable = true; whichKey.enable = true;
}; };
fzf-lua = {
enable = true;
setupOpts = {
previewers = {
builtin = {
extensions = {
"jpg" = {
"kitty" = "";
};
};
snacks_image = {
enabled = false;
render_inline = false;
};
};
};
winopts = {
preview = {
hidden = "hidden";
};
border = "rounded";
};
fzf_opts = {
"--no-header" = "";
"--no-scrollbar" = "";
};
files = {
formatter = "path.filename_first";
prompt = ":";
no_header = true;
cwd_header = false;
cwd_prompt = false;
winopts = {
title = " files 📑 ";
title_pos = "center";
title_flags = false;
};
};
buffers = {
formatter = "path.filename_first";
prompt = ":";
no_header = true;
fzf_opts = {
"--delimiter" = " ";
"--with-nth" = "-1..";
};
winopts = {
title = " buffers 📝 ";
title_pos = "center";
};
};
lsp = {
symbols = {
cwd_only = true;
no_header = true;
prompt = ":";
winopts = {
title = " symbols ";
title_pos = "center";
height = 0.6;
preview = {
hidden = "nohidden";
horizontal = "down:40%";
wrap = "wrap";
};
};
};
};
registers = {
prompt = "registers:";
filter = "%a";
winopts = {
title = " registers 🏷 ";
title_pos = "center";
};
};
};
};
dashboard = { dashboard = {
alpha.enable = true; alpha.enable = true;
}; };

View file

@ -0,0 +1,55 @@
{ pkgs, ... }:
{
programs.nvf.settings.vim = {
keymaps = import ./keymaps.nix;
extraPackages = with pkgs; [ fd ];
};
programs.nvf.settings.vim.utility.snacks-nvim = {
enable = true;
setupOpts = {
bigfile = {
enabled = true;
};
dashboard = {
enabled = false;
};
explorer = {
enabled = true;
};
indent = {
enabled = true;
};
input = {
enabled = true;
};
picker = {
enabled = true;
sources = {
explorer.layout.layout.position = "right";
};
formatters = {
file.filename_first = true;
};
};
notifier = {
enabled = true;
};
quickfile = {
enabled = true;
};
scope = {
enabled = true;
};
scroll = {
enabled = true;
};
statuscolumn = {
enabled = false;
};
words = {
enabled = true;
};
};
};
}

View file

@ -0,0 +1,132 @@
let
keyList = [
{
key = "<leader>e";
action = "explorer()";
desc = "Toggle explorer";
}
{
key = "<leader><space>";
action = "picker.smart()";
desc = "Smart Find Files";
}
{
key = "<leader>/";
action = "picker.grep()";
desc = "Live Grep";
}
{
key = "<leader>ss";
action = "picker.lsp_symbols()";
desc = "Find symbols";
}
{
key = "<leader>sS";
action = "picker.lsp_workspace_symbols()";
desc = "Find symbols (Workspace)";
}
# Grep
{
key = "<leader>sb";
action = "picker.lines()";
desc = "Buffer Lines";
}
{
key = "<leader>sB";
action = "picker.grep_buffers()";
desc = "Grep Open Buffers";
}
{
key = "<leader>sw";
action = "picker.grep_word()";
desc = "Visual selection or word";
mode = [
"n"
"x"
];
}
{
key = ''<leader>s"'';
action = "picker.registers()";
desc = "Registers";
}
{
key = "<leader>sd";
action = "picker.diagnostics()";
desc = "Diagnostics";
}
{
key = "<leader>sD";
action = "picker.diagnostics_buffer()";
desc = "Buffer Diagnostics";
}
{
key = "gd";
action = "picker.lsp_definitions()";
desc = "Goto Definition";
}
{
key = "gD";
action = "picker.lsp_declarations()";
desc = "Goto Declaration";
}
{
key = "gr";
action = "picker.lsp_references()";
desc = "References";
}
{
key = "gI";
action = "picker.lsp_implementations()";
desc = "Goto Implementation";
}
{
key = "gy";
action = "picker.lsp_type_definitions()";
desc = "Goto T[y]pe Definition";
}
{
key = "<leader>st";
action = "picker.todo_comments()";
desc = "Todo";
}
{
key = "<leader>sT";
action = ''picker.todo_comments({ keywords = { "TODO", "FIX", "FIXME" } })'';
desc = "Todo/Fix/Fixme";
}
# === Git === #
{
key = "<leader>gd";
action = "picker.git_diff()";
desc = "Git Diff";
}
{
key = "<leader>gl";
action = "picker.git_log()";
desc = "Git Log";
}
{
key = "<leader>gs";
action = "picker.git_stash()";
desc = "Git Stash";
}
];
mkLuaKeyMap =
{
key,
action,
desc ? "",
mode ? [ "n" ],
}:
{
inherit key desc mode;
action = "function() Snacks.${action} end";
lua = true;
nowait = true;
unique = true;
};
in
map (x: mkLuaKeyMap x) keyList

View file

@ -6,15 +6,10 @@
osConfig, osConfig,
... ...
}: }:
let
md2html = pkgs.callPackage ../scripts/md2html.nix { };
in
{ {
programs.poetry = {
enable = true;
settings = {
virtualenvs.create = true;
virtualenvs.in-project = true;
};
};
programs.btop = { programs.btop = {
enable = true; enable = true;
settings = { settings = {
@ -93,6 +88,8 @@
ffmpegthumbnailer ffmpegthumbnailer
thunderbird thunderbird
md2html
] ]
++ ( ++ (
if osConfig.programs.steam.enable then if osConfig.programs.steam.enable then

View file

@ -139,11 +139,17 @@ let
allowedIPs = [ "10.0.0.145/32" ]; allowedIPs = [ "10.0.0.145/32" ];
} }
{ {
# Skydrive # Skydrive Lap
dns = "skydrive-mesh"; dns = "skydrive-mesh";
publicKey = "MK6UX8WadSbDXI3919F5EarYlZHjFNbHwYJH8Ub/YXk="; publicKey = "MK6UX8WadSbDXI3919F5EarYlZHjFNbHwYJH8Ub/YXk=";
allowedIPs = [ "10.0.0.146/32" ]; allowedIPs = [ "10.0.0.146/32" ];
} }
{
# Skydrive Phone
dns = "skydrive-mesh-phone";
publicKey = "K6Pd69/Hfu4ceCAp/JbeEL2QQ+/4ohugW1lAOxHFKDA=";
allowedIPs = [ "10.0.0.147/32" ];
}
]; ];
in in
{ {

View file

@ -8,27 +8,24 @@
{ {
imports = [ imports = [
(modulesPath + "/installer/scan/not-detected.nix") (modulesPath + "/installer/scan/not-detected.nix")
(modulesPath + "/profiles/qemu-guest.nix")
./disk.nix ./disk.nix
./hardware-configuration.nix ./hardware-configuration.nix
../../modules/nixsettings.nix ../../modules/nixsettings.nix
]; ];
# boot.loader.systemd-boot.enable = true; boot.loader.systemd-boot.enable = true;
boot.loader.grub = {
enable = true;
devices = [ "/dev/sda" ];
efiSupport = true;
efiInstallAsRemovable = true;
};
boot.kernelPackages = pkgs.linuxPackages_latest; boot.kernelPackages = pkgs.linuxPackages_latest;
networking.firewall = {
allowedTCPPorts = [ 22 ];
allowedUDPPorts = [ ];
};
services.openssh = { services.openssh = {
enable = true; enable = true;
ports = [ ports = [
22 22
30072
]; ];
settings = { settings = {
PasswordAuthentication = true; PasswordAuthentication = true;

View file

@ -152,5 +152,6 @@ in
users.users."${username}".openssh.authorizedKeys.keys = [ users.users."${username}".openssh.authorizedKeys.keys = [
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJSAOufpee7f8D8ONIIGU3qsN+8+DGO7BfZnEOTYqtQ5 danny@pre7780.dn" "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJSAOufpee7f8D8ONIIGU3qsN+8+DGO7BfZnEOTYqtQ5 danny@pre7780.dn"
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIBDk8GmC7b9+XSDxnIj5brYmNLPVO47G5enrL3Q+8fuh "
]; ];
} }