aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/api/vim.c
Commit message (Collapse)AuthorAge
...
* fix(api): nvim_create_buf assert fails if autocmds set &swapfileSean Dewar2024-03-19
| | | | | | | | | | | | | | | | | | Problem: assertion failure in nvim_create_buf if buflist_new autocommands open a swapfile when "scratch" is set. Solution: block autocommands when setting up the buffer; fire them later instead. Note that, unlike buflist_new, I don't check if autocommands aborted script processing; the buffer is already created and configured at that point, so might as well return the handle anyway. Rather than repeat try_{start,end} and {un}block_autocmds for each relevant operation, just do it at the start and near the end. This means that, if TermResponse fires from unblock_autocmds for whatever reason, it can see the buffer in an already configured state if we didn't bail due to an error (plus it's probably a bit cleaner this way).
* fix(api): nvim_create_buf leaks memory if buffer is loaded earlySean Dewar2024-03-19
| | | | | | | Problem: memory leak in nvim_create_buf if buflist_new autocommands load the new buffer early. Solution: do not open a memfile in that case.
* vim-patch:9.1.0147: Cannot keep a buffer focused in a windowColin Kennedy2024-03-11
| | | | | | | | | | | | | | | Problem: Cannot keep a buffer focused in a window (Amit Levy) Solution: Add the 'winfixbuf' window-local option (Colin Kennedy) fixes: vim/vim#6445 closes: vim/vim#13903 https://github.com/vim/vim/commit/215703563757a4464907ead6fb9edaeb7f430bea N/A patch: vim-patch:58f1e5c0893a
* docs: support inline markdownLewis Russell2024-03-09
| | | | | | - Tags are now created with `[tag]()` - References are now created with `[tag]` - Code spans are no longer wrapped
* 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)
* feat(docs): replace lua2dox.luaLewis Russell2024-02-27
| | | | | | | | | | | | | | | | | | | | | | | | | | Problem: The documentation flow (`gen_vimdoc.py`) has several issues: - it's not very versatile - depends on doxygen - doesn't work well with Lua code as it requires an awkward filter script to convert it into pseudo-C. - The intermediate XML files and filters makes it too much like a rube goldberg machine. Solution: Re-implement the flow using Lua, LPEG and treesitter. - `gen_vimdoc.py` is now replaced with `gen_vimdoc.lua` and replicates a portion of the logic. - `lua2dox.lua` is gone! - No more XML files. - Doxygen is now longer used and instead we now use: - LPEG for comment parsing (see `scripts/luacats_grammar.lua` and `scripts/cdoc_grammar.lua`). - LPEG for C parsing (see `scripts/cdoc_parser.lua`) - Lua patterns for Lua parsing (see `scripts/luacats_parser.lua`). - Treesitter for Markdown parsing (see `scripts/text_utils.lua`). - The generated `runtime/doc/*.mpack` files have been removed. - `scripts/gen_eval_files.lua` now instead uses `scripts/cdoc_parser.lua` directly. - Text wrapping is implemented in `scripts/text_utils.lua` and appears to produce more consistent results (the main contributer to the diff of this change).
* docs: remove mention of foreground/background/special keys in nvim_set_hl ↵rktjmp2024-02-21
| | | | | | | | | | (#27558) To align the output of `nvim_get_hl` with its documentation -- which points to `nvim_set_hl`, remove mentions of the keys `foreground`, `background` and `special`. The long keys are are still supported (via fallback checks inside `dict2hlattrs`), but the `fg`, `bg` and `sp` keys are preferenced.
* refactor(api): make freeing of return-value opt-in instead of opt outbfredl2024-02-21
| | | | | | | | | As only a few API functions make use of explicit freeing of the return value, make it opt-in instead. The arena is always present under the hood, so `Arena *arena` arg now doesn't mean anything other than getting access to this arena. Also it is in principle possible to return an allocated value while still using the arena as scratch space for other stuff (unlikely, but there no reason to not allow it).
* refactor(api): reduce temporary allocations when replacing linesbfredl2024-02-20
| | | | | | | | | | | | | | | The way ml_replace_buf is implemented makes it unfriendly for being used in a loop: every call allocates a scratch buffer for putting the line into the "dirty" state. This then immediately needs to be freed as the next ml_replace_buf and/or ml_append_buf call will flush that buffer. It's better to later pay the price of allocating the scratch buffer only if the line is being immediately edited (likely when using the API to only change one line) with an extra memcpy, than allocating that buffer multiple times every time the API is called. Of course, a separate xmalloc/xfree cycle for each time the dirty line changes is unwanted to begin with. But fixing that is a later refactor.
* refactor(api): use arena for nvim_put and nvim_pastebfredl2024-02-19
|
* refactor(api): use arena when listing objectsbfredl2024-02-19
|
* refactor(api): use arena for runtime and client infobfredl2024-02-19
|
* refactor(api): use arena for metadata; msgpack_rpc_to_object delenda estbfredl2024-02-18
| | | | | | Note: kSDItemHeader is something is _written_ by nvim in the shada file to identify it for debugging purposes outside of nvim. But this data wasn't ever used by neovim after reading the file back, So I removed the parsing of it for now.
* refactor(api): use arena for channel info and terminal infobfredl2024-02-18
|
* refactor(api): use an arena for mappingsbfredl2024-02-18
|
* fix(api): don't use stl 'fillchar' for "use_statuscol_lnum" (#27501)luukvbaal2024-02-17
| | | | Problem: nvim_eval_statusline() uses "stl" from 'fillchars' with "use_statuscol_lnum". Solution: Reorder "fillchar" else chain.
* 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.
* refactor(api): use an arena for nvim_buf_get_lines and buffer updatesbfredl2024-02-11
| | | | | Refactor some earlier "temporary Array" code in buffer_updates.c to use the modern style of MAXSIZE_TEMP_ARRAY and ADD_C
* refactor(api): use arena for hlstate inspectionbfredl2024-02-09
|
* refactor(api): use arena for nvim_list_uis()bfredl2024-02-09
|
* refactor(api): make cstr_as_string accept "const char*"bfredl2024-02-09
| | | | | In the context a String inside an Object/Dictionary etc is consumed, it is considered to be read-only.
* refactor(api): refactor more api functions to use arena returnbfredl2024-02-08
| | | | | | | | | | | | | | | Currently having two separate memory strategies for API return values is a bit unnecessary, and mostly a consequence of converting the hot spot cases which needed it first. But there is really no downside to using arena everywhere (which implies also directly using strings which are allocated earlier or even statically, without copy). There only restriction is we need to know the size of arrays in advance, but this info can often be passed on from some earlier stage if it is missing. This collects some "small" cases. The more complex stuff will get a PR each.
* feat(api): pass 0 to nvim_get_chan_info for current channel (#27321)nikolightsaber2024-02-08
| | | | | | | | | | | Getting current channel info was kind of annoying via RPC. Two functions had to be called: 1. `nvim_get_api_info` which returns `[channel_id, meta_data]`. - This results in `channel_id = api.nvim_get_api_info()[0]`. - Here the meta_data is sent but never used. 2. Finally call `nvim_get_chan_info(channel_id)`. This commit reduces the need for `nvim_get_api_info` as passing 0 returns current channel info.
* refactor(api): remove some unnecessary HAS_KEY() (#27283)zeertzjq2024-02-01
| | | | Since keydicts are already zero-initialized, HAS_KEY() isn't needed if the zero-initialized value can satisfy some other condition.
* vim-patch:9.1.0047: issues with temp curwin/buf while cmdwin is openSean Dewar2024-01-28
| | | | | | | | | | | | | | | | | Problem: Things that temporarily change/restore curwin/buf (e.g: win_execute, some autocmds) may break assumptions that curwin/buf is the cmdwin when "cmdwin_type != 0", causing issues. Solution: Expose the cmdwin's real win/buf and check that instead. Also try to ensure these variables are NULL if "cmdwin_type == 0", allowing them to be used directly in most cases without checking cmdwin_type. (Sean Dewar) Reset and save `cmdwin_old_curwin` in a similar fashion. Apply suitable changes for API functions and add Lua tests. https://github.com/vim/vim/commit/988f74311c26ea9917e84fbae608de226dba7e5f
* feat(ui): add support for OSC 8 hyperlinks (#27109)Gregory Anders2024-01-24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Extmarks can contain URLs which can then be drawn in any supporting UI. In the TUI, for example, URLs are "drawn" by emitting the OSC 8 control sequence to the TTY. On terminals which support the OSC 8 sequence this will create clickable hyperlinks. URLs are treated as inline highlights in the decoration subsystem, so are included in the `DecorSignHighlight` structure. However, unlike other inline highlights they use allocated memory which must be freed, so they set the `ext` flag in `DecorInline` so that their lifetimes are managed along with other allocated memory like virtual text. The decoration subsystem then adds the URLs as a new highlight attribute. The highlight subsystem maintains a set of unique URLs to avoid duplicating allocations for the same string. To attach a URL to an existing highlight attribute we call `hl_add_url` which finds the URL in the set (allocating and adding it if it does not exist) and sets the `url` highlight attribute to the index of the URL in the set (using an index helps keep the size of the `HlAttrs` struct small). This has the potential to lead to an increase in highlight attributes if a URL is used over a range that contains many different highlight attributes, because now each existing attribute must be combined with the URL. In practice, however, URLs typically span a range containing a single highlight (e.g. link text in Markdown), so this is likely just a pathological edge case. When a new highlight attribute is defined with a URL it is copied to all attached UIs with the `hl_attr_define` UI event. The TUI manages its own set of URLs (just like the highlight subsystem) to minimize allocations. The TUI keeps track of which URL is "active" for the cell it is printing. If no URL is active and a cell containing a URL is printed, the opening OSC 8 sequence is emitted and that URL becomes the actively tracked URL. If the cursor is moved while in the middle of a URL span, we emit the terminating OSC sequence to prevent the hyperlink from spanning multiple lines. This does not support nested hyperlinks, but that is a rare (and, frankly, bizarre) use case. If a valid use case for nested hyperlinks ever presents itself we can address that issue then.
* 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): use schar_T representation for fillchars and listcharsbfredl2024-01-08
| | | | | | | | | | | A bit big, but practically it was a lot simpler to change over all fillchars and all listchars at once, to not need to maintain two parallel implementations. This is mostly an internal refactor, but it also removes an arbitrary limitation: that 'fillchars' and 'listchars' values can only be single-codepoint characters. Now any character which fits into a single screen cell can be used.
* refactor: follow style guidedundargoc2023-12-30
|
* refactor: remove CPO_TO_CPO_FLAGS() (#26718)zeertzjq2023-12-23
| | | | | Just pass p_cpo to replace_termcodes() directly. This allows removing option_vars.h from keycodes.h, and also avoids the mistake of passing 0 as cpo_flags.
* refactor: run IWYU on entire repodundargoc2023-12-21
| | | | Reference: https://github.com/neovim/neovim/issues/6371.
* refactor(IWYU): move decor provider types to decoration_defs.h (#26692)zeertzjq2023-12-21
|
* feat(api): add forward and back mouse buttonsAmanda Graven2023-12-18
|
* refactor: move non-symbols to defs.h headersdundargoc2023-12-17
|
* feat(ui): completeopt support popup like vimmathew2023-12-16
|
* feat(nvim_open_term): convert LF => CRLF (#26384)Raphael2023-12-14
| | | | | | | | | | | | | | | | | | | | | | | | | | Problem: Unlike termopen(), nvim_open_term() PTYs do not carriage-return the cursor on newline ("\n") input. nvim --clean :let chan_id = nvim_open_term(1, {}) :call chansend(chan_id, ["here", "are", "some", "lines"]) Actual behavior: here are some lines Expected behaviour: here are some lines Solution: Add `force_crlf` option, and enable it by default.
* 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.
* perf(column): keep track of number of lines that hold up the 'signcolumn'Luuk van Baal2023-12-07
| | | | | | | | | | | | | | | | | | | | Problem: The entire marktree needs to be traversed each time a sign is removed from the sentinel line. Solution: Remove sentinel line and instead keep track of the number of lines that hold up the 'signcolumn' in "max_count". Adjust this number for added/removed signs, and set it to 0 when the maximum number of signs on a line changes. Only when "max_count" is decremented to 0 due to sign removal do we need to check the entire buffer. Also replace "invalid_top" and "invalid_bot" with a map of invalid ranges, further reducing the number of lines to be checked. Also improve tree traversal when counting the number of signs. Instead of looping over the to be checked range and counting the overlap for each row, keep track of the overlap in an array and add this to the count.
* refactor(api): complete conversion from `Dictionary` to `Dict(opts)` (#26365)Riccardo Mazzarini2023-12-05
|
* refactor(terminal): only remove const qualifier when necessary (#26386)zeertzjq2023-12-04
|
* 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(IWYU): create normal_defs.h (#26293)zeertzjq2023-11-29
|
* refactor: fix headers with IWYUdundargoc2023-11-28
|
* feat(decoration): allow conceal_char to be a composing charbfredl2023-11-28
| | | | | | | | decor->text.str pointer must go. This removes it for conceal char, in preparation for a larger PR which will also handle the sign case. By actually allowing composing chars for a conceal chars, this becomes a feature and not just a refactor, as a bonus.
* refactor: rename types.h to types_defs.hdundargoc2023-11-27
|
* refactor: fix includes for api/autocmd.hdundargoc2023-11-27
|
* build(IWYU): fix includes for undo_defs.hdundargoc2023-11-27
|
* build(IWYU): fix includes for func_attr.hdundargoc2023-11-27
|
* refactor: move Arena and ArenaMem to memory_defs.h (#26240)zeertzjq2023-11-27
|