|
| 1 | +# Installation Guide |
| 2 | + |
| 3 | +This guide covers the installation of the vimania-uri-rs Vim plugin, which provides advanced URI handling capabilities with Rust performance. |
| 4 | + |
| 5 | +## Prerequisites |
| 6 | + |
| 7 | +- Vim with Python3 support (check with `:echo has('python3')` in Vim) |
| 8 | +- Rust toolchain (for building the extension module) |
| 9 | +- Python 3.10 or higher |
| 10 | +- `maturin` for building Python extensions from Rust |
| 11 | + |
| 12 | +## Installation Steps |
| 13 | + |
| 14 | +### 1. Install Rust Dependencies |
| 15 | + |
| 16 | +```bash |
| 17 | +# Install maturin if not already installed |
| 18 | +pip install maturin |
| 19 | +``` |
| 20 | + |
| 21 | +### 2. Build and Install the Rust Extension Module |
| 22 | + |
| 23 | +The plugin requires a Rust extension module (`vimania_uri_rs`) to be available in your system Python. This is the most critical step: |
| 24 | + |
| 25 | +```bash |
| 26 | +# From the project root directory |
| 27 | + |
| 28 | +# Option A: Build and install in one step (if your system allows it) |
| 29 | +pip install -e . |
| 30 | + |
| 31 | +# Option B: Build wheel and install manually (for externally-managed environments) |
| 32 | +maturin build --release |
| 33 | +pip install --break-system-packages target/wheels/vimania_uri_rs-*.whl |
| 34 | + |
| 35 | +# Option C: For Homebrew Python specifically |
| 36 | +/opt/homebrew/bin/python3 -m pip install --break-system-packages target/wheels/vimania_uri_rs-*.whl |
| 37 | +``` |
| 38 | + |
| 39 | +This will: |
| 40 | +- Build the Rust extension module using maturin |
| 41 | +- Install it to your system Python |
| 42 | +- Make it available to Vim's Python interpreter |
| 43 | + |
| 44 | +**Note**: This step is essential because Vim's Python interpreter needs access to the `vimania_uri_rs` module. The module must be installed in the same Python environment that Vim uses (usually Homebrew Python on macOS). |
| 45 | + |
| 46 | +### 3. Install the Vim Plugin |
| 47 | + |
| 48 | +Copy or symlink the plugin files to your Vim configuration: |
| 49 | + |
| 50 | +#### Option A: Manual Installation |
| 51 | + |
| 52 | +```bash |
| 53 | +# Copy plugin files to your Vim plugin directory |
| 54 | +cp plugin/vimania_uri_rs.vim ~/.vim/plugin/ |
| 55 | +cp plugin/vimania_uri_rs.py ~/.vim/plugin/ |
| 56 | + |
| 57 | +# Copy Python modules to your Vim pythonx directory |
| 58 | +cp -r pythonx/vimania_uri_ ~/.vim/pythonx/ |
| 59 | +``` |
| 60 | + |
| 61 | +#### Option B: Using a Plugin Manager |
| 62 | + |
| 63 | +Add this repository to your preferred Vim plugin manager (vim-plug, Vundle, etc.): |
| 64 | + |
| 65 | +```vim |
| 66 | +" Example for vim-plug |
| 67 | +Plug 'sysid/vimania-uri-rs' |
| 68 | +``` |
| 69 | + |
| 70 | +### 4. Verify Installation |
| 71 | + |
| 72 | +1. Start Vim |
| 73 | +2. The plugin should load without errors |
| 74 | +3. Test with a markdown file containing URIs |
| 75 | + |
| 76 | +## Troubleshooting |
| 77 | + |
| 78 | +### Common Issues |
| 79 | + |
| 80 | +#### ModuleNotFoundError: No module named 'vimania_uri_rs' |
| 81 | + |
| 82 | +This error occurs when the Rust extension module is not properly installed in the system Python that Vim uses. |
| 83 | + |
| 84 | +**Solution**: Ensure you've run `pip install -e .` from the project root directory. This installs the module system-wide, making it available to Vim's Python interpreter. |
| 85 | + |
| 86 | +#### Virtual Environment Issues |
| 87 | + |
| 88 | +If you're working in a virtual environment but Vim can't find the module: |
| 89 | + |
| 90 | +1. Activate your virtual environment |
| 91 | +2. Run `pip install -e .` to install the module |
| 92 | +3. If the issue persists, install to system Python: `deactivate && pip install -e .` |
| 93 | + |
| 94 | +#### Python Path Issues |
| 95 | + |
| 96 | +Verify that Vim is using the correct Python: |
| 97 | + |
| 98 | +```vim |
| 99 | +:py3 import sys; print(sys.executable) |
| 100 | +:py3 import sys; print(sys.path) |
| 101 | +``` |
| 102 | + |
| 103 | +### Development Installation |
| 104 | + |
| 105 | +For development work: |
| 106 | + |
| 107 | +```bash |
| 108 | +# Install in development mode with editable installation |
| 109 | +pip install -e . |
| 110 | + |
| 111 | +# Install development dependencies |
| 112 | +pip install -r requirements-dev.txt # if available |
| 113 | +``` |
| 114 | + |
| 115 | +### Uninstallation |
| 116 | + |
| 117 | +To remove the plugin: |
| 118 | + |
| 119 | +```bash |
| 120 | +# Remove the Python module |
| 121 | +pip uninstall vimania_uri_rs |
| 122 | + |
| 123 | +# Remove plugin files |
| 124 | +rm ~/.vim/plugin/vimania_uri_rs.vim |
| 125 | +rm ~/.vim/plugin/vimania_uri_rs.py |
| 126 | +rm -rf ~/.vim/pythonx/vimania_uri_ |
| 127 | +``` |
| 128 | + |
| 129 | +## Configuration |
| 130 | + |
| 131 | +After installation, you can configure the plugin by setting variables in your `.vimrc`: |
| 132 | + |
| 133 | +```vim |
| 134 | +" Supported file extensions for URI handling |
| 135 | +let g:vimania_uri_extensions = ['.md', '.txt', '.rst', '.py', '.conf', '.sh', '.json', '.yaml', '.yml'] |
| 136 | +
|
| 137 | +" Vim split policy (none, horizontal, vertical) |
| 138 | +let g:vimania_uri_rs_default_vim_split_policy = "none" |
| 139 | +``` |
0 commit comments