aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/msgpack_rpc
Commit message (Collapse)AuthorAge
...
* refactor(api): use hashy hash for looking up api method and event namesbfredl2022-05-30
| | | | | This avoids generating khash tables at runtime, and is consistent with how evalfuncs lookup work.
* refactor(uncrustify): set maximum number of consecutive newlines to 2 (#18695)dundargoc2022-05-25
|
* feat(server): set $NVIM, unset $NVIM_LISTEN_ADDRESS #11009Justin M. Keyes2022-05-03
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | PROBLEM ------------------------------------------------------------------------ $NVIM_LISTEN_ADDRESS has conflicting purposes as both a parameter ("the current process should listen on this address") and a descriptor ("the current process is a child of this address"). This contradiction means the presence of NVIM_LISTEN_ADDRESS is ambiguous, so child Nvim always tries to listen on its _parent's_ socket. This is the cause of lots of "Failed to start server" spam in our test/CI logs: WARN 2022-04-30… server_start:154: Failed to start server: address already in use: \\.\pipe\nvim-4480-0 WARN 2022-04-30… server_start:154: Failed to start server: address already in use: \\.\pipe\nvim-2168-0 SOLUTION ------------------------------------------------------------------------ 1. Set $NVIM to the parent v:servername, *only* in child processes. - Now the correct way to detect a "parent" Nvim is to check for $NVIM. 2. Do NOT set $NVIM_LISTEN_ADDRESS in child processes. 3. On startup if $NVIM_LISTEN_ADDRESS exists, unset it immediately after server init. 4. Open a channel to parent automatically, expose it as v:parent. Fixes #3118 Fixes #6764 Fixes #9336 Ref https://github.com/neovim/neovim/pull/8247#issuecomment-380275696 Ref #8696
* refactor(uncrustify): change rules to better align with the style guideDundar Goc2022-04-29
| | | | | | | | | | | | | Add space around arithmetic operators '+' and '-'. Remove space between back-to-back parentheses, i.e. ')(' vs. ') ('. Remove space between '((' or '))' of control statements. Add space between ')' and '{' of control statements. Remove space between function name and '(' on function declaration. Collapse empty blocks between '{' and '}'. Remove newline at the end of the file. Remove newline between 'enum' and '{'. Remove newline between '}' and ')' in a function invocation. Remove newline between '}' and 'while' of 'do' statement.
* feat(ui): invoke ui client handlersbfredl2022-03-15
|
* feat(ui): connect to remote ui (only debug messages for now)bfredl2022-03-12
| | | | co-authored-by: hlpr98 <hlpr98@gmail.com>
* refactor(misc1): move out high-level input functions to a new file: input.cBjörn Linse2021-12-10
| | | | | Possibly dialog code is messages.c could be moved here as well. misc1.c is now empty, so delete it.
* refactor: upgrade uncrustify config version to 0.74.0Dundar Göc2021-11-23
| | | | | Disable formatting for assert.h since there's a bug that results in a segmentation fault in uncrustify.
* refactor: format header files with uncrustify #15877dundargoc2021-10-09
| | | | | | * refactor: format header files with uncrustify * fixup(justin): skip formatting of terminfo_defs.h * fixup: force winsock2 to be included first * fixup: simplify disable/enable directive to "uncrustify:off/on"
* refactor(api): cleanup modify_keymap and parse_keymap_optsBjörn Linse2021-10-07
|
* refactor(api): remove duplicated handle mpack encode/decode functionsBjörn Linse2021-10-07
|
* refactor(api): handle option dicts properlyBjörn Linse2021-10-03
| | | | | | | Do not copy a lot of lua strings (dict keys) to just strequal() them Just compare them directly to a dedicated hash function. feat(generators): HASHY McHASHFACE
* Refactor/uncrustify (#15790)dundargoc2021-09-29
| | | | | | | | | | | | | * refactor: format with uncrustify * fixup(dundar): fix functions comments * fixup(dundar): remove space between variable and ++/-- * fixup(dundar): better workaround for macro attributes This is done to be able to better use uncrustify rules for macros * fixup(justin): make preprocessors follow neovim style guide
* refactor(style): switch-case formatting, "uncrustify:indent-off" #15669dundargoc2021-09-17
| | | | | | * refactor: disable formatting for attribute in macro * fixup: disable/enable uncrustify with uncrustify:indent-off/on * fixup: stop indenting contents inside braces in case * fixup: remove case brace if no variable declaration
* perf(api): avoid spurious allocations when converting small objectsBjörn Linse2021-08-28
| | | | | | | Converter functions use a heap-allocated stack to handle complex nested objects. However, these are often called with simple, primitive values like integers or bools wrapped in an Object. Avoid the memory allocation in this case using kvec_withinit_t
* refactor(map): remove extra-allocating map_new/map_free functionsBjörn Linse2021-08-22
| | | | | | | | | | Note: the reason for removing them is not that there after this refactor is no use of them, but rather that having them available is an anti-pattern: they manange an _extra_ heap allocation which has nothing to do with the functionality of the map itself (khash manages the real buffers internally). In case there happens to be a reason to allocate the map structure itself later, this should be made explicit using xcalloc/xfree calls.
* Lower "closed by the client" message level to INFOJames McCoy2021-04-08
| | | | [skip ci]
* rpc: don't handle stale requests on already closed channelBjörn Linse2020-12-23
|
* Stop bailing out of msgpack_parse if we see a responseAlex Foley2020-08-11
|
* nvim:msgpack: Correctly set up global ch_before_blocking_eventsAndreas Schneider2020-02-23
| | | | | | | gcc10 builds with -fno-common by default. This mean you can't define a global variable with the same name twice. See also https://bugzilla.redhat.com/show_bug.cgi?id=1799680
* test/LSP: assert contents of log fileJustin M. Keyes2020-02-16
|
* refactor: rename mch_exit => os_exitJustin M. Keyes2020-02-02
| | | | | - No code changes - Move it to main.c
* Remove excess <stdint.h>Jan Edmund Lazo2019-09-11
|
* rename: SplitEvent => MulticastEvent #10989Justin M. Keyes2019-09-11
| | | | | "Multicast" is perhaps a more conventional name for the concept. "One-shot" is the conventional name for how the event is (currently) scheduled.
* rpc: allow handling of nvim_ui_try_resize at the pagerBjörn Linse2019-09-08
| | | | | | This makes external UI behave consistenly with TUI w.r.t resizes. Which will be needed anyway as TUI will use the external UI protocol soon.
* pvs/V1037: two case branches doing the same thing (#10527)Ihor Antonov2019-07-18
|
* rename: FUNC_API_ASYNC => FUNC_API_FASTBjörn Linse2019-06-30
|
* api: allow nvim_buf_attach from lua using callbacksBjörn Linse2019-06-04
|
* build: fix some warningsJustin M. Keyes2019-06-03
| | | | | | | | | | | | | | | | | | ../src/nvim/event/rstream.c:119:44: warning: format specifies type 'void *' but the argument has type 'Stream *' (aka 'struct stream *') [-Wformat-pedantic] DLOG("Closing Stream (%p): %s (%s)", stream, ~~ ^~~~~~ ../src/nvim/event/stream.c:95:30: warning: format specifies type 'void *' but the argument has type 'Stream *' (aka 'struct stream *') [-Wformat-pedantic] DLOG("closing Stream: %p", stream); ~~ ^~~~~~ ../src/nvim/msgpack_rpc/channel.c:71:72: warning: format specifies type 'void *' but the argument has type 'Stream *' (aka 'struct stream *') [-Wformat-pedantic] DLOG("rpc ch %" PRIu64 " in-stream=%p out-stream=%p", channel->id, in, out); ~~ ^~ ../src/nvim/msgpack_rpc/channel.c:71:76: warning: format specifies type 'void *' but the argument has type 'Stream *' (aka 'struct stream *') [-Wformat-pedantic] DLOG("rpc ch %" PRIu64 " in-stream=%p out-stream=%p", channel->id, in, out); ~~ ^~~ ../src/nvim/msgpack_rpc/channel.c:226:28: warning: format specifies type 'void *' but the argument has type 'Stream *' (aka 'struct stream *') [-Wformat-pedantic] channel->id, count, stream); ^~~~~~
* messages: use proper multiline error message for rpcrequest and API wrappersBjörn Linse2019-05-26
|
* API: emit nvim_error_event on failed async requestJustin M. Keyes2019-04-13
| | | | | We already do this for _invalid_ async requests #9300. Now we also do it for failed invocation of valid requests.
* RPC: conform message-id type to msgpack-RPC specDaniel Bershatsky2019-04-12
| | | | | | | | | | | | | | | | | | | | According to [MessagePack RPC specification](https://github.com/msgpack-rpc/msgpack-rpc), message ID must be 32-bit unsigned integer. But Neovim implementation uses uint64_t instead of uint32_t. This can have wrong results in the case of large ids or a malformed request, for example: Actual response: [1,18446744073709551615,[1,"Message is not an array"],null] Expected response: [1,4294967295,[1,"Message is not an array"],null] The issue does not affect RPC clients written in dynamically-typed languages like Python. Wrong type of sequence id number breaks RPC clients written statically typed languages like C/C++/Golang: all of them expect uint32_t as message id. Examples: https://github.com/msgpack-rpc/msgpack-rpc-cpp/blob/11268ba2be5954ddbb2b7676c7da576985e45cfc/src/msgpack/rpc/protocol.h#L27 https://github.com/ugorji/go/blob/master/codec/msgpack.go#L993 closes #8850
* RPC: eliminate NO_RESPONSEJustin M. Keyes2019-04-12
| | | | | | | | | | Using a sentinel value in the response-id is ambiguous because the msgpack-rpc spec allows all values (including zero/max). And clients control the id, so we can't be sure they won't use the sentinel value. Instead of a sentinel value, check the message type explicitly. ref #8850
* build: enable -WshadowJustin M. Keyes2019-01-02
| | | | | | | | | | Note about shada.c: - shada_read_next_item_start was intentionally shadowing `unpacked` and `i` because many of the macros (e.g. ADDITIONAL_KEY) implicitly depended on those variable names. - Macros were changed to parameterize `unpacked` (but not `i`). Macros like CLEAR_GA_AND_ERROR_OUT do control-flow (goto), so any other approach is messy.
* RPC: turn errors from async calls into notificationsBjörn Linse2018-12-03
| | | | | Previously, nvim sent a response with invalid request id (UINT64_MAX). In functionaltests, catch unexpected error notifications in after_each().
* startup: always wait for UI with --embed, unless --headless also is suppliedBjörn Linse2018-09-22
|
* log: RPC, input, other eventsJustin M. Keyes2018-09-19
|
* startup: wait for embedder before executing startup commands and filesBjörn Linse2018-09-18
| | | | | | Give embeders a chance to set up nvim, by processing a request before startup. This allows an external UI to show messages and prompts from --cmd and buffer loading (e.g. swap files)
* API: nvim_unsubscribe(): Handle unknown events #8745Daniel Hahler2018-08-28
| | | | close #8745
* channel.c: refactor spaghetti codemicha2018-07-14
| | | | | | | | | | | | | | | | | | | | channel.c: WIP remove redundant method check and added FUNC_ATTR_NONNULL_ALL macro channel.c channel_defs.h helpers.c: added Error field to RequestEvent, added no_op handler func channel.c: use const char* instead of string and cleanup channel.c; channel_defs.h; helpers.c: removed error from event again; send errors directly to the channel without using handlers and events channel.c: fixed memory leak and lint errors api/private/dispatch.c; api/vim.c; msgpack_rpc/channel.c msgpack_rpc/helpers.c added Error* field to msgpack_get_handler_for; further refactored channel.c channel.c:323 changed order of evaluation in if statement channel.c: removed superflous whitespace dispatch.c: review comment
* API: validation: mention invalid method name (#8489)Justin M. Keyes2018-06-07
|
* api: list information about all channels/jobs.Björn Linse2018-05-23
| | | | | Fire autocmd when channel opens or its info changes. Add a way for API clients can describe themselves.
* server: init v:servername if $NVIM_LISTEN_ADDRESS is invalidJustin M. Keyes2018-04-11
| | | | | Before this change, if $NVIM_LISTEN_ADDRESS was invalid, v:servername was left empty.
* server: introduce --listen, deprecate $NVIM_LISTEN_ADDRESSJustin M. Keyes2018-04-11
|
* serverstop(): return FALSE for invalid addressJustin M. Keyes2018-04-11
|
* channels: generalize jobclose()Björn Linse2017-11-25
|
* channels: allow bytes sockets and stdio, and buffered bytes outputBjörn Linse2017-11-24
|
* channels: refactorBjörn Linse2017-11-24
|
* Revert channel logging, rebased on new code belowBjörn Linse2017-11-24
|
* server.c: Fix bug in release mode (#7594)Phlosioneer2017-11-20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When compiling with CMAKE_BUILD_TYPE=RelWithDebInfo, several -Wmaybe-uninitialized warnings are printed. These were thought to be false positives (#5061); there are no control paths that lead to an uninitialized value. However, when gcc is run in -O2 mode, it makes a mistake while generating the necessary logic. Specifically, for the code: ... int = 0; // Index of the server whose address equals addr. for (; i < watchers.ga_len; i++) { watcher = ((SocketWatcher **)watchers.ga_data)[i]; // <snip> } if (i >= watchers.ga_len) { ELOG("Not listening on %s", addr); return; } ... Gcc generates: ... <+98>: cmp %ebx, %ebp <+100>: jg 0x530f13 <server_stop+55> <+102>: cmp %ebp, ebx <+104>: jl 0x530f7e <server_stop+162> ... Normally, the if statement should catch the only control path where watcher is not assigned: watchers.ga_len <= 0. When compiled, the assembly lines 98 and 100 correspond to checking if i < watchers.ga_len, and the lines 102 and 104 correspond to checking if i >= watchers.ga_len. The assembly seems to compare ebp (which is watchers.ga_len) with ebx (which is i), and jump if greater; then do the same comparison and jump if less. This is where gcc makes a mistake: it flips the order of the cmp instruction. This means that the REAL behavior is first check if i < watchers.ga_len and then check if i < watchers.ga_len. Which means the code inside the if statement is NEVER executed; no combination of i and watchers.ga_len will ever trigger ELOG(). So not only is this a use of an uninitialized value if watchers.ga_len == 0 (or technically, if it's less than zero too), it also clobbers any error detection if the for loop reaches the last entry (which would normally cause i == watchers.ga_len too). This commit fixes this issue by adding a bool to keep track of whether a watcher was found during the loop. This makes gcc generate the correct code, avoiding both bugs.