From 5e0ebe4406d914b47232e6e69804ec1abdea5316 Mon Sep 17 00:00:00 2001 From: Martin Pander Date: Fri, 10 Jul 2026 09:02:17 +0200 Subject: [PATCH] Fix sshfs intricacies; Add todo cycle for markdown --- flake.lock | 66 +++++++++++++++++------------------ modules/home/dev.nix | 10 ++++++ modules/home/tmux.nix | 9 ++--- modules/nvim/lua/base.lua | 30 +++++++++------- modules/nvim/lua/filetype.lua | 64 +++++++++++++++++++++++++++++---- modules/nvim/lua/plugins.lua | 14 ++++---- 6 files changed, 131 insertions(+), 62 deletions(-) diff --git a/flake.lock b/flake.lock index 4bf789b..8aaf62a 100644 --- a/flake.lock +++ b/flake.lock @@ -125,11 +125,11 @@ ] }, "locked": { - "lastModified": 1778716662, - "narHash": "sha256-m1Yf0wZ8j1OHjTc2UwHwyQRSnNeSgLJOd7q5Y45hzi4=", + "lastModified": 1782949081, + "narHash": "sha256-vp6Y/Grm98ESt6ceOkWiHWyZRDV3J1RID4w+6NWK9yA=", "owner": "hercules-ci", "repo": "flake-parts", - "rev": "f7c1a2d347e4c52d5fb8d10cb4d94b5884e546fb", + "rev": "17c9d6cdfc60c64f4ee8d306f9bc0b4ccb51481e", "type": "github" }, "original": { @@ -181,11 +181,11 @@ ] }, "locked": { - "lastModified": 1782704057, - "narHash": "sha256-G1I1gd32F7mp9LAe1DaZ4ZL7NX5gyiKwdCMwro1Vrck=", + "lastModified": 1783221248, + "narHash": "sha256-ESQnuNHEDChsB4IxoLRhscVahqkDWkTb+qdIz8euYt4=", "owner": "nix-community", "repo": "home-manager", - "rev": "868d0a692de703c2de98fab61968e4e310b7c28e", + "rev": "af2beae5f0fae0a4310cc0e6aef2572f56090353", "type": "github" }, "original": { @@ -202,11 +202,11 @@ ] }, "locked": { - "lastModified": 1782704057, - "narHash": "sha256-G1I1gd32F7mp9LAe1DaZ4ZL7NX5gyiKwdCMwro1Vrck=", + "lastModified": 1783221248, + "narHash": "sha256-ESQnuNHEDChsB4IxoLRhscVahqkDWkTb+qdIz8euYt4=", "owner": "nix-community", "repo": "home-manager", - "rev": "868d0a692de703c2de98fab61968e4e310b7c28e", + "rev": "af2beae5f0fae0a4310cc0e6aef2572f56090353", "type": "github" }, "original": { @@ -224,11 +224,11 @@ ] }, "locked": { - "lastModified": 1782739581, - "narHash": "sha256-0zK4mQsx4dTQ0D8xY/6REuvE+onPfKSUvvZz+bAVwIw=", + "lastModified": 1783426737, + "narHash": "sha256-yQFZXU2rFrwR+OJMktg9Zvrn3jnfVcQAuT8fWVNsnCs=", "owner": "modem-dev", "repo": "hunk", - "rev": "65a27400099dd5db29d10e1dcbdd0918748cadba", + "rev": "059dd13c8bd27fe503ef59652077edf0041034c8", "type": "github" }, "original": { @@ -262,11 +262,11 @@ "treefmt-nix": "treefmt-nix_2" }, "locked": { - "lastModified": 1782888034, - "narHash": "sha256-bmM+TfnodBmk/95HE/eIoNzRY8b7wRWbcYU3cUvKIZw=", + "lastModified": 1783567605, + "narHash": "sha256-LyF84yqWppXAAEOAkL325Lt+DrVmkbbeXGzDgX9zMzI=", "owner": "numtide", "repo": "llm-agents.nix", - "rev": "2a0d5e87e34cbec74c2df9764eeddf1a655d2046", + "rev": "a4c847460f0e773d02d0655ce28dc6b532dd65d6", "type": "github" }, "original": { @@ -282,11 +282,11 @@ ] }, "locked": { - "lastModified": 1781761792, - "narHash": "sha256-rCPytmKNjctLloB6UgK5CRrHSwV4b0ygxtJLPPp8R14=", + "lastModified": 1783395956, + "narHash": "sha256-AAbexQvDoK+6GFJdhY6kqjA+6ECKRkidgWxkn4gMwAA=", "owner": "LnL7", "repo": "nix-darwin", - "rev": "a1fa429e945becaf60468600daf649be4ba0350c", + "rev": "d5bd9cd77aea4c0a8f49e7fd85545671a208ed15", "type": "github" }, "original": { @@ -340,11 +340,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1782760764, - "narHash": "sha256-N66fYdUuZ9hpdM7jsQ7CUWtLJduqGDyTGCaLR62CXaQ=", + "lastModified": 1783279667, + "narHash": "sha256-/NAkDSsve+GNM0Bt6tleJdCGfsTlK89nPjkVOzZMo0s=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "7a1a64774a5fd0b0cd39ac95d0e170ace8b266a0", + "rev": "f205b5574fd0cb7da5b702a2da51507b7f4fdd1b", "type": "github" }, "original": { @@ -386,11 +386,11 @@ }, "nixpkgs-stable": { "locked": { - "lastModified": 1782847225, - "narHash": "sha256-JC9PjqKYG9ve5U8aDOLQipp3+KLANBHUvGdLZlxzdKI=", + "lastModified": 1783389287, + "narHash": "sha256-0xIy4dVLqq47rA+mRy0hXDfjhQd4E5PoIns/RmB7nR4=", "owner": "nixos", "repo": "nixpkgs", - "rev": "95ca1e203c0750115fd4a6f17d5a245dfe6b1edd", + "rev": "0ad6f47ea4fe188f4bc8f0380f93ae8523337c6c", "type": "github" }, "original": { @@ -402,11 +402,11 @@ }, "nixpkgs-wsl-stable": { "locked": { - "lastModified": 1782847225, - "narHash": "sha256-JC9PjqKYG9ve5U8aDOLQipp3+KLANBHUvGdLZlxzdKI=", + "lastModified": 1783389287, + "narHash": "sha256-0xIy4dVLqq47rA+mRy0hXDfjhQd4E5PoIns/RmB7nR4=", "owner": "nixos", "repo": "nixpkgs", - "rev": "95ca1e203c0750115fd4a6f17d5a245dfe6b1edd", + "rev": "0ad6f47ea4fe188f4bc8f0380f93ae8523337c6c", "type": "github" }, "original": { @@ -418,11 +418,11 @@ }, "nixpkgs_2": { "locked": { - "lastModified": 1782723713, - "narHash": "sha256-oPXCU/SSUokcGaJREHibG1CBX3+s/W7orDWQOZDsEeQ=", + "lastModified": 1783224372, + "narHash": "sha256-8i/87eeoqiGE4yOTjwSA3Eh/ziJRQEmd/unYU+K27sk=", "owner": "nixos", "repo": "nixpkgs", - "rev": "b5aa0fbd538984f6e3d201be0005b4463d8b09f8", + "rev": "d407951447dcd00442e97087bf374aad70c04cea", "type": "github" }, "original": { @@ -471,11 +471,11 @@ ] }, "locked": { - "lastModified": 1782165805, - "narHash": "sha256-478kKQBvK6SYTOdN2h9jhKJv94nbXRbFMfuL1WshErg=", + "lastModified": 1783174389, + "narHash": "sha256-aCWC8ngycU7OdJrU2+Je3qf+1a2ykuBvpPhZT/9tXMc=", "owner": "Mic92", "repo": "sops-nix", - "rev": "56b24064fdcaedca53553b1a6d607fd23b613a24", + "rev": "f1406619a3884cd5c47992a70b8b35c9c0fcb4c9", "type": "github" }, "original": { diff --git a/modules/home/dev.nix b/modules/home/dev.nix index 4023e12..c3f7cc6 100644 --- a/modules/home/dev.nix +++ b/modules/home/dev.nix @@ -39,6 +39,16 @@ in enable = true; enableZshIntegration = true; nix-direnv.enable = true; + stdlib = '' + : ''${XDG_CACHE_HOME:=$HOME/.cache} + declare -A direnv_layout_dirs + direnv_layout_dir() { + echo "''${direnv_layout_dirs[$PWD]:=$( + echo -n "$XDG_CACHE_HOME"/direnv/layouts/ + echo -n "$PWD" | sha1sum | cut -d ' ' -f 1 + )}" + } + ''; }; home.packages = with pkgs; [ diff --git a/modules/home/tmux.nix b/modules/home/tmux.nix index 8ce0bcb..8c12965 100644 --- a/modules/home/tmux.nix +++ b/modules/home/tmux.nix @@ -123,6 +123,9 @@ in set -s set-clipboard on set -g extended-keys on set -g extended-keys-format csi-u + set -g renumber-windows on + set -g base-index 1 + set -g pane-base-index 1 unbind S bind S command-prompt "switch -t %1" @@ -168,10 +171,8 @@ in set -g status-right "#[bg=#BCBCBC] %H:%M #[bg=#808080,fg=#ffffff] %d.%m.%y " - # setw -g window-status-format " #W#F " - # setw -g window-status-current-format " #W#F " - setw -g window-status-format " #W " - setw -g window-status-current-format " #W " + setw -g window-status-format "#W:#I " + setw -g window-status-current-format " #W:#I " setw -g window-status-separator "" ####################################### diff --git a/modules/nvim/lua/base.lua b/modules/nvim/lua/base.lua index b59df6d..46642ae 100644 --- a/modules/nvim/lua/base.lua +++ b/modules/nvim/lua/base.lua @@ -80,18 +80,24 @@ vim.g.clipboard = { } if vim.fn.has("wsl") == 1 then - vim.g.clipboard = { - name = 'WslClipboard', - copy = { - ["+"] = 'win32yank.exe -i --crlf', - ["*"] = 'win32yank.exe -i --crlf', - }, - paste = { - ["+"] = 'win32yank.exe -o --lf', - ["*"] = 'win32yank.exe -o --lf', - }, - cache_enabled = 0, - } + local function win32yank_works() + return os.execute("win32yank.exe -o >/dev/null 2>&1") == 0 + end + + if win32yank_works() then + vim.g.clipboard = { + name = 'WslClipboard', + copy = { + ["+"] = 'win32yank.exe -i --crlf', + ["*"] = 'win32yank.exe -i --crlf', + }, + paste = { + ["+"] = 'win32yank.exe -o --lf', + ["*"] = 'win32yank.exe -o --lf', + }, + cache_enabled = 0, + } + end end vim.opt.clipboard = 'unnamedplus' diff --git a/modules/nvim/lua/filetype.lua b/modules/nvim/lua/filetype.lua index bd6c0a7..8bab121 100644 --- a/modules/nvim/lua/filetype.lua +++ b/modules/nvim/lua/filetype.lua @@ -89,6 +89,63 @@ vim.api.nvim_create_autocmd('FileType', { end, }) +local function cycle_todo() + local line = vim.api.nvim_get_current_line() + + -- 0. STRICT CHECK: If the line doesn't start with a list marker (-), fall back to normal Enter behavior + if not line:match("^%s*%-") then + -- This simulates a normal carriage return if mapped to + local keys = vim.api.nvim_replace_termcodes("", true, false, true) + vim.api.nvim_feedkeys(keys, "n", false) + return + end + + -- The sequence of checkbox states we want to cycle through + local states = { " ", ">", "x", "!", "~", "c" } + + -- 1. If it's a cancelled todo [c], strip the brackets but KEEP the list item (- ) + if line:match("^%s*%-%s*%[c%]") then + local clean_line = line:gsub("(%s*%-%s*)%[c%]%s*", "%1") + vim.api.nvim_set_current_line(clean_line) + return + end + + -- 2. If it's a standard list item without a checkbox, turn it into `- [ ]` + if not line:match("^%s*%-%s*%[.%]") then + -- Matches the list prefix (e.g., "- " or " - ") and appends "[ ] " + local new_line = line:gsub("^(%s*%-%s*)", "%1[ ] ") + vim.api.nvim_set_current_line(new_line) + return + end + + -- 3. Cycle through the custom states natively + for i, state in ipairs(states) do + -- Escape special Lua magic characters like !, >, ~, c + local escaped_state = state:gsub("([^%w])", "%%%1") + local pattern = "^(%s*%-%s*%[)" .. escaped_state .. "(%])" + + if line:match(pattern) then + local next_state = states[(i % #states) + 1] + local new_line = line:gsub(pattern, "%1" .. next_state .. "%2", 1) + vim.api.nvim_set_current_line(new_line) + return + end + end +end + + +vim.api.nvim_create_autocmd('FileType', { + group = vim.api.nvim_create_augroup('FileTypeConfigs', { clear = true }), + pattern = 'markdown', + once = true, + callback = function() + vim.keymap.set('n', '', cycle_todo, { + buffer = true, + desc = 'Cycle todo state' + }) + end, +}) + -- vim.api.nvim_create_autocmd('FileType', { -- group = vim.api.nvim_create_augroup('FileTypeConfigs', { clear = true }), -- pattern = 'proto', @@ -97,13 +154,6 @@ vim.api.nvim_create_autocmd('FileType', { -- end, -- }) -- --- vim.api.nvim_create_autocmd('FileType', { --- group = vim.api.nvim_create_augroup('FileTypeConfigs', { clear = true }), --- pattern = 'markdown', --- once = true, --- callback = function() --- end, --- }) -- -- vim.api.nvim_create_autocmd('FileType', { -- group = vim.api.nvim_create_augroup('FileTypeConfigs', { clear = true }), diff --git a/modules/nvim/lua/plugins.lua b/modules/nvim/lua/plugins.lua index 0b81a76..bc23bcb 100644 --- a/modules/nvim/lua/plugins.lua +++ b/modules/nvim/lua/plugins.lua @@ -465,7 +465,7 @@ require("obsidian").setup({ time_format = "%H:%M", }, checkbox = { - order = { " ", ">", "x", "!", "~", "" }, + order = { " ", ">", "x", "!", "~", "c", "" }, }, frontmatter = { enabled = true, @@ -505,19 +505,21 @@ require('render-markdown').setup({ bullet = false, right_pad = 1, unchecked = { - icon = '󰄱 ', + icon = '󰄱', highlight = 'RenderMarkdownUnchecked', scope_highlight = nil, }, checked = { - icon = '󰱒 ', + icon = '󰱒', highlight = 'RenderMarkdownChecked', scope_highlight = nil, }, custom = { - next = { raw = '[!]', rendered = ' ', highlight = 'RenderMarkdownNext', scope_highlight = nil }, - ongoing = { raw = '[>]', rendered = '▶ ', highlight = 'RenderMarkdownOngoing', scope_highlight = nil }, - waiting = { raw = '[~]', rendered = '󰥔 ', highlight = 'RenderMarkdownWaiting', scope_highlight = nil }, + next = { raw = '[!]', rendered = '', highlight = 'RenderMarkdownNext', scope_highlight = nil }, + in_progress = { raw = '[>]', rendered = '◐', highlight = 'RenderMarkdownOngoing', scope_highlight = nil }, + waiting = { raw = '[~]', rendered = '󰥔', highlight = 'RenderMarkdownWaiting', scope_highlight = nil }, + cancelled = { raw = '[c]', rendered = 'x', highlight = 'RenderMarkdownCancelled', scope_highlight = nil }, }, }, }) +