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

@ -15,6 +15,6 @@
../user/vscode.nix
../user/yazi.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,
lib,
osConfig,
inputs,
system,
...
}:
let
@ -25,6 +23,10 @@ let
};
in
{
imports = [
./plugins/snacks-nvim
];
programs.nvf = {
enable = true;
settings = {
@ -87,68 +89,6 @@ in
};
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 === #
{
key = "<Leader>bo";
@ -181,34 +121,6 @@ in
action = "<C-d>";
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";
mode = [ "n" ];
@ -496,12 +408,6 @@ in
visuals = {
nvim-web-devicons.enable = true;
nvim-cursorline.enable = true;
cinnamon-nvim = {
enable = true;
setupOpts.keymaps = {
basic = true;
};
};
fidget-nvim = {
enable = true;
setupOpts.notification = {
@ -705,7 +611,15 @@ in
snippets.luasnip = {
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;
};
@ -715,7 +629,7 @@ in
filetree = {
neo-tree = {
enable = true;
enable = false;
setupOpts = {
window = {
position = "right";
@ -754,86 +668,6 @@ in
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 = {
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,
...
}:
let
md2html = pkgs.callPackage ../scripts/md2html.nix { };
in
{
programs.poetry = {
enable = true;
settings = {
virtualenvs.create = true;
virtualenvs.in-project = true;
};
};
programs.btop = {
enable = true;
settings = {
@ -93,6 +88,8 @@
ffmpegthumbnailer
thunderbird
md2html
]
++ (
if osConfig.programs.steam.enable then