Skip to content

spacebarlabs/vim-logseq

Repository files navigation

vim-logseq

A Vim plugin for working with Logseq-style markdown files.

Features

  • Syntax Highlighting for TODO/DOING/DONE keywords and tags
  • Tag Search (:Ltag) with editable results that propagate changes back to source files
  • Jump to Today's Journal (:Ltoday) - opens journals/YYYY_MM_DD.md
  • Wiki Links - navigate with gf on [[page]] links
  • Tag Navigation - use gf on #tag to search for all occurrences
  • Full Directory Search (:Lsearch) across all Logseq markdown files
  • Task Status Cycling - cycle through task states: (no task) → TODO → DOING → DONE → (no task)
  • Block Movement - move lines or selections up/down like in Logseq Desktop
  • Wiki Link Creation - wrap selected text with [[]] brackets in visual mode

Installation

Using vim-plug

Plug 'spacebarlabs/vim-logseq'

After adding to your init.vim or .vimrc:

  1. Restart Vim/Neovim or run :source $MYVIMRC
  2. Run :PlugInstall
  3. Restart Vim/Neovim again

Using Vundle

Plugin 'spacebarlabs/vim-logseq'

After adding, run :PluginInstall and restart Vim/Neovim.

Manual

git clone https://github.com/spacebarlabs/vim-logseq.git ~/.vim/pack/plugins/start/vim-logseq

For Neovim:

git clone https://github.com/spacebarlabs/vim-logseq.git ~/.local/share/nvim/site/pack/plugins/start/vim-logseq

Quick Start

  1. Open any markdown file in your Logseq directory
  2. Try :Ltoday to open today's journal
  3. Use :Ltag <tagname> to search for tags
  4. Press gf on tags or wiki links to navigate

Default Keybindings

The following keybindings are available in Logseq files (automatically enabled for files in journals/ or pages/ directories):

  • <Leader>t - Cycle task status on current line (plain → TODO → DOING → DONE → plain)
  • <Alt-k> - Move current line or visual selection up
  • <Alt-j> - Move current line or visual selection down
  • gf - Follow link or tag under cursor

Note: The wiki link creation feature has no default keybinding to avoid conflicts with standard Vim behavior. You can map it yourself (see Customization section below).

Customization

You can customize keybindings using the provided <Plug> mappings. Add to your .vimrc or init.vim:

" Custom keybindings for Logseq features
nmap <Leader>c <Plug>(logseq-cycle-task)
nmap <C-Up> <Plug>(logseq-move-up)
vmap <C-Up> <Plug>(logseq-move-up)
nmap <C-Down> <Plug>(logseq-move-down)
vmap <C-Down> <Plug>(logseq-move-down)
vmap <Leader>l <Plug>(logseq-make-link)

Available <Plug> mappings:

  • <Plug>(logseq-cycle-task) - Cycle task status
  • <Plug>(logseq-move-up) - Move block up
  • <Plug>(logseq-move-down) - Move block down
  • <Plug>(logseq-make-link) - Create wiki link (visual mode only)

Troubleshooting

Plugin not loading (:Ltag command not found)

  1. Check if plugin is installed: Run :LogseqDebug to see plugin status
  2. Verify filetype plugin is enabled: Add to your config:
    filetype plugin indent on
    syntax on
  3. Check installation path: Run :set runtimepath? and verify vim-logseq is listed
  4. Restart Vim/Neovim: After installing or modifying config, restart completely
  5. Run the test script: From the plugin directory, run ./test-install.sh

Syntax highlighting not working

  1. Check filetype is set correctly: Open a Logseq file and run :set filetype?
    • Should show logseq for files in journals/ or pages/ directories
    • If it shows markdown, manually set: :set filetype=logseq
  2. Ensure syntax is enabled: :syntax on
  3. For files outside journals/pages, manually set filetype: :set filetype=logseq

Commands exist but don't work

  1. Ensure you're in a Logseq directory structure (with journals/ or pages/ subdirectories)
  2. Set the Logseq root: let g:logseq_root = '/path/to/your/logseq'
  3. Run :LogseqDebug to check configuration

For vim-plug users specifically

Make sure your init.vim or .vimrc has this structure:

call plug#begin()
Plug 'spacebarlabs/vim-logseq'
call plug#end()

" These must come AFTER plug#end()
filetype plugin indent on
syntax on

Documentation

See :help vim-logseq for full documentation.

Configuration

" Set your Logseq root directory (optional)
let g:logseq_root = '~/Documents/Logseq'

" Customize keybindings (optional)
" Example: Use different keys for task cycling
autocmd FileType logseq nmap <buffer> <C-t> <Plug>(logseq-cycle-task)

" Example: Use Ctrl+Up/Down instead of Alt+j/k for block movement
autocmd FileType logseq nmap <buffer> <C-Up> <Plug>(logseq-move-up)
autocmd FileType logseq nmap <buffer> <C-Down> <Plug>(logseq-move-down)
autocmd FileType logseq vmap <buffer> <C-Up> <Plug>(logseq-move-up)
autocmd FileType logseq vmap <buffer> <C-Down> <Plug>(logseq-move-down)

About

A vim plugin for Logseq-style files

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages