Commit Graph

363 Commits

Author SHA1 Message Date
Famiu Haque
a27419f3fc
feat(options)!: disallow setting hidden options #28400
Problem:
There are three different ways of marking an option as hidden, `enable_if
= false`, `hidden = true` and `immutable = true`. These also have different
behaviors. Options hidden with `enable_if = false` can't have their value
fetched using Vim script or the API, but options hidden with `hidden = true` or
`immutable = true` can. On the other hand, options with `hidden = true` do not
error when trying to set their value, but options with `immutable = true` do.

Solution:
Remove `enable_if = false`, remove the `hidden` property for options, and use
`immutable = true` to mark an option as hidden instead. Also make hidden option
variable pointers always point to the default value, which allows fetching the
value of every hidden option using Vim script and the API. This does also mean
that trying to set a hidden option will now give an error instead of just being
ignored.
2024-11-04 05:00:12 -08:00
zeertzjq
3075c69ff0
vim-patch:9.1.0831: 'findexpr' can't be used as lambad or Funcref (#31058)
Problem:  'findexpr' can't be used for lambads
          (Justin Keyes)
Solution: Replace the findexpr option with the findfunc option
          (Yegappan Lakshmanan)

related: vim/vim#15905
closes: vim/vim#15976

a13f3a4f5d

Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
2024-11-03 10:06:41 +08:00
zeertzjq
7bf3a616e1
vim-patch:b5e7da1: runtime(doc): mention 'iskeyword' at :h charclass() (#31026)
fixes: vim/vim#15965

b5e7da1f27

Co-authored-by: Christian Brabandt <cb@256bit.org>
2024-11-01 18:22:08 +08:00
Kai Moschcau
4c7f5032af
docs(options): shell-powershell #30969
`-NonInteractive` at least somewhat hints to pwsh/powershell, that shell
sessions created from :! are not interactive, though even that is not
foolproof, because powershell is weird.
`$PSStyle.OutputRendering='plaintext'` causes pwsh/powershell
to omit ANSI escape sequences in its output.
2024-10-29 07:36:58 -07:00
zeertzjq
60b3ccd850 vim-patch:9.1.0821: 'findexpr' completion doesn't set v:fname to cmdline argument
Problem:  'findexpr' completion doesn't set v:fname to cmdline argument.
Solution: Set v:fname to the cmdline argument as-is (zeertzjq).

closes: vim/vim#15934

20e045f781
2024-10-29 08:20:00 +08:00
zeertzjq
378d9135e7 vim-patch:9.1.0810: cannot easily adjust the |:find| command
Problem:  cannot easily adjust the |:find| command
Solution: Add support for the 'findexpr' option (Yegappan Lakshmanan)

closes: vim/vim#15901
closes: vim/vim#15905

aeb1c97db5

Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
2024-10-29 08:20:00 +08:00
Tristan Knight
230b0c7f02
feat(stdlib): overload vim.str_byteindex, vim.str_utfindex #30735
PROBLEM:
There are several limitations to vim.str_byteindex, vim.str_utfindex:
1. They throw given out-of-range indexes. An invalid (often user/lsp-provided)
   index doesn't feel exceptional and should be handled by the caller.
   `:help dev-error-patterns` suggests that `retval, errmsg` is the preferred
   way to handle this kind of failure.
2. They cannot accept an encoding. So LSP needs wrapper functions. #25272
3. The current signatures are not extensible.
    * Calling: The function currently uses a fairly opaque boolean value to
      indicate to identify the encoding.
    * Returns: The fact it can throw requires wrapping in pcall.
4. The current name doesn't follow suggestions in `:h dev-naming` and I think
   `get` would be suitable.

SOLUTION:
- Because these are performance-sensitive, don't introduce `opts`.
- Introduce an "overload" that accepts `encoding:string` and
  `strict_indexing:bool` params.

```lua
local col = vim.str_utfindex(line, encoding, [index, [no_out_of_range]])
```

Support the old versions by dispatching on the type of argument 2, and
deprecate that form.

```lua
vim.str_utfindex(line)                             -- (utf-32 length, utf-16 length), deprecated
vim.str_utfindex(line, index)                      -- (utf-32 index, utf-16 index), deprecated
vim.str_utfindex(line, 'utf-16')                   -- utf-16 length
vim.str_utfindex(line, 'utf-16', index)            -- utf-16 index
vim.str_utfindex(line, 'utf-16', math.huge)        -- error: index out of range
vim.str_utfindex(line, 'utf-16', math.huge, false) -- utf-16 length
```
2024-10-23 06:33:57 -07:00
dundargoc
3a86b60032 docs: misc
Co-authored-by: David Pedersen <limero@me.com>
Co-authored-by: Gregory Anders <greg@gpanders.com>
Co-authored-by: Leo Schlosser <Leo.Schlosser@Student.HTW-Berlin.de>
Co-authored-by: zeertzjq <zeertzjq@outlook.com>
2024-10-23 14:13:42 +02:00
Famiu Haque
07b4cb6ada
docs(options): remove description for hidden options #30903
Problem:
Hidden options are documented despite being no-ops.

Solution:
Remove docs for hidden options.
Move tags for options that we plan to restore, to ":help nvim-missing".
Move tags for permanently removed options, to ":help nvim-removed".
2024-10-22 09:14:01 -07:00
Lewis Russell
c8e47f6480 fix(meta): do not use hyphens in param names
Fixes #30882
2024-10-21 12:09:33 +01:00
zeertzjq
9b8907d905
feat(float): allow enabling mouse for non-focusable window (#30844)
Problem:  Cannot allow mouse interaction for non-focusable float window.
Solution: Add a "mouse" field to float window config.
2024-10-20 22:18:26 +08:00
zeertzjq
3cf602486c
feat(terminal)!: make 'belloff' and 'visualbell' apply to terminal bell (#30859)
vim-patch:8.2.4744: a terminal window can't use the bell
vim-patch:8.2.4745: using wrong flag for using bell in the terminal

BREAKING CHANGE: Bells from :terminal are now silent by default, unless
'belloff' option doesn't contain "term" or "all".
2024-10-20 07:59:43 +08:00
Lewis Russell
fa6ab0d909
Merge pull request #30825 from lewis6991/refactor/lsputil 2024-10-17 13:35:02 +01:00
Lewis Russell
21151144c6 feat(meta): add type for quickfix entries 2024-10-17 10:54:19 +01:00
zeertzjq
c89150241d vim-patch:6c2fc37: runtime(help): Update help syntax
This commit makaes the following changes to the vim help syntax:

- fix excessive URL detection in help, because `file:{filename}` in
  doc/options.txt is determined to be a URL.
- update highlighting N for :resize in help
- split Italian-specific syntax into separate help script
- highlight `Note` in parentheses in help
- update 'titlestring' behaviour in documentation for invalid '%' format

closes: vim/vim#15883

6c2fc377bf

Co-authored-by: Milly <milly.ca@gmail.com>
2024-10-17 07:55:55 +08:00
Christian Clason
82b02ae2f2 fix(runtime): clean up one-off scripts
Problem: Some runtime files no longer spark joy.

Solution: Kondo the place up.

Still sparks _some_ joy (moved to new `runtime/scripts` folder):
* `macros/less.*`
* `mswin.vim`
* `tools/emoji_list.lua`

No longer sparks joy (removed):
* `macmap.vim` (gvimrc file; not useful in Nvim)
* `tools/check_colors.vim` (no longer useful with new default colorscheme and treesitter)
* `macros/editexisting.vim` (throws error on current Nvim)
* `macros/justify.vim` (obsolete shim for `packadd! justify`)
* `macros/matchit.vim` (same)
* `macros/shellmenu.vim` (same)
* `macros/swapmous.vim` (same)
2024-10-15 20:50:21 +02:00
zeertzjq
84623dbe93
vim-patch:9.1.0785: cannot preserve error position when setting quickfix list (#30820)
Problem:  cannot preserve error position when setting quickfix lists
Solution: Add the 'u' action for setqflist()/setloclist() and try
          to keep the closes target position (Jeremy Fleischman)

fixes: vim/vim#15839
closes: vim/vim#15841

27fbf6e5e8

Co-authored-by: Jeremy Fleischman <jeremyfleischman@gmail.com>
2024-10-15 18:53:59 +08:00
zeertzjq
dbd172e7e9 vim-patch:5bcfb5a: runtime(doc): add some docs for file-watcher programs
fixes: vim/vim#15733

5bcfb5a30c

Co-authored-by: Christian Brabandt <cb@256bit.org>
2024-10-15 08:21:19 +08:00
zeertzjq
9701cbf036 vim-patch:7b5e52d: runtime(doc): add preview flag to statusline example
Problem:  The standard statusline example is missing the preview flag
          "%w"
Solution: Add the preview flag "%w"

closes: vim/vim#15874

7b5e52d16f

Co-authored-by: saher <msaher.shair@gmail.com>
2024-10-15 08:19:46 +08:00
zeertzjq
6f1601a1b9
vim-patch:9.1.0774: "shellcmdline" doesn't work with getcompletion() (#30750)
Problem:  "shellcmdline" doesn't work with getcompletion().
Solution: Use set_context_for_wildcard_arg() (zeertzjq).

closes: vim/vim#15834

85f36d61e0
2024-10-10 22:48:45 +00:00
zeertzjq
f449a38f6a
vim-patch:9.1.0770: current command line completion is a bit limited (#30728)
Problem:  current command completion is a bit limited
Solution: Add the shellcmdline completion type and getmdcomplpat()
          function (Ruslan Russkikh).

closes: vim/vim#15823

0407d621bb

Co-authored-by: Ruslan Russkikh <dvrussk@yandex.ru>
2024-10-09 08:14:18 +08:00
Justin M. Keyes
61f1b091ea
docs: dev-arch, focusable windows #30510
- 'statuscolumn' is no longer experimental
- add tags for popular searches on neovim.io
2024-10-07 08:27:38 -07:00
Justin M. Keyes
7335988ce6
docs: generate params/returns in builtin.txt #30654 2024-10-07 05:32:49 -07:00
zeertzjq
bf868e76e1
vim-patch:9.1.0762: 'cedit', 'termwinkey' and 'wildchar' may not be parsed correctly (#30704)
Problem:  'cedit', 'termwinkey' and 'wildchar' may not be parsed
          correctly
Solution: improve string_to_key() function in option.c
          (Milly)

- Problem: `^@` raises an error.
  Solution: Store as `<Nul>`.
- Problem: `<t_xx` does not raise an error.
  Solution: Raise an error if closing `>` is missing.
- Problem: Single `<` or `^` raises an error. It is inconvenient for users.
  Solution: They are stored as a single character.

closes: vim/vim#15811

a9c6f90918

Co-authored-by: Milly <milly.ca@gmail.com>
2024-10-07 02:22:52 +00:00
zeertzjq
d0dc2920e1
vim-patch:fd4e47e: runtime(doc): clarify the effect of 'startofline' option (#30701)
fixes: vim/vim#15794

fd4e47e06b

Co-authored-by: Christian Brabandt <cb@256bit.org>
2024-10-07 07:30:50 +08:00
Justin M. Keyes
6628741ada
feat(docs): improve @see meta docstrings #30693 2024-10-06 09:12:35 -07:00
Christian Clason
9788b81d7e fix(runtime): fully port emoji_list to Lua
Problem: `runtime/tools/emoji_list.vim` is a Lua script masquerading as
Vimscript, which is unnecessary now that `:source` works for Lua files.

Solution: Remove Vimscript wrapper.
2024-10-06 12:44:50 +02:00
Justin M. Keyes
056009f741
fix(docs): markdown instead of vimdoc in meta docstrings #30680
LuaLS/meta docstrings expect markdown, not vimdoc. This matters for lists, codeblocks, etc.

Also, line length doesn't matter for docstrings.
2024-10-06 03:24:21 -07:00
Justin M. Keyes
8801b77ed0
fix(docs): missing @returns desc in _meta/api.lua #30673 2024-10-05 08:52:57 -07:00
Justin M. Keyes
b45c50f314
docs: render @since versions, 0 means experimental #30649
An implication of this current approach is that `NVIM_API_LEVEL` should be
bumped when a new Lua function is added.

TODO(future): add a lint check which requires `@since` on all new functions.

ref #25416
2024-10-04 02:13:31 -07:00
James Trew
385fbfb3e7
docs: improve luacats support #30580
Some composite/compound types even as basic as `(string|number)[]` are
not currently supported by the luacats LPEG grammar used by gen_vimdoc.
It would be parsed & rendered as just `string|number`.

Changeset adds better support for these types.
2024-10-03 03:45:51 -07:00
zeertzjq
aeea63081c
vim-patch:ae62fe5: runtime(doc): 'filetype', 'syntax' and 'keymap' only allow alphanumeric + some characters (#30630)
closes: vim/vim#15783

ae62fe5c28

Co-authored-by: Milly <milly.ca@gmail.com>
2024-10-03 06:58:31 +08:00
glepnir
6a2f8958e8
vim-patch:9.1.0754: fixed order of items in insert-mode completion menu (#30619)
Problem:  fixed order of items in insert-mode completion menu
Solution: Introduce the 'completeitemalign' option with default
          value "abbr,kind,menu" (glepnir).

Adding an new option `completeitemalign` abbr is `cia` to custom
the complete-item order in popupmenu.

closes: vim/vim#14006
closes: vim/vim#15760

6a89c94a9e
2024-10-03 06:45:01 +08:00
zeertzjq
2168d772b8
vim-patch:9.1.0752: can set 'cedit' to an invalid value (#30616)
Problem:  can set cedit to an invalid value
Solution: Check that the value is a valid key name
          (Milly)

closes: vim/vim#15778

25732435c5

Co-authored-by: Milly <milly.ca@gmail.com>
2024-10-01 23:39:28 +00:00
Lewis Russell
0fb5299e53 test: refactor exec_lua in xdiff_spec 2024-09-30 11:51:33 +01:00
Lewis Russell
c65646c247 fix(diff): use mmfile_t in linematch
Problem:

Linematch used to use strchr to navigate a string, however strchr does
not supoprt embedded NULs.

Solution:

Use `mmfile_t` instead of `char *` in linematch and introduce `strnchr()`.

Also remove heap allocations from `matching_char_iwhite()`

Fixes: #30505
2024-09-30 11:51:33 +01:00
zeertzjq
c2fb1fc700 vim-patch:9.1.0741: No way to get prompt for input()/confirm()
Problem:  No way to get prompt for input()/confirm()
Solution: add getcmdprompt() function (Shougo Matsushita)
          (Shougo Matsushita)

closes: vim/vim#15667

6908428560

Co-authored-by: Shougo Matsushita <Shougo.Matsu@gmail.com>
2024-09-26 22:15:28 +08:00
Justin M. Keyes
ce7017b850
docs: render @see, @note items in _meta/api.lua #30494 2024-09-25 02:34:13 -07:00
Justin M. Keyes
3f6bc34e66
docs: lua error patterns #30240
Co-authored-by: Mathias Fussenegger <f.mathias@zignar.net>
Co-authored-by: Ananth Bhaskararaman <antsub@gmail.com>
2024-09-24 04:46:50 -07:00
zeertzjq
d831392b15
feat(paste): unify cancel and error behavior (#30476)
Before this PR, the behavior of nvim_paste is:
- When vim.paste() returns false, return false to the client, but treat
  following chunks normally (i.e. rely on the client cancelling the
  paste as expected).
- When vim.paste() throws an error, still return true to the client, but
  drain the following chunks in the stream without calling vim.paste().

There are two problems with such behavior:
- When vim.paste() errors, the client is still supposed to send the
  remaining chunks of the stream, even though they do nothing.
- Having different code paths for two uncommon but similar situations
  complicates maintenance.

This PR makes both the cancel case and the error case return false to
the client and drain the remaining chunks of the stream, which, apart
from sharing the same code path, is beneficial whether the client checks
the return value of nvim_paste or not:
- If the client checks the return value, it can avoid sending the
  following chunks needlessly after an error.
- If the client doesn't check the return value, chunks following a
  cancelled chunk won't be pasted on the server regardless, which leads
  to less confusing behavior.
2024-09-24 07:14:14 +08:00
Justin M. Keyes
737f58e232 refactor(api)!: rename Dictionary => Dict
In the api_info() output:

    :new|put =map(filter(api_info().functions, '!has_key(v:val,''deprecated_since'')'), 'v:val')
    ...

    {'return_type': 'ArrayOf(Integer, 2)', 'name': 'nvim_win_get_position', 'method': v:true, 'parameters': [['Window', 'window']], 'since': 1}

The `ArrayOf(Integer, 2)` return type didn't break clients when we added
it, which is evidence that clients don't use the `return_type` field,
thus renaming Dictionary => Dict in api_info() is not (in practice)
a breaking change.
2024-09-23 14:42:57 +02:00
Evgeni Chasnovski
29bceb4f75
docs(api): nvim_get_runtime_file preserves 'runtimepath' order #30454 2024-09-22 03:51:22 -07:00
zeertzjq
7dbbaaec3f
refactor!: rename 'jumpoptions' flag "unload" to "clean" (#30418)
Follow-up to #29347
2024-09-19 18:05:27 +08:00
glepnir
a0d8c2b86e
docs(eval): update param types of prompt-buffer functions (#30392) 2024-09-16 18:33:35 +08:00
Gregory Anders
98ba65b8be
fix: replace NVIM with Nvim in default titlestring (#30348) 2024-09-11 20:32:08 +00:00
zeertzjq
4b98d38870
vim-patch:d657d3d: runtime(doc): clarify the effect of the timeout for search()-functions (#30337)
related: vim/vim#15657
related: vim/vim#15404

d657d3d8fd

Co-authored-by: Christian Brabandt <cb@256bit.org>
2024-09-11 06:09:58 +08:00
zeertzjq
3d1110674e
vim-patch:9.1.0720: Wrong breakindentopt=list:-1 with multibyte or TABs (#30293)
Problem:  Wrong breakindentopt=list:-1 with multibyte chars or TABs in
          text matched by 'formatlistpat' (John M Devin)
Solution: Use the width of the match text (zeertzjq)

fixes: vim/vim#15634
closes: vim/vim#15635

61a6ac4d00
2024-09-07 10:50:52 +00:00
Justin M. Keyes
61e9137394
docs: misc #28970 2024-09-01 13:01:24 -07:00
Gregory Anders
318c0415d5
fix(ui): correctly pass metadata to get_node_text #30222
Fixes: #30220
2024-09-01 10:15:02 -07:00
bfredl
cfdf68a7ac feat(mbyte): support extended grapheme clusters including more emoji
Use the grapheme break algorithm from utf8proc to support grapheme
clusters from recent unicode versions.

Handle variant selector VS16 turning some codepoints into double-width
emoji. This means we need to use ptr2cells rather than char2cells when
possible.
2024-08-30 11:49:09 +02:00