clone of my dotfiles.ssp.sh
1
fork

Configure Feed

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

add float_todo app

+108
+1
nvim/lua/sspaeti/init.lua
··· 3 3 require("theme.kanagawa") 4 4 require("sspaeti.set") 5 5 require("sspaeti.remap") 6 + require("sspaeti.plugins_custom") 6 7 -- require("sspaeti.transparency") 7 8 8 9 vim.opt.listchars = { eol = "↵", tab = "→ ", trail = "·", extends = "$" }
+4
nvim/lua/sspaeti/plugins_custom/init.lua
··· 1 + require("sspaeti.plugins_custom.todo_float").setup({ 2 + target_file = "todo.md", 3 + global_file = "~/Simon/SecondBrain/🌿 Projects/My Todos.md", 4 + })
+88
nvim/lua/sspaeti/plugins_custom/todo_float.lua
··· 1 + -- from https://github.com/vimichael/my-nvim-config/blob/c495324cf7435707f5a84a2bb127a764632872c4/lua/cool_stuff/todo_float.lua and this YT: https://www.youtube.com/watch?v=LaIa1tQFOSY 2 + local utils = require("sspaeti.plugins_custom.utils") 3 + 4 + local M = {} 5 + 6 + local function float_win_config() 7 + local width = math.min(math.floor(vim.o.columns * 0.8), 64) 8 + local height = math.floor(vim.o.lines * 0.8) 9 + 10 + return { 11 + relative = "editor", 12 + width = width, 13 + height = height, 14 + col = utils.center_in(vim.o.columns, width), 15 + row = utils.center_in(vim.o.lines, height), 16 + border = "single", 17 + } 18 + end 19 + 20 + local function open_floating_file(filepath) 21 + local path = utils.expand_path(filepath) 22 + 23 + -- Check if the file exists 24 + if vim.fn.filereadable(path) == 0 then 25 + vim.notify("File does not exist: " .. path, vim.log.levels.ERROR) 26 + return 27 + end 28 + 29 + -- Look for an existing buffer with this file 30 + local buf = vim.fn.bufnr(path, true) 31 + 32 + -- If the buffer doesn't exist, create one and edit the file 33 + if buf == -1 then 34 + buf = vim.api.nvim_create_buf(false, false) 35 + vim.api.nvim_buf_set_name(buf, path) 36 + vim.api.nvim_buf_call(buf, function() 37 + vim.cmd("edit " .. vim.fn.fnameescape(path)) 38 + end) 39 + end 40 + 41 + local win = vim.api.nvim_open_win(buf, true, float_win_config()) 42 + vim.cmd("setlocal nospell") 43 + 44 + vim.api.nvim_buf_set_keymap(buf, "n", "q", "", { 45 + noremap = true, 46 + silent = true, 47 + callback = function() 48 + -- Check if the buffer has unsaved changes 49 + if vim.api.nvim_get_option_value("modified", { buf = buf }) then 50 + vim.notify("Please save changes first", vim.log.levels.WARN) 51 + else 52 + vim.api.nvim_win_close(0, true) 53 + end 54 + end, 55 + }) 56 + 57 + vim.api.nvim_create_autocmd("VimResized", { 58 + callback = function() 59 + vim.api.nvim_win_set_config(win, float_win_config()) 60 + end, 61 + once = false, 62 + }) 63 + end 64 + 65 + local function setup_user_commands(opts) 66 + local target_file = opts.target_file or "todo.md" 67 + local resolved_target_file = vim.fn.resolve(target_file) 68 + 69 + if vim.fn.filereadable(resolved_target_file) == true then 70 + opts.target_file = resolved_target_file 71 + else 72 + opts.target_file = opts.global_file 73 + end 74 + vim.api.nvim_create_user_command("Td", function() 75 + open_floating_file(opts.target_file) 76 + end, {}) 77 + end 78 + 79 + local function setup_keymaps() 80 + vim.keymap.set("n", "<leader>mt", ":Td<CR>", { desc = "open my todo file", silent = true }) 81 + end 82 + 83 + M.setup = function(opts) 84 + setup_user_commands(opts) 85 + setup_keymaps() 86 + end 87 + 88 + return M
+15
nvim/lua/sspaeti/plugins_custom/utils/init.lua
··· 1 + -- from https://github.com/vimichael/my-nvim-config/blob/c495324cf7435707f5a84a2bb127a764632872c4/lua/cool_stuff/todo_float.lua and this YT: https://www.youtube.com/watch?v=LaIa1tQFOSY 2 + local utils = {} 3 + 4 + function utils.expand_path(path) 5 + if path:sub(1, 1) == "~" then 6 + return os.getenv("HOME") .. path:sub(2) 7 + end 8 + return path 9 + end 10 + 11 + function utils.center_in(outer, inner) 12 + return (outer - inner) / 2 13 + end 14 + 15 + return utils