VimR Documentation

repository·master·Indexed 27 days ago

https://github.com/qvacua/vimr

A Neovim GUI for macOS written in Swift. This documentation covers building from source, setting up the Python bin environment, generating Swift API files, and publishing releases. It also includes technical details on implementing the NSTextInputClient protocol for Cocoa text input and mapping Neovim API types to Swift types via NvimApi.

Tokens
2.4K
Snippets
8
Records
19
Agent score
92%

What's inside VimR

  1. Set up the VimR bin environment

    master

    To use the tools in the bin directory, you must set up a specific Python virtual environment using pyenv and pyenv-virtualenv.

    1. Navigate to the bin directory of the project.
    2. Install pyenv and pyenv-virtualenv on your system.
    3. Install Python 3.9.7 using pyenv.
    4. Create a virtualenv named com.qvacua.VimR.bin.
    5. Verify that you are using the correct Python executable from the virtualenv.
    6. Install the necessary dependencies via pip.
  2. Enable the Debug menu in a Release build

    master

    To enable the Debug menu in a Release build of VimR, use the defaults command to set the enable-debug-menu key for the VimR domain.

    defaults write com.qvacua.VimR enable-debug-menu 1
  3. Configure notarytool credentials for VimR releases

    master

    Before releasing VimR, you must set up the apple-dev-notar keychain item for notarytool using your Apple developer credentials.

    xcrun notarytool store-credentials "apple-dev-notar" \
      --apple-id <your-apple-id> \
      --team-id <your-team-id> \
      --password <app-specific-password>
  4. Set up Neovim for VimR development

    master

    VimR uses a bundled Neovim. You can either use a pre-built universal Neovim or build Neovim locally from source.

    To use the pre-built Neovim, run:

    clean=true for_dev=false ./bin/build_nvimserver.sh

    To build Neovim locally (required when generating sources to ensure header files are present), run:

    clean=true for_dev=true ./bin/build_nvimserver.sh

    After running either command, you can run the VimR target directly in Xcode.

    clean=true for_dev=false ./bin/build_nvimserver.sh
  5. Set a new version for VimR

    master

    Use the set_new_versions.sh script to prepare for a new release or snapshot. This creates a release specification file and a temporary release notes file.

    For a snapshot:

    is_snapshot=true ./bin/set_new_versions.sh

    For a marketing release:

    is_snapshot=false marketing_version=0.38.3 ./bin/set_new_versions.sh

    Remember to commit the changes generated by this script.

    is_snapshot=false marketing_version=0.38.3 ./bin/set_new_versions.sh
  6. Generate the API Swift file

    master

    To generate the API Swift file, you must first checkout the appropriate reference branch (for example, develop or update-neovim). Once the correct branch is checked out, run the source generation script from the repository root.

    ./bin/generate_sources.sh
  7. Install built VimR to /Applications

    master

    After building the application, you can use the provided helper script to automatically overwrite the application in your /Applications folder.

    ./bin/build_and_install_local_release.sh
  8. Build and publish a VimR release

    master

    After setting the version and tagging, follow these steps to build and publish:

    1. Build the release: Use the generated release spec file with build_release.sh.

      release_spec_file=path/to/your/spec.sh ./bin/build_release.sh
    2. Publish to GitHub: Use publish_release.sh to upload the build and update the appcast.

      create_gh_release=true upload=true update_appcast=true \
        release_spec_file=path/to/your/spec.sh \
        ./bin/publish_release.sh
    3. Finalize: Check and push the modified appcast{-snapshot}.xml file.

  9. Handle marked text replacement and finalization

    master

    When implementing NSTextInputClient, you must correctly handle the distinction between marking text and finalizing it:

    Marking Text

    When setMarkedText is called with replacementRange: NSRange(NSNotFound, 0), you should append the new marked text to the existing text. For example, if is finalized and setMarkedText is called with , you append to .

    Replacing Text

    If replacementRange is not NSNotFound, you must delete the text in the specified range before inserting the new marked text. For example, to replace with , use setMarkedText("下", selectedRange: NSRange(1, 0), replacementRange: NSRange(1, 1)).

    Finalizing Input

    When the user confirms the input (e.g., by pressing Return or Space), the system calls insertText(_:replacementRange:). You should use the replacementRange provided in this call to replace the entire marked text block with the final string.

  10. Build VimR from source

    master

    To build VimR, clone the repository, install Homebrew, and run the following commands in the project root. Ensure you have initialized submodules and installed Xcode command line tools first.

    git submodule update --init
    
    xcode-select --install
    brew bundle
    clean=true notarize=false trust_plugins=true ./bin/build_vimr.sh