Commit Graph

6112 Commits

Author SHA1 Message Date
zeertzjq
bc5dfda441
vim-patch:9.0.2041: trim(): hard to use default mask (#25692)
Problem:  trim(): hard to use default mask (partly revert v9.0.2040)
Solution: use default mask when it is empty

The default 'mask' value is pretty complex, as it includes many
characters.  Yet, if one needs to specify the trimming direction, the
third argument, 'trim()' currently requires the 'mask' value to be
provided explicitly.

Currently, an empty 'mask' will make 'trim()' call return 'text' value
that is passed in unmodified.  It is unlikely that someone is using it,
so the chances of scripts being broken by this change are low.

Also, this reverts commit 9.0.2040 (which uses v:none for the default
and requires to use an empty string instead).

closes: vim/vim#13358

8079917447

vim-patch:9.0.2040: trim(): hard to use default mask

Problem:  trim(): hard to use default mask
Solution: Use default 'mask' when it is v:none

The default 'mask' value is pretty complex, as it includes many
characters.  Yet, if one needs to specify the trimming direction, the
third argument, 'trim()' currently requires the 'mask' value to be
provided explicitly.

'v:none' is already used to mean "use the default argument value" in
user defined functions.  See |none-function_argument| in help.

closes: vim/vim#13363

6e6386716f

Co-authored-by: Illia Bobyr <illia.bobyr@gmail.com>
2023-10-18 06:08:14 +08:00
Maria José Solano
3fd7449d5a
fix(treesitter): check that buf is loaded in autocommands (#25679) 2023-10-17 15:34:39 -05:00
zeertzjq
272ef27115
vim-patch:9.0.2035: [security] use-after-free with wildmenu (#25687)
Problem:  [security] use-after-free with wildmenu
Solution: properly clean up the wildmenu when exiting

Fix wildchar/wildmenu/pum memory corruption with special wildchar's

Currently, using `wildchar=<Esc>` or `wildchar=<C-\>` can lead to a
memory corruption if using wildmenu+pum, or wrong states if only using
wildmenu. This is due to the code only using one single place inside the
cmdline process loop to perform wild menu clean up (by checking
`end_wildmenu`) but there are other odd situations where the loop could
have exited and we need a post-loop clean up just to be sure. If the
clean up was not done you would have a stale popup menu referring to
invalid memory, or if not using popup menu, incorrect status line (if
`laststatus=0`).

For example, if you hit `<Esc>` two times when it's wildchar, there's a
hard-coded behavior to exit command-line as a failsafe for user, and if
you hit `<C-\><C-\><C-N>` it will also exit command-line, but the clean
up code would not have hit because of specialized `<C-\>` handling.

Fix Ctrl-E / Ctrl-Y to not cancel/accept wildmenu if they are also
used for 'wildchar'/'wildcharm'. Currently they don't behave properly,
and also have potentially memory unsafe behavior as the logic is
currently not accounting for this situation and try to do both.
(Previous patch that addressed this: vim/vim#11677)

Also, correctly document Escape key behavior (double-hit it to escape)
in wildchar docs as it's previously undocumented.

In addition, block known invalid chars to be set in `wildchar` option,
such as Ctrl-C and `<CR>`. This is just to make it clear to the user
they shouldn't be set, and is not required for this bug fix.

closes: vim/vim#13361

8f4fb007e4

Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-10-17 22:43:42 +08:00
Jaehwang Jung
35f475d0a5
fix(diagnostics): if buffer not loaded, skip handlers that set extmark (#25628)
Problem:
When enabling diagnostics, there can be diagnostics for unloaded buffer,
but some handlers nevertheless attempt to set extmarks in such buffers.

Solution:
* Exit underline/virtual_text handler if buffer is not loaded.
* Don't require is_loaded as precondition for show(), because handlers
  don't necessarily depend on it.
2023-10-16 20:51:36 -05:00
bfredl
a63c67005b
Merge pull request #25394 from famiu/refactor/options/set_option
refactor(options)!: unify interfaces for setting options
2023-10-16 20:41:35 +02:00
Famiu Haque
5df4fdf253 refactor(options)!: make OptionSet v: values use typval
BREAKING CHANGE: This breaks the OptionSet autocommand, as the `v:` values associated with it (`v:option_new`, `v:option_old`, `v:option_oldlocal` and `v:option_oldglobal`) are now the same type as the option, instead of all option values being converted to strings.
2023-10-17 00:08:47 +06:00
James Barford-Evans
a4c4b39d55
fix(man.lua): hardwrapped manpage is not resized #25646
Problem:
If a manpage is opened, its hardwrapped dimensions are not recalculated
after closing then revisiting the same manpage.

Solution:
Unload the manpage when it is hidden. This forces it to be reloaded,
which forces the hard-wrapping to be recalculated when it is revisited.

Fixes: #25457
2023-10-16 09:59:33 -07:00
Maria José Solano
2eecb1b85d
fix(lsp): highlight active parameter in signature help #25663
Fixes #25662
2023-10-16 08:52:48 -07:00
Maria José Solano
c46a6c065e
docs: do not hardcode LSP version in URL #25648 2023-10-16 08:13:37 -07:00
zeertzjq
3222f0ad00
vim-patch:dbf749bd5aae (#25665)
runtime: Fix more typos (vim/vim#13354)

* Fix more typos

* Fix typos in ignored runtime/ directory

dbf749bd5a

Co-authored-by: Viktor Szépe <viktor@szepe.net>
2023-10-16 16:36:25 +08:00
zeertzjq
75b488d3ef
vim-patch:9.0.2025: no cmdline completion for ++opt args (#25657)
Problem:  no cmdline completion for ++opt args
Solution: Add cmdline completion for :e ++opt=arg and :terminal
          [++options]

closes: vim/vim#13319

989426be6e

Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-10-15 17:52:08 +08:00
zeertzjq
d974a3dcbb
vim-patch:9.0.2032: cannot get mouse click pos for tab or virt text (#25653)
Problem:  Cannot accurately get mouse clicking position when clicking on
          a TAB or with virtual text.
Solution: Add a "coladd" field to getmousepos() result.

closes: vim/vim#13335

f5a94d5165
2023-10-15 17:19:01 +08:00
zeertzjq
e5a424d78e
vim-patch:9.0.2030: no max callback recursion limit (#25655)
Problem:  no max callback recursion limit
Solution: bail out, if max call recursion for callback functions
          has been reached.

This checks the 'maxfuncdepth' setting and throws E169 when a callback
function recursively calls itself.

closes: vim/vim#13337
closes: vim/vim#13339

47510f3d65

Co-authored-by: Christian Brabandt <cb@256bit.org>
2023-10-15 17:02:17 +08:00
zeertzjq
aa62579a68
docs: restore accidentally removed line in :h 'ignorecase' (#25651) 2023-10-15 09:05:27 +08:00
Christian Clason
28ef4a4492 vim-patch:7687238e1b0d
runtime(tcsh): Update ftplugin (vim/vim#13327)

Fix b:browsefilter deletion error when calling b:undo_ftplugin.

Fixes vim/vim#13167

7687238e1b

Co-authored-by: dkearns <dougkearns@gmail.com>
2023-10-14 17:07:09 +02:00
Christian Clason
729a9c4c61 vim-patch:9.0.2024: no filetype detection for Debian sources
Problem:  no filetype detection for Debian sources
Solution: Add new deb822sources filetype

closes: vim/vim#13320

bd734c3bea

Co-authored-by: James McCoy <jamessan@jamessan.com>
2023-10-14 16:41:33 +02:00
zeertzjq
20dacacf37
vim-patch:2bbd0d30eebd (#25637)
runtime(doc): Improve command-line completion docs (vim/vim#13331)

* Improve command-line completion docs

Add more details about 'ignorecase' and its effect on cmdline
completion.

Make sure keys used in wildmenu are properly documented and linked in the
keys' documentation entries, and in `:h index` for proper
cross-referencing, as wildmenu popup is slightly different from
insert-mode popup menu.

* Fix docs typos

2bbd0d30ee

Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-10-14 19:28:41 +08:00
zeertzjq
bcda800933
vim-patch:9.0.2022: getmousepos() returns wrong index for TAB char (#25636)
Problem:  When clicking in the middle of a TAB, getmousepos() returns
          the column of the next char instead of the TAB.
Solution: Break out of the loop when the vcol to find is inside current
          char. Fix invalid memory access when calling virtcol2col() on
          an empty line.

closes: vim/vim#13321

b583eda703
2023-10-14 19:18:25 +08:00
Mathias Fußenegger
57ce9b6a92
refactor(lsp): fix luals warnings in tagfunc and add type annotations (#25150) 2023-10-14 11:31:16 +02:00
Mathias Fußenegger
712adacdf5
refactor(lsp): make is_pull in lsp.diagnostic.get_namespace optional (#25156)
Follw up to 63b3408551

`is_pull` should be optional, otherwise it is an API change that
introduces warnings in consumers.

Also fixes the type annotation of `_client_pull_namespaces` where the
key is a string.
2023-10-14 09:47:20 +02:00
Maria José Solano
ee156ca60e
fix(lsp): refactor escaping snippet text (#25611) 2023-10-14 09:06:40 +02:00
zeertzjq
840e1864c2
fix(lsp): handle NUL bytes in popup text (#25612)
Fix #25610
2023-10-12 15:39:39 +08:00
Christian Clason
7474874baa vim-patch:9.0.2011: INI files not detected
Problem:  INI files not detected
Solution: detect uppercase .INI as dosini files

It previo~1 only worked for lower-case .ini files, but upperc~1 .INI is
also somewhat common on account of DOS' old 8.3 upperc~2 only filena~1.

closes: vim/vim#13316

4a82bdfaa8

Co-authored-by: Martin Tournoij <martin@arp242.net>
2023-10-11 23:54:41 +02:00
Maria José Solano
2fde6295df
fix(lsp): display initialization errors (#25409) 2023-10-11 15:38:58 -05:00
sisrfeng
37da0bc0c6
docs: clarify about error in shada (#25594) 2023-10-11 17:58:07 +08:00
Raphael
f79052faef
refactor(float): rename ex_floatclose to ex_fclose (#25596) 2023-10-11 15:03:59 +08:00
Famiu Haque
c4f8be464c docs(style): add guideline for fixing compiler error on switch statement
Problem: Certain compilers (primarily GCC) do not recognize an exhaustive enum switch statement as being exhaustive. This manifests in the form of compiler errors in exhaustive switch statements where each case has a return statement but there isn't a catch-all return statements. These compiler errors are spurious in the context of the Neovim codebase. So #25533 added the `UNREACHABLE` macro to denote apart of the code that's unreachable, which was used after every such switch statement to tell the compiler to treat the switch statement as exhaustive. However, the macro is mentioned nowhere in the style guide,and new contributors would not have any natural way of learning about it as it stands now. This would lead to confusion when they inevitably encounter one of these compiler errors.

Solution: Add a style guideline which shows how to use the `UNREACHABLE` macro to fix these compiler errors.
2023-10-10 22:23:54 +02:00
dundargoc
c3d21ad1bc docs: small fixes
Co-authored-by: Wansmer <wansmer@gmail.com>
Co-authored-by: Andrew Voynov <andrewvoynov.b@gmail.com>
Co-authored-by: David Moberg <david.moberg@mediatek.com>
2023-10-10 19:20:32 +02:00
bfredl
fd39f5ce8c
Merge pull request #25561 from glepnir/9663
feat(float): add fclose command
2023-10-10 16:36:55 +02:00
glepnir
372aa2eb3d feat(float): add fclose command 2023-10-10 21:17:08 +08:00
Famiu Haque
9ff6f73f83 refactor: allow not having a default case for enum
Problem: The style guide states that all switch statements that are not conditional on an enum must have a `default` case, but does not give any explicit guideline for switch statements that are conditional on enums. As a result, a `default` case is added in many enum switch statements, even when the switch statement is exhaustive. This is not ideal because it removes the ability to have compiler errors to easily detect unchanged switch statements when a new possible value for an enum is added.

Solution: Add explicit guidelines for switch statements that are conditional on an enum, clarifying that a `default` case is not necessary if the switch statement is exhaustive. Also refactor pre-existing code with unnecessary `default` cases.
2023-10-10 11:19:41 +01:00
zeertzjq
c40a1c0f41
vim-patch:9.0.2009: cmdline-completion for comma-separated options wrong (#25569)
Problem:  cmdline-completion for comma-separated options wrong
Solution: Fix command-line expansions for options with filenames with
          commas

Fix command-line expansions for options with filenames with commas

Cmdline expansion for option values that take a comma-separated list
of file names is currently not handling file names with commas as the
commas are not escaped. For such options, the commas in file names need
to be escaped (to differentiate from a comma that delimit the list
items). The escaped comma is unescaped in `copy_option_part()` during
option parsing.

Fix as follows:
- Cmdline completion for option values with comma-separated file/folder
  names will not start a new match when seeing `\\,` and will instead
  consider it as one value.
- File/folder regex matching will strip the `\\` when seeing `\\,` to
  make sure it can match the correct files/folders.
- The expanded value will escape `,` with `\\,`, similar to how spaces
  are escaped to make sure the option value is correct on the cmdline.

This fix also takes into account the fact that Win32 Vim handles file
name escaping differently. Typing '\,' for a file name results in it
being handled literally but in other platforms '\,' is interpreted as a
simple ',' and commas need to be escaped using '\\,' instead.

Also, make sure this new logic only applies to comma-separated options
like 'path'. Non-list options like 'set makeprg=<Tab>' and regular ex
commands like `:edit <Tab>` do not require escaping and will continue to
work.

Also fix up documentation to be clearer. The original docs are slightly
misleading in how it discusses triple slashes for 'tags'.

closes: vim/vim#13303
related: vim/vim#13301

54844857fd

Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-10-10 09:15:21 +08:00
zeertzjq
f5eabaa940
fix(path): restore space separation in 'path' (#25571)
Removing this behavior causes more inconsistencies and bugs.
2023-10-10 08:22:32 +08:00
zeertzjq
43f22853fe
docs: fix misplaced mention of 'backupdir' (#25568) 2023-10-10 07:06:34 +08:00
Maria José Solano
c80a3976cb
docs: miscellaneous doc and type fixes (#25554) 2023-10-10 06:34:48 +08:00
Jaehoon Hwang
dacd34364f
feat(ui-ext): make 'mousehide' into proper ui_option (#25532) 2023-10-09 16:48:24 +08:00
Christian Clason
e5855697e9 vim-patch:1e33cd72b60a
runtime: make command name for &iskeywordprg more unique (vim/vim#13297)

See https://github.com/vim/vim/pull/13213/commits by @dkearns:
Rename 'keywordprg' user command to ShKeywordPrg as this is just a
leaking implementation detail.

1e33cd72b6

Co-authored-by: Enno <Konfekt@users.noreply.github.com>
2023-10-08 23:31:49 +02:00
LW
9abced6ad9
fix(lsp): account for border height in max floating popup height (#25539) 2023-10-08 10:09:25 +02:00
Famiu Haque
380870335f docs: use abort() for unreachable default: case in C
Problem: The style guide currently recommends having a `default:` case for switch statements that are not conditional on an enumerated value. Additionally, it recommends using `assert(false)` if `default:` is unreachable. This is problematic because `assert()` only runs on debug builds, which may lead to confusing breakages in release builds. Moreover, this suggestion is followed nowhere in the C code and `abort()` is used everywhere instead.

Solution: Suggest using `abort()` instead of `assert(false)`, that way the program always terminates if a logically unreachable case is reached.
2023-10-07 20:47:55 +06:00
zeertzjq
7e9407490c
Merge pull request #25529 from zeertzjq/vim-9.0.1990
vim-patch:9.0.1990,27e12c7669e3
2023-10-07 07:01:55 +08:00
Christian Clason
e7c268e38f vim-patch:2a281ccca017
runtime(sh): Update ftplugin (vim/vim#13213)

Rename 'keywordprg' user command to ShKeywordPrg as this is just a
leaking implementation detail.

2a281ccca0

Co-authored-by: dkearns <dougkearns@gmail.com>
2023-10-07 00:48:35 +02:00
zeertzjq
92df389f1b vim-patch:27e12c7669e3
runtime(doc): remove E1520 tag (vim/vim#13289)

27e12c7669
2023-10-07 05:54:12 +08:00
zeertzjq
8bb0878013 vim-patch:9.0.1990: strange error number
Problem:  strange error number
Solution: change error number,
          add doc tag for E1507

closes: vim/vim#13270

ea746f9e86

Co-authored-by: Christ van Willegen <cvwillegen@gmail.com>
2023-10-07 05:54:10 +08:00
Aayush Ojha
5db076c7cc
fix(lua): vim.region on linewise selection #25467
fixes #18155
2023-10-06 05:44:50 -07:00
Justin M. Keyes
133e2990ef refactor: cleanup 2023-10-06 14:09:21 +02:00
Leonardo Mello
1dd700a8d9 fix: gf fails on "foo/bar.txt:1:2" on Windows
Problem:
On Windows, "gf" fails on a filepath that has a line:column suffix.
Example:

    E447: Can't find file "src/app/core/services/identity/identity.service.ts:64:23"

Solution:
- Remove ":" from 'isfname' on Windows. Colon is not a valid filename
  character (except for the drive-letter).
- Handle drive letters specially in file_name_in_line().

Fixes #25160
2023-10-06 12:59:58 +02:00
Christian Clason
a6cccd728a vim-patch:0e958410046a
runtime(netrw): diff (`df`) may open the wrong window (vim/vim#13275)

closes: vim/vim#11359

0e95841004

Co-authored-by: KSR-Yasuda <31273423+KSR-Yasuda@users.noreply.github.com>
2023-10-06 10:18:33 +02:00
Christian Clason
ac6d8d0087 vim-patch:f449825ae238
runtime(netrw): Update `.netrwbook` immediately on bookmark change (vim/vim#13276)

closes: vim/vim#9738

f449825ae2

Co-authored-by: KSR-Yasuda <31273423+KSR-Yasuda@users.noreply.github.com>
2023-10-06 10:18:33 +02:00
Christian Clason
1338140ee3 vim-patch:9.0.1978: No filetype detection for just files
Problem:  No filetype detection for just files
Solution: Detect just files (*.just, justfile, etc)

closes: vim/vim#13271

3d90f71b76

vim-patch:b6d01f13: runtime(just): Correct filetype detection pattern and style

Co-authored-by: dundargoc <gocdundar@gmail.com>
2023-10-06 09:52:24 +02:00
Christian Clason
0ff13a6a5a vim-patch:4dbb2669e9ed
runtime(netrw): error when trying to :bd unloaded buffer

closes: vim/vim#13215
closes: vim/vim#13082

4dbb2669e9

Co-authored-by: yasuda <yasuda@kyoto-sr.co.jp>
2023-10-05 09:08:17 +02:00