Commit Graph

22010 Commits

Author SHA1 Message Date
zeertzjq
f17d88c47a
vim-patch:8.2.5132: :mkview test doesn't test much (#19045)
Problem:    :mkview test doesn't test much.
Solution:   Save the view with the folds closed. (James McCoy, closes vim/vim#10596)
c829faa821
2022-06-22 11:08:00 +08:00
Lewis Russell
34ae896b82
refactor(option): DRY get/set option value #19038
The main motivation for this is for the buf and win cases which need to
set up and restore context, and it's what specifically makes the
semantics of options nuanced, and thus this should not be repeated more
than once.

- nvim_get/set_option_value now share argument validation.
2022-06-21 19:09:50 -07:00
bfredl
04592759fa
Merge pull request #19043 from dundargoc/cmake
build(cmake): use glob_wrapper instead of file(GLOB ...) in main CMakeLists
2022-06-22 00:06:35 +02:00
Dundar Goc
230cb00cc5 build(cmake): use glob_wrapper instead of file(GLOB in main CMakeLists
This will allow cmake to check if any directories needs re-globbing, in
other words, if any new file has been added since last time cmake was
run. This will (allegedly) make the configure stage slower but I have
not noticed any difference so I believe this is well worth it.
2022-06-21 23:29:05 +02:00
Jonas Strittmatter
e3b51d5842
refactor(runtime): refactor filetype.lua (#18813)
Move some filetype detection functions to detect.lua,
sort patterns by detected filetype.
2022-06-21 11:29:52 -06:00
bfredl
8cd94e3bc0 perf(ui): remove spurious allocations from mode_style_array() 2022-06-21 18:40:35 +02:00
bfredl
a9442c532e perf(highlight): allocate permanent names in an arena for fun and cache locality 2022-06-21 18:40:35 +02:00
bfredl
1dad288432 refactor: remove atrocious HL_TABLE()[idx] syntax before I poke my eyes out 2022-06-21 18:40:35 +02:00
bfredl
ce7d18f86a refactor(highlight): get rid of syn_unadd_group()
This is a sham. if the user does

  hi ExistingGroup guifg=AliceBlue invalidkey=foobar

the "guifg" part will still be executed. No need to micro-manage
the same case where ANewGroup is added instead.
2022-06-21 18:40:35 +02:00
bfredl
374e0b6678 perf(highlight): don't allocate duplicates for color names 2022-06-21 18:40:33 +02:00
bfredl
5ad97fcc0e perf(highlight): get rid of local memory allocations for "{key}={arg}" 2022-06-21 18:09:11 +02:00
eyalk11
f479dd0bbe
docs(deprecated): alternatives for $NVIM_LISTEN_ADDRESS 2022-06-21 10:25:44 +02:00
Gregory Anders
6d52a29c3b
Merge pull request #18743 from gpanders/bowooptvalue
Add "buf" and "win" to nvim_get_option_value and use them in vim.bo and vim.wo
2022-06-20 17:28:37 -06:00
zeertzjq
bc6a5943de
Merge pull request #19030 from zeertzjq/vim-8.2.5138
vim-patch:8.2.{5107,5138}: various small issues
2022-06-21 07:06:56 +08:00
Christian Clason
7a309311a2
vim-patch:d799daa660b8 (#19031)
Update runtime files
d799daa660
2022-06-20 18:47:30 +02:00
Gregory Anders
87a68b6a3a refactor: use nvim_{get,set}_option_value for vim.{b,w}o
`nvim_get_option_value` and `nvim_set_option_value` better handle
unsetting local options. For instance, this is currently not possible:

    vim.bo.tagfunc = nil

This does not work because 'tagfunc' is marked as "local to buffer" and
does not have a fallback global option. However, using :setlocal *does*
work as expected

    :setlocal tagfunc=

`nvim_set_option_value` behaves more like :set and :setlocal (by
design), so using these as the underlying API functions beneath vim.bo
and vim.wo makes those two tables act more like :setlocal. Note that
vim.o *already* uses `nvim_set_option_value` under the hood, so that
vim.o behaves like :set.
2022-06-20 09:16:21 -06:00
Gregory Anders
58d028f64b feat(api): add "buf" and "win" to nvim_get_option_value
These mirror their counterparts in nvim_set_option_value.
2022-06-20 09:16:21 -06:00
Zaz Brown
99ef06d846
refactor(provider): use list comprehension #19027
- list(filter(lambda x: x != "", sys.path))
+ [p for p in sys.path if p != ""]
2022-06-20 06:17:00 -07:00
bfredl
e3bfc1293e
Merge pull request #18988 from bfredl/uipack
refactor(ui): encode "redraw" events without intermediate allocations
2022-06-20 15:04:40 +02:00
zeertzjq
9aaff18489 vim-patch:8.2.5138: various small issues
Problem:    Various small issues.
Solution:   Various small improvments.
8088ae95bb

N/A patches for version.c:

vim-patch:8.2.5107: some callers of rettv_list_alloc() check for not OK

Problem:    Some callers of rettv_list_alloc() check for not OK. (Christ van
            Willegen)
Solution:   Use "==" instead of "!=" when checking the return value.
93a1096fe4
2022-06-20 20:51:11 +08:00
bfredl
5d69872105 perf(ui): reduce allocation overhead when encoding "redraw" events
Note for external UIs: Nvim can now emit multiple "redraw" event batches
before a final "flush" event is received. To retain existing behavior,
clients should make sure to update visible state at an explicit "flush"
event, not just the end of a "redraw" batch of event.

* Get rid of copy_object() blizzard in the auto-generated ui_event layer
* Special case "grid_line" by encoding screen state directly to
  msgpack events with no intermediate API events.
* Get rid of the arcane notion of referring to the screen as the "shell"
* Array and Dictionary are kvec_t:s, so define them as such.
* Allow kvec_t:s, such as Arrays and Dictionaries, to be allocated with
  a predetermined size within an arena.
* Eliminate redundant capacity checking when filling such kvec_t:s
  with values.
2022-06-20 12:44:56 +02:00
Justin M. Keyes
b2ed439bd5
Merge #19015 delete cmake code 2022-06-19 19:51:16 +02:00
ii14
a195dc7c83
fix(decorations): nvim_buf_set_extmark breaks conceal #19010
Closes #19007

Co-authored-by: bfredl <bjorn.linse@gmail.com>
Co-authored-by: Justin M. Keyes <justinkz@gmail.com>
2022-06-19 10:33:54 -07:00
Dundar Goc
ae7a4ad3d7 build: remove FindLua.cmake since it's already built into cmake
FindLua.cmake is a copy from the cmake repo:
0419ecbcad/Modules/FindLua.cmake.
It's a cmake module, meaning it's already shipped with cmake by default.
There have been two changes done to our version of FindLua.cmake.

The first change is that

include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)

was changed to

include(FindPackageHandleStandardArgs.cmake)

This change is required only because we have imported FindLua.cmake
module but not FindPackageHandleStandardArgs module. Had FindLua been
called as a module as intended then this file would not need changing.

The second change is that support for Lua 5.4 is added. However, support
for any version of Lua except for 5.1 is disabled since
e322b5c864.

Because these changes from the upstream FindLua.cmake is unnecessary I
believe we can and should use the builtin FindLua.cmake instead of our
own.
2022-06-19 18:34:28 +02:00
Dundar Goc
636a309981 build(cmake): simplify def_cmd_target function
Instead of appending to a command output, append to an existing target
instead. The primary benefit is intermediary ...-cmd targets aren't
needed, we can instead append commands to the relevant target directly.
2022-06-19 18:34:28 +02:00
Dundar Goc
cd1b2998d3 build(cmake): simplify and speed up the uninstall target
More specifically, replace exec_program with file(REMOVE ...) so that
the uninstall target is run during the build stage instead of the
configure stage, significantly speeding up the target.

The code snippet that was removed is taken from the cmake FAQ
https://gitlab.kitware.com/cmake/community/-/wikis/FAQ#can-i-do-make-uninstall-with-cmake.
However, this uses undocumented features such as IMMEDIATE when calling
configure_file, which is an artifact from cmake 2.x (it's so old it's
difficult to find information on it). Similarly, this particular code
snippet has been around for a long time and originated from the cmake
mailing lists. Based on this I believe the in-file was a workaround for
the limitations of cmake back then and that it's not required anymore.
2022-06-19 18:34:28 +02:00
Dundar Goc
668591ae04 build(cmake): remove unnecessary globbing with file
There's no need to use globbing since there's only one file.
2022-06-19 18:34:28 +02:00
Dundar Goc
8a6f728315 build(cmake): remove unnecessary *-prereqs targets
Running the tests on their own works just fine.
2022-06-19 18:34:28 +02:00
Kevin Sicong Jiang
837ea6da9f
fix(tui): piping nodejs to nvim breaks input handling #18932
Problem:
Piping NodeJS output into Neovim makes the editor unusable.
This happens because NodeJS changes the tty state on exit after
Nvim calls uv_tty_set_mode(). (May not always happen due to race
condition.)
This should have been fixed by 4ba5b4a864 #13084. But some
commands and functions (:sleep, system(), …) call ui_flush()
internally, in particular the first tui_mode_change() is called before
the end of startup.

Steps to reproduce:
1. node -e "setTimeout(()=>{console.log('test')}, 1000)" | nvim -u NORC +"sleep 500m" -
2. The cursor key letters just overwrite the editor screen, and CTRL+C exits.

Solution:
Skip pending_mode_update during startup.
Note: Delaying ui_flush() entirely could be a more general solution
(emit a new UI event on VimEnter?). But "remote/coprocess TUI" #18375
could make all of this moot anyway.
Fixes #18470
2022-06-19 08:22:39 -07:00
Christian Clason
c5c5d980a1
ci(release): skip CoreServices system library on macOS (#19021)
Problem:
The release script bundles a system library (CoreServices) that was
added in #18294, which leads to errors on M1 since the architecture is
different from the Github runner.

Solution:
Skip CoreServices when bundling the libraries (as was done for the
CoreFoundation library that #18294 replaced with CoreServices).
2022-06-19 16:20:27 +02:00
Justin M. Keyes
7b2b44bce4
fix(ci): noisy logs, unreliable test #19019
Problem:
1. CI logs have too many (40+) logs mentioning SIGHUP:
   ```
   WRN 2022-06-18T16:05:47.075 T3568.22499.0/c deadly_signal:177: got signal 1 (SIGHUP)
   WRN 2022-06-18T16:05:47.273 T3569.91095.0/c deadly_signal:177: got signal 1 (SIGHUP)
   WRN 2022-06-18T16:05:47.651 T3570.59545.0/c deadly_signal:177: got signal 1 (SIGHUP)
   ```
2. TS parser test still sometimes fails on BSD CI.
3. remote_spec test fails too often.

Solution:
1. Log deadly signals at INFO level. It hasn't been helpful in CI, and
   for local troubleshooting it's reasonable to adjust the loglevel as
   needed.
2. Adjust the TS parser test again. ref #18911
3. Skip the remote_spec test. The `--remote` feature was merged before
   it was fully formed and needs to be revisited.
2022-06-18 19:19:08 -07:00
Justin M. Keyes
605631ac29
build(lint): set some linters as non-fatal #19018
luacheck and clint are the most important, and they are bundled.
The others are nice-to-have, and not always available (and not bundled),
so make them optional. This allows the "lint" target to function as
a convenient and low-hassle handle for contributors.

We still get the full power of lint in CI.

TODO: bundle uncrustify (and then set it as required for "lint")?
2022-06-18 11:10:10 -07:00
Justin M. Keyes
ff6b8f5435
fix(terminal): coverity USE_AFTER_FREE #18978
Problem:
Coverity reports use after free:

    *** CID 352784:  Memory - illegal accesses  (USE_AFTER_FREE)
    /src/nvim/buffer.c: 1508 in set_curbuf()
    1502         if (old_tw != curbuf->b_p_tw) {
    1503           check_colorcolumn(curwin);
    1504         }
    1505       }
    1506
    1507       if (bufref_valid(&prevbufref) && prevbuf->terminal != NULL) {
    >>>     CID 352784:  Memory - illegal accesses  (USE_AFTER_FREE)
    >>>     Calling "terminal_check_size" dereferences freed pointer "prevbuf->terminal".
    1508         terminal_check_size(prevbuf->terminal);
    1509       }
    1510     }
    1511
    1512     /// Enter a new current buffer.
    1513     /// Old curbuf must have been abandoned already!  This also means "curbuf" may

Solution:
Change terminal_destroy and terminal_close to set caller storage to NULL,
similar to XFREE_CLEAR. This aligns with the pattern found already in:
terminal_destroy e897ccad3e
term_delayed_free 3e59c1e20d
2022-06-18 09:53:12 -07:00
Justin M. Keyes
9c0f2253a5
fix(logging): try harder to resolve Nvim "name" #19016
Problem:
If startup finishes (starting=false) before the logger ever happens to
see a v:servername, we're stuck with the "?.<PID>" fallback name
forever.

Solution:
Drop the `starting` condition. Discard the "?.<PID>" fallback after
using it for the current log message. So logging will always check
v:servername next time.
2022-06-18 09:30:54 -07:00
Oliver Marriott
1ad6423f02
fix(highlight): use ctermbg/fg instead of bg/fg when use_rgb=false #18982
If `use_rgb` was false, we would attempt to set the `cterm_bg_color` to the
variable `bg`, which is only retrieved from `bg` and `background` keys, not
`ctermbg`. Same for `fg`. This means the values would be `-1` (the default,
un-got value) and we'd always set the returned values to `0`.

My understanding is `fg/bg` is always "gui" values, so instead we should be
using `ctermbg` when needed.

Nb: when looking around I think this function is currently *always* called with
`use_rgb = true`.
2022-06-18 08:33:58 -07:00
zeertzjq
901fde60c6
Merge pull request #19011 from zeertzjq/vim-8.2.5120
vim-patch:8.2.{5120.5121}
2022-06-18 20:02:52 +08:00
zeertzjq
dc56b442d8 vim-patch:8.2.5121: interrupt test sometimes fails
Problem:    Interrupt test sometimes fails.
Solution:   Use a different file name.
8d6420631c

Add a modeline to test_interrupt.vim.
2022-06-18 19:37:45 +08:00
zeertzjq
aab05cd5ff vim-patch:8.2.5120: searching for quotes may go over the end of the line
Problem:    Searching for quotes may go over the end of the line.
Solution:   Check for running into the NUL.
2f074f4685
2022-06-18 19:36:43 +08:00
zeertzjq
966d55effe
vim-patch:8.2.5116: "limit" option of matchfuzzy() not always respected (#19005)
Problem:    "limit" option of matchfuzzy() not always respected.
Solution:   Remove "else". (Kazuyuki Miyagi, closes vim/vim#10586)
47f1a55849
2022-06-18 13:43:02 +08:00
Christian Clason
e651ae5864
vim-patch:d592deb33652 (#19002)
Update runtime files
d592deb336
2022-06-17 20:38:21 +02:00
Oliver Marriott
98e2da7d50
fix(hl): return cterm fg/bg even if they match Normal #18981
Fixes #18980

- 831fa45ad8 is related but this doesn't regress that
- The `cterm_normal_fg_color != ae.cterm_fg_color` comparison is originally
  carried from patch to patch starting all the way back in 29bc6dfabd where it
  was avoiding setting a HL attr. But `hlattrs2dict()` now is just
  informational.
2022-06-16 18:33:58 -07:00
Lewis Russell
e0aa1d87e8
test(treesitter): add benchmark #18989
add benchmark from #18109
2022-06-16 17:22:43 -07:00
zeertzjq
1fe94cb008
docs: improve 'insertmode' emulation #18962
The current emulation script enters Insert mode much too frequently.
Using only BufWinEnter seems to be a closer simulation.

Also add a few more mappings.
2022-06-16 17:16:33 -07:00
Justin M. Keyes
c57f6b28d7
Merge #8519 feat: name, test ids, sockets in stdpath(state) 2022-06-17 01:23:48 +02:00
bfredl
279bc71f3c
Merge pull request #18760 from kevinhwang91/fix-treesitter-fold
fix(treesitter): new iter if folded
2022-06-16 18:29:27 +02:00
kevinhwang91
8780076a78 fix(treesitter): new iter if folded 2022-06-16 17:38:10 +02:00
Christian Clason
35c9fe9895
vim-patch:8.2.5110: icon filetype not recognized from the first line (#18987)
Problem:    Icon filetype not recognized from the first line.
Solution:   Add a check for the first line. (Doug Kearns)
bf6614643f
2022-06-16 15:53:38 +02:00
zeertzjq
179faa3edd
fix(lua): clear got_int when calling vim.on_key() callback (#18979) 2022-06-16 18:51:36 +08:00
notomo
0e8186bdd8
fix(lua): highlight.on_yank can close timer in twice #18976
Steps to reproduce:

1. setting `vim.highlight.on_yank`
   ```
   vim.api.nvim_create_autocmd({ "TextYankPost" }, {
     pattern = { "*" },
     callback = function()
       vim.highlight.on_yank({ timeout = 200 })
     end,
   })
   ```
2. repeat typing `yeye` ...
3. causes the following error.
   ```
   Error executing vim.schedule lua callback: vim/_editor.lua:0: handle 0x01e96970 is already closing
   stack traceback:
           [C]: in function 'close'
           vim/_editor.lua: in function ''
           vim/_editor.lua: in function <vim/_editor.lua:0>
   ```

📝 Test result before fix:

    [----------] Global test environment setup.
    [----------] Running tests from test/functional/lua/highlight_spec.lua
    [ RUN      ] vim.highlight.on_yank does not show errors even if buffer is wiped before timeout: 15.07 ms OK
    [ RUN      ] vim.highlight.on_yank does not show errors even if executed between timeout and clearing highlight: 15.07 ms ERR
    test/helpers.lua:73: Expected objects to be the same.
    Passed in:
    (string) 'Error executing vim.schedule lua callback: vim/_editor.lua:0: handle 0x02025260 is already closing
    stack traceback:
            [C]: in function 'close'
            vim/_editor.lua: in function ''
            vim/_editor.lua: in function <vim/_editor.lua:0>'
    Expected:
    (string) ''
2022-06-15 19:39:55 -07:00
Justin M. Keyes
1f2c2a35ad feat(server): instance "name", store pipes in stdpath(state)
Problem:
- Unix sockets are created in random /tmp dirs.
  - /tmp is messy, unclear when OSes actually clear it.
  - The generated paths are very ugly. This adds friction to reasoning
    about which paths belong to which Nvim instances.
- No way to provide a human-friendly way to identify Nvim instances in
  logs or server addresses.

Solution:
- Store unix sockets in stdpath('state')
- Allow --listen "name" and serverstart("name") to given a name (which
  is appended to a generated path).

TODO:
- is stdpath(state) the right place?
2022-06-15 19:29:51 -07:00