Skip to content
The Chat Archive
o1-mini-2024-09-12· OpenAI WildChat-4.8M (AI2)

I have Neovim installed and want to create a second brain with wiki.vim that can be…

  1. User

    I have Neovim installed and want to create a second brain with wiki.vim that can be accessed on all my devices. I have Syncthing for syncing with Android, but I also want to use it to create a light web interface to edit markdown, browse, create files, etc. I am on Windows.

  2. Assistant

    Creating a "second brain" with Neovim, vimwiki, Syncthing, and a web interface is a powerful way to manage and access your knowledge base across multiple devices. Below is a comprehensive guide to help you set up this system on your Windows machine, ensuring seamless synchronization with Android devices and providing a lightweight web interface for editing and browsing your Markdown files.


    1. Setting Up vimwiki with Neovim

    a. Install vimwiki Plugin

    First, ensure you have the vimwiki plugin installed in Neovim. If you're using a plugin manager like Packer, you can add the following configuration to your init.lua or equivalent configuration file:

    use {
      'vimwiki/vimwiki',
      config = function()
        vim.g.vimwiki_list = {
          {
            path = 'C:/Users/YourName/Documents/Wiki/',  -- Replace with your desired path
            syntax = 'markdown',                         -- Use 'markdown' for Markdown syntax
            ext = '.md',                                 -- Set file extension to .md
          }
        }
      end
    }
    

    Note: Replace C:/Users/YourName/Documents/Wiki/ with the path where you want to store your wiki files.

    b. Initialize Your Wiki

    1. Create the Wiki Directory: Ensure the directory specified in the path exists. If not, create it.

    2. Launch Neovim and Initialize vimwiki: Open Neovim and run the command to create a new wiki index:

      :VimwikiIndex
      

      This will generate an index.md file where you can start building your wiki.


    2. Synchronizing Your Wiki with Syncthing

    Syncthing is an excellent tool for real-time file synchronization across devices, including Windows and Android.

    a. Install Syncthing

    1. On Windows:

      • Download Syncthing from the official website.
      • Extract the downloaded archive and run syncthing.exe.
    2. On Android:

    b. Configure Syncthing

    1. Set Up the Wiki Folder:

      • In Syncthing on your Windows machine, add the wiki directory (C:/Users/YourName/Documents/Wiki/) as a new folder to sync.
      • Assign a unique Folder ID and give it a recognizable name, e.g., NeovimWiki.
    2. Share the Folder with Your Devices:

      • On each device you want to sync with (e.g., your Android phone), accept the share request for the NeovimWiki folder.
      • Ensure that the folder path on each device is correctly set to mirror the location of your wiki files.
    3. Adjust Sync Settings:

      • Folder Master: For most use cases, leave this unchecked to allow bidirectional syncing.
      • Ignore Patterns: Ensure that temporary or system files are ignored to prevent conflicts.

    c. Verify Synchronization

    • Add or edit a file in your wiki directory on one device and ensure it reflects on all other connected devices.
    • On Android, you can use a Vim-based text editor or any Markdown editor to interact with the wiki files.

    3. Building a Lightweight Web Interface

    To access and manage your wiki through a web browser, you can set up a lightweight web server that serves your Markdown files and provides editing capabilities. One of the simplest and effective tools for this purpose is Gollum, a Git-powered wiki with a web interface.

    a. Install Prerequisites

    1. Install Ruby: Gollum is a Ruby application, so you'll need Ruby installed.

      • Download Ruby from the RubyInstaller website.
      • Run the installer and follow the setup instructions, ensuring that you check the option to add Ruby to your system PATH.
    2. Verify Ruby Installation: Open Command Prompt and run:

      ruby --version
      

      You should see the installed Ruby version.

    b. Install Gollum

    1. Install Gollum via Gem: In Command Prompt, execute:

      gem install gollum
      

      This command installs Gollum and its dependencies.

    2. Verify Gollum Installation:

      gollum --version
      

      You should see the Gollum version information.

    c. Initialize Gollum in Your Wiki Directory

    1. Navigate to Your Wiki Directory:

      cd C:/Users/YourName/Documents/Wiki/
      
    2. Initialize Gollum:

      gollum
      

      By default, Gollum runs a web server on http://localhost:4567.

    d. Accessing the Web Interface Locally

    1. Open Your Web Browser: Navigate to http://localhost:4567.

    2. Interact with Your Wiki:

      • Browse Pages: View your existing wiki pages.
      • Edit/Create Pages: Use the web editor to modify or add new Markdown files.
      • Formatting: Utilize Markdown syntax for formatting your content.

    e. Accessing Gollum from Other Devices

    To access the Gollum web interface from other devices on your local network:

    1. Allow Gollum to Listen on All Interfaces: Stop the current Gollum server (Ctrl + C in Command Prompt) and restart it with:

      gollum --port 4567 --host 0.0.0.0
      
    2. Configure Windows Firewall:

      • Open Windows Defender Firewall: Go to Control Panel > System and Security > Windows Defender Firewall.
      • Allow Port 4567:
        • Click on "Advanced settings."
        • Create a new inbound rule to allow TCP traffic on port 4567.
    3. Find Your Windows Machine’s IP Address:

      ipconfig
      

      Look for the IPv4 Address, e.g., 192.168.1.100.

    4. Access from Other Devices: On another device connected to the same network, open a web browser and navigate to:

      http://192.168.1.100:4567
      

    Security Note: Gollum does not provide built-in authentication. To secure access when exposing it beyond your local network:

    • Restrict Access to Local Network: Ensure firewall rules only allow internal traffic.

    • Use a Reverse Proxy with Authentication: Set up a reverse proxy (e.g., Nginx) with basic authentication and HTTPS.

    f. Automate Gollum Startup (Optional)

    To have Gollum start automatically with your system:

    1. Create a Batch Script: Create a start_gollum.bat file with the following content:

      @echo off
      cd C:/Users/YourName/Documents/Wiki/
      gollum --port 4567 --host 0.0.0.0
      
    2. Add to Startup:

      • Press Win + R, type shell:startup, and press Enter.
      • Place a shortcut to start_gollum.bat in the Startup folder.

    4. Using the Web Interface to Manage Your Wiki

    With Gollum set up, you can now:

    • Browse Existing Pages: Easily navigate through your knowledge base.
    • Edit Pages: Click on any page to edit its content in the browser.
    • Create New Pages: Use the interface to add new Markdown files.
    • Formatting and Linking: Utilize Markdown features and wiki-style linking to interconnect your notes.

    5. Additional Tips and Best Practices

    a. Consistency Between Neovim and Web Interface

    • Avoid Simultaneous Edits: To prevent conflicts, avoid editing the same file simultaneously in Neovim and the web interface.

    • Refresh Gollum Regularly: If you make changes via Neovim, refresh the web interface to see updates, and vice versa.

    b. Backup and Version Control

    • Regular Backups: Even with Syncthing, consider having periodic backups of your wiki directory.

    • Integrate Git (Optional): While Gollum is Git-powered, using Git in combination with Syncthing can be complex. If you choose to use Git:

      • Initialize a Git Repository:
        cd C:/Users/YourName/Documents/Wiki/
        git init
        
      • Configure Syncthing to Ignore Git Files: Add .git to Syncthing’s ignore patterns to prevent syncing Git metadata.

    c. Enhancing the Web Interface

    • Custom Themes: Explore Gollum themes to customize the look and feel of your web interface.

    • Plugins and Extensions: While Gollum has limited plugin support, check the Gollum documentation for any available extensions that might enhance functionality.

    d. Mobile Access Considerations

    • Responsive Design: Gollum's web interface is generally responsive, but ensure your Android browser displays it correctly.

    • Use Vim-Based Editors on Android: For consistency, consider using Vim or compatible editors on Android that can interact with your synced wiki files.


    6. Alternative Web Interface Options (Optional)

    If Gollum doesn't meet all your requirements, consider alternative lightweight web-based solutions:

    a. CodiMD/HedgeDoc

    • Features: Collaborative Markdown editor with live previews.

    • Installation: Requires Node.js and additional setup compared to Gollum.

    • Use Case: Ideal for collaborative editing but may be overkill for personal use.

    b. wiki.js

    • Features: Modern, powerful wiki software with support for various data sources.

    • Installation: Primarily Docker-based, which might be more complex on Windows.

    • Use Case: Suitable for more advanced needs, including user management and integrations.

    Note: These alternatives may require more resources and complex setup compared to Gollum. Evaluate based on your specific needs.


    Conclusion

    By combining Neovim with vimwiki, Syncthing for synchronization, and Gollum as a lightweight web interface, you can create a robust and accessible "second brain" that spans across your Windows and Android devices. This setup allows you to harness the power of Vim's editing capabilities alongside the convenience of web-based access and synchronization.

    Remember to regularly backup your data and monitor synchronization to prevent conflicts or data loss. With this system in place, you'll have a flexible and portable knowledge base tailored to your workflow.


    If you encounter any issues or need further customization, feel free to ask for more detailed assistance!