neovim

Neovim text editor
git clone https://git.dasho.dev/neovim.git
Log | Files | Refs | README

provider.txt (13982B)


      1 *provider.txt*		Nvim
      2 
      3 
      4 	 NVIM REFERENCE MANUAL	  by Thiago de Arruda
      5 
      6 
      7 Providers					*provider*
      8 
      9 Nvim delegates some features to dynamic "providers". This document describes
     10 the providers and how to install them.
     11 					*E319*
     12 Use of a feature requiring a missing provider is an error: >
     13 
     14    E319: No "foo" provider found. Run ":checkhealth vim.provider"
     15 
     16 Run the |:checkhealth| command, and review the sections below.
     17 
     18 			      Type |gO| to see the table of contents.
     19 
     20 ==============================================================================
     21 Python integration				*provider-python*
     22 
     23 Nvim supports Python |remote-plugin|s and the Vim legacy |python3| and
     24 |pythonx| interfaces (which are implemented as remote-plugins).
     25 
     26 Note: Only the Vim 7.3 legacy interface is supported, not later features such
     27 as |python-bindeval| (Vim 7.4); use the Nvim API instead. Python 2 is not
     28 supported.
     29 
     30 
     31 PYTHON QUICKSTART ~
     32 
     33 To use Python plugins, you need the "pynvim" module. Run |:checkhealth| to see
     34 if you already have it (some package managers install the module with Nvim
     35 itself).
     36 
     37 For Python 3 plugins:
     38 1. Make sure Python 3.9+ is available in your $PATH.
     39 2. Install either uv (https://docs.astral.sh/uv/) or pipx
     40   (https://pipx.pypa.io/stable/).
     41 3. Install the module: >bash
     42   pipx install pynvim
     43   # or:
     44   uv tool install --upgrade pynvim
     45 
     46 The `--upgrade` flag ensures that you get the latest version even if
     47 a previous version was already installed.
     48 
     49 See also |python-virtualenv|.
     50 
     51 PYTHON PROVIDER CONFIGURATION ~
     52 					*g:python3_host_prog*
     53 Command to start Python 3 (executable, not directory). Setting this makes
     54 startup faster. Useful for working with virtualenvs. Must be set before any
     55 check for has("python3").  >vim
     56    let g:python3_host_prog = '/path/to/python3'
     57 <
     58 					*g:loaded_python3_provider*
     59 To disable Python 3 support: >vim
     60    let g:loaded_python3_provider = 0
     61 
     62 
     63 PYTHON VIRTUALENVS ~
     64 					*python-virtualenv*
     65 Using pynvim 0.6.0+ installed via uv or pipx, Nvim will automatically detect
     66 pynvim even if other Python virtual environments are activated (technical
     67 note: via the "pynvim-python" global python tool).  For older pynvim (or older
     68 Neovim), where detection involved finding the first Python interpreter and
     69 checking if it could import pynvim, automatic detection would fail when
     70 another virtual environment is active.  Upgrading to the latest pynvim is the
     71 recommended solution to this; but if that's not an option, then you can set
     72 the variable |g:python3_host_prog| in `init.vim` to point to the full path to
     73 the Python interpreter where `pynvim` is installed, e.g.: >vim
     74 
     75  let g:python3_host_prog = '/path/to/pynvim-venv/bin/python'
     76 <
     77 See also: https://github.com/zchee/deoplete-jedi/wiki/Setting-up-Python-for-Neovim
     78 
     79 ==============================================================================
     80 Ruby integration			      *provider-ruby*
     81 
     82 Nvim supports Ruby |remote-plugin|s and the Vim legacy |ruby-vim| interface
     83 (which is itself implemented as a Nvim remote-plugin).
     84 
     85 
     86 RUBY QUICKSTART ~
     87 
     88 To use Ruby plugins with Nvim, install the latest "neovim" RubyGem: >bash
     89    gem install neovim
     90 
     91 Run |:checkhealth| to see if your system is up-to-date.
     92 
     93 
     94 RUBY PROVIDER CONFIGURATION ~
     95 					*g:loaded_ruby_provider*
     96 To disable Ruby support: >vim
     97    let g:loaded_ruby_provider = 0
     98 <
     99 					*g:ruby_host_prog*
    100 Command to start the Ruby host. By default this is "neovim-ruby-host". With
    101 project-local Ruby versions (via tools like RVM or rbenv) setting this can
    102 avoid the need to install the "neovim" gem in every project.
    103 
    104 To use an absolute path (e.g. to an rbenv installation): >vim
    105    let g:ruby_host_prog = '~/.rbenv/versions/2.4.1/bin/neovim-ruby-host'
    106 
    107 To use the RVM "system" Ruby installation: >vim
    108    let g:ruby_host_prog = 'rvm system do neovim-ruby-host'
    109 
    110 ==============================================================================
    111 Perl integration				*provider-perl*
    112 
    113 Nvim supports Perl |remote-plugin|s on Unix platforms. Support for polling STDIN
    114 on MS-Windows is currently lacking from all known event loop implementations.
    115 The Vim legacy |perl-vim| interface is also supported (which is itself
    116 implemented as a Nvim remote-plugin).
    117 https://github.com/jacquesg/p5-Neovim-Ext
    118 
    119 Note: Only perl versions from 5.22 onward are supported.
    120 
    121 PERL QUICKSTART~
    122 
    123 To use perl remote-plugins with Nvim, install the "Neovim::Ext" cpan package: >bash
    124    cpanm -n Neovim::Ext
    125 
    126 Run |:checkhealth| to see if your system is up-to-date.
    127 
    128 
    129 PERL PROVIDER CONFIGURATION~
    130 					*g:loaded_perl_provider*
    131 To disable Perl support: >vim
    132    :let g:loaded_perl_provider = 0
    133 <
    134 					*g:perl_host_prog*
    135 Command to start the Perl executable. Must be set before any
    136 check for has("perl").  >vim
    137    let g:perl_host_prog = '/path/to/perl'
    138 <
    139 ==============================================================================
    140 Node.js integration				*provider-nodejs*
    141 
    142 Nvim supports Node.js |remote-plugin|s.
    143 https://github.com/neovim/node-client/
    144 
    145 
    146 NODEJS QUICKSTART~
    147 
    148 To use javascript remote-plugins with Nvim, install the "neovim" npm package: >bash
    149    npm install -g neovim
    150 
    151 Run |:checkhealth| to see if your system is up-to-date.
    152 
    153 
    154 NODEJS PROVIDER CONFIGURATION~
    155 					*g:loaded_node_provider*
    156 To disable Node.js support: >vim
    157    :let g:loaded_node_provider = 0
    158 <
    159 					*g:node_host_prog*
    160 Command to start the Node.js host. Setting this makes startup faster.
    161 
    162 By default, Nvim searches for "neovim-node-host" using "npm root -g", which
    163 can be slow. To avoid this, set g:node_host_prog to the host path: >vim
    164    let g:node_host_prog = '/usr/local/bin/neovim-node-host'
    165 <
    166 ==============================================================================
    167 Clipboard integration			      *provider-clipboard* *clipboard*
    168 
    169 Nvim has no direct connection to the system clipboard. Instead it depends on
    170 a |provider| which transparently uses shell commands to communicate with the
    171 system clipboard or any other clipboard "backend".
    172 
    173 To ALWAYS use the clipboard for ALL operations (instead of interacting with
    174 the "+" and/or "*" registers explicitly): >vim
    175    set clipboard+=unnamedplus
    176 
    177 See 'clipboard' for details and options.
    178 
    179 						      *clipboard-tool*
    180 The presence of a working clipboard tool implicitly enables the "+" and "*"
    181 registers. Nvim supports these clipboard tools, in order of priority:
    182 
    183 - |g:clipboard| : User override (if set to a dict or any string "name" below;
    184  e.g. `g:clipboard="tmux"` forces tmux clipboard and skips auto-detection).
    185 - "pbcopy"    : pbcopy, pbpaste (macOS)
    186 - "wl-copy"   : wl-copy, wl-paste (if $WAYLAND_DISPLAY is set)
    187 - "wayclip"   : waycopy, waypaste (if $WAYLAND_DISPLAY is set)
    188 - "xsel"      : xsel (if $DISPLAY is set)
    189 - "xclip"     : xclip (if $DISPLAY is set)
    190 - "lemonade"  : lemonade (for SSH) https://github.com/pocke/lemonade
    191 - "doitclient": doitclient (for SSH) https://www.chiark.greenend.org.uk/~sgtatham/doit/
    192 - "win32yank" : *win32yank* (Windows)
    193 - "putclip"   : putclip, getclip (Windows) https://cygwin.com/packages/summary/cygutils.html
    194 - "clip"      : clip, powershell (Windows) https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/clip
    195 - "termux"    : termux (via termux-clipboard-set, termux-clipboard-get)
    196 - "tmux"      : tmux (if $TMUX is set)
    197 - "osc52"     : |clipboard-osc52| (if supported by your terminal)
    198 
    199 							 *g:clipboard*
    200 To configure a custom clipboard tool, set `g:clipboard` to a string name (from
    201 the above |clipboard-tool| list), or dict (to explicitly specify the shell
    202 commands or |lambda| functions) before clipboard providers are initialized.
    203 
    204 Note: Clipboard providers are initialized by calling `has('clipboard')`, which
    205 is best avoided before setting `g:clipboard`. See "G:CLIPBOARD SETTINGS ARE NOT
    206 USED" in |faq-runtime| for workarounds.
    207 
    208 If "cache_enabled" is |TRUE| then when a selection is copied Nvim will cache
    209 the selection until the copy command process dies. When pasting, if the copy
    210 process has not died the cached selection is applied.
    211 
    212 The "copy" function stores a list of lines and the register type. The "paste"
    213 function returns the clipboard as a `[lines, regtype]` list, where `lines` is
    214 a list of lines and `regtype` is a register type conforming to |setreg()|.
    215 
    216 Example: set to "osc52" to force OSC52, skipping auto-detection of terminal
    217 support: >vim
    218 
    219    let g:clipboard = 'osc52'
    220 
    221 Example: set to "wayclip" to force waycopy/waypaste: >vim
    222 
    223    let g:clipboard = 'wayclip'
    224 
    225 Example: set to a dict which integrates the tmux clipboard: >vim
    226 
    227    let g:clipboard = {
    228      \   'name': 'myClipboard',
    229      \   'copy': {
    230      \      '+': ['tmux', 'load-buffer', '-'],
    231      \      '*': ['tmux', 'load-buffer', '-'],
    232      \    },
    233      \   'paste': {
    234      \      '+': ['tmux', 'save-buffer', '-'],
    235      \      '*': ['tmux', 'save-buffer', '-'],
    236      \   },
    237      \   'cache_enabled': 1,
    238      \ }
    239 
    240 
    241 Example: set to a dict which uses g:foo as a fake clipboard: >vim
    242 
    243    let g:clipboard = {
    244      \   'name': 'myClipboard',
    245      \   'copy': {
    246      \      '+': {lines, regtype -> extend(g:, {'foo': [lines, regtype]}) },
    247      \      '*': {lines, regtype -> extend(g:, {'foo': [lines, regtype]}) },
    248      \    },
    249      \   'paste': {
    250      \      '+': {-> get(g:, 'foo', [])},
    251      \      '*': {-> get(g:, 'foo', [])},
    252      \   },
    253      \ }
    254 <
    255 						      *clipboard-wsl*
    256 For Windows WSL, try this g:clipboard definition:
    257 >vim
    258    let g:clipboard = {
    259      \   'name': 'WslClipboard',
    260      \   'copy': {
    261      \      '+': 'clip.exe',
    262      \      '*': 'clip.exe',
    263      \    },
    264      \   'paste': {
    265      \      '+': 'powershell.exe -NoLogo -NoProfile -c [Console]::Out.Write($(Get-Clipboard -Raw).tostring().replace("`r", ""))',
    266      \      '*': 'powershell.exe -NoLogo -NoProfile -c [Console]::Out.Write($(Get-Clipboard -Raw).tostring().replace("`r", ""))',
    267      \   },
    268      \   'cache_enabled': 0,
    269      \ }
    270 <
    271 						    *clipboard-osc52*
    272 Nvim bundles a clipboard provider that allows copying to the system clipboard
    273 using OSC 52, an "Operating System Command" control-sequence that causes the
    274 terminal emulator to write to or read from the system clipboard.
    275 
    276 When Nvim is running in the |TUI|, it automatically detects host terminal
    277 support for OSC 52. If successful, then Nvim will use OSC 52 for copying and
    278 pasting if no other |clipboard-tool| is found and when 'clipboard' is unset.
    279 NOTE: Using a terminal multiplexer (e.g. tmux) may inhibit automatic OSC 52
    280 support detection.
    281 
    282 						*g:termfeatures*
    283 To disable the automatic detection, set the "osc52" key of |g:termfeatures| to
    284 false early in your |config|. Example: >lua
    285 local termfeatures = vim.g.termfeatures or {}
    286 termfeatures.osc52 = false
    287 vim.g.termfeatures = termfeatures
    288 <
    289 To force Nvim to use the OSC 52 provider you can set |g:clipboard|: >lua
    290 
    291    vim.g.clipboard = 'osc52'
    292 
    293 Which is equivalent to: >lua
    294    vim.g.clipboard = {
    295      name = 'OSC 52',
    296      copy = {
    297        ['+'] = require('vim.ui.clipboard.osc52').copy('+'),
    298        ['*'] = require('vim.ui.clipboard.osc52').copy('*'),
    299      },
    300      paste = {
    301        ['+'] = require('vim.ui.clipboard.osc52').paste('+'),
    302        ['*'] = require('vim.ui.clipboard.osc52').paste('*'),
    303      },
    304    }
    305 <
    306 Note: not all terminal emulators support reading from the system clipboard
    307 (and even for those that do, users should be aware of the security
    308 implications), so using OSC 52 for pasting may not be possible (and not
    309 necessary, because you can |paste| instead using your system paste function).
    310 Users may need to configure their terminal emulator to allow reading from the
    311 clipboard.
    312 <
    313 ==============================================================================
    314 Paste							*provider-paste* *paste*
    315 
    316 "Paste" is a separate concept from |clipboard|: paste means "dump a bunch of
    317 text to the editor", whereas clipboard provides features like |quote+| to get
    318 and set the OS clipboard directly.  For example, middle-click or CTRL-SHIFT-v
    319 (macOS: CMD-v) in your terminal is "paste", not "clipboard": the terminal
    320 application (Nvim) just gets a stream of text, it does not interact with the
    321 clipboard directly.
    322 
    323 						*bracketed-paste-mode*
    324 Pasting in the |TUI| depends on the "bracketed paste" terminal capability,
    325 which allows terminal applications to distinguish between user input and
    326 pasted text.  https://cirw.in/blog/bracketed-paste
    327 This works automatically if your terminal supports it.
    328 
    329 						*ui-paste*
    330 GUIs can paste by calling |nvim_paste()|.
    331 
    332 PASTE BEHAVIOR ~
    333 
    334 Paste inserts text after the cursor.  Lines break at <NL>, <CR>, and <CR><NL>.
    335 When pasting a huge amount of text, screen-updates are throttled and the
    336 message area shows a "..." pulse.
    337 
    338 In cmdline-mode only the first line is pasted, to avoid accidentally executing
    339 many commands.  Use the |cmdline-window| if you really want to paste multiple
    340 lines to the cmdline.
    341 
    342 You can implement a custom paste handler by redefining |vim.paste()|.
    343 Example: >lua
    344 
    345  vim.paste = (function(lines, phase)
    346    vim.api.nvim_put(lines, 'c', true, true)
    347  end)
    348 
    349 ==============================================================================
    350 X11 selection mechanism			      *clipboard-x11* *x11-selection*
    351 
    352 X11 clipboard providers store text in "selections". Selections are owned by an
    353 application, so when the application gets closed, the selection text is lost.
    354 The contents of selections are held by the originating application (e.g., upon
    355 a copy), and only passed to another application when that other application
    356 requests them (e.g., upon a paste).
    357 
    358 			*primary-selection* *quotestar* *quoteplus* *quote+*
    359 
    360 There are three documented X11 selections: PRIMARY, SECONDARY, and CLIPBOARD.
    361 CLIPBOARD is typically used in X11 applications for copy/paste operations
    362 (CTRL-c/CTRL-v), while PRIMARY is used for the last selected text, which is
    363 generally inserted with the middle mouse button.
    364 
    365 Nvim's X11 clipboard providers only use the PRIMARY and CLIPBOARD selections,
    366 for the "*" and "+" registers, respectively.
    367 
    368 vim:tw=78:ts=8:noet:ft=help:norl: