Skip to content

Conversation

@paris3200
Copy link
Owner

Summary

This PR adds automatic workspace detection that switches to the appropriate workspace when opening markdown files based on their file path.

Changes

  • Added auto_detect_workspace() function in workspace.lua that:

    • Checks the current file's absolute path
    • Compares it against all configured workspace vault paths
    • Automatically switches to the matching workspace if found
  • Added setup_autocommands() function in init.lua that:

    • Sets up autocommands for BufEnter and BufRead events
    • Triggers workspace detection for all *.md files

Benefits

  • Eliminates the need to manually switch workspaces with <leader>nw
  • Works seamlessly when editing files across multiple vaults
  • Only switches workspaces when necessary (avoids redundant switches)

Testing

Tested with multiple workspaces by opening files from different vault paths and verifying that:

  • The correct workspace is automatically selected
  • Link following (gf) works correctly across workspaces
  • No unnecessary workspace switches occur when already in the correct workspace

Automatically switches to the appropriate workspace when opening markdown files based on their file path. This eliminates the need to manually switch workspaces when working across multiple vaults.

The plugin now sets up an autocommand that runs on BufEnter and BufRead events for *.md files, detecting which workspace the file belongs to by matching the file path against configured vault paths.
@paris3200 paris3200 merged commit d538088 into main Oct 29, 2025
4 checks passed
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