aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/main.c
Commit message (Collapse)AuthorAge
* fix(startup): avoid crash with completion from -l script (#32160)zeertzjq2025-01-22
| | | Related #27764
* "nvim -es": disable shada #21723Justin M. Keyes2025-01-05
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Problem: `nvim -es` (and `nvim -Es`) is the recommended way to non-interactively run commands/vimscript. But it enables shada by default, which is usually not wanted. Solution: - Disable shada by default for `nvim -es/-Es`. This can be overridden by `-i foo` if needed. - Do NOT change the 'loadplugins' default. - User config + packages _should_ be enabled by default, for both `nvim -es` and `nvim -l`. Else any Lua packages you have can't be accessed without `-u path/to/config`, which is clumsy. - Use-cases: ``` nvim --headless "+Lazy! sync" +qa would become: nvim -es "+Lazy! sync" nvim --headless +PlugInstall +qall would become: nvim -es +PlugInstall ``` - Opt-out (`--clean` or `-u NONE`) is much easier than opt-in (`-u path/to/config`). - User config/packages are analogous to pip packages, which are expected when doing `python -c ...`. related: 7c94bcd2d77e2e54b8836ab8325460a367b79eae related: ddd0eb6f5120a09b97867d2561ea61309038ccd2
* test: spawn_wait() starts a non-RPC Nvim processJustin M. Keyes2025-01-03
| | | | | | | | | | | Problem: Can't use `n.clear()` to test non-RPC `nvim` invocations. So tests end up creating ad-hoc wrappers around `system()` or `jobstart()`. Solution: - Introduce `n.spawn_wait()` - TODO (followup PR): Rename `n.spawn()` and `n.spawn_wait()`. It's misleading that `n.spawn()` returns a RPC session...
* refactor: iwyu #31637Justin M. Keyes2024-12-23
| | | Result of `make iwyu` (after some "fixups").
* refactor(options): autogenerate valid values and flag enums for options (#31089)Famiu Haque2024-11-23
| | | | | | | | | | | | | | Problem: Option metadata like list of valid values for an option and option flags are not listed in the `options.lua` file and are instead manually defined in C, which means option metadata is split between several places. Solution: Put metadata such as list of valid values for an option and option flags in `options.lua`, and autogenerate the corresponding C variables and enums. Supersedes #28659 Co-authored-by: glepnir <glephunter@gmail.com>
* refactor(windows)!: only support UCRT, even for mingwbfredl2024-11-21
| | | | | | | | | | | The newer UCRT runtime has native support for UTF-8, including forcing it as the active codepage even before `main()` is called. This means the c runtime will properly convert windows WCHAR:s into UTF-8 bytes, as early as the argv/argc params to `main()` . Whereas MSVCRT does not support this reliably and required us to use `wmain()`. Only MSVC supports using manifest files directly as source files. The solution for other Windows toolchains is to use a .rc file.
* vim-patch:9.1.0797: testing of options can be further improved (#30893)zeertzjq2024-10-22
| | | | | | | | | | | Problem: testing of options can be further improved Solution: split the generated option test into test_options_all.vim, add more test cases, save and restore values, fix use-after-free closes: vim/vim#15894 https://github.com/vim/vim/commit/6eca04e9f1d446dc509ba51e32da56fa413fe2f0 Co-authored-by: Milly <milly.ca@gmail.com>
* fix(exit): close memfiles after processing events (#30872)zeertzjq2024-10-21
| | | | | Problem: When exiting, processed events may still use memfiles after they are closed. Solution: Close memfiles after processing events.
* fix(build): remove USE_FNAME_CASE, redundant with CASE_INSENSITIVE_FILENAMEbfredl2024-10-11
| | | | | It stands to reason, you need to "fix" case-insensitive filenames if-and-only-if you have case-insensitive filenames.
* refactor(api)!: rename Dictionary => DictJustin M. Keyes2024-09-23
| | | | | | | | | | | | | | In the api_info() output: :new|put =map(filter(api_info().functions, '!has_key(v:val,''deprecated_since'')'), 'v:val') ... {'return_type': 'ArrayOf(Integer, 2)', 'name': 'nvim_win_get_position', 'method': v:true, 'parameters': [['Window', 'window']], 'since': 1} The `ArrayOf(Integer, 2)` return type didn't break clients when we added it, which is evidence that clients don't use the `return_type` field, thus renaming Dictionary => Dict in api_info() is not (in practice) a breaking change.
* feat(tui): builtin UI (TUI) sets client info #30397Justin M. Keyes2024-09-18
| | | | | | | | | | | | Problem: The default builtin UI client does not declare its client info. This reduces discoverability and makes it difficult for plugins to identify the UI. Solution: - Call nvim_set_client_info after attaching, as recommended by `:help dev-ui`. - Also set the "pid" field. - Also change `ui_active()` to return a count. Not directly relevant to this commit, but will be useful later.
* refactor: rename "process" => "proc" #30387Justin M. Keyes2024-09-15
| | | | | | | | | | | | Problem: - "process" is often used as a verb (`multiqueue_process_events`), which is ambiguous for cases where it's used as a topic. - The documented naming convention for processes is "proc". - `:help dev-name-common` - Shorter is better, when it doesn't harm readability or discoverability. Solution: Rename "process" => "proc" in all C symbols and module names.
* fix(startup): ignore broken $XDG_RUNTIME_DIR #30285Justin M. Keyes2024-09-08
| | | | | | | | | | | | | | | | | | | | | | | | | Problem: $XDG_RUNTIME_DIR may be broken on WSL, which prevents starting (and even building) Nvim. #30282 Solution: - When startup fails, mention the servername in the error message. - If an autogenerated server address fails, log an error and continue with an empty `v:servername`. It's only fatal if a user provides a bad `--listen` or `$NVIM_LISTEN_ADDRESS` address. Before: $ nvim --headless --listen ./hello.sock nvim: Failed to --listen: "address already in use" $ NVIM_LISTEN_ADDRESS='./hello.sock' ./build/bin/nvim --headless nvim: Failed to --listen: "address already in use" After: $ nvim --headless --listen ./hello.sock nvim: Failed to --listen: address already in use: "./hello.sock" $ NVIM_LISTEN_ADDRESS='./hello.sock' ./build/bin/nvim --headless nvim: Failed $NVIM_LISTEN_ADDRESS: address already in use: "./hello.sock"
* feat(startup): validate --listen addressJustin M. Keyes2024-09-02
| | | | | | | | | | | | | Problem: `nvim --listen` does not error on EADDRINUSE. #30123 Solution: Now that `$NVIM_LISTEN_ADDRESS` is deprecated and input *only* (instead of the old, ambiguous situation where it was both an input *and* an output), we can be fail fast instead of trying to "recover". This reverts the "recovery" behavior of 704ba4151e7f67999510ee0ac19fdabb595d530c, but that was basically a workaround for the fragility of `$NVIM_LISTEN_ADDRESS`.
* docs: misc #28970Justin M. Keyes2024-09-01
|
* refactor(shada): rework msgpack decoding without msgpack-cbfredl2024-08-05
| | | | | | | This also makes shada reading slightly faster due to avoiding some copying and allocation. Use keysets to drive decoding of msgpack maps for shada entries.
* docs: misc (#29622)dundargoc2024-07-15
| | | | Co-authored-by: Christian Clason <c.clason@uni-graz.at> Co-authored-by: zeertzjq <zeertzjq@outlook.com>
* refactor: Windows tilde expansion followup (#29380)Rafael Kitover2024-06-18
| | | | | | | | | | | | | | | | | | | | | | | Followup to #28515: Rename the static os_homedir() to os_uv_homedir() to emphasize that it is a wrapper around a libuv function. Add the function os_get_homedir() to os/env.c to return the cached homedir value as a const. Must be called after homedir is initialized or it fails. The difference between this function and the static os_uv_homedir() is that the latter gets the homedir from libuv and is used to initialize homedir in init_homedir(), while os_get_homedir() just returns homedir as a const if it's initialized and is public. Use the os_get_homedir() accessor for ~/ expansion on Windows to make the code more concise. Add a Windows section to main_spec.lua with tests for expanding ~/ and ~\ prefixes for files passed in on the command-line. Signed-off-by: Rafael Kitover <rkitover@gmail.com>
* Merge pull request #29124 from bfredl/inputringbfredl2024-06-02
|\ | | | | refactor(input): don't use a ring for input
| * refactor(input): don't use a ring for inputbfredl2024-06-01
| | | | | | | | Since paste data is handled via a separate channel, the data processed via `input_buffer` is typically just explicit keys as typed in by the user. Therefore it should be fine to use `memmove()` to always put the remaining data in front when refilling the buffer.
* | refactor: move shared messages to errors.h #26214Justin M. Keyes2024-06-01
|/
* refactor(fileio): remove useless use of FileDescriptorbfredl2024-05-28
| | | | | | | FileDescriptor is used to buffer togheter many small writes to fewer syscalls. if the data to write already is in a single buffer, it is perfectly fine to just use os_write directly (which will take care of the reverse problem: splitting a too big write into many syscalls)
* feat(main): expand file ~\ or ~/ prefix on Windows (#28515)Rafael Kitover2024-05-25
| | | | | | | | In command_line_scan() for MSWIN, expand "~\" or "~/" prefixed paths to the USERPROFILE environment variable for the user's profile directory. Fix #23901 Signed-off-by: Rafael Kitover <rkitover@gmail.com>
* fix(treesitter): make tests for memoize more robustbfredl2024-04-29
| | | | | | | | | | | | Instead of painfully messing with timing to determine if queries were reparsed, we can simply keep a counter next to the call to ts_query_new Also memoization had a hidden dependency on the garbage collection of the the key, a hash value which never is kept around in memory. this was done intentionally as the hash does not capture all relevant state for the query (external included files) even if actual query objects still would be reachable in memory. To make the test fully deterministic in CI, we explicitly control GC.
* perf(ui_client): skip some initialization not necessary for ui clientbfredl2024-04-29
| | | | | In particular, TUI manages its own screen buffers and highlight table, so we don't need to run init_highlight() and default_grid_alloc() in the ui client process.
* fix(lua): vim.fn.has('nvim-0.10') in fast context, used by vim.deprecatebfredl2024-04-25
|
* ci(windows): optionally test windows with ASANdundargoc2024-03-23
| | | | Add the label `ci:windows-asan` to enable it.
* refactor(options): remove `set_string_option_direct()`Famiu Haque2024-03-21
| | | | | | Problem: `set_string_option_direct()` contains a separate codepath specifically for setting string options. Not only is that unnecessary code duplication, but it's also limited to only string options. Solution: Replace `set_string_option_direct()` with `set_option_direct()` which calls `set_option()` under the hood. This reduces code duplication and allows directly setting an option of any type.
* fix(startup): set full_screen when in ex_modeglepnir2024-03-09
| | | | | | | | Problem Description: In ex_mode, the default_grid.chars are not allocated, and subsequently, the w_grid.target in curwin is not allocated to default_grid in update_screen. This leads to a null pointer crash when the completion function is executed in ex_mode. Solution: Set full_screen when in ex_mode to ensure that default_grid is allocated.
* refactor(msgpack): allow flushing buffer while packing msgpackbfredl2024-03-07
| | | | | | | | | | | | | | Before, we needed to always pack an entire msgpack_rpc Object to a continous memory buffer before sending it out to a channel. But this is generally wasteful. it is better to just flush whatever is in the buffer and then continue packing to a new buffer. This is also done for the UI event packer where there are some extra logic to "finish" of an existing batch of nevents/ncalls. This doesn't really stop us from flushing the buffer, just that we need to update the state machine accordingly so the next call to prepare_call() always will start with a new event (even though the buffer might contain overflow data from a large event).
* refactor(metadata): generate all metadata in luabfredl2024-02-28
| | | | | | | | Then we can just load metadata in C as a single msgpack blob. Which also can be used directly as binarly data, instead of first unpacking all the functions and ui_events metadata to immediately pack it again, which was a bit of a silly walk (and one extra usecase of `msgpack_rpc_from_object` which will get yak shaved in the next PR)
* refactor(fileio): remove API shell layer encouraging unnecessary allocationsbfredl2024-02-25
| | | | | | | | | | | | | | | | | | | | | | | | Functions like file_open_new() and file_open_fd_new() which just is a wrapper around the real functions but with an extra xmalloc/xfree around is an anti-pattern. If the caller really needs to allocate a FileDescriptor as a heap object, it can do that directly. FileDescriptor by itself is pretty much a pointer, or rather two: the OS fd index and a pointer to a buffer. So most of the time an extra pointer layer is just wasteful. In the case of scriptin[curscript] in getchar.c, curscript used to mean in practice: N+1 open scripts when curscript>0 zero or one open scripts when curscript==0 Which means scriptin[0] had to be compared to NULL to disambiguate the curscript=0 case. Instead, use curscript==-1 to mean that are no script, then all pointer comparisons dissappear and we can just use an array of structs without extra pointers.
* refactor(api): use arena for channel info and terminal infobfredl2024-02-18
|
* refactor(eval): use arena when converting typvals to Objectbfredl2024-02-15
| | | | | | | | | | | | Note: this contains two _temporary_ changes which can be reverted once the Arena vs no-Arena distinction in API wrappers has been removed. Both nlua_push_Object and object_to_vim_take_luaref() has been changed to take the object argument as a pointer. This is not going to be necessary once these are only used with arena (or not at all) allocated Objects. The object_to_vim() variant which leaves luaref untouched might need to stay for a little longer.
* refactor(lua): use Arena when converting from lua stack to API argsbfredl2024-02-13
| | | | | | | | | | | | and for return value of nlua_exec/nlua_call_ref, as this uses the same family of functions. NB: the handling of luaref:s is a bit of a mess. add api_luarefs_free_XX functions as a stop-gap as refactoring luarefs is a can of worms for another PR:s. as a minor feature/bug-fix, nvim_buf_call and nvim_win_call now preserves arbitrary return values.
* fix(startup): multiprocess startuptime #26790Pablo Arias2024-02-09
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Problem: Since 24488169564c39a506c235bf6a33b8e23a8cb528, the --startuptime report shows two blocks of data. The TUI process and its embedded nvim process write to the file concurrently, which may interleave the two startup sequences into the same timeline. Solution: Report each process as a separate section in the same file. 1. Each process buffers the full report. 2. After startup is finished, the buffer is flushed (appended) to the file. Fix #23036 Sample report: --- Startup times for process: Primary/TUI --- times in msec clock self+sourced self: sourced script clock elapsed: other lines 000.006 000.006: --- NVIM STARTING --- 000.428 000.422: event init 000.728 000.301: early init ... 005.880 000.713: init highlight 005.882 000.002: --- NVIM STARTED --- --- Startup times for process: Embedded --- times in msec clock self+sourced self: sourced script clock elapsed: other lines 000.006 000.006: --- NVIM STARTING --- 000.409 000.403: event init 000.557 000.148: early init 000.633 000.077: locale set ... 014.383 000.430: first screen update 014.387 000.003: --- NVIM STARTED ---
* feat(quickfix): support -q - to read 'errorfile' from stdin (#27303)zeertzjq2024-02-02
| | | Note that this only works when stdin is a pipe.
* refactor(IWYU): fix headersdundargoc2024-01-11
| | | | | | Remove `export` pramgas from defs headers as it causes IWYU to believe that the definitions from the defs headers comes from main header, which is not what we really want.
* refactor(options): remove `OPT_FREE` (#26963)Famiu Haque2024-01-10
| | | | | | Problem: `OPT_FREE` macro doesn't seem to do anything as `P_ALLOCED` already handles allocations. Solution: Remove `OPT_FREE`.
* refactor: follow style guidedundargoc2023-12-30
|
* refactor: remove os_errmsg and os_msg functionsdundargoc2023-12-23
| | | | Instead replace them with fprintf and printf.
* refactor: run IWYU on entire repodundargoc2023-12-21
| | | | Reference: https://github.com/neovim/neovim/issues/6371.
* refactor: use `bool` to represent boolean valuesdundargoc2023-12-19
|
* refactor(options): reduce `findoption()` usageFamiu Haque2023-12-09
| | | | | | Problem: Many places in the code use `findoption()` to access an option using its name, even if the option index is available. This is very slow because it requires looping through the options array over and over. Solution: Use option index instead of name wherever possible. Also introduce an `OptIndex` enum which contains the index for every option as enum constants, this eliminates the need to pass static option names as strings.
* refactor(IWYU): fix includes for cmdhist.h (#26324)zeertzjq2023-11-30
|
* refactor: move extern variables out of _defs.h files (#26320)zeertzjq2023-11-30
|
* build: don't define FUNC_ATTR_* as empty in headers (#26317)zeertzjq2023-11-30
| | | | | | FUNC_ATTR_* should only be used in .c files with generated headers. Defining FUNC_ATTR_* as empty in headers causes misuses of them to be silently ignored. Instead don't define them by default, and only define them as empty after a .c file has included its generated header.
* refactor: move some constants out of vim_defs.h (#26298)zeertzjq2023-11-29
|
* refactor: fix headers with IWYUdundargoc2023-11-28
|
* refactor: rename types.h to types_defs.hdundargoc2023-11-27
|