clone of my dotfiles.ssp.sh
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

add neomd custom config

sspaeti bddd4c10 9fc49d3c

+68
+68
nvim/.config/nvim/lua/sspaeti/custom.lua
··· 1 + -- ── neomd: attach file from within the email editor ─────────────────────── 2 + -- Usage: <leader>a in normal mode while writing a neomd-*.md email buffer. 3 + -- Opens yazi in a floating window. Selected file path(s) are inserted as 4 + -- <!-- Attach: /absolute/path/to/file.pdf --> 5 + -- neomd strips these lines before sending and adds them as MIME attachments. 6 + local function neomd_attach() 7 + local target_buf = vim.api.nvim_get_current_buf() 8 + local target_win = vim.api.nvim_get_current_win() 9 + local cursor_row = vim.api.nvim_win_get_cursor(target_win)[1] 10 + local chooser = vim.fn.tempname() 11 + 12 + -- Floating terminal sized to 85 % of the screen 13 + local W = math.floor(vim.o.columns * 0.85) 14 + local H = math.floor(vim.o.lines * 0.85) 15 + local float_buf = vim.api.nvim_create_buf(false, true) 16 + local float_win = vim.api.nvim_open_win(float_buf, true, { 17 + relative = "editor", 18 + width = W, height = H, 19 + col = math.floor((vim.o.columns - W) / 2), 20 + row = math.floor((vim.o.lines - H) / 2), 21 + style = "minimal", 22 + border = "rounded", 23 + title = " attach file — <Enter> select, q quit ", 24 + title_pos = "center", 25 + }) 26 + 27 + vim.fn.termopen({ "yazi", "--chooser-file", chooser }, { 28 + on_exit = function() 29 + if vim.api.nvim_win_is_valid(float_win) then 30 + vim.api.nvim_win_close(float_win, true) 31 + end 32 + vim.schedule(function() 33 + local ok, lines = pcall(vim.fn.readfile, chooser) 34 + vim.fn.delete(chooser) 35 + if not ok or not lines or #lines == 0 then return end 36 + 37 + local inserts = {} 38 + for _, path in ipairs(lines) do 39 + path = vim.trim(path) 40 + if path ~= "" then 41 + table.insert(inserts, "[attach] " .. path) 42 + end 43 + end 44 + if #inserts == 0 then return end 45 + 46 + -- Insert after the current cursor row, then move cursor past them 47 + vim.api.nvim_buf_set_lines(target_buf, cursor_row, cursor_row, false, inserts) 48 + if vim.api.nvim_win_is_valid(target_win) then 49 + vim.api.nvim_win_set_cursor(target_win, { cursor_row + #inserts, 0 }) 50 + end 51 + end) 52 + end, 53 + }) 54 + vim.cmd("startinsert") 55 + end 56 + 57 + -- Only map <leader>a when editing a neomd compose buffer (neomd-*.md) 58 + vim.api.nvim_create_autocmd("BufEnter", { 59 + pattern = "neomd-*.md", 60 + callback = function() 61 + vim.keymap.set("n", "<leader>a", neomd_attach, { 62 + buffer = true, 63 + desc = "neomd: attach file via yazi", 64 + }) 65 + end, 66 + }) 67 + -- ── end neomd ────────────────────────────────────────────────────────────── 68 + 1 69 --custom function to set colortheme based on session session_name 2 70 --please make sure that the theme isn't loaded lazy when set as initial theme 3 71 function SetThemeBasedOnTmuxSession(sessionThemes)