vuciv / vim-bujo

A minimalist task manager for vim.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

checking off todos changes last search register, interacts with :hlsearch

davidscotson opened this issue · comments

In (neo)Vim I leave my last search highlighted until I clear it manually (Ctr+l mapped to :noh) as I like the visual hint of where I can jump to next.

With vim-bujo, this reveals that the command for (un)ticking a checkbox is done via a search and replace, as all the the opposite tickboxes on the page become highlighted afterwards.

I've added :noh to the mapping, but it still flickers very briefly. I can probably live with that, but as a result of this I noticed that the search history gets updated e.g. if you were searching for every item on the list that said "bacon" you could jump to the first, tick it off, but then trying to jump to the next one will instead search for the next checkbox.

Again, not exactly a massive problem, but I think I should be able to save the search register, and restore it afterwards, possibly even disabling the hlsearch for this specific search to avoid the flicker but not actually got that all working as a mapping yet. (When trying to google for helpful info, it's mostly people wanting to turn hlsearch off entirely or after manually searching that comes up)

I'm currently looking into different ways to achieve the same edit without a search as an alternative if that is possible, but thought I'd mention it in case there's an obvious solution I'm missing.

Thanks for a great plugin.

I endeded up with:

" done, toggle checkbox
nmap <C-d> :let search=@/<CR>:let hl=v:hlsearch<CR>:set nohlsearch<CR><Plug>BujoChecknormal :let @/=search<CR>:let &hls=hl<CR>
imap <C-d> <esc>:let search=@/<CR>:let hl=v:hlsearch<CR>:set nohlsearch<CR><Plug>BujoChecknormal :let @/=search<CR>:let &hls=hl<CR>i

Some further searching found this: https://www.reddit.com/r/vim/comments/c2h28r/a_small_markdown_mapping_for_checkboxes/

and then in the comments from olminator:
https://gist.github.com/olmokramer/feadbf14a055efd46a8e1bf1e4be4447

Which is a generic Markdown checkbox checker. Notably it uses :keeppatterns which is the Vim 8+ way to do what I was doing above, to avoid changing the search register.

I also like the idea of being able to add and cycle through the checkbox states with a single command (I use 3 stages . (todo), / (started), X (done) in my actual paper bullet journal, so might try to match that in my vim config.

FYI, What I ended up with (calling the script linked above):

" done, works as toggle and to add initial checkbox too
noremap <silent> <C-d> :call markdown#checkbox#toggle('x')<CR>
" started
noremap <silent> <C-s> :call markdown#checkbox#toggle('/')<CR>

" make it fit nicely in thin window
setlocal wrap 
setlocal linebreak
setlocal breakindent
setlocal breakindentopt=sbr
setlocal showbreak=>>>
setlocal conceallevel=2
setlocal concealcursor=nc

" fancy unicode bullet points (saves horizontal space too)
syntax match Bujo '\v[-+*] \[ \]' conceal cchar=•
syntax match Bujo '\c\v[-+*] \[x\]' conceal cchar=✕
syntax match Bujo '\v[-+*] \[\/\]' conceal cchar=⟋

I also noticed that I can use :sort to put finished tasks to the bottom of the list (and "started") in the middle, and that if I use the different markdown bullets, I can prioritize within the list using -, +, * in rising order of priority, which is nice.
u

Hi, @davidscotson.

First off, wow. I'm humbled by the amount of time you put into this. These are very tricky issues and you've found a beautiful solution. I wanted to commend you for that.

Secondly, I'd like to ask you if you would like to become a contributor. I unfortunately have slowed down on my contributions to vim-bujo because my current job requires me to work with a .NET stack. This means, I have been primarily coding in Visual Studio and can't find many places to use vim. I am looking for someone else to take over this project, and the impressive work you've put into this issue makes me want it to be you :)

Hey,

I'm not sure I'm ready to take on maintainership of a project for other people to use, though I am continuing to use the plugin myself and finding it useful. I'll push my changes to a fork on github in case any other users or future maintainers are wanting to pull them in. I'm currently looking at Telescope integration for creating, opening and searching todo since that's my main project switcher as well, but since I'm switching most of my stuff to Neovim, there's a chance I might start writing some stuff in lua if things get complicated, which might cut off some of the existing users.