aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/api/private/helpers.c
Commit message (Collapse)AuthorAge
...
* fix(api): validate command names in nvim_add_user_command (#17406)Gregory Anders2022-02-15
| | | | This uses the same validation used when defining commands with `:command`.
* vim-patch:8.2.4018: ml_get error when win_execute redraws with Visual selectionSean Dewar2022-02-03
| | | | | | | | | | | Problem: ml_get error when win_execute redraws with Visual selection. Solution: Disable Visual area temporarily. (closes vim/vim#9479) https://github.com/vim/vim/commit/18f4740f043b353abe47b7a00131317052457686 {switch_to/restore}_win_for_buf is N/A (marked as such in v8.0.0860; currently only used in Vim's if_py). Add a modeline to test_execute_func.vim.
* vim-patch:8.2.4241: some type casts are redundantDundar Göc2022-01-30
| | | | | | | | Problem: Some type casts are redundant. Solution: Remove the type casts. (closes vim/vim#9643) https://github.com/vim/vim/commit/420fabcd4ffeaf79082a6e43db91e1d363f88f27 This is not a literal port but an equivalent one.
* vim-patch:8.2.3584: "verbose set efm" reports location of the :compiler commandzeertzjq2022-01-21
| | | | | | | | Problem: "verbose set efm" reports the location of the :compiler command. (Gary Johnson) Solution: Add the "-keepscript" argument to :command and use it when defining CompilerSet. https://github.com/vim/vim/commit/58ef8a31d7087d495ab1582be5b7a22796ac2451
* refactor(extmarks): use a more efficient representationBjörn Linse2022-01-15
| | | | | | | | | | | | | | | | | | | | | | | | | | | marktree.c was originally constructed as a "generic" datatype, to make the prototyping of its internal logic as simple as possible and also as the usecases for various kinds of extmarks/decorations was not yet decided. As a consequence of this, various extra indirections and allocations was needed to use marktree to implement extmarks (ns/id pairs) and decorations of different kinds (some which is just a single highlight id, other an allocated list of virtual text/lines) This change removes a lot of indirection, by making Marktree specialized for the usecase. In particular, the namespace id and mark id is stored directly, instead of the 64-bit global id particular to the Marktree struct. This removes the two maps needed to convert between global and per-ns ids. Also, "small" decorations are stored inline, i.e. those who doesn't refer to external heap memory anyway. That is highlights (with priority+flags) are stored inline, while virtual text, which anyway occurs a lot of heap allocations, do not. (previously a hack was used to elide heap allocations for highlights with standard prio+flags) TODO(bfredl): the functionaltest-lua CI version of gcc is having severe issues with uint16_t bitfields, so splitting up compound assignments and redundant casts are needed. Clean this up once we switch to a working compiler version.
* fix(api): validate user_command name (#17004)Lewis Russell2022-01-09
| | | | The name argument of nvim_add_user_command must begin with an uppercase character. Check that is does.
* fix(api): force redefinition of user commands by default (#16918)Gregory Anders2022-01-04
|
* perf(api): elide luaref copy when setting 'callback' in nvim_set_keymapBjörn Linse2022-01-01
|
* feat(api): add support for lua function & description in keymapshadmansaleh2022-01-01
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Behavioral changes: 1. Added support for lua function in keymaps in -------------------------------------------- - nvim_set_keymap Can set lua function as keymap rhs like following: ```lua vim.api.nvim_{buf_}set_keymap('n', '<leader>lr', '', {callback = vim.lsp.buf.references}) ``` Note: lua function can only be set from lua . If api function being called from viml or over rpc this option isn't available. - nvim_{buf_}get_keymap When called from lua, lua function is returned is `callback` key . But in other cases callback contains number of the function ref. - :umap, nvim_del_keymap & nvim_buf_del_keymap clears lua keymaps correctly. - :map commands for displaing rhs . For lua keymaps rhs is displayed as <Lua function ref_no> Note: lua keymap cannot be set through viml command / functions. - mapargs() When dict is false it returns string in `<Lua function ref_no>` format (same format as :map commands). When dict is true it returns ref_no number in `callback` key. - mapcheck() returns string in `<Lua function ref_no>` format (same format as :map commands). 2. Added support for keymap description --------------------------------------- - nvim_{buf_}set_keymap: added `desc` option in opts table . ```lua vim.api.nvim_set_keymap('n', '<leader>w', '<cmd>w<cr>', {desc='Save current file'}) ``` - nvim_{buf_}get_keymap: contains `desc` in returned list. - commands like `:nmap <leader>w` will show description in a new line below rhs. - `maparg()` return dict contains `desc`.
* feat(api): implement nvim_{add,del}_user_commandGregory Anders2021-12-28
| | | | | Add support for adding and removing custom user commands with the Nvim API.
* fix: add STRNLEN compatability macroClaes Nästén2021-12-06
| | | | | Older SunOS systems come without strnlen, add STRNLEN macro in line with the other str* compat macros.
* refactor: saner options for uncrustify #16196dundargoc2021-10-31
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * refactor: general good option changes sp_deref = remove sp_not = remove sp_inv = remove sp_inside_paren_cast = remove mod_remove_duplicate_include = true sp_after_semi = add sp_after_semi_for = force sp_sizeof_paren = remove nl_return_expr = remove nl_else_brace = remove nl_else_if = remove * refactor: mod_remove_extra_semicolon = true * refactor: nl_max = 3 * refactor: sp_bool = force * refactor: sp_compare = force * refactor: sp_inside_paren = remove * refactor: sp_paren_paren = remove * refactor: sp_inside_sparen = remove * refactor: sp_before_sparen = force * refactor: sp_sign = remove * refactor: sp_addr = remove * refactor: sp_member = remove * refactor: nl_struct_brace = remove * refactor: nl_before_if_closing_paren = remove * refactor: nl_fdef_brace = force * refactor: sp_paren_comma = force * refactor: mod_full_brace_do = add
* refactor(api): break out vim_to_object/object_to_vim to own fileBjörn Linse2021-10-29
|
* refactor(api): move extmark API to its own fileBjörn Linse2021-10-25
|
* feat(api): evaluate statusline string #16020Famiu Haque2021-10-18
| | | | | | Adds API function `nvim_eval_statusline` to allow evaluating a statusline string and obtaining information regarding it. Closes https://github.com/neovim/neovim/issues/15849
* refactor: reduce number of unique char casts (#15995)dundargoc2021-10-12
|
* refactor: format all C files under nvim/ #15977dundargoc2021-10-12
| | | | | | | | * refactor: format all C files under nvim * refactor: disable formatting for Vim-owned files: * src/nvim/indent_c.c * src/nvim/regexp.c * src/nvim/regexp_nfa.c * src/nvim/testdir/samples/memfile_test.c
* refactor(api): cleanup modify_keymap and parse_keymap_optsBjörn Linse2021-10-07
|
* feat(api): named marks set, get, delete #15346Javier Lopez2021-10-05
| | | | | | | | | | | | | | | | | | | | | | | Adds the following API functions. - nvim_buf_set_mark(buf, name, line, col) * Set marks in a buffer. - nvim_buf_del_mark(buf, name) * Delete a mark that belongs to buffer. - nvim_del_mark(name) * Delete a global mark. - nvim_get_mark(name) * Get a global mark. Tests: - Adds test to all the new api functions, and adds more for the existing nvim_buf_get_mark. * Tests include failure cases. Documentation: - Adds documentation for all the new functions, and improves the existing fucntion docs.
* Merge pull request #15901 from bfredl/apiorgBjörn Linse2021-10-04
|\ | | | | refactor(api): re-organanize public and private API functions
| * refactor(api): move window config related functions to own fileBjörn Linse2021-10-04
| |
* | refactor: remove redundant char casts #15888dundargoc2021-10-04
|/
* 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
* feat(decorations): support virtual lines (for now: only one block at a time)Björn Linse2021-09-26
|
* fix(api): fix crash after set_option_value_for() #15390gmntroll2021-09-25
| | | | | | | | | | | | | | | | | | | | | 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
* refactor: format #15702dundargoc2021-09-18
|
* feat(api): convert Blobs to API stringsSean Dewar2021-09-15
| | | | Note that these are not NUL-terminated; the API supports this.
* vim-patch:8.1.0735: cannot handle binary dataSean Dewar2021-09-15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Problem: Cannot handle binary data. Solution: Add the Blob type. (Yasuhiro Matsumoto, closes vim/vim#3638) https://github.com/vim/vim/commit/6e5ea8d2a995b32bbc5972edc4f827b959f2702f Nvim-specific Blob conversions are implemented in future commits. Refactor write_blob() to use a FileDescriptor, as f_writefile() was refactored to use one (does not apply to read_blob()). Use var_check_lock() in f_add() for Blobs from v8.1.0897. Add a modeline to test_blob.vim and fix some doc typos. Include if_perl.txt's VIM::Blob() documentation. Interestingly, this function already worked before this port, as it just returns a Blob string literal, not an actual Blob object. N/A patches for version.c: vim-patch:8.1.0741: viminfo with Blob is not tested Problem: Viminfo with Blob is not tested. Solution: Extend the viminfo test. Fix reading a blob. Fixed storing a special variable value. https://github.com/vim/vim/commit/8c8b8bb56c724cc1bfc3d8520eec33f2d399697c vim-patch:8.1.1022: may use NULL pointer when out of memory Problem: May use NULL pointer when out of memory. (Coverity) Solution: Check for blob_alloc() returning NULL. https://github.com/vim/vim/commit/e142a9467a7f6845a426d8db6efedf246d3c13ac
* 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.
* refactor(api): remove unneccesary indirection around handlesBjörn Linse2021-08-22
| | | | | These things are just maps to pointers, no need to perform a huge song and dance around it.
* refactor(map): get rid of spurious subsystem_init() functions due to mapsBjörn Linse2021-08-22
|
* refactor: PVS/V501: removed duplicate sub-expression 'chunk.size > 2'Dundar Göc2021-07-30
|
* feat(decorations): deprecate nvim_buf_set_virtual_textBjörn Linse2021-07-29
| | | | Full virt_text functionality is provided by nvim_buf_set_extmark
* refactor(decorations): merge the two different code paths for virt_textBjörn Linse2021-07-29
| | | | | | test(bufhl): CHANGE of tested behaviour (inb4 a proper priority mechanism) test(decoration): change of test; previous behavior was buggy (ghost buffer text)
* feat(decorations): allow more than one stacked highlight in a virt_textBjörn Linse2021-07-29
|
* clang/'Dead initialization': don't assign unused value to variable "string" ↵dundargoc2021-07-07
| | | | #15015
* feat(float): add rounded borders presetChristian Clason2021-06-14
| | | | | | | | Add `borders = "rounded"` preset for `nvim_open_win`, equivalent to border = {"╭", "─", "╮", "│", "╯", "─", "╰", "│"} Also add undocumented "solid" preset to docs.
* api(parse_float_config): use api_object_to_bool()Sean Dewar2021-06-01
|
* api(nvim_open_win): add "noautocmd" optionSean Dewar2021-06-01
| | | | | | This option, when set, stops nvim_open_win() from potentially firing buffer-related autocmd events (BufEnter, BufLeave and BufWinEnter in the case of nvim_open_win()).
* lua: use proper conversion of vim.g valuesBjörn Linse2021-05-19
|
* floats: z-indexBjörn Linse2021-05-15
|
* float: add "solid" border style (#14310)Marco Hinz2021-04-12
| | | | | | It looks solid with the default `FloatBorder` group. If you set the bgcolor of FloatBorder to the same color as for FloatNormal, you effectively get an "1-cell padding".
* Border: allow to enable/disable specific border edgesBjörn Linse2021-04-04
|
* luaref: free decoration providersBjörn Linse2021-04-03
|
* floats: add borders (MS-DOS MODE)Björn Linse2021-03-22
|
* wheel: move non-window code out of window.cBjörn Linse2021-03-22
|
* api: nvim_echonotomo2021-01-20
|
* fix: check for valid buffer handles in modify_keymap (#13543)Thomas Vigouroux2021-01-03
| | | | Fixes #13541 Neovim would crash when trying to map a key on non existant buffer
* decoration: split out "decoration" from "extmark" moduleBjörn Linse2020-11-07
| | | | | Decorations will only grow more complex. move the to a separate file, so that extmark.c remains about extmarks.