Commit Graph

6331 Commits

Author SHA1 Message Date
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
bfredl
4e4ad4312e
Merge pull request #25513 from bfredl/cleangrid
refactor(grid): get rid of unbatched grid_puts and grid_putchar
2023-10-06 11:21:46 +02:00
bfredl
a58bb21544 refactor(grid): get rid of unbatched grid_puts and grid_putchar
This finalizes the long running refactor from the old TUI-focused grid
implementation where text-drawing cursor was not separated from the
visible cursor.

Still, the pattern of setting cursor position together with updating a
line was convenient. Introduce grid_line_cursor_goto() to still allow
this but now being explicit about it.

Only having batched drawing functions makes code involving drawing
a bit longer. But it is better to be explicit, and this highlights
cases where multiple small redraws can be grouped together. This was the
case for most of the changed places (messages, lastline, and :intro)
2023-10-06 10:16:30 +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
zeertzjq
5f4f83ba32
vim-patch:9.0.1983: scrolling inactive window not possible with cursorbind (#25507)
Problem:  Scrolling non-current window using mouse is inconsistent
          depending on 'scrollbind'/'scrolloff' and different from GUI
          vertical scrollbar when 'cursorbind' is set.
Solution: Don't move cursor in non-current windows for 'cursorbind' if
          cursor in the current window didn't move.

closes: vim/vim#13219
closes: vim/vim#13210

8e5f26ec6a
2023-10-05 07:48:37 +08:00
zeertzjq
d7a240b1e9
vim-patch:9.0.1981: not being able to scroll up in diff mode (#25506)
Problem:  Cannot scroll up in diff mode with many filler lines and zero
          'scrolloff'.
Solution: Invalidate w_cline_row before calling comp_botline().

closes: vim/vim#13256

0583491277
2023-10-05 07:36:14 +08:00
bfredl
3079fa1f9f
Merge pull request #25491 from glepnir/25474
fix(highlight): attr set all when normal attr changed
2023-10-04 16:24:33 +02:00
Justin M. Keyes
29fe883aa9
feat: ignore swapfile for running Nvim processes #25336
Problem:
The swapfile "E325: ATTENTION" dialog is displayed when editing a file
already open in another (running) Nvim. Usually this behavior is
annoying and irrelevant:
- "Recover" and the other options ("Open readonly", "Quit", "Abort") are
  almost never wanted.
- swapfiles are less relevant for "multi-Nvim" since 'autoread' is
  enabled by default.
  - Even less relevant if user enables 'autowrite'.

Solution:
Define a default SwapExists handler which does the following:
1. If the swapfile is owned by a running Nvim process, automatically
   chooses "(E)dit anyway" (caveat: this creates a new, extra swapfile,
   which is mostly harmless and ignored except by `:recover` or `nvim -r`.
2. Shows a 1-line "ignoring swapfile..." message.
3. Users can disable the default SwapExists handler via `autocmd! nvim_swapfile`.
2023-10-04 06:31:25 -07:00
glepnir
d4872377fe fix(highlight): attr set all when normal attr changed 2023-10-04 18:42:13 +08:00
Leonardo Mello
1e7e9ee91f
fix(path): accept special characters on Windows (#25424) 2023-10-04 06:04:19 +08:00
bfredl
70ec8d60e0
Merge pull request #25470 from bfredl/msg_display
refactor(message): simplify msg_puts_display and use batched grid updates
2023-10-03 20:56:43 +02:00
bfredl
a9a48d6b5f refactor(message): simplify msg_puts_display and use batched grid updates
msg_puts_display was more complex than necessary in nvim, as in
nvim, it no longer talks directly with a terminal.

In particular we don't need to scroll the grid before emiting the last
char. The TUI already takes care of things like that, for terminals
where it matters.
2023-10-03 15:20:09 +02:00
zeertzjq
b2a8a93147
fix(api): avoid immediate TextChanged with nvim_create_buf (#25492) 2023-10-03 20:54:42 +08:00
zeertzjq
3af59a415c
fix(treesitter): make Visual hl work consistently with foldtext (#25484)
Problem:  Visual highlight is inconsistent on a folded line with
          treesitter foldtext.
Solution: Don't added Folded highlight as it is already in background.
2023-10-03 13:07:03 +08:00
zeertzjq
04af9d49ee
test(fileio_spec): fix files not cleaned up properly (#25483) 2023-10-03 12:13:04 +08:00
zeertzjq
e115732465
fix(terminal): check terminal size at end of screen update (#25480) 2023-10-03 10:23:03 +08:00
zeertzjq
bd8550ddca
vim-patch:9.0.1973: Clean up cmdline option completion code (#25477)
Problem:  Clean up cmdline option completion code
Solution: Fix various minor problems

- Fix manual array size calculations to just use `ARRAY_LENGTH()`.
- Fix unintentional typo in comments due to copy-paste error.
- Fix assert_equal() usages to pass the expected value to first
  parameter instead of 2nd one to avoid confusion.
- Fix signed vs unsigned warnings
- Correct misplaced comments about set_op_T and set_prefix_T
  and fix a typo in another comment

closes: vim/vim#13249
closes: vim/vim#13237

6d11347260

N/A patch:
vim-patch:9.0.1976: style: space before tab in optionstr.c

Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-10-03 07:45:37 +08:00
zeertzjq
1101cfeb34
vim-patch:9.0.1972: win32: missing '**' expansion test (#25476)
Problem:  win32: missing '**' expansion test (after v9.0.1947)
Solution: Add test for MS-Windows

win32: Add "**" test

Vim supports "**" on MS-Windows. However, it is not tested by
`Test_glob_extended_bash`.

Unlike Unix, it doesn't use 'shell' and doesn't support {,} expansion.
So, I added as a separate test.

related: vim/vim#13205
closes: vim/vim#13250

4a1ad55564

Co-authored-by: Ken Takata <kentkt@csc.jp>
2023-10-03 07:24:54 +08:00
Maria José Solano
eb1f0e8fcc feat(lsp)!: replace snippet parser by lpeg grammar 2023-10-02 22:21:35 +02:00
Mathias Fußenegger
4a09c178a1
feat(lsp): fallback to code-action command on resolve failure (#25464)
The haskell-language-server supports resolve only for a subset of code
actions. For many code actions trying to resolve the `edit` property
results in an error, but the unresolved action already contains a
command that can be executed without issue.

The protocol specification is unfortunately a bit vague about this,
and what the haskell-language-server does seems to be valid.

Example:

    newtype Dummy = Dummy Int
    instance Num Dummy where

Triggering code actions on "Num Dummy" and choosing "Add placeholders
for all missing methods" resulted in:

    -32601: No plugin enabled for SMethod_CodeActionResolve, potentially available: explicit-fields, importLens, hlint, overloaded-record-dot

With this change it will insert the missing methods:

    instance Num Dummy where
      (+) = _
      (-) = _
      (*) = _
      negate = _
      abs = _
      signum = _
      fromInteger = _
2023-10-02 22:14:19 +02:00
Till Bungert
9ce1623837
feat(treesitter): add foldtext with treesitter highlighting (#25391) 2023-10-01 14:10:51 -05:00
zeertzjq
01c51a4913 feat(completion): support completing more string options 2023-10-01 20:00:23 +08:00
zeertzjq
5821c857e0 vim-patch:9.0.1968: cmdline completion should consider key option
Problem:  cmdline completion should consider key option
Solution: Disable cmdline completion for key option, slightly
          refactor how P_NO_CMD_EXPAND is handled

Harden crypto 'key' option: turn off cmdline completion, disable set-=

"set-=" can be used maliciously with a crypto key, as it allows an
attacker (who either has access to the computer or a plugin author) to
guess a substring by observing the modified state. Simply turn off
set+=/-=/^= for this option as there is no good reason for them to be
used.

Update docs to make that clear as well.

Also, don't allow cmdline completion for 'key' as it just shows *****
which is not useful and confusing to the user what it means (if the user
accidentally hits enter they will have replaced their key with "*****"
instead).

Move logic to better location, don't use above 32-bit for flags

Move P_NO_CMD_EXPAND to use the unused 0x20 instead of going above
32-bits, as currently the flags parameter is only 32-bits on some
systems. Left a comment to warn that future additions will need to
change how the flags work either by making it 64-bit or split into two
member vars.

Also, move the logic for detecting P_NO_CMD_EXPAND earlier so it's not
up to each handler to decide, and you won't see the temporary "..." that
Vim shows while waiting for completion handler to complete.

closes: vim/vim#13224

6ee7b521fa

Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-10-01 20:00:23 +08:00
zeertzjq
81be840768 vim-patch:9.0.1961: 'listchars' completion misses "multispace" and "leadmultispace"
Problem:  Cmdline completion for 'listchars' fields doesn't include
          "multispace" and "leadmultispace" (after 9.0.1958).
Solution: Include "multispace" and "leadmultispace" in lcstab.

closes: vim/vim#13225

1f025b01e2
2023-10-01 20:00:23 +08:00
zeertzjq
f06af5e669 vim-patch:9.0.1958: cannot complete option values
Problem:  cannot complete option values
Solution: Add completion functions for several options

Add cmdline tab-completion for setting string options

Add tab-completion for setting string options on the cmdline using
`:set=` (along with `:set+=` and `:set-=`).

The existing tab completion for setting options currently only works
when nothing is typed yet, and it only fills in with the existing value,
e.g. when the user does `:set diffopt=<Tab>` it will be completed to
`set diffopt=internal,filler,closeoff` and nothing else. This isn't too
useful as a user usually wants auto-complete to suggest all the possible
values, such as 'iblank', or 'algorithm:patience'.

For set= and set+=, this adds a new optional callback function for each
option that can be invoked when doing completion. This allows for each
option to have control over how completion works. For example, in
'diffopt', it will suggest the default enumeration, but if `algorithm:`
is selected, it will further suggest different algorithm types like
'meyers' and 'patience'. When using set=, the existing option value will
be filled in as the first choice to preserve the existing behavior. When
using set+= this won't happen as it doesn't make sense.

For flag list options (e.g. 'mouse' and 'guioptions'), completion will
take into account existing typed values (and in the case of set+=, the
existing option value) to make sure it doesn't suggest duplicates.

For set-=, there is a new `ExpandSettingSubtract` function which will
handle flag list and comma-separated options smartly, by only suggesting
values that currently exist in the option.

Note that Vim has some existing code that adds special handling for
'filetype', 'syntax', and misc dir options like 'backupdir'. This change
preserves them as they already work, instead of converting to the new
callback API for each option.

closes: vim/vim#13182

900894b09a

Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-10-01 20:00:23 +08:00
bfredl
9b3045103f
Merge pull request #25455 from bfredl/highlight_namespace_getters
feat(ui): allow to get the highlight namespace. closes #24390
2023-10-01 10:39:31 +02:00
zeertzjq
2da66f1f71
vim-patch:9.0.1967: xattr errors not translated (#25454)
Problem:  xattr errors not translated
Solution: mark for translation, consistently capitalize
          first letter.

closes: vim/vim#13236

7ece036d72
2023-10-01 16:29:55 +08:00
Daniel Steinberg
2615ed879e feat(ui): allow to get the highlight namespace 2023-10-01 10:02:36 +02:00
zeertzjq
5c60fbe9db vim-patch:9.0.1963: Configure script may not detect xattr
Problem:  Configure script may not detect xattr correctly
Solution: include sys/xattr instead of attr/xattr,
          make Test_write_with_xattr_support() test
          xattr feature correctly

This also applies to the Smack security feature, so change the include
and configure script for it as well.

closes: vim/vim#13229

6de4e58cf2
2023-09-30 22:09:55 +08:00
zeertzjq
f6e72c3dfe vim-patch:9.0.1962: No support for writing extended attributes
Problem:  No support for writing extended attributes
Solution: Add extended attribute support for linux

It's been a long standing issue, that if you write a file with extended
attributes and backupcopy is set to no, the file will loose the extended
attributes.

So this patch adds support for retrieving the extended attributes and
copying it to the new file. It currently only works on linux, mainly
because I don't know the different APIs for other systems (BSD, MacOSX and
Solaris).  On linux, this should be supported since Kernel 2.4 or
something, so this should be pretty safe to use now.

Enable the extended attribute support with normal builds.

I also added it explicitly to the :version output as well as make it
able to check using `:echo has("xattr")`, to have users easily check
that this is available.

In contrast to the similar support for SELINUX and SMACK support (which
also internally uses extended attributes), I have made this a FEAT_XATTR
define, instead of the similar HAVE_XATTR.

Add a test and change CI to include relevant packages so that CI can
test that extended attributes are correctly written.

closes: vim/vim#306
closes: vim/vim#13203

e085dfda5d

Co-authored-by: Christian Brabandt <cb@256bit.org>
2023-09-30 22:09:55 +08:00
zeertzjq
a4132e1d62
test(unit): move statusline tests to statusline_spec.lua (#25441) 2023-09-30 20:38:04 +08:00
bfredl
578d634176
Merge pull request #25386 from glepnir/toggle_float
feat(float): support toggle show float window
2023-09-30 13:40:35 +02:00
glepnir
4200a0f167 feat(float): support toggle show float window 2023-09-30 18:30:23 +08:00
zeertzjq
dc6d0d2daf
refactor: reorganize option header files (#25437)
- Move vimoption_T to option.h
- option_defs.h is for option-related types
- option_vars.h corresponds to Vim's option.h
- option_defs.h and option_vars.h don't include each other
2023-09-30 14:41:34 +08:00
zeertzjq
5f2d0b9329
test(old): don't check for $CLANG_SANITIZER (#25432)
Functional tests don't check for an environment variable before printing
ASAN logs, so oldtests shouldn't either.
2023-09-30 08:35:29 +08:00
zeertzjq
dbfdb52ea8
vim-patch:9.0.1956: Custom completion skips orig cmdline if it invokes glob() (#25427)
Problem:  Custom cmdline completion skips original cmdline when pressing
          Ctrl-P at first match if completion function invokes glob().
Solution: Move orig_save into struct expand_T.

closes: vim/vim#13216

28a23602e8
2023-09-30 06:30:10 +08:00
dundargoc
af7d317f3f refactor: remove long
long is 32-bits even on 64-bit windows which makes the type suboptimal
for a codebase meant to be cross-platform.
2023-09-29 14:56:34 +02:00
James McCoy
9afbfb4d64 fix(unittests): ignore __s128 and __u128 types in ffi
Linux added these types to their userspace headers in [6.5], which
causes unit tests to fail like

```
-------- Running tests from test/unit/api/private_helpers_spec.lua
RUN       vim_to_object converts true: 17.00 ms ERR
test/unit/helpers.lua:748: test/unit/helpers.lua:732: (string) '
test/unit/helpers.lua:264: ';' expected near '__s128' at line 194'
exit code: 256

stack traceback:
	test/unit/helpers.lua:748: in function 'itp_parent'
	test/unit/helpers.lua:784: in function <test/unit/helpers.lua:774>
```

Since we don't use these types, they can be ignored to avoid LuaJIT's C
parser choking on them.

[6.5]: 224d80c584
2023-09-28 22:36:14 -04:00
zeertzjq
7ec20a4082
vim-patch:9.0.1950: Vim9: error codes spread out (#25405)
Problem:  Vim9: error codes spread out
Solution: group them together and reserve 100
          more for future use

Reserve 100 error codes for future enhancements to the Vim9 class
support

closes: vim/vim#13207

413f83990f

Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
2023-09-29 06:52:02 +08:00
zeertzjq
3465e0daa0 vim-patch:9.0.1947: Bash Expansion test fails on Windows/MacOS
Problem:  Bash Expansion test fails on Windows/MacOS
Solution: Disable Test_glob_extended_bash for now

This test doesn't work on Windows even if bash can be executed, since
the globstar functionality has only been enabled in Unix builds of Vim
(Commit 9eb1ce531527a7177d16373b0f8689bbcd3d5f73, patch 9.0.1946).

closes: vim/vim#13205

03ca4002c1

Co-authored-by: Ken Takata <kentkt@csc.jp>
2023-09-29 06:07:27 +08:00
zeertzjq
92e40f8d18 vim-patch:9.0.1946: filename expansion using ** in bash may fail
Problem:  filename expansion using ** in bash may fail
Solution: Try to enable the globstar setting

Starting with bash 4.0 it supports extended globbing using the globstar
shell option. This makes matching recursively below a certain directory
using the ** pattern work as expected nowadays.  However, we need to
explicitly enable this using the 'shopt -s globstar' bash command.

So let's check the bash environment variable $BASH_VERSINFO (which is
supported since bash 3.0 and conditionally enable the globstar option,
if the major version is at least 4. For older bashs, this at least
shouldn't cause errors (unless one is using really ancient bash 2.X or
something).

closes: vim/vim#13002
closes: vim/vim#13144

9eb1ce5315

Co-authored-by: Christian Brabandt <cb@256bit.org>
2023-09-29 06:07:27 +08:00
zeertzjq
7f58b2bb6a vim-patch:9.0.0607: verbose echo message test fails on Mac OS
Problem:    Verbose echo message test fails on Mac OS.
Solution:   Skip the test on Mac OS.

f802767df7

Co-authored-by: Bram Moolenaar <Bram@vim.org>
2023-09-29 06:07:27 +08:00
zeertzjq
28ffd96c9b
test: decoration provider with wrapped lines (#25404) 2023-09-28 20:20:25 +08:00
Rory Nesbitt
a66b0fdfaa
feat: NVIM_APPNAME supports relative paths #25233
Problem:
NVIM_APPNAME does not allow path separators in the name, so relative
paths can't be used:

    NVIM_APPNAME="neovim-configs/first-config" nvim
    NVIM_APPNAME="neovim-configs/second-config" nvim

Solution:
Let NVIM_APPNAME be a relative path. Absolute paths are not supported.

fix #23056
fix #24966
2023-09-27 10:09:55 -07:00
bfredl
26d6f03023
Merge pull request #25374 from bfredl/batchupdate
refactor(grid): use batched updates for more things
2023-09-27 13:21:29 +02:00
zeertzjq
10e57ad4cb
vim-patch:8.2.3467: CursorHoldI event interferes with "CTRL-G U" (#25383)
Problem:    CursorHoldI event interferes with "CTRL-G U". (Naohiro Ono)
Solution:   Restore the flag for "CTRL-G U" after triggering CursorHoldI.
            (closes vim/vim#8937)

5a9357d0bf

Co-authored-by: Bram Moolenaar <Bram@vim.org>
2023-09-27 18:58:43 +08:00
zeertzjq
b65f4151d9
vim-patch:8.2.3517: TextChanged does not trigger after TextChangedI (#25384)
Problem:    TextChanged does not trigger after TextChangedI.
Solution:   Store the tick separately for TextChangedI. (Christian Brabandt,
            closes vim/vim#8968, closes vim/vim#8932)

db3b44640d

Co-authored-by: Christian Brabandt <cb@256bit.org>
2023-09-27 18:51:40 +08:00
bfredl
10cabf7877 refactor(grid): use batched updates for statusline and ruler 2023-09-27 11:31:45 +02:00