Commit Graph

593 Commits

Author SHA1 Message Date
bfredl
0b351c3740 test(api): update tests to new error messages 2023-08-07 13:18:11 +02:00
Tyler Miller
0804034c07
fix(loader): cache path ambiguity #24491
Problem: cache paths are derived by replacing each reserved/filesystem-
path-sensitive char with a `%` char in the original path. With this
method, two different files at two different paths (each containing `%`
chars) can erroneously resolve to the very same cache path in certain
edge-cases.

Solution: derive cache paths by url-encoding the original (path) instead
using `vim.uri_encode()` with `"rfc2396"`. Increment `Loader.VERSION` to
denote this change.
2023-08-01 08:28:28 -07:00
Lewis Russell
24e3ee9d07
fix(api/options): validate buf and win
Fixes #24398
2023-07-22 09:52:13 +01:00
Justin M. Keyes
7907b1fca5 test(vim.ui.open): mock failure on Windows
Problem:
On Windows, `rundll32` exits zero (success) even when given
a non-existent file.

Solution:
Mock vim.system() on Windows to force a "failure" case.
2023-07-21 14:38:17 +02:00
zeertzjq
ca9f4a7cb1
docs: also change "vimL" and "viml" to "Vimscript" (#24414) 2023-07-21 16:30:05 +08:00
Mike
e4da418ba8
fix(fs.lua): normalize slash truncation (#23753)
Preserve last slash in windows' root drive directories
2023-07-18 14:36:04 +08:00
kylo252
98b22867c3
test(fs): vim.loop was renamed to vim.uv (#24376)
test(fs): vim.loop has been replaced with vim.uv
2023-07-17 19:27:55 +08:00
kylo252
f660b79480
test(fs): get tmpdir robustly #23021
Problem:
helpers.tmpname() may create a local file, depending on circumstances.

Solution:
Only use helpers.tmpname() for its parent directory (the "temp root").
Use fs_mkdtemp() to actually get a unique name.
2023-07-16 05:50:10 -07:00
zeertzjq
9176b5e10a
fix(runtime): respect 'fileignorecase' when sourcing (#24344) 2023-07-14 07:57:13 +08:00
zeertzjq
dbb840da01
fix(runtime): respect 'rtp' order for all runtime files (#24335) 2023-07-14 06:46:16 +08:00
Lewis Russell
516b173780
perf(rtp): reduce rtp scans (#24191)
* perf(rtp): reduce rtp scans

Problem:
  Scanning the filesystem is expensive and particularly affects
  startuptime.

Solution:
  Reduce the amount of redundant directory scans by relying less on glob
  patterns and handle vim and lua sourcing lower down.
2023-07-13 10:17:19 +01:00
zeertzjq
fbeef0d4ef
fix(completion): don't add backslashes to runtime pattern (#24296)
Problem:    Bashslashes added as regexp in runtime completion may be
            treated as path separator with some 'isfname' value.
Solution:   Make curly braces work for runtime completion and use it.
2023-07-08 23:29:24 +08:00
Lewis Russell
c379d72c49
feat(lua): allow vim.wo to be double indexed (#20288)
* feat(lua): allow vim.wo to be double indexed

Problem: `vim.wo` does not implement `setlocal`
Solution: Allow `vim.wo` to be double indexed

Co-authored-by: Christian Clason <c.clason@uni-graz.at>
2023-07-07 16:37:36 +01:00
zeertzjq
2afb04758c
fix(vim.system): close check handle (#24270)
Fix hang after running vim.system() with sanitizers.
2023-07-06 12:56:19 +08:00
Justin M. Keyes
e644e7ce0b fix(vim.ui.open): return (don't show) error message
Problem:
Showing an error via vim.notify() makes it awkward for callers such as
lsp/handlers.lua to avoid showing redundant errors.

Solution:
Return the message instead of showing it. Let the caller decide whether
and when to show the message.
2023-07-05 00:49:10 +02:00
Justin M. Keyes
67b2ed1004 fix(gx): visual selection, expand env vars
---
Rejected experiment: move vim.ui.open() to vim.env.open()

Problem:
`vim.ui` is where user-interface "providers" live, which can be
overridden. It would also be useful to have a "providers" namespace for
platform-specific features such as "open", clipboard, python, and the other
providers listed in `:help providers`. We could overload `vim.ui` to
serve that purpose as the single "providers" namespace, but
`vim.ui.nodejs()` for example seems awkward.

Solution:
`vim.env` currently has too narrow of a purpose. Overload it to also be
a namespace for `vim.env.open`.

diff --git a/runtime/lua/vim/_meta.lua b/runtime/lua/vim/_meta.lua
index 913f1fe20348..17d05ff37595 100644
--- a/runtime/lua/vim/_meta.lua
+++ b/runtime/lua/vim/_meta.lua
@@ -37,8 +37,28 @@ local options_info = setmetatable({}, {
   end,
 })

-vim.env = setmetatable({}, {
-  __index = function(_, k)
+vim.env = setmetatable({
+  open = setmetatable({}, {
+      __call = function(_, uri)
+        print('xxxxx'..uri)
+        return true
+      end,
+      __tostring = function()
+        local v = vim.fn.getenv('open')
+        if v == vim.NIL then
+          return nil
+        end
+        return v
+      end,
+    })
+  },
+  {
+  __index = function(t, k, ...)
+    if k == 'open' then
+      error()
+      -- vim.print({...})
+      -- return rawget(t, k)
+    end
     local v = vim.fn.getenv(k)
     if v == vim.NIL then
       return nil
2023-07-04 23:45:35 +02:00
zeertzjq
92760a7f42
fix(api, lua): make blank lines in a message work properly (#24244) 2023-07-04 07:19:02 +08:00
zeertzjq
751b9d73fd
Merge pull request #24147 from clason/fix/ftplugin
fix(ftplugin): respect runtimepath ordering
2023-06-30 18:22:02 +08:00
zeertzjq
6cceef6d4c test(lua/runtime_spec): add test for ftplugin ordering 2023-06-30 17:09:43 +08:00
Justin M. Keyes
036da0d079 fix(docs): vimdoc syntax errors
gen_help_html: truncate parse-error sample text
2023-06-25 17:14:28 +02:00
Justin M. Keyes
4e6356559c
test: spellcheck :help (vimdoc) files #24109
Enforce consistent terminology (defined in
`gen_help_html.lua:spell_dict`) for common misspellings.

This does not spellcheck English in general (perhaps a future TODO,
though it may be noisy).
2023-06-22 03:44:51 -07:00
Justin M. Keyes
8d4a53fe6e
fix(vim.json)!: remove global options, "null", "array_mt" #24070
Problem:
- `vim.json` exposes various global options which:
  - affect all Nvim Lua plugins (especially the LSP client)
  - are undocumented and untested
  - can cause confusing problems such as: cc76ae3abe
- `vim.json` exposes redundant mechanisms:
  - `vim.json.null` is redundant with `vim.NIL`.
  - `array_mt` is redundant because Nvim uses a metatable
    (`vim.empty_dict()`) for empty dict instead, which `vim.json` is
    configured to use by default (see `as_empty_dict`).
    Example:
    ```
    :lua vim.print(vim.json.decode('{"bar":[],"foo":{}}'))
    --> { bar = {},  foo = vim.empty_dict() }
    ```
    Thus we don't need to also decorate empty arrays with `array_mt`.

Solution:
Remove the functions from the public vim.json interface.
Comment-out the implementation code to minimize drift from upstream.

TODO:
- Expose the options as arguments to `vim.json.new()`
2023-06-21 01:10:32 -07:00
Evgeni Chasnovski
8a7e3353eb
fix(fs): make normalize() work with '/' path (#24047)
Problem: Current implementation of "remove trailing /" doesn't
account for the case of literal '/' as path.
Solution: Remove trailing / only if it preceded by something else.

Co-authored by: notomo <notomo.motono@gmail.com>
2023-06-18 06:49:33 -05:00
Jon Huhn
79a5b89d66
perf(lsp): reduce polling handles for workspace/didChangeWatchedFiles (#23500)
Co-authored-by: Lewis Russell <lewis6991@gmail.com>
2023-06-14 12:40:11 +02:00
Justin M. Keyes
e688793253 feat: tostring(vim.version())
Problem:
tostring(vim.version()) returns "table: 0x…".

Solution:
Modify vim.version() to return a string prerelease instead of a boolean.

Fix #23863
2023-06-12 01:14:33 +02:00
Mathias Fußenegger
302d3cfb96
feat(lua): use callable table as iterator in vim.iter (#23957)
A table passed to `vim.iter` can be a class instance with a `__call`
implementation for the iterator protocol.
2023-06-10 20:33:23 +02:00
Mathias Fußenegger
7c661207cc
feat(lua): add ringbuffer (#22894)
https://en.wikipedia.org/wiki/Circular_buffer
2023-06-08 12:11:24 +02:00
Lewis Russell
c0952e62fd
feat(lua): add vim.system()
feat(lua): add vim.system()

Problem:

  Handling system commands in Lua is tedious and error-prone:
  - vim.fn.jobstart() is vimscript and comes with all limitations attached to typval.
  - vim.loop.spawn is too low level

Solution:

  Add vim.system().
  Partly inspired by Python's subprocess module
  Does not expose any libuv objects.
2023-06-07 13:52:23 +01:00
Gianmaria Bajo
ca887b80a9
fix: version-range < and <= #23539
vim.version.range() couldn't parse them correctly.
For example, vim.version.range('<0.9.0'):has('0.9.0') returned `true`.

fix: range:has() accepts vim.version()
So that it's possible to compare a range with:

    vim.version.range(spec):has(vim.version())
2023-06-06 06:38:45 -07:00
zeertzjq
eceb2dffce
fix(spell): splice extmarks on :spellrepall (#23929) 2023-06-06 10:32:30 +08:00
Lewis Russell
2db719f6c2
feat(lua): rename vim.loop -> vim.uv (#22846) 2023-06-03 12:06:00 +02:00
zeertzjq
62e0e0349c
fix(colorscheme): try .lua files in 'rtp' before .vim files in 'pp' (#23727)
This ensures that colorschemes in 'rtp' are tried before ones in 'pp',
because some colorschemes in 'pp' may not work if not added to 'rtp'.

This also match the current documentation better.
2023-05-23 16:12:16 +08:00
Famiu Haque
576dddb461 test: don't unnecessarily specify win/buf for nvim_(get|set)_option_value
`nvim_(get|set)_option_value` pick the current buffer / window by default for buffer-local/window-local (but not global-local) options. So specifying `buf = 0` or `win = 0` in opts is unnecessary for those options. This PR removes those to reduce code clutter.
2023-05-22 13:02:07 +06:00
Lewis Russell
1fe1bb084d refactor(options): deprecate nvim[_buf|_win]_[gs]et_option
Co-authored-by: zeertzjq <zeertzjq@outlook.com>
Co-authored-by: famiu <famiuhaque@protonmail.com>
2023-05-21 15:14:01 +06:00
Christian Clason
e3e6fadfd8
feat(fs): expose join_paths as vim.fs.joinpath (#23685)
This is a small function but used a lot in some plugins.
2023-05-20 17:30:48 +02:00
dundargoc
826b95203a
build: bundle uncrustify
Uncrustify is sensitive to version changes, which causes friction for
contributors that doesn't have that exact version. It's also simpler to
download and install the correct version than to have bespoke version
checking.
2023-05-18 16:27:47 +02:00
zeertzjq
4a098b97e5 fix(excmd): append original command to error message
Revert the change to do_cmdline_cmd() from #5226.

This function is used in many places, so making it different from Vim
leads to small differences from Vim in the behavior of some functions
like execute() and assert_fails(). If DOCMD_VERBOSE really needs to be
removed somewhere, a do_cmdline() call without DOCMD_VERBOSE is also
shorter than a do_cmdline() call with DOCMD_VERBOSE.
2023-05-05 10:43:28 +08:00
zeertzjq
88cfb49bee vim-patch:8.2.4890: inconsistent capitalization in error messages
Problem:    Inconsistent capitalization in error messages.
Solution:   Make capitalization consistent. (Doug Kearns)

cf030578b2

Co-authored-by: Bram Moolenaar <Bram@vim.org>
2023-05-05 09:20:30 +08:00
zeertzjq
7b6d041bae fix(heredoc): allow missing end marker for scripts
Also do not crash when getting heredoc fails.
2023-04-29 09:39:55 +08:00
bfredl
0ff58d1bb9
Merge pull request #23216 from bfredl/lpeg
refactor(build): include lpeg as a library
2023-04-27 12:06:44 +02:00
bfredl
45bcf83869 refactor(build): include lpeg as a library 2023-04-27 11:40:00 +02:00
zeertzjq
d321deb4a9
test: fix dependencies between test cases (#23343)
Discovered using --shuffle argument of busted.
2023-04-27 15:51:44 +08:00
Gregory Anders
147bb87245 test: move vim.iter tests to separate file 2023-04-24 20:31:25 -06:00
Gregory Anders
f68af3c3bc
refactor(iter): use metatable as packed table tag (#23254)
This is a more robust method for tagging a packed table as it completely
eliminates the possibility of mistaking an actual table key as the
packed table tag.
2023-04-21 16:13:39 -06:00
Justin M. Keyes
622b1ae38a fix(lua): vim.split may trim inner empty items
Problem:
`vim.split('a:::', ':', {trimempty=true})` trims inner empty items.
Regression from 9c49c10470

Solution:
Set `empty_start=false` when first non-empty item is found.
close #23212
2023-04-21 13:50:22 +02:00
Gregory Anders
9489406879 fix(iter): remove special case totable for map-like tables
This was originally meant as a convenience but prevents possible
functionality. For example:

  -- Get the keys of the table with even values
  local t = { a = 1, b = 2, c = 3, d = 4 }
  vim.iter(t):map(function(k, v)
    if v % 2 == 0 then return k end
  end):totable()

The example above would not work, because the map() function returns
only a single value, and cannot be converted back into a table (there
are many such examples like this).

Instead, to convert an iterator into a map-like table, users can use
fold():

  vim.iter(t):fold({}, function(t, k, v)
    t[k] = v
    return t
  end)
2023-04-19 07:52:04 -06:00
Gregory Anders
6b96122453 fix(iter): add tag to packed table
If pack() is called with a single value, it does not create a table; it
simply returns the value it is passed. When unpack is called with a
table argument, it interprets that table as a list of values that were
packed together into a table.

This causes a problem when the single value being packed is _itself_ a
table. pack() will not place it into another table, but unpack() sees
the table argument and tries to unpack it.

To fix this, we add a simple "tag" to packed table values so that
unpack() only attempts to unpack tables that have this tag. Other tables
are left alone. The tag is simply the length of the table.
2023-04-19 07:04:49 -06:00
Gregory Anders
ab1edecfb7
feat(lua): add vim.iter (#23029)
vim.iter wraps a table or iterator function into an `Iter` object with
methods such as `filter`, `map`, and `fold` which can be chained to
produce iterator pipelines that do not create new tables at each step.
2023-04-17 12:54:19 -06:00
Jon Huhn
6cc76011ca
fix(watchfiles): skip Created events when poll starts (#23139) 2023-04-17 18:50:05 +02:00
Isak Samsten
07b60efd80
feat(diagnostic): specify diagnostic virtual text prefix as a function
- vim.diagnostic.config() now accepts a function for the virtual_text.prefix
  option, which allows for rendering e.g., diagnostic severities differently.
2023-04-17 12:53:34 +01:00
zeertzjq
fd68cd1c0a
vim-patch:8.2.2857: Vim9: exception in ISN_INSTR caught at wrong level (#23131)
Problem:    Vim9: exception in ISN_INSTR caught at wrong level.
Solution:   Set the starting trylevel in exec_instructions(). (closes vim/vim#8214)

ff65288aa8

Co-authored-by: Bram Moolenaar <Bram@vim.org>
2023-04-16 18:27:33 +08:00
Raphael
2f779b94e7
fix(lua): inspect_pos respect bufnr when get syntax info (#23098) 2023-04-16 17:50:32 +08:00
zeertzjq
68ca16c376 vim-patch:8.2.3783: confusing error for using a variable as a function
Problem:    Confusing error for using a variable as a function.
Solution:   If a function is not found but there is a variable, give a more
            useful error. (issue vim/vim#9310)

2ef9156b42

Co-authored-by: Bram Moolenaar <Bram@vim.org>
2023-04-16 10:15:15 +08:00
NAKAI Tsuyoshi
7caf0eafd8
feat(lua)!: add stricter vim.tbl_islist() and rename old one to vim.tbl_isarray() (#16440)
feat(lua)!: add stricter vim.tbl_islist(), rename vim.tbl_isarray()

Problem: `vim.tbl_islist` allows gaps in tables with integer keys
("arrays").

Solution: Rename `vim.tbl_islist` to `vim.tbl_isarray`, add new
`vim.tbl.islist` that checks for consecutive integer keys that start
from 1.
2023-04-14 12:01:08 +02:00
Christian Clason
4d04feb662
feat(lua): vim.tbl_contains supports general tables and predicates (#23040)
* feat(lua): vim.tbl_contains supports general tables and predicates

Problem: `vim.tbl_contains` only works for list-like tables (integer
keys without gaps) and primitive values (in particular, not for nested
tables).

Solution: Rename `vim.tbl_contains` to `vim.list_contains` and add new
`vim.tbl_contains` that works for general tables and optionally allows
`value` to be a predicate function that is checked for every key.
2023-04-14 10:39:57 +02:00
Lewis Russell
66c66d8db8
fix(loader): reset hashes when running the loader 2023-04-13 17:34:47 +01:00
NAKAI Tsuyoshi
9e86f473e0
feat(lua): vim.region accepts getpos() arg (#22635) 2023-04-11 16:28:46 +02:00
Gregory Anders
d675bd01b1
feat(lua): allow vim.F.if_nil to take multiple arguments (#22903)
The first argument which is non-nil is returned. This is useful when
using nested default values (e.g. in the EditorConfig plugin).

Before:

  local enable = vim.F.if_nil(vim.b.editorconfig, vim.F.if_nil(vim.g.editorconfig, true))

After:

  local enable = vim.F.if_nil(vim.b.editorconfig, vim.g.editorconfig, true)
2023-04-07 08:22:47 -06:00
zeertzjq
b2d10aa01d
test(lua/diagnostic_spec): remove unnecessary after_each()
There is already a call to clear() in before_each(), so after_each() isn't necessary.
2023-04-07 09:38:52 +08:00
dundargoc
fd32a98752
test(vim.fs.normalize): enable test on Windows 2023-04-05 23:56:33 +02:00
Lewis Russell
34ac75b329
refactor: rename local API alias from a to api
Problem:
  Codebase inconsistently binds vim.api onto a or api.

Solution:
  Use api everywhere. a as an identifier is too short to have at the
  module level.
2023-04-05 17:19:53 +01:00
dundargoc
743860de40
test: replace lfs with luv and vim.fs
test: replace lfs with luv

luv already pretty much does everything lfs does, so this duplication
of dependencies isn't needed.
2023-04-04 21:59:06 +02:00
Luuk van Baal
a930245557 refactor(lua): get all marks instead of iterating over namespaces
Inspector now also includes highlights set in anonymous namespaces.

Close #22732
2023-04-02 19:14:23 +02:00
dundargoc
d510bfbc8e
refactor: remove char_u (#22829)
Closes https://github.com/neovim/neovim/issues/459
2023-04-02 16:11:42 +08:00
Gregory Anders
643c0ed571
feat: allow function passed to defaulttable to take an argument (#22839)
Pass the value of the key being accessed to the create function, to
allow users to dynamically generate default values.
2023-04-01 08:02:58 -06:00
Lewis Russell
226a6c3eae
feat(diagnostic): add support for tags
The LSP spec supports two tags that can be added to diagnostics:
unnecessary and deprecated. Extend vim.diagnostic to be able to handle
these.
2023-03-30 14:49:58 +01:00
Jon Huhn
6a6191174a
test: fix flaky watchfiles tests (#22637) 2023-03-26 10:41:27 +01:00
luukvbaal
b02880593e
build(win): export extern symbols for use in FFI #22756
Makes `extern` variables accessible through ffi on Windows.

Follow-up to https://github.com/neovim/neovim/pull/15999
2023-03-23 04:58:50 -07:00
Justin M. Keyes
e51139f5c1 refactor(vim.gsplit): remove "keepsep"
string.gmatch() is superior, use that instead.
2023-03-22 17:46:01 +01:00
Justin M. Keyes
8a70adbde0 fix(vim.version): prerelease compare
Problem:
semver specifies that digit sequences in a prerelease string should be
compared as numbers, not lexically: https://semver.org/#spec-item-11
> Precedence for two pre-release versions with the same major, minor,
> and patch version MUST be determined by comparing each dot separated
> identifier from left to right until a difference is found as follows:
> 1. Identifiers consisting of only digits are compared numerically.
> 2. Identifiers with letters or hyphens are compared lexically in ASCII sort order.
> 3. Numeric identifiers always have lower precedence than non-numeric identifiers.
> 4. A larger set of pre-release fields has a higher precedence than a smaller set, if all of the preceding identifiers are equal.
Example:
1.0.0-alpha < 1.0.0-alpha.1 < 1.0.0-alpha.beta < 1.0.0-beta < 1.0.0-beta.2 < 1.0.0-beta.11 < 1.0.0-rc.1 < 1.0.0.

Solution:
cmp_prerel() treats all digit sequences in a prerelease string as
numbers. This doesn't _exactly_ match the spec, which specifies that
only dot-delimited digit sequences should be treated as numbers...
2023-03-22 17:46:01 +01:00
Justin M. Keyes
9c49c10470 feat(vim.gsplit): gain features of vim.split
Problem:
- vim.split has more features than vim.gsplit.
- Cannot inspect the "separator" segments of vim.split or vim.gsplit.

Solution:
- Move common implementation from vim.split into vim.gsplit.
  - TODO: deprecate vim.split in favor of vim.totable(vim.gsplit())?
- Introduce `keepsep` parameter.

Related: 84f66909e4
2023-03-22 17:46:01 +01:00
bfredl
a92b38934a feat(lua): allow :=expr as a shorter version of :lua =expr
existing behavior of
  :=
and
  :[range]=

are unchanged. `|` is still allowed with this usage.

However,
   :=p
and similar are changed in a way which could be construed as a breaking
change. Allowing |ex-flags| for := in the first place was a mistake as
any form of := DOES NOT MOVE THE CURSOR. So it would print one line number
and then print a completely different line contents after that.
2023-03-22 09:10:04 +01: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
a715e6f87e refactor(vim.version): use lazy.nvim semver module
Now the Nvim version string "v0.9.0-dev-1233+g210120dde81e" parses
correctly.
2023-03-20 13:40:38 +01:00
Justin M. Keyes
990c481551 refactor(vim.version): use lazy.nvim semver module
Use semver code from https://github.com/folke/lazy.nvim
License: Apache License 2.0

Co-authored-by: Folke Lemaitre <folke.lemaitre@gmail.com>
2023-03-20 13:36:55 +01:00
Lewis Russell
e5641df6d3 feat: add vim.filetype.get_option() 2023-03-20 10:06:32 +00:00
zeertzjq
c6f8af36e1
fix(spell): properly source spell/LANG.{vim,lua} (#22716)
Using regexp doesn't work here because there are no wildcards.
2023-03-18 09:55:08 +08:00
Justin M. Keyes
210120dde8
fix(lua): vim.deprecate() shows ":help deprecated" #22677
Problem:
vim.deprecate() shows ":help deprecated" for third-party plugins. ":help
deprecated" only describes deprecations in Nvim, and is unrelated to any
3rd party deprecations.

Solution:
If `plugin` is specified, don't show  ":help deprecated".

fix #22235
2023-03-15 05:56:13 -07:00
Justin M. Keyes
673d2b52fa refactor!: rename vim.pretty_print => vim.print
Problem:
The function name `vim.pretty_print`:
1. is verbose, which partially defeats its purpose as sugar
2. does not draw from existing precedent or any sort of convention
   (except external projects like penlight or python?), which reduces
   discoverability, and degrades signaling about best practices.

Solution:
- Rename to `vim.print`.
- Change the behavior so that
  1. strings are printed without quotes
  2. each arg is printed on its own line
  3. tables are indented with 2 instead of 4 spaces
- Example:
  :lua ='a', 'b', 42, {a=3}
  a
  b
  42
  {
    a = 3
  }

Comparison of alternatives:
- `vim.print`:
  - pro: consistent with Lua's `print()`
  - pro: aligns with potential `nvim_print` API function which will
    replace nvim_echo, nvim_notify, etc.
  - con: behaves differently than Lua's `print()`, slightly misleading?
- `vim.echo`:
  - pro: `:echo` has similar "pretty print" behavior.
  - con: inconsistent with Lua idioms.
- `vim.p`:
  - pro: very short, fits with `vim.o`, etc.
  - con: not as discoverable as "echo"
  - con: less opportunity for `local p = vim.p` because of potential shadowing.
2023-03-13 01:25:09 +01:00
Jaehwang Jung
2748202e0e fix(diff): trigger on_bytes only once after diffget/diffput
Problem: The fix from b50ee4a8dc may
adjust extmark twice, triggering on_bytes callback twice.

Solution: Don't let mark_adjust adjust extmark.
2023-03-11 18:22:00 +09:00
zeertzjq
89a525de9f
fix(buffer_updates): save and restore current window cursor (#16732)
When a buffer update callback is called, textlock is active so buffer
text cannot be changed, but cursor can still be moved. This can cause
problems when the buffer update is in the middle of an operator, like
the one mentioned in #16729. The solution is to save cursor position and
restore it afterwards, like how cursor is saved and restored when
evaluating an <expr> mapping.
2023-03-09 10:19:00 +08:00
bfredl
39096f48f0
Merge pull request #13834 from bfredl/omnilua
omnifunc for builtin lua
2023-03-07 00:28:53 +01:00
Björn Linse
79571b92ce feat(lua): omnifunc for builting lua interpreter
also make implicit submodules "uri" and "_inspector" work with completion

this is needed for `:lua=vim.uri_<tab>` wildmenu completion
to work even before uri or _inspector functions are used.
2023-03-06 23:12:21 +01:00
Justin M. Keyes
74ffebf8ec fix(vim.version): incorrect version.cmp()
Problem:
If major<major but minor>minor, cmp_version_core returns 1

Solution:
- Fix logic in cmp_version_core
- Delete most eq()/gt()/lt() tests, they are redundant.
2023-03-06 15:36:25 +01:00
Justin M. Keyes
e31e49a8e3 refactor(vim.version): cleanup
- version.cmp(): assert valid version
- add test for loading vim.version (the other tests use shared.lua in
  the test runner)
- reduce test scopes, reword test descriptions
2023-03-06 14:51:56 +01:00
Kelly Lin
0e7196438d feat(lua): add semver api 2023-03-06 13:45:59 +01:00
dundargoc
ba38f35d3e
test: don't search entire repo for files
Searching the entire repo for a directory named "contrib" causes failure
if there happens to be another subdirectory with the name "contrib".
Instead, point directly to the correct contrib directory.
2023-03-05 11:21:37 +01:00
Jon Huhn
ac69ba5fa0
feat(lsp): implement workspace/didChangeWatchedFiles (#22405) 2023-03-05 07:52:27 +01:00
Mike
bc15b075d1
feat(vim.fs): pass path to find() predicate, lazy evaluate #22378
Problem:
No easy way to find files under certain directories (ex: grab all files under
`test/`) or exclude the content of certain paths (ex. `build/`, `.git/`)

Solution:
Pass the full `path` as an arg to the predicate.
2023-03-01 08:51:22 -08:00
Mathias Fussenegger
f0f27e9aef Revert "feat(lsp): implement workspace/didChangeWatchedFiles (#21293)"
This reverts commit 5732aa706c.

Causes editor to freeze in projects with many watcher registrations
2023-02-25 11:17:28 +01:00
Jon Huhn
5732aa706c
feat(lsp): implement workspace/didChangeWatchedFiles (#21293) 2023-02-25 10:07:18 +01:00
Christian Clason
1c37553476 test(help): drop treesitter parse error to 0
All parser errors have been fixed; make sure we don't introduce new
ones.
2023-02-23 10:24:15 +01:00
bfredl
799edca18a feat(lua): make sure require'bit' always works, even with PUC lua 5.1 2023-02-22 22:15:19 +01:00
zeertzjq
9b9f8dfcc4 test: make {MATCH:} behave less unexpectedly in screen:expect()
Include the rest of the line and allow multiple {MATCH:} patterns.
2023-02-18 10:44:35 +08:00
zeertzjq
05faa8f30a
test: make expect_unchanged() less confusing (#22255)
Problem:
The sleep before collecting the initial screen state is confusing and
may lead to unexpected success if it comes after a blocking RPC call.

Solution:
Remove that sleep and add an "intermediate" argument.
2023-02-15 07:26:55 +08:00
Justin M. Keyes
ff3d04b75b
refactor(api): VALIDATE macros #22256
- VALIDATE() takes a format string
- deduplicate check_string_array
- VALIDATE_RANGE
- validate UI args
2023-02-14 05:07:38 -08:00
Justin M. Keyes
46a87a5d2b
refactor(api): VALIDATE macros #22187
Problem:
- API validation involves too much boilerplate.
- API validation errors are not consistently worded.

Solution:
Introduce some macros. Currently these are clumsy, but they at least
help with consistency and avoid some nesting.
2023-02-14 02:19:04 -08:00
Jonas Strittmatter
b518aceaa8
feat(filetype): fall back to file extension when matching from hashbang (#22140)
If nothing matched in match_from_hashbang, also check the file extension table.
For a hashbang like '#!/bin/env foo', this will set the filetype to 'fooscript'
assuming the filetype for the 'foo' extension is 'fooscript' in the extension
table.
2023-02-13 16:04:16 -07:00
Jonas Strittmatter
9668c166e8
fix(filetype): make vim.filetype.match() work with contents only (#22181)
Co-authored-by: Gregory Anders <greg@gpanders.com>
2023-02-11 08:08:33 -07:00
zeertzjq
62f09017e0 test: add test for :runtime completion for .lua 2023-01-26 11:55:34 +08:00