Commit Graph

24483 Commits

Author SHA1 Message Date
Sean Dewar
bcdbf77537
fix(lsp): check method is supported when range formatting (#21970)
`vim.lsp.buf.format()` silently did nothing if no servers supported
`textDocument/rangeFormatting` when formatting with a range.

Issue found by `@hwrd:matrix.org` in the Matrix chat.
2023-01-24 07:15:43 +01:00
zeertzjq
7126d9b8c7
refactor(window): remove aucmd_win check from one_window() (#21972)
In most places where one_window() or last_window() is called, aucmd_win
has already been checked, so there is no need to check for it again.

The only place where this isn't checked is when using `:wincmd T`.
Before this PR using `:wincmd T` in an aucmd_win will give a warning
when there is only one non-floating window, but E813 error if there are
multiple. Now it consistently gives E813 error.
2023-01-24 11:29:37 +08:00
zeertzjq
fa12b9ca2b
vim-patch:partial:9.0.1237: code is indented more than necessary (#21971)
Problem:    Code is indented more than necessary.
Solution:   Use an early return where it makes sense. (Yegappan Lakshmanan,
            closes vim/vim#11858)

6ec6666047

Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
2023-01-24 08:43:51 +08:00
zeertzjq
dbb6c7f1b8
vim-patch:9.0.1236: code in same_leader() can be simplified (#21968)
Problem:    Code in same_leader() can be simplified.
Solution:   Simplify code that is executed only once. (closes vim/vim#11867)

9cbf791995
2023-01-24 07:40:22 +08:00
dundargoc
322c83896d
build: remove unnecessary unit test code (#21940)
The files generated by test/includes/CMakeLists.txt have been unused
since commit c49e22d396. The unittests include the headers in
test/includes directly without any processing, meaning that the
CMakeLists.txt file is no longer necessary.
2023-01-24 00:03:25 +01:00
dundargoc
5a94d24095
fix: add manifest file to correctly determine Windows version (#21953)
In Windows 8.1 and later, GetVersionEx does not automatically give the
correct information if a manifest file doesn't explicitly mention we
support that version. This will enable further detection for Windows 8.1
and Windows 10/11 when using windowsversion(), with an easy way to add
future versions. A list of all operating system versions can be found
here:
https://learn.microsoft.com/en-us/windows/win32/sysinfo/operating-system-version
2023-01-23 23:47:06 +01:00
Lewis Russell
f08051c2e6
feat!: make iconv a non-optional dep 2023-01-23 16:33:45 +00:00
zeertzjq
3b75485043
revert: "shada/context: fully remove jumplist duplicates #10898" (#21874)
This reverts commit 8b8ecf44f2.
It is causing performance problems on exit.
Fix #21082.
2023-01-23 19:32:27 +08:00
zeertzjq
0371d0f7af
refactor(win_close): remove "force", don't pass on "free_buf" (#21921)
Problem:
The "force" flag of win_close() complicates the code and adds edge cases
where it is not clear what the correct behavior should be.
The "free_buf" flag of win_close() is passed on to float windows when
closing the last window of a tabpage, which doesn't make much sense.

Solution:
Remove the "force" flag and always close float windows as if :close! is
used when closing the last window of a tabpage, and set the "free_buf"
flag for a float window based on whether its buffer can be freed.
As 'hidden' is on by default, this change shouldn't affect many people.
2023-01-23 18:55:11 +08:00
zeertzjq
d58bf4ff30
perf(completion): use one call to globpath() for .vim and .lua #21942
Test using the following test script (timings with ASAN):

    let start = reltime()
    for i in range(100)
      call getcompletion('', 'filetype')
    endfor
    echomsg reltimefloat(reltime(start))

Without this PR: 3.251825 seconds
With this PR: 2.747285 seconds
2023-01-23 02:42:37 -08:00
Mathias Fußenegger
45d511574c
project: "steps to reproduce" in lsp_bug_report #21932 2023-01-23 02:11:53 -08:00
Enan Ajmain
b36b58d0d4
fix(Windows): restore console title at exit #21922
Fixes #21404
2023-01-23 01:45:18 -08:00
Arnout Engelen
cb757f2663
build: make generated source files reproducible #21586
Problem:
Build is not reproducible, because generated source files (.c/.h/) are not
deterministic, mostly because Lua pairs() is unordered by design (for security).

https://github.com/LuaJIT/LuaJIT/issues/626#issuecomment-707005671
https://www.lua.org/manual/5.1/manual.html#pdf-next
> The order in which the indices are enumerated is not specified [...]
>
>> The hardening of the VM deliberately randomizes string hashes. This in
>> turn randomizes the iteration order of tables with string keys.

Solution:
- Update the code generation scripts to be deterministic.
    - That is only a partial solution: the exported function
      (funcs_metadata.generated.h) and ui event
      (ui_events_metadata.generated.h) metadata have some mpack'ed
      tables, which are not serialized deterministically.
    - As a workaround, introduce `PRG_GEN_LUA` cmake setting, so you can
      inject a modified build of luajit (with LUAJIT_SECURITY_PRN=0)
      that preserves table order.
    - Longer-term we should change the mpack'ed data structure so it no
      longer uses tables keyed by strings.

Closes #20124

Co-Authored-By: dundargoc <gocdundar@gmail.com>
Co-Authored-By: Arnout Engelen <arnout@bzzt.net>
2023-01-23 01:26:46 -08:00
Lucas Merritt
da671b21cc
refactor(PVS/V1048): remove redundant assignment (#21871) 2023-01-23 11:42:16 +08:00
luukvbaal
323ea17a19
fix(extmarks): problems with folded virtual lines (#21930)
Problem:    When a folded line has virtual lines attached, the following
            problems occur:
              - The virtual lines are drawn empty.
              - The 'foldtext' line is drawn empty.
              - The cursor is drawn incorrectly.
Solution:   Check whether virtual lines belong to a folded line.

Fix #17027
Fix #19557
Fix #21837

Co-authored-by: zeertzjq <zeertzjq@outlook.com>
2023-01-23 07:43:04 +08:00
zeertzjq
0f633ff494
vim-patch:9.0.1233: search() loops forever if "skip" is TRUE for all matches (#21956)
Problem:    search() loops forever if "skip" is TRUE for all matches.
Solution:   Keep the position of the first match.

3d79f0a430

Co-authored-by: Bram Moolenaar <Bram@vim.org>
2023-01-23 07:36:01 +08:00
Amaan Qureshi
1b642648f6
vim-patch:9.0.1230: Apache Thrift files are not recognized (#21955)
Problem:    Apache thrift files are not recognized.
Solution:   Add a pattern for thrift files. (Amaan Qureshi, closes vim/vim#11859)

f3da4c8427
2023-01-23 07:08:08 +08:00
dundargoc
e5a537c885
fix: use correct number for INT_MAX (#21951)
Actually use INT_MAX rather than a number to prevent these types of
situations to begin with.
2023-01-23 06:08:38 +08:00
Mathias Fußenegger
8e52d8a394
fix(lsp): assert workspace/applyEdit receives params (#21945)
According to the specification `workspace/applyEdit` must be called with
`ApplyWorkspaceEditParams`.

So far the client just returned, which could lead to a misleading error
on the server side because `workspace/applyEdit` must respond with a
`ApplyWorkspaceEditResult`.

This adds an assertion to clarify that the server is violating the
specification.

See https://github.com/neovim/neovim/issues/21925
2023-01-22 18:54:09 +01:00
dundargoc
63e67468b4
build: use CMAKE_POSITION_INDEPENDENT_CODE instead of -fPIC (#21947)
It's simpler to let cmake figure out what flags to add to each platforms
to create position independent code rather than handling it ourselves.

Also remove code that sets POSITION_INDEPENDENT_CODE property on SHARED
and MODULE libraries, as it's already on by default.
2023-01-22 18:02:02 +01:00
Matthieu Coudron
151b9fc52e
feat(treesitter): show filetype associated with parser (#17633)
to ease debug. At one point I had an empty filetype and the current message was not helpful enough
2023-01-22 16:51:17 +01:00
Amaan Qureshi
80bede1dfc
vim-patch:9.0.1229: Cap'n Proto files are not recognized (#21950)
Problem:    Cap'n Proto files are not recognized.
Solution:   Add a pattern and the "capnp" filetype. (Amaan Qureshi,
            closes vim/vim#11862)

040e795e8d
2023-01-22 22:08:33 +08:00
zeertzjq
2ef913468b
vim-patch:9.0.1228: fuzzy menu completion is only tested in the GUI (#21948)
Problem:    Fuzzy menu completion is only tested in the GUI.
Solution:   Make fuzzy menu completion test work without GUI.
            (closes vim/vim#11861)

145a6afe3a
2023-01-22 21:13:52 +08:00
zeertzjq
18fb669b9b
fix(completion): include lua syntaxes in :ownsyntax completion (#21941)
This just removes DIP_LUA and always executes its branches.
Also add tests for cmdline completion for other lua runtime files.
2023-01-22 11:19:58 +08:00
zeertzjq
108452aaba
vim-patch:9.0.1225: reading past the end of a line when formatting text (#21937)
Problem:    Reading past the end of a line when formatting text.
Solution:   Check for not going over the end of the line.

11977f9175

Co-authored-by: Bram Moolenaar <Bram@vim.org>
2023-01-22 07:41:39 +08:00
zeertzjq
0f52e2c849
vim-patch:8.2.0382: some tests fail when run under valgrind (#21936)
Problem:    Some tests fail when run under valgrind.
Solution:   Increase timeouts.

353c351bd2

Cherry-pick Test_pum_with_preview_win() from patch 8.2.0011.

Co-authored-by: Bram Moolenaar <Bram@vim.org>
2023-01-21 20:50:46 +08:00
zeertzjq
fb805bb8b7
fix(remote): don't leak memory on failure to connect to server (#21931)
Also fix the race between output and resize in the test for this.
2023-01-21 18:54:17 +08:00
zeertzjq
eec979ca81
test(tui_spec): don't expect exact screen in rapid resize test (#21935)
There may be a race between resizes, so don't expect exact screen.
Expect window width instead.
2023-01-21 18:15:38 +08:00
zeertzjq
e336251f2b
test(tui_spec): make rapid resize test test what it wants to test (#21933)
Actually execute the command.
Don't use assert_alive() as it checks the host session instead of the
child session. Use screen:expect() instead.
2023-01-21 17:11:02 +08:00
dundargoc
9a81ce6854
build: bump MSVC warning to level two (#21890) 2023-01-21 09:55:10 +01:00
kishii
7ef5e363d3
feat(lsp): add triggerKind option for vim.lsp.buf.code_action (#21905) 2023-01-21 08:22:34 +01:00
zeertzjq
e86d2734a9
refactor: use uint8_t for blobs and ga_append() (#21916)
A blob is used as a sequence of bytes and usually accessed individually,
not as as a NUL-terminuated string, so uint8_t should be better.

Not sure about ga_append(), but using uint8_t leads to fewer casts.
2023-01-21 09:24:09 +08:00
zeertzjq
1c16d0994d
refactor: change char_u to uint8_t or char in sha256.c/undo.c (#21914)
Use uint8_t for bytes in hashes as it doesn't make sense for them to be signed.
2023-01-21 08:58:57 +08:00
zeertzjq
efe5ce6fa8
vim-patch:9.0.1223: cannot use setcellwidths() below 0x100 (#21929)
Problem:    Cannot use setcellwidths() below 0x100.
Solution:   Also accept characters between 0x80 and 0x100. (Ken Takata,
            closes vim/vim#11834)

7193323b77

Co-authored-by: K.Takata <kentkt@csc.jp>
2023-01-21 08:44:14 +08:00
dundargoc
4c5c6ca800
build: various cmake fixes (#21902)
* build: various cmake refactors and simplifications

- Add STATUS keyword to message to ensure messages are shown in the
  correct order.
- Remove DEPS_CXX_COMPILER as we don't rely on C++ for any of our
  dependencies.
- Simplify how msgpack and luv configure options are constructed.
- Rely on the default installation for luv instead of manually passing
  configure, build and install commands.
- Simplify return code conditional.

* build: remove CMAKE_OSX_ARCHITECTURES_ALT_SEP workaround

CMAKE_OSX_ARCHITECTURES_ALT_SEP was defined as a workaround to prevent
the shell from interpreting `;`, which CMake uses as a list separator.
However, the same thing can be achieved by instead passing
CMAKE_OSX_ARCHITECTURES as a cache variable instead, which is a more
idiomatic way of achieving the same thing.

* build: define CMAKE_BUILD_TYPE before adding it to BUILD_TYPE_STRING

The problem with the current setup is that CMAKE_BUILD_TYPE is defined
after BUILD_TYPE_STRING. BUILD_TYPE_STRING will then be empty on the
first run, meaning that dependencies are built without a build type.
However, since CMAKE_BUILD_TYPE is a cache variable its value will
persist in subsequent runs. On the second run BUILD_TYPE_STRING will
have the correct value, but it's a different value from the ones the
dependencies were built with. This will force some dependencies to be
built again.

Fixes https://github.com/neovim/neovim/issues/21672.
2023-01-20 23:48:46 +01:00
Sizhe Zhao
c41214c7d4
docs: docs: use codeblocks in runtime/doc/options.txt (#21919)
ensure correct parsing with tree-sitter

Co-authored-by: zeertzjq <zeertzjq@outlook.com>
2023-01-20 17:29:15 +01:00
Raphael
d8d39344e3
fix(lsp): fix removed param value in add_workspace_folder (#21915) 2023-01-20 07:59:31 +01:00
zeertzjq
51d082b466
vim-patch:9.0.0358: 'breakindent' does not indent non-lists (#21913)
Problem:    'breakindent' does not indent non-lists with
            "breakindentopt=list:-1".
Solution:   Adjust indent computation. (Maxim Kim, closes vim/vim#11038)

119167265e

Co-authored-by: Maxim Kim <habamax@gmail.com>
2023-01-20 10:35:52 +08:00
zeertzjq
0481f04ec9
test(syn_attr_spec): add more information (#21912)
This makes it clear on test failure what the attributes are.
2023-01-20 10:03:29 +08:00
luukvbaal
999bb983f0
perf(statuscolumn): only fill click defs array once per redraw (#21884)
Problem:    'statuscolumn' click definitions are cleared, evaluated,
            allocated and filled each redraw for every row in a window.
            This despite the fact that we only store a single click
            definition array for the entire column as opposed to one
            for each row.
Solution:   Only fill the 'statuscolumn' click definition array once per
            window per redraw.

Resolve https://github.com/neovim/neovim/issues/21767.
2023-01-20 07:47:02 +08:00
dundargoc
775e292290
build: remove nvim as a dependency of unittests (#21903)
Unittests rely on nvim-test and not nvim, leading to both nvim and
nvim-test being compiled each time a file is changed. Furthermore, the
dependencies are already specified by CMakeLists.txt and shouldn't need
to be specified in Makefile as it's only meant to be syntactic sugar.
2023-01-19 22:12:27 +01:00
Lewis Russell
5f3b76d5ce
refactor(highlight_group.c): reduce scope of locals 2023-01-19 15:54:59 +00:00
dundargoc
4c531714ff
refactor: replace char_u with char 25 (#21838)
refactor: replace char_u with char

Work on https://github.com/neovim/neovim/issues/459
2023-01-19 22:25:56 +08:00
zeertzjq
adfad50ac0
fix(rpc): don't parse msgpack if buflen is 0 (#21899)
This prevents `buflen` from becoming a very large number when it is 0
when calling mpack_rtoken().
2023-01-19 20:38:29 +08:00
dundargoc
363d153bb9
fix: pass value instead of pointer to isalpha (#21898) 2023-01-19 18:48:49 +08:00
dundargoc
00a976129b
build: enable cmake workflow presets (#21860)
Workflow presets allows combining configure, build, test and packaging
steps and makes it possible to run everything in a single command. So

cmake --preset iwyu
cmake --build --preset iwyu

instead becomes

cmake --workflow --preset iwyu

Workflow presets requires at least cmake version 3.25 to use.
2023-01-19 10:34:45 +01:00
zeertzjq
6e3890f4ce
vim-patch:8.2.4655: cmdline completion popup menu positioned wrong (#21894)
Problem:    Command line completion popup menu positioned wrong when using a
            terminal window.
Solution:   Position the popup menu differently when editing the command line.
            (Yegappan Lakshmanan, closes vim/vim#10050, closes vim/vim#10035)

1104a6d0c2

The test in the patch looks a bit hard to understand.
Add a Lua test that is more straightforward.

Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
2023-01-19 15:13:27 +08:00
zeertzjq
93adf74a03
refactor(eval.c): factor out get_number_tv() (#21893)
It was refactored into a separate function in Vim in patch 8.2.0149.
2023-01-19 13:27:36 +08:00
zeertzjq
42e9a09a44
Merge pull request #21879 from zeertzjq/stl-click-zero-len
Fix statusline memory leaks with click labels
2023-01-19 11:00:00 +08:00
zeertzjq
01ddc09747 fix(statusline): don't leak memory with truncated click labels 2023-01-19 10:36:29 +08:00