Commit Graph

19059 Commits

Author SHA1 Message Date
Michael Lingelbach
96614f84ab
fix(lsp): avoid serializing boolean as key (#15810)
In vim.lsp.buf.references, the key vim.type_idx (which evaluates to a
boolean) was set to equal vim.types.dictionary. This resulted in a
boolean key in json which is not allowed by the json spec, and which
lua-cjson fails to serialize.
2021-09-27 00:32:30 -07:00
Michael Lingelbach
bec7f47cee
docs: document dependencies in MAINTAIN.md #15801
Co-authored-by: Justin M. Keyes <justinkz@gmail.com>
2021-09-26 17:24:20 -07:00
Gregory Anders
187e3a3b7e
refactor(diagnostic): use sign priority for severity_sort #15785
Rather than relying on the order in which signs are placed to dictate
the order in which they are displayed, explicitly set the priority of
the sign according to the severity of the diagnostic and the value of
severity_sort. If severity_sort is false or unset then all signs use the
same priority.
2021-09-26 16:02:18 -07:00
Michael Lingelbach
cb51a1b615
docs: add lua-cjson to third-party licenses #15800 2021-09-26 14:57:57 -07:00
Mathias Fußenegger
73280a7987
feat(lsp): allow subset of CodeActionContext as arg to code_action methods (#15793)
This makes it easier to filter the code actions. For example:

    vim.lsp.buf.code_action { only = 'refactor' }
2021-09-26 23:40:28 +02:00
Michael Lingelbach
c217766f7c
feat(lsp): use cjson for lsp rpc (#15759) 2021-09-26 22:53:04 +02:00
Michael Lingelbach
68c65b7732
Merge pull request #14871 from mjlbach/feature/lua-cjson-embedded
feat(lua): expose lua-cjson as vim.json
2021-09-26 12:23:46 -07:00
dundargoc
3246bf5f4e
ci(lintcommit.lua): replace third-party commitlint #15747 2021-09-26 12:13:59 -07:00
Michael Lingelbach
9c31f3b026 test: add tests for vim.json 2021-09-26 11:52:17 -07:00
Björn Linse
9686c21237
Merge pull request #15797 from smolck/ui-stuff
fix(ui_bridge): set bridge width and height on attach
2021-09-26 20:16:39 +02:00
smolck
08ee03cb16
fix(ui_bridge): set bridge width and height on attach 2021-09-26 11:00:40 -05:00
erw7
44145847dc
fix(tui): remove obsolete $NVIM detection #15791
Initially, we planned to set the NVIM environment variable to detect that
neovim is running in the neovim built-in terminal. At the time this code
was written, there was no way for a parent to set environment variables
for a program running in an embedded terminal. Later it was implemented in
 #12937, but the code to set the NVIM was not added. #11390 now uses ConPTY
instead of winpty when possible, so it is no longer necessary to force the
use of win32con even when running inside an embedded terminal. Therefore,
we now do not need this code.
2021-09-26 08:27:18 -07:00
Björn Linse
d4fa1649fb
Merge pull request #15351 from bfredl/virt_line
feat(screen): virtual lines
2021-09-26 16:56:19 +02:00
dundargoc
c273eb3100
refactor: replace sprintf with snprintf #15794 2021-09-26 07:53:51 -07:00
Björn Linse
68d6ff8802
Merge pull request #15721 from bfredl/electricboogalo
fix(runtime): some ordering issues (and start work on cache mechanism)
2021-09-26 16:20:23 +02:00
Björn Linse
ac3288d556 fix(runtime): ordering of loading packages with user config
site packages must be sourced before user config

NOTE: we only consider dirs exactly matching "after" to be an AFTER dir.
vim8 considers all dirs like "foo/bar_after", "Xafter" etc, as an
"after" dir in SOME codepaths not not in ALL codepaths.
2021-09-26 15:44:40 +02:00
Björn Linse
392c658d4d feat(decorations): support virtual lines (for now: only one block at a time) 2021-09-26 12:19:54 +02:00
Michael Lingelbach
30fed27241 feat(lua): expose lua-cjson as vim.json
* add vim.json.encode and vim.json.decode
* use vim.NIL instead of cjson.null
* resolve strict-prototypes warnings

* The following benchmark shows an approximately 2.5x (750 ms vs 300 ms) improvement in deserialization performance over
  vim.fn.json_decode on a medium package.json

  ```lua
  local uv = vim.loop
  local function readfile(path)
    return
  end

  local json_url = "https://raw.githubusercontent.com/rust-analyzer/rust-analyzer/b24c8d5c89ee93d1172b4127564f5da3b0c88dad/editors/code/package.json"
  io.popen(string.format('curl -v -f -L -O %q &> /dev/null', json_url))

  local json_string = io.open('package.json'):read '*a'

  uv.update_time()
  local start = uv.hrtime()

  for i = 1,1000 do
    vim.fn.json_decode(json_string)
  end

  uv.update_time()
  print(string.format("Deserialization time vim.fn.json_decode: %s ms", (uv.hrtime() - start) * (1e-6)))

  uv.update_time()
  local start = uv.hrtime()

  for i = 1,1000 do
    vim.json.decode(json_string)
  end
  uv.update_time()
  print(string.format("Deserialization time vim.json.decode: %s ms", (uv.hrtime() - start) * (1e-6)))
  ```

Co-Authored-By: Björn Linse <bjorn.linse@gmail.com>
2021-09-26 00:35:55 -07:00
Michael Lingelbach
8decc9f52d feat(lua): add lua-cjson as vendored dependency
Derived from the openresty lua-cjson fork at commit 3d93d29709
2021-09-26 00:35:47 -07:00
Dundar Göc
b3b02eb529 docs(CONTRIBUTING.md): how to use uncrustify #15780
close #15780
2021-09-25 18:38:51 -07:00
gmntroll
8b0e6cc05d
fix(api): fix crash after set_option_value_for() #15390
Problem:
This crashes Nvim:
    tabedit
    call nvim_win_set_option(1000, 'statusline', 'status')
    split
    wincmd J
    wincmd j

Solution:
- Change `no_display` parameter value to be the same as in matching
  `restore_win_noblock` call. In case of different values `topframe`
  isn't restored to `curtab->tp_topframe`.
- Call `restore_win_noblock` if `switch_win_noblock` returns `FAIL`
  (`switch_win` must always have matching `restore_win`)
- Change `switch_win`/`restore_win` to `_noblock` versions to allow
  autocommands.

fixes #14097
fixes #13577
2021-09-25 17:48:06 -07:00
dundargoc
2f9b9e61d7
refactor: format with uncrustify #15778
* fixup: force exactly one whitespace between type and variable
2021-09-25 17:16:04 -07:00
James McCoy
05d685be52
Merge pull request #15776 from jamessan/macos-11-ci
Add macos-11 CI
2021-09-25 09:43:57 -04:00
Thomas Vigouroux
7cb34a341d
test(normal): CA_COMMAND_BUSY in visual select mode #15292
Fix was already applied in 5f144efefa #15688,
but this commit adds another dimension to the test.

Test correctly fails after reverting 5f144efefa.

ref #15288
2021-09-24 09:59:36 -07:00
James McCoy
64a5eddc89
ci: use runner, instead of os, for job name and cache key 2021-09-24 09:01:50 -04:00
James McCoy
e0cf32c6de
ci: add macOS 11 build 2021-09-24 09:01:30 -04:00
Justin M. Keyes
bc570b0064
Merge #15774 fix(pvs): fix warnings, script 2021-09-24 05:13:55 -07:00
Justin M. Keyes
55d1e630b4
Merge #15731 vim-patch:7.4.725,8.2.{0597,0598,0924,1035}
fixes #14581
2021-09-24 05:11:19 -07:00
dundargoc
7a26eb8a56
refactor: format with uncrustify #15755 2021-09-24 05:03:15 -07:00
Justin M. Keyes
03ed72642d fix(pvs): Exclude xdiff from analysis
ref 088161a945
ref fbe88ef8f5
2021-09-24 03:26:31 -07:00
Justin M. Keyes
508fcdadb7 fix(PVS): disable "typo" warnings V1051, V1074
PVS is worried about typos. Now we need it to stop worrying...
Disable these checks entirely, they are all false positives.

tui.c:1873        V1074   Boundary between escape sequence and string is unclear. The escape sequence ends with a letter and the next character is also a letter. Check for typos.
tui.c:1983        V1074   Boundary between escape sequence and string is unclear. The escape sequence ends with a letter and the next character is also a letter. Check for typos.

regexp_nfa.c:6189 V1051   Consider checking for misprints. It's possible that the 'pim->result' should be checked here.
screen.c:2928     V1051   Consider checking for misprints. It's possible that the 'vcol_sbr' should be checked here.
screen.c:3187     V1051   Consider checking for misprints. It's possible that the 'line_attr' should be checked here.
screen.c:3267     V1051   Consider checking for misprints. It's possible that the 'multi_attr' should be checked here.
screen.c:4747     V1051   Consider checking for misprints. It's possible that the 'redraw_next' should be checked here.
syntax.c:3448     V1051   Consider checking for misprints. It's possible that the 'arg_end' should be checked here.
syntax.c:3625     V1051   Consider checking for misprints. It's possible that the 'arg_end' should be checked here.
tui.c:1836        V1051   Consider checking for misprints. It's possible that the 'data->unibi_ext.set_cursor_style' should be checked here.
tui.c:1863        V1051   Consider checking for misprints. It's possible that the 'data->unibi_ext.set_cursor_style' should be checked here.
tui.c:1882        V1051   Consider checking for misprints. It's possible that the 'data->unibi_ext.set_cursor_style' should be checked here.
2021-09-24 03:22:26 -07:00
Justin M. Keyes
3c7cef7b08 fix(PVS V681): function call order is undefined
https://pvs-studio.com/en/docs/warnings/v681/
2021-09-24 02:49:59 -07:00
Justin M. Keyes
fefd1652e7 fix(PVS V576): false positive
`lower`, `upper` are `varnumber_T`, correctly matched to `PRIdVARNUMBER`
format.
2021-09-24 02:43:37 -07:00
Justin M. Keyes
0d59c01a64 fix(PVS V576): wrong fprintf() format
https://pvs-studio.com/en/docs/warnings/v576/

Before 1bffe66508 this was originally
"%ld" but that looks like a mistake. At least now, w_height_inner and
w_width_inner are just `int`.
2021-09-24 02:29:49 -07:00
Justin M. Keyes
d15defeb2f fix(PVS V507): false positive
https://pvs-studio.com/en/docs/warnings/v507/

"Pointer to local array 'sourcing_name_buf' is stored outside the scope
of this array. Such a pointer will become invalid."

False positive: `sourcing_name = save_sourcing_name` before returning
from this scope.
2021-09-24 02:09:52 -07:00
Chris Kipp
433bda405e
fix(lsp): guard textDocument/codeAction command logic #15769
Problem:

    Error executing vim.schedule lua callback: ...ovim/HEAD-aba3979/share/nvim/runtime/lua/vim/lsp/buf.lua:502: command: expected string, got
     nil
    stack traceback:
            ...ovim/HEAD-aba3979/share/nvim/runtime/lua/vim/lsp/buf.lua:502: in function 'execute_command'
            ...HEAD-aba3979/share/nvim/runtime/lua/vim/lsp/handlers.lua:151: in function <...HEAD-aba3979/share/nvim/runtime/lua/vim/lsp/handlers.lua:113>
            ...ovim/HEAD-aba3979/share/nvim/runtime/lua/vim/lsp/buf.lua:465: in function 'callback'
            ...r/neovim/HEAD-aba3979/share/nvim/runtime/lua/vim/lsp.lua:1325: in function 'handler'
            ...r/neovim/HEAD-aba3979/share/nvim/runtime/lua/vim/lsp.lua:899: in function 'cb'
            vim.lua:281: in function <vim.lua:281>


Solution:

This is a follow-up to the work done in
6c03601e3a.
There are valid situations where a `textDocument/codeAction` is returned
without a command, since a command in optional. For example from Metals,
the Scala language server when you get a code action to add a missing
import, it looks like this:

```json
Result: [
  {
    "title": "Import \u0027Instant\u0027 from package \u0027java.time\u0027",
    "kind": "quickfix",
    "diagnostics": [
      {
        "range": {
          "start": {
            "line": 6,
            "character": 10
          },
          "end": {
            "line": 6,
            "character": 17
          }
        },
        "severity": 1,
        "source": "bloop",
        "message": "not found: value Instant"
      }
    ],
    "edit": {
      "changes": {
        "file:///Users/ckipp/Documents/scala-workspace/sanity/src/main/scala/Thing.scala": [
          {
            "range": {
              "start": {
                "line": 6,
                "character": 10
              },
              "end": {
                "line": 6,
                "character": 17
              }
            },
            "newText": "Instant"
          },
          {
            "range": {
              "start": {
                "line": 1,
                "character": 0
              },
              "end": {
                "line": 1,
                "character": 0
              }
            },
            "newText": "\nimport java.time.Instant\n"
          }
        ]
      }
    }
  }
]
```

This change just wraps the logic that grabs the command in a conditional
to skip it if there is no command.
2021-09-23 18:20:10 -07:00
Justin M. Keyes
be93821647
fix: move contrib/uncrustify.cfg -> src/uncrustify.cfg #15768
If uncrustify is now the (partial) authority on code style, it is no
longer "contrib".
2021-09-23 14:56:58 -07:00
Gregory Anders
9cde1e5891
fix(diagnostic): check for nil in show_diagnostics (#15772) 2021-09-23 09:52:21 -07:00
Gregory Anders
057606e845
fix(diagnostic): don't return nil when callers expect a table (#15765)
diagnostic_lines() returns a table, so make the early exit condition an
empty table rather than 'nil'. This way, functions that use the input
from diagnostic_lines don't have to do a bunch of defensive nil checking
and can always assume they're operating on a table.
2021-09-23 08:23:57 -07:00
Justin M. Keyes
abf13258cf
Merge #14979 doc: convert Nvim style guide XML to vim :help 2021-09-23 07:02:43 -07:00
Justin M. Keyes
c05b10748c doc(dev_style.txt): misc updates 2021-09-23 06:59:30 -07:00
Dundar Göc
5f49d0efee doc: convert neovim style guide to vim doc. 2021-09-23 06:59:30 -07:00
Sean Dewar
f1bf70c2f9
vim-patch:8.2.1035: setreg() does not always clear the register
Problem:    setreg() does not always clear the register.
Solution:   Clear the register if the dict argument is empty. (Andy Massimino,
            closes vim/vim#3370)
7633fe595e

Do not getdigits for block_len strictly. For example, a user could
previously abort Nvim using:

:call setreg("0", "abort!", "\<C-V>999999999999999999")

or, after v8.2.0924's port:

:call setreg("0", #{regcontents: ["abort!"],
                  \ regtype: "\<C-V>999999999999999999"})

Instead, default to 0 so block_len is -1, which acts like the selection
width was omitted (defaults to length of longest line).
2021-09-23 02:07:21 +01:00
Sean Dewar
f8241f825a
vim-patch:7.4.725
Problem:    ":call setreg('"', [])" reports an internal error.
Solution:   Make the register empty. (Yasuhiro Matsumoto)
659c94d483

Required for v8.2.1035.

Note that setreg('"', []) didn't cause an internal error for us, but
didn't clear the register properly either...
2021-09-23 02:04:16 +01:00
Sean Dewar
f9779facca
vim-patch:8.2.0924: cannot save and restore a register properly
Problem:    Cannot save and restore a register properly.
Solution:   Add getreginfo() and make setreg() accept a dictionary. (Andy
            Massimino, closes vim/vim#3370)
bb861e293e

Cherry-pick eval.txt changes for getreginfo() from:
6aa57295cf
207f009326
2021-09-23 02:04:11 +01:00
Sean Dewar
74ddd14241
vim-patch:8.2.0598: test_eval_stuff fails in normal terminal
Problem:    Test_eval_stuff fails in normal terminal.
Solution:   Close the new window.
61fbb3371e

Required for v8.2.0598 to work.
2021-09-22 23:53:13 +01:00
Sean Dewar
3b2be8f3de
vim-patch:8.2.0597: test_eval is old style
Problem:    Test_eval is old style.
Solution:   Change some tests to a new style test.
90455cfa87

Cherry-pick Test_setreg_basic changes from v8.2.0610.

Note that the old-style version of the tests (and the cherry-picked
changes) exist in legacy/eval_spec.lua; keep them as they've already
been Lua'd.

Required for v8.2.0924.
2021-09-22 23:53:13 +01:00
Christian Clason
aba397991b
build(deps): bump luarocks to 3.7.0 #15740
Besides bugfixes, this brings `XDG_*` compliance and improved
robustness, especially for network errors.

See https://github.com/luarocks/luarocks/blob/master/CHANGELOG.md

- fixup: set LIBUV_LIBDIR to workaround 83126ba324
    - https://github.com/luarocks/luarocks/issues/1214
    - https://github.com/luarocks/luarocks/pull/1355
2021-09-22 12:26:01 -07:00
Gregory Anders
d999c96cf3
feat(diagnostic): allow customized diagnostic messages (#15742)
Provide a 'format' option for virtual text and floating window previews
that allows the displayed text of a diagnostic to be customized.
2021-09-22 12:20:15 -07:00
James McCoy
80e3f0eb34
Merge pull request #15739 from clason/luv-bump 2021-09-22 15:11:10 -04:00