aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/api/buffer.c
Commit message (Collapse)AuthorAge
...
* refactor: change type of linenr_T from long to int32_tDundar Goc2022-06-10
| | | | | | | | | | | | | The size of long varies depending on architecture, in contrast to the MAXLNUM constant which sets the maximum allowable number of lines to 2^32-1. This discrepancy may lead to hard to detect bugs, for example https://github.com/neovim/neovim/issues/18454. Setting linenr_T to a fix maximum size of 2^32-1 will prevent this type of errors in the future. Also change the variables `amount` and `amount_after` to be linenr_T since they're referring to "the line number difference" between two texts.
* refactor(uncrustify): set maximum number of consecutive newlines to 2 (#18695)dundargoc2022-05-25
|
* docs: nvim_buf_[get|set]_[text|lines] (#18404)Andrey Mishchenko2022-05-11
| | | | - Use consistent formatting for args docs. - Clarify inclusivity/exclusivity in `nvim_buf_[get|set]_text`.
* refactor: replace char_u variables and functions with charDundar Goc2022-05-05
| | | | Work on https://github.com/neovim/neovim/issues/459
* refactor: replace char_u variables and functions with charDundar Goc2022-04-30
| | | | Work on https://github.com/neovim/neovim/issues/459
* 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.
* docs: make docstring consistent with parameters #18178dundargoc2022-04-23
| | | Closes: https://github.com/neovim/neovim/issues/12691
* refactor!: rename nvim_add_user_command to nvim_create_user_commandGregory Anders2022-04-10
|
* docs: reword description for nvim_buf_line_count() (#17766)Xiretza2022-03-18
| | | This adds a few more keywords to make the function easier to find.
* refactor: minimize variable scope and eliminate empty declarationsDundar Göc2022-03-13
|
* refactor(uncrustify): format all c filesDundar Göc2022-03-10
|
* chore: fix typos (#17331)dundargoc2022-03-10
| | | | | | Co-authored-by: Hongyi Lyu <hongyi.lyu95@gmail.com> Co-authored-by: Gregory Anders <greg@gpanders.com> Co-authored-by: notomo <notomo.motono@gmail.com> Co-authored-by: zeertzjq <zeertzjq@outlook.com>
* feat(lua): show proper verbose output for lua configurationshadmansaleh2022-02-28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | `:verbose` didn't work properly with lua configs (For example: options or keymaps are set from lua, just say that they were set from lua, doesn't say where they were set at. This fixes that issue. Now `:verbose` will provide filename and line no when option/keymap is set from lua. Changes: - compiles lua/vim/keymap.lua as vim/keymap.lua - When souring a lua file current_sctx.sc_sid is set to SID_LUA - Moved finding scripts SID out of `do_source()` to `get_current_script_id()`. So it can be reused for lua files. - Added new function `nlua_get_sctx` that extracts current lua scripts name and line no with debug library. And creates a sctx for it. NOTE: This function ignores C functions and blacklist which currently contains only vim/_meta.lua so vim.o/opt wrappers aren't targeted. - Added function `nlua_set_sctx` that changes provided sctx to current lua scripts sctx if a lua file is being executed. - Added tests in tests/functional/lua/verbose_spec.lua - add primary support for additional types (:autocmd, :function, :syntax) to lua verbose Note: These can't yet be directly set from lua but once that's possible :verbose should work for them hopefully :D - add :verbose support for nvim_exec & nvim_command within lua Currently auto commands/commands/functions ... can only be defined by nvim_exec/nvim_command this adds support for them. Means if those Are defined within lua with vim.cmd/nvim_exec :verbose will show their location . Though note it'll show the line no on which nvim_exec call was made.
* fix(api)!: correctly handle negative line numbers for nvim_buf_set_text (#17498)Gregory Anders2022-02-23
| | | | | | | | | | | | | | | | | | | | | | | | nvim_buf_set_text does not handle negative row numbers correctly: for example, nvim_buf_set_text(0, -2, 0, -1, 20, {"Hello", "world"}) should replace the 2nd to last line in the buffer with "Hello" and the first 20 characters of the last line with "world". Instead, it reports "start_row out of bounds". This happens because when negative line numbers are used, they are incremented by one additional number to make the non-negative line numbers end-exclusive. However, the line numbers for nvim_buf_set_text should be end-inclusive. In #15181 we handled this for nvim_buf_get_text by adding a new parameter to `normalize_index`. We can solve the problem with nvim_buf_set_text by simply availing ourselves of this new argument. This is a breaking change, but makes the semantics of negative line numbers much clearer and more obvious (as well as matching nvim_buf_get_text). BREAKING CHANGE: Existing usages of nvim_buf_set_text that use negative line numbers will be off-by-one.
* feat(api): implement nvim_buf_get_text (#15181)Gregory Anders2022-02-22
| | | | | | | | | | nvim_buf_get_text is the mirror of nvim_buf_set_text. It differs from nvim_buf_get_lines in that it allows retrieving only portions of lines. While this can typically be done easily enough by API clients, implementing this function provides symmetry between the get/set text/lines APIs, and also provides a nice convenience that saves API clients the work of having to slice the result of nvim_buf_get_lines themselves.
* 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.
* refactor(build): remove unused includeskylo2522021-12-12
|
* 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.
* chore: fix typos (#16361)dundargoc2021-11-27
| | | | | | | | | | | | | | | | | | | | | | | | | | Co-authored-by: Brede Yabo Sherling Kristensen <bredeyabo@hotmail.com> Co-authored-by: zeertzjq <zeertzjq@outlook.com> Co-authored-by: István Donkó <istvan.donko@gmail.com> Co-authored-by: Julian Berman <Julian@GrayVines.com> Co-authored-by: bryant <bryant@users.noreply.github.com> Co-authored-by: Michael Lingelbach <m.j.lbach@gmail.com> Co-authored-by: nlueb <9465658+nlueb@users.noreply.github.com> Co-authored-by: Leonhard Saam <leonhard.saam@yahoo.com> Co-authored-by: Jesse Wertheim <jaawerth@gmail.com> Co-authored-by: dm1try <me@dmitry.it> Co-authored-by: Jakub Łuczyński <doubleloop@o2.pl> Co-authored-by: Louis Lebrault <louis.lebrault@gmail.com> Co-authored-by: Brede Yabo Sherling Kristensen <bredeyabo@hotmail.com> Co-authored-by: zeertzjq <zeertzjq@outlook.com> Co-authored-by: István Donkó <istvan.donko@gmail.com> Co-authored-by: Julian Berman <Julian@GrayVines.com> Co-authored-by: bryant <bryant@users.noreply.github.com> Co-authored-by: Michael Lingelbach <m.j.lbach@gmail.com> Co-authored-by: nlueb <9465658+nlueb@users.noreply.github.com> Co-authored-by: Leonhard Saam <leonhard.saam@yahoo.com> Co-authored-by: Jesse Wertheim <jaawerth@gmail.com> Co-authored-by: dm1try <me@dmitry.it> Co-authored-by: Jakub Łuczyński <doubleloop@o2.pl> Co-authored-by: Louis Lebrault <louis.lebrault@gmail.com>
* refactor(api/marks)!: add opts param for feature extensibility (#16146)Javier Lopez2021-11-01
| | | | | In the future we might want to extend the concept of named marks and adding opts reduces the need of changing the function signature in the furute.
* refactor(api): move extmark API to its own fileBjörn Linse2021-10-25
|
* feat(decorations): support more than one virt_lines blockBjörn Linse2021-10-23
|
* 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
* Merge pull request #15934 from kylo252/replacement-sizeBjörn Linse2021-10-07
|\ | | | | fix(lint): remove redundant ternary operator
| * fix(lint): remove redundant ternary operatorkylo2522021-10-06
| | | | | | | | | | The value of `new_len` will never be '0' since `replacement.size` is checked against that early on.
* | Merge pull request #15941 from dundargoc/refactor/remove-redundant-castsBjörn Linse2021-10-07
|\ \ | | | | | | refactor: remove redundant casts
| * | refactor: remove redundant castsDundar Göc2021-10-07
| |/
* / fix(api): fix nvim_buf_set_extmarkerw72021-10-07
|/ | | | Fix the problem of calling clear_virttext on undefined variables.
* 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.
* 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
|
* refactor: format #15702dundargoc2021-09-18
|
* docs: extmarks indexing #15311Javier López2021-09-10
| | | | fix #11456
* docs: extmark indexing #12742Patrice Peterson2021-09-10
| | | | | | | Extmarks mostly use api-indexing, except for nvim_buf_get_extmarks(), which uses api-indexing with inclusive ranges. ref #11456
* refactor(api): remove redundant api_set_errorJavier López2021-08-10
| | | | This error is already handled by 'find_buffer_by_handle'
* 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
|
* fix: fix incorrect call sites of xcallocGregory Anders2021-07-24
| | | | The number of elements comes first and the size of each element second.
* perf(extmarks): allow ephemeral extmarks past EOFThomas Vigouroux2021-06-16
|
* Merge pull request #14510 from urandom/doc_nvim_buf_set_extmarkBjörn Linse2021-06-10
|\ | | | | Minor observational corrections to the nvim_buf_set_extmark documentation
| * Update the functio documentation in CViktor Kojouharov2021-05-10
| |
* | fixup! refactor nvim_buf_set_lines to use extmark_spliceJan Edmund Lazo2021-05-12
| |
* | Fix nvim_buf_set_linesdisrupted2021-05-10
| |
* | make get_region_bytecount end-exclusivechentau2021-05-09
| |
* | refactor nvim_buf_set_lines to use extmark_splicechentau2021-05-09
|/
* fix(gcc): compile warning in nvim_buf_set_extmarkSean Dewar2021-05-05
|
* decorations: right_align and win_colBjörn Linse2021-05-01
|