Commit Graph

162 Commits

Author SHA1 Message Date
dundargoc
0ebc4de0ff
feat: allow opting in to builtin clipboard providers (#28083)
Setting `vim.g.clipboard = false` will use the builtin clipboard
providers.

Closes https://github.com/neovim/neovim/issues/27698.

Co-authored-by: Gregory Anders <greg@gpanders.com>
2024-03-28 15:17:08 -05:00
dundargoc
2e982f1aad refactor: create function for deferred loading
The benefit of this is that users only pay for what they use. If e.g.
only `vim.lsp.buf_get_clients()` is called then they don't need to load
all modules under `vim.lsp` which could lead to significant startuptime
saving.

Also `vim.lsp.module` is a bit nicer to user compared to
`require("vim.lsp.module")`.

This isn't used for some nested modules such as `filetype` as it breaks
tests with error messages such as "attempt to index field 'detect'".
It's not entirely certain the reason for this, but it is likely it is
due to filetype being precompiled which would imply deferred loading
isn't needed for performance reasons.
2024-02-03 16:53:41 +01:00
dundargoc
b280d57db9 refactor: rewrite ruby provider in lua 2024-01-24 19:26:53 +01:00
dundargoc
576db141be refactor: rewrite perl provider in lua 2024-01-24 11:55:28 +01:00
dundargoc
eb5d15e383 refactor: rewrite python provider in lua 2024-01-22 22:36:40 +01:00
zeertzjq
6851b265ba
fix(clipboard): don't pass --foreground to wl-copy (#25481)
Fix #25466
2023-10-03 11:24:33 +08:00
zeertzjq
61ecb3e16c
fix(provider/pythonx): import the correct module (#25342) 2023-09-24 22:04:29 +08:00
Jongwook Choi
7bd6bd1ef7
fix(provider): cannot detect python3.12 #25316
PROBLEM: The builtin python3 provider cannot auto-detect python3.12
when g:python3_host_prog is not set. As a result, when python3 on $PATH
is currently python 3.12, neovim will fail to load python3 provider
and result in `has("python3") == 0`, e.g.,
"Failed to load python3 host. You can try to see what happened by ..."

ROOT CAUSE: the `system()` call from `provider#pythonx#DetectByModule`
does not ignore python warnings, and `pkgutil.get_loader` will print
a warning message in the very first line:
```
<string>:1: DeprecationWarning: 'pkgutil.get_loader' is deprecated and
slated for removal in Python 3.14; use importlib.util.find_spec() instead
```

SOLUTION:
- Use `importlib.util.find_spec` instead (python >= 3.4)
- Use `-W ignore` option to prevent any potential warning messages
2023-09-23 02:49:34 -07:00
Kai Ting
c3de6524a5
fix(clipboard): ignore exit caused by signal #23378
Problem:
If clipboard job exits by signal, the exit code is >=128:
939d9053bd
xclip 0.13 often exits with code 143, which spams unhelpful messages:

    clipboard: error invoking xclip: Waiting for selection requests,
    Control-C to quit   Waiting for selection request number 1

Solution:
Don't show a warning if the clipboard tool exit code is >=128.
Fixes: #7054
2023-07-16 04:15:30 -07:00
Justin M. Keyes
a40eb7cc99 feat(vim.version): more coercion with strict=false
Problem:
"tmux 3.2a" (output from "tmux -V") is not parsed easily.

Solution:
With `strict=false`, discard everything before the first digit.

- rename Semver => Version
- rename vim.version.version() => vim.version._version()
- rename matches() => has()
- remove `opts` from cmp()
2023-03-20 13:40:38 +01:00
Justin M. Keyes
04e8e1f9ea
refactor(runtime): use vim.version to compare versions #22550
TODO:
Unfortunately, cannot (yet) use vim.version for tmux version comparison,
because `vim.version.parse(…,{strict=false})` does not coerce tmux's
funny "tmux 3.3a" version string.
6969d3d749/runtime/autoload/provider/clipboard.vim (L148)
2023-03-07 06:28:53 -08:00
Charles Nguyen
1390e97c20
feat(provider): add support for Yarn node modules on Windows (#21246) 2022-12-01 11:50:53 +08:00
XDream8
db407010fa
feat(clipboard): added wayclip support (#21091) 2022-11-18 08:39:56 -07:00
Gregory Anders
ef1d291f29
fix(clipboard): update version regex pattern (#21012)
Building tmux from source uses a 'next-' prefix, so account for that.
Also handle failures to match more gracefully.
2022-11-09 16:21:54 -07:00
wzy
b042f6d902
fix(clipboard): prefer xsel #20918
Problem:
xclip is not actively maintained compared to xsel, and it has a bug:

    $ touch a
    $ xsel -ib < a
    $ xsel -ob
    $ xclip -o -selection clipboard
    Error: target STRING not available

Years ago, the situation was reversed.
We originally preferred xsel 46bd3c0f77
but then swapped to xclip 799d9c3215
to work around https://github.com/neovim/neovim/issues/7237#issuecomment-443440633

Solution:
Prefer xsel again.

close #20862
ref #9302
ref https://github.com/astrand/xclip/issues/38
2022-11-06 19:46:58 -08:00
Gregory Anders
81722896e4
feat(clipboard): copy to system clipboard in tmux when supported (#20936)
Since version 3.2 tmux has had the ability to read/write buffer contents
from/to the system clipboard, if the underlying terminal emulator
supports it. Enable this feature when we can detect that tmux supports
it.
2022-11-04 20:43:11 -06:00
Percy Ma
c6181a672a
feat(node): add pnpm support #19461 2022-08-01 07:21:54 -07:00
Zaz Brown
99ef06d846
refactor(provider): use list comprehension #19027
- list(filter(lambda x: x != "", sys.path))
+ [p for p in sys.path if p != ""]
2022-06-20 06:17:00 -07:00
dundargoc
33ada232c7
fix(checkhealth): make provider checkhealth output more consistent (#17722)
Change missing provider plugins from errors to warnings for python and
perl. Also give proper advice under the ADVICE section instead of just
the errors.
2022-03-16 09:36:26 +01:00
Björn Linse
baec0d3152 feat(provider)!: remove support for python2 and python3.[3-5]
These versions of python has reached End-of-life. getting rid
of python2 support removes a lot of logic to support two
incompatible python versions in the same version.
2022-01-29 19:49:37 +01:00
Tejasvi S. Tomar
e16adbf238
fix(provider): compare versions as number, not string #15937
"3.10" < "3.3" but v3.10 > v3.3
Fixes #14586
2021-10-07 14:27:40 -07:00
Shadman
22b5381396
fixup(clipboard): Fix error not properly handled #14984
fixes #14967
2021-07-11 06:19:54 -07:00
Shadman
d791274a9d
fixup(clipboard): Use case matching #14962
Context: https://github.com/neovim/neovim/pull/14848#discussion_r663203173
2021-07-02 17:47:18 -07:00
shadmansaleh
21444552c0 BugFix(clipboard): Fix block paste not working properly
Block copy and paste from system-clipboard currently breaks formatting.
This fixes it.

The bug occurs because system-clipboard doesn't contain information
about what mode the copy was made.
Simple solution to this is we keep a cache of copy we last made along
with mode information. If system-clipboard returns the cache we apply
the mode information that we know about that cache.
2021-07-01 15:01:01 +06:00
Marco Hinz
17434b88b4
checkhealth: ignore 'wildignore' when seeking executables (#14495)
Certain values of 'wildignore', .e.g `*/node_modules/**`, would make the
provider checks not find the right executables.

Fixes https://github.com/neovim/neovim/issues/14388
2021-05-07 11:07:07 +02:00
Aditya Alok
291f1ece7f
added support for termux-clipboard : clipboard.vim (#14244)
Termux - Android terminal emulator
Link - https://termux.com/
2021-03-29 20:52:35 -04:00
necabo
037ffd54dc
Fix clipboard provider detection (#13190)
Fixes #13189
2020-10-29 21:35:20 -04:00
Marco Hinz
ca6815115c
provider: update supported Python versions (#13070)
Python 3.9 was released, so we need to add support for the upcoming Python 3.10.
Python 3.5 and earlier reached their end-of-life.

PEP 478: Python 3.5  Release Schedule: https://www.python.org/dev/peps/pep-0478
PEP 596: Python 3.9  Release Schedule: https://www.python.org/dev/peps/pep-0596
PEP 619: Python 3.10 Release Schedule: https://www.python.org/dev/peps/pep-0619
2020-10-08 11:52:17 +02:00
Justin M. Keyes
bedab7e87b
provider: align all foo#Detect() functions #12839
Problem: ruby#Detect() and node#Detect() don't return a [prog, err] pair
which means callers must special-case them.

Solution: align their return signatures with the perl/pythonx providers.
2020-09-05 15:02:46 -07:00
Justin M. Keyes
858c056133
Support for :perl, :perlfile, :perldo and perleval() (#12809)
* support for :perl, :perlfile, :perldo and perleval()

* document that the perl provider doesn't currently work on Windows

* document that the perl legacy interface is now also supported

* added perleval() documentation

* import legacy perl interface tests

* only perl 5.22+ is supported

* healtcheck: use g:perl_host_prog if its set instead

using just 'perl' isn't correct as it may not be the version requested.
ditto for 'cpanm', rather go through 'App::cpanminus' to find the latest
perl version
2020-09-05 13:55:06 -07:00
Jacques Germishuys
8705fbf77c healtcheck: use g:perl_host_prog if its set instead
using just 'perl' isn't correct as it may not be the version requested.
ditto for 'cpanm', rather go through 'App::cpanminus' to find the latest
perl version
2020-09-05 13:09:15 +01:00
Jacques Germishuys
98dea93ba0 only perl 5.22+ is supported 2020-09-03 09:57:59 +01:00
DDoSolitary
c14a9f6fcc
g📋 allow command given as a list #12775
fixes #12768
2020-09-01 00:27:38 -07:00
Jacques Germishuys
9bef25314e support for :perl, :perlfile, :perldo and perleval() 2020-08-30 17:19:05 +01:00
erw7
d17e38e482 Add overlapped option to jobstart
When UV_OVERLAPPED_PIPE was used for the pipe passed to the child process, a
problem occurred with the standard input of the .Net Framework application
(#11809). Therefore, add the overlapped option to jobstart() and change it so
that it is set only when necessary
2020-06-10 22:21:14 +09:00
Faris A Chugthai
7116105d66
provider: Add python3.9 to autoload/provider/pythonx.vim (#12344)
3.9's scheduled for beta release today.
https://www.python.org/dev/peps/pep-0596/
2020-05-20 13:57:46 +02:00
erw7
e8269a3ab5
win,runtime: Fix problem when win32yank was a symbolic link in WSL [skip ci] (#12124)
On some versions of Windows, WSL is unable to execute symbolic links to
Windows executables (microsoft/WSL#3999). As a workaround for that problem
this changes to use resolve() on WSL if win32yank was a symbolic link.

fixes #12113.
2020-04-15 14:54:23 +02:00
Jan Edmund Lazo
ef3e610138
provider/perl: simplify detection 2020-01-20 19:43:59 -05:00
Jacques Germishuys
c25b5a1576
remote plugins: add support for perl hosts 2020-01-20 19:43:59 -05:00
Björn Linse
6e3793bf11 clipboard: do not close stderr together with stdout (fixup #11617)
stderr is needed to get error messages in case of failure, and
job handler expects it to be open.
2020-01-02 19:27:55 +01:00
Jan Edmund Lazo
67d7906652 clipboard: close stdout when copying via xclip #11617
test_registers.vim can fail even if a clipboard manager is running.
If a clipboard manager is not running, this test always fails with xclip.
Use xsel as a workaround.
https://github.com/astrand/xclip/issues/20 suggests closing stdout
when sending input via stdin.

Environment
- Ubuntu Xenial
- Vim 7.4 (any app with broken clipboard code will do)
- Neovim nightly

Steps to reproduce:
0. Start the clipboard manager.
1. Open a file in Vim on Linux.
   Vim should have +clipboard enabled.
   'set clipboard='
2. Yank some text to the clipboard register.
3. Quit Vim.
4. Run 'cd /path/to/neovim/repo/'
5. Run 'make oldtest'.
   Do not run any individual tests.
   They likely pass with or without this fix.

Before fix: test_registers.vim can fail.
After fix: test_registers.vim always passes.

Close https://github.com/neovim/neovim/issues/7958

https://wiki.ubuntu.com/ClipboardPersistence#The_state_of_things
2020-01-02 00:41:36 -08:00
Daniel Hahler
b3686b1597 system(), jobstart(): raise error on non-executable #11234
* tv_to_argv: error when cmd is not executable
  Callers always assume that emsg was emitted:
  - https://github.com/neovim/neovim/blob/57fbf288/src/nvim/eval.c#L12509
  - https://github.com/neovim/neovim/blob/57fbf288/src/nvim/eval.c#L17923
  - https://github.com/neovim/neovim/blob/57fbf288/src/nvim/eval.c#L18202
* test/functional/provider: display reason from missing_provider
* provider#node#Detect: skip / handle non-existing node executable
2019-12-24 07:53:56 +01:00
Marco Hinz
97f1222005
provider/python: add python3.8 executable (#11402)
Python 3.8 was released 2019-10-14:

  https://www.python.org/dev/peps/pep-0569
2019-11-17 14:23:17 +01:00
supermomonga
31536ae003 provider/pythonx: don't assume CWD (empty string) is in path #11304
sys.path.remove("") raises ValueError if the item is missing.

https://docs.python.org/3/library/functions.html#filter:
> filter(function, iterable) is equivalent to the generator expression (item
> for item in iterable if function(item))

fixes #11293
2019-10-27 14:27:22 -07:00
Daniel Hahler
179c46a016
provider#pythonx: resolve/expand exe from host var (#11047)
This reverts part of ade88fe4c [1].

This is required for `let g:python3_host_prog = 'python'` etc, where it
should get picked up from PATH.

Without this it would show:

```
  - INFO: pyenv: Path: /home/user/.pyenv/libexec/pyenv
  - INFO: pyenv: Root: /home/user/.pyenv
  - INFO: Using: g:python3_host_prog = "python"
  - ERROR: "python" was not found.
  - INFO: Executable: Not found
  - ERROR: Detected pip upgrade failure: Python executable can import "pynvim" but not "neovim": python
    - ADVICE:
      - Use that Python version to reinstall "pynvim" and optionally "neovim".
          pip3 uninstall pynvim neovim
          pip3 install pynvim
          pip3 install neovim  # only if needed by third-party software
```

Note that it additionally causes a weird error
("Detected pip upgrade failure"), due to `s:check_bin` emptying
`python_exe` (because the non-absolute file not being readable), and
`provider#pythonx#DetectByModule('pynvim', a:version)` from 75593e6fce
then just getting the value from the host var again (without actual
checks).
This is implicitly fixed via this patch now (because it is skipped), but
could need some improvement in this regard probably.

With this patch it resolves it (for a virtualenv where pynvim is not
made available intentionally):
```
  - INFO: pyenv: Path: /home/daniel/.pyenv/libexec/pyenv
  - INFO: pyenv: Root: /home/daniel/.pyenv
  - INFO: Using: g:python3_host_prog = "python"
  - WARNING: $VIRTUAL_ENV exists but appears to be inactive. This could lead to unexpected results.
    - ADVICE:
      - If you are using Zsh, see: http://vi.stackexchange.com/a/7654
  - INFO: Executable: /home/daniel/.pyenv/shims/tmp-system-deoplete.nvim-f205aF/python
  - ERROR: Command error (job=11, exit code 1): `'/home/daniel/.pyenv/shims/tmp-system-deoplete.nvim-f205aF/python' -c 'import sys; sys.path.remove(""); import neovim; print(neovim.__file__)'` (in '/home/daniel/.dotfiles/vim/plugged/deoplete.nvim')
    Output: Traceback (most recent call last):  File "<string>", line 1, in <module>ModuleNotFoundError: No module named 'neovim'
    Stderr: Traceback (most recent call last):  File "<string>", line 1, in <module>ModuleNotFoundError: No module named 'neovim'
  - INFO: Python version: 3.7.4
  - INFO: pynvim version: unable to load neovim Python module
  - ERROR: pynvim is not installed.
    Error: unable to load neovim Python module
    - ADVICE:
      - Run in shell: pip3 install pynvim

```

Note: this appears to display the error twice via "Output:" and
"Stderr:".

1: https://github.com/neovim/neovim/pull/8784
2019-09-30 12:52:04 +02:00
Daniel Hahler
2fafed6bb8 clipboard: handle/avoid SIGTERM with previous owner #10765
Fixes regression due to signal being reported with exit status.
ref #10573 939d9053bd
ref https://github.com/neovim/neovim/issues/7054#issuecomment-520282429
2019-08-14 09:58:52 +02:00
Justin M. Keyes
241956720d provider: g:loaded_xx_provider=2 means "enabled and working"
Value of 1 cannot be used, because users might set that in their vimrc
to _disable_ a provider, which would confuse :checkhealth and has().
2019-08-04 13:23:46 +02:00
Justin M. Keyes
66938b928c provider: decide status by g:loaded_xx_provider 2019-08-04 13:23:46 +02:00
Rui Abreu Ferreira
2cfe4748e5 provider: let providers decide their status
Instead of deciding provider status in eval_has_provider, move the
decision to the provider Vim scripts.

Previously, provider loading worked as follows:

1. eval_has_provider() verified provider availability by searching for
   the provider#providername#Call function and cached this verificaion as a static
   variable for some providers
2. providers short-circuited on loading to prevent the definition of the
   Call function (with the exception of the node provider that did not)

This commit changes the expected interface between nvim and its
providers to facilitate provider reloading, by splitting the
verification of the provider from the availability of the Call function.

eval_has_provider() now checks for a provider#providername#enabled
variable. It is up to the provider script to set this to 0 or 1
accordingly. eval_call_provider() remains unchanged.

All providers hosting a Call function were updated to respect this.

The clipboard provider now has a Reload function to reload the
provider.
2019-08-04 13:23:46 +02:00
Tim Morgan
d8316f2a1b clipboard: Always copy as plain text in Wayland #9737
`wl-copy` by default tries to determine the mime type of a copied bit of
text. From the [readme](https://github.com/bugaevc/wl-clipboard):

> wl-copy automatically infers the type of the copied content by running
> xdg-mime(1) on it.

So copying a Ruby script from Nvim may store it in the Wayland clipboard
as mime-type `application/x-ruby`.

This is a small reproduction without Nvim:

    $ cat test.rb
    #!/usr/bin/env ruby
    puts 'hello world'
    $ cat test.rb | wl-copy
    $ wl-paste --list-types
    application/x-ruby

This commit fixes that by telling wl-copy that all text copied from
Nvim has the mime type `text/plain`.

    $ cat test.rb | wl-copy --type text/plain
    $ wl-paste --list-types
    text/plain;charset=utf-8
2019-03-16 22:55:24 +01:00