Skip to content

Add vim plugin for Logseq markdown with task tracking and wiki navigation#1

Merged
benjaminoakes merged 20 commits intomainfrom
copilot/add-vim-plugin-todo-support
Jan 11, 2026
Merged

Add vim plugin for Logseq markdown with task tracking and wiki navigation#1
benjaminoakes merged 20 commits intomainfrom
copilot/add-vim-plugin-todo-support

Conversation

Copy link

Copilot AI commented Jan 11, 2026

  • Create standard vim plugin directory structure (plugin/, syntax/, ftdetect/, autoload/)
  • Implement syntax highlighting for TODO/DOING/DONE keywords
  • Add syntax highlighting for tags (#tag) and wiki links ([[page]])
  • Implement :Ltag command for tag search with editable results buffer
  • Implement gf functionality for tags to trigger tag search
  • Implement :Ltoday command to jump to today's journal entry
  • Implement gf functionality for wiki links [[page]]
  • Implement :Lsearch command for searching across entire Logseq directory
  • Add file type detection for .md files in Logseq context
  • Add comprehensive documentation
  • Fix buffer naming to avoid vim special character issues
  • Fix cursor position detection for proper tag/link matching
  • Create manual testing guide and example files
  • Address code review feedback (security, magic numbers, performance)
  • Run security check with CodeQL
  • Complete final verification and testing
  • Fix ftdetect to properly override built-in markdown detection
  • Add :LogseqDebug command for troubleshooting
  • Add installation test script and comprehensive troubleshooting guide
  • Fix LogseqDebug to handle undefined variables safely
  • Fix test-install.sh to prevent ANSI escape sequences from leaking into shell
Original prompt

Make a basic vim plugin that supports:

  • TODO/DOING/DONE syntax. Use appropriate colors.
  • Searching by tag (that is gf on #foo and see everything with that tag). Or with a command to allow arbitrary tag search. (:Ltag foo) Allow updating the results of that search, which propogates the changes back to the file where the line came from.
  • Jump to today's journal entry. Assume named like journals/2026_01_10.md
  • Wiki links to other pages
  • Search across the entire Logseq directory

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 5 commits January 11, 2026 04:35
Co-authored-by: benjaminoakes <5323+benjaminoakes@users.noreply.github.com>
…iki links

Co-authored-by: benjaminoakes <5323+benjaminoakes@users.noreply.github.com>
Co-authored-by: benjaminoakes <5323+benjaminoakes@users.noreply.github.com>
…eview

Co-authored-by: benjaminoakes <5323+benjaminoakes@users.noreply.github.com>
Co-authored-by: benjaminoakes <5323+benjaminoakes@users.noreply.github.com>
Copilot AI changed the title [WIP] Add basic Vim plugin with TODO syntax highlighting Add vim plugin for Logseq markdown with task tracking and wiki navigation Jan 11, 2026
Copilot AI requested a review from benjaminoakes January 11, 2026 04:48
@benjaminoakes
Copy link
Member

@copilot

I have:

benjaminoakes@bdo-x13:~/git/personal.logseq$ cat ~/.config/nvim/init.vim 
call plug#begin()

" List your plugins here
Plug 'tpope/vim-sensible'
Plug 'git@github.com:spacebarlabs/vim-logseq.git'

call plug#end()

PlugInstall says it installed

However, :scriptnames doesn't display vim-logseq:

:scriptnames                                                                                                                                                                                                                                       
  1: /usr/share/nvim/runtime/ftplugin.vim
  2: /usr/share/nvim/runtime/indent.vim
  3: ~/.config/nvim/init.vim
  4: ~/.local/share/nvim/site/autoload/plug.vim
  5: /usr/share/nvim/runtime/filetype.lua
  6: /usr/share/nvim/runtime/syntax/syntax.vim
  7: /usr/share/nvim/runtime/syntax/synload.vim
  8: ~/.local/share/nvim/plugged/vim-sensible/plugin/sensible.vim
  9: /usr/share/nvim/runtime/plugin/gzip.vim
 10: /usr/share/nvim/runtime/plugin/health.vim
 11: /usr/share/nvim/runtime/plugin/matchit.vim
 12: /usr/share/nvim/runtime/pack/dist/opt/matchit/plugin/matchit.vim
 13: /usr/share/nvim/runtime/plugin/matchparen.vim
 14: /usr/share/nvim/runtime/plugin/netrwPlugin.vim
 15: /usr/share/nvim/runtime/plugin/rplugin.vim
 16: /usr/share/nvim/runtime/plugin/shada.vim
 17: /usr/share/nvim/runtime/plugin/spellfile.vim
 18: /usr/share/nvim/runtime/plugin/tarPlugin.vim
 19: /usr/share/nvim/runtime/plugin/tohtml.vim
 20: /usr/share/nvim/runtime/plugin/tutor.vim
 21: /usr/share/nvim/runtime/plugin/zipPlugin.vim
 22: /usr/share/nvim/runtime/plugin/editorconfig.lua
 23: /usr/share/nvim/runtime/plugin/man.lua
 24: /usr/share/nvim/runtime/plugin/nvim.lua
 25: /usr/share/nvim/runtime/ftplugin/markdown.vim
 26: /usr/share/nvim/runtime/ftplugin/html.vim
 27: /usr/share/nvim/runtime/autoload/htmlcomplete.vim
 28: /usr/share/nvim/runtime/syntax/markdown.vim
 29: /usr/share/nvim/runtime/syntax/html.vim
 30: /usr/share/nvim/runtime/syntax/xml.vim
 31: /usr/share/nvim/runtime/syntax/dtd.vim
 32: /usr/share/nvim/runtime/syntax/javascript.vim
 33: /usr/share/nvim/runtime/syntax/vb.vim
 34: /usr/share/nvim/runtime/syntax/css.vim
 35: /usr/share/nvim/runtime/syntax/yaml.vim
 36: /usr/share/nvim/runtime/autoload/provider/python3.vim
 37: /usr/share/nvim/runtime/autoload/provider/pythonx.vim
 38: /usr/share/nvim/runtime/autoload/remote/host.vim
 39: /usr/share/nvim/runtime/autoload/provider/ruby.vim
 40: /usr/share/nvim/runtime/ftoff.vim

I also don't see any visual change when I :set filetype=logseq

(While this is is running in nvim, I do want to retain compatibility with vim.)

Please add whatever is necessary to fix this or debug output to help diagnose. If possible, add automated tests that can be run in CI.

…llation troubleshooting

Co-authored-by: benjaminoakes <5323+benjaminoakes@users.noreply.github.com>
Copy link
Author

Copilot AI commented Jan 11, 2026

@copilot

I have:
...

Fixed in commit 5df3459. The issue was that ftdetect was using setfiletype which doesn't override when markdown is already set. Changed to set filetype=logseq to properly override the built-in markdown detection.

Added :LogseqDebug command to help diagnose issues. After updating, please:

  1. Restart Neovim completely (not just :source)
  2. Verify your config has:
    filetype plugin indent on
    syntax on
  3. Test: Open a file in journals/ and run :LogseqDebug

If :LogseqDebug command is not found, the plugin didn't load. Common causes:

  • vim-plug installation incomplete (try :PlugClean then :PlugInstall)
  • Config was sourced but Neovim wasn't restarted
  • filetype plugin on is missing or commented out

You can also run ./test-install.sh from the plugin directory for automated testing.

The plugin now correctly overrides markdown filetype detection for files in Logseq directories, and syntax highlighting (TODO/DOING/DONE with colors) should work automatically.

Co-authored-by: benjaminoakes <5323+benjaminoakes@users.noreply.github.com>
@benjaminoakes
Copy link
Member

@copilot

benjaminoakes@bdo-x13:~/git/vim-logseq$  ./test-install.sh
=== vim-logseq Installation Test ===

Test directory created at: /tmp/tmp.qEkuFB1qNg
Test vimrc created at: /tmp/tmp.sRHWiLNuqu

Testing with Vim...

✓ Vim test completed

Testing with Neovim...

✓ Neovim test completed

=== Test Summary ===
If you see 'Plugin loaded: 1' and commands showing '2' in the output above,
then the plugin is working correctly!

If the plugin didn't load, make sure:
1. vim-plug completed the installation (:PlugInstall)
2. You restarted Vim/Neovim after installation
3. You have 'filetype plugin on' in your init.vim/vimrc

For debugging, open a Logseq markdown file and run: :LogseqDebug
^[]11;rgb:1717/1414/2121^G^[[?61;1;21;22cbenjaminoakes@bdo-x13:~/git/vim-logseq$ 11;rgb:1717/1414/212161;1;21;22c11;rgb:1717/1414/212161;1;21;22c

11: command not found
-bash: rgb:1717/1414/212161: No such file or directory
1: command not found
21: command not found
22c11: command not found
-bash: rgb:1717/1414/212161: No such file or directory
1: command not found
21: command not found
Command '22c' not found, did you mean:
  command 'g2c' from deb goo (0.155+ds-4)
  command 'f2c' from deb f2c (20200916-1)
Try: sudo apt install <deb name>
benjaminoakes@bdo-x13:~/git/vim-logseq

…o shell

Co-authored-by: benjaminoakes <5323+benjaminoakes@users.noreply.github.com>
Copy link
Author

Copilot AI commented Jan 11, 2026

@copilot

...

Fixed in commit f2f8a46. The issue was that vim/nvim were outputting ANSI escape sequences (terminal control codes) that were being printed to your shell, causing them to be interpreted as commands.

The fix uses vim's :redir command to capture only the LogseqDebug output to a file, and properly redirects all stdin/stdout/stderr to /dev/null to prevent escape sequences from leaking:

vim ... -c "redir! > $TEMP_OUTPUT" -c "LogseqDebug" -c "redir END" -c "quit" ... </dev/null >/dev/null 2>&1

The test script now outputs clean text without any control sequences that could interfere with your shell.

@benjaminoakes benjaminoakes marked this pull request as ready for review January 11, 2026 21:40
@benjaminoakes benjaminoakes merged commit 0dd28d2 into main Jan 11, 2026
1 check passed
@benjaminoakes benjaminoakes deleted the copilot/add-vim-plugin-todo-support branch January 11, 2026 21:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants