Fix sshfs intricacies; Add todo cycle for markdown
This commit is contained in:
@@ -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'
|
||||
|
||||
@@ -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 <CR>
|
||||
local keys = vim.api.nvim_replace_termcodes("<CR>", 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', '<CR>', 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 }),
|
||||
|
||||
@@ -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 },
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user