aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/autocmd.c
Commit message (Collapse)AuthorAge
...
* refactor: reorganize option header files (#25437)zeertzjq2023-09-30
| | | | | | - Move vimoption_T to option.h - option_defs.h is for option-related types - option_vars.h corresponds to Vim's option.h - option_defs.h and option_vars.h don't include each other
* refactor(message): smsg_attr -> smsgbfredl2023-09-29
|
* refactor(messages): fold msg_outtrans_attr into msg_outtransbfredl2023-09-27
| | | | | problem: there are too many different functions in message.c solution: fold some of the functions into themselves
* vim-patch:8.2.4609: :unhide does not check for failing to close a window ↵zeertzjq2023-09-23
| | | | | | | | | | | (#25317) Problem: :unhide does not check for failing to close a window. Solution: When closing a window fails continue with the next one. Do not try closing the autocmd window. (closes vim/vim#9984) https://github.com/vim/vim/commit/6f2465d336a9d4afe392db4084ef7e9db17e67c1 Co-authored-by: Bram Moolenaar <Bram@vim.org>
* docs: fix typos and other small fixes (#25005)dundargoc2023-09-14
| | | | | | | Co-authored-by: nuid64 <lvkuzvesov@proton.me> Co-authored-by: Mike Smith <10135646+mikesmithgh@users.noreply.github.com> Co-authored-by: XTY <xty@xty.io> Co-authored-by: Empa <emanuel@empa.xyz> Co-authored-by: kyu08 <49891479+kyu08@users.noreply.github.com>
* refactor(map): enhanced implementation, Clean Code™, etc etcbfredl2023-09-08
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This involves two redesigns of the map.c implementations: 1. Change of macro style and code organization The old khash.h and map.c implementation used huge #define blocks with a lot of backslash line continuations. This instead uses the "implementation file" .c.h pattern. Such a file is meant to be included multiple times, with different macros set prior to inclusion as parameters. we already use this pattern e.g. for eval/typval_encode.c.h to implement different typval encoders reusing a similar structure. We can structure this code into two parts. one that only depends on key type and is enough to implement sets, and one which depends on both key and value to implement maps (as a wrapper around sets, with an added value[] array) 2. Separate the main hash buckets from the key / value arrays Change the hack buckets to only contain an index into separate key / value arrays This is a common pattern in modern, state of the art hashmap implementations. Even though this leads to one more allocated array, it is this often is a net reduction of memory consumption. Consider key+value consuming at least 12 bytes per pair. On average, we will have twice as many buckets per item. Thus old implementation: 2*12 = 24 bytes per item New implementation 1*12 + 2*4 = 20 bytes per item And the difference gets bigger with larger items. One might think we have pulled a fast one here, as wouldn't the average size of the new key/value arrays be 1.5 slots per items due to amortized grows? But remember, these arrays are fully dense, and thus the accessed memory, measured in _cache lines_, the unit which actually matters, will be the fully used memory but just rounded up to the nearest cache line boundary. This has some other interesting properties, such as an insert-only set/map will be fully ordered by insert only. Preserving this ordering in face of deletions is more tricky tho. As we currently don't use ordered maps, the "delete" operation maintains compactness of the item arrays in the simplest way by breaking the ordering. It would be possible to implement an order-preserving delete although at some cost, like allowing the items array to become non-dense until the next rehash. Finally, in face of these two major changes, all code used in khash.h has been integrated into map.c and friends. Given the heavy edits it makes no sense to "layer" the code into a vendored and a wrapper part. Rather, the layered cake follows the specialization depth: code shared for all maps, code specialized to a key type (and its equivalence relation), and finally code specialized to value+key type.
* fix(events): avoid unnecessary CursorMoved (#24675)zeertzjq2023-08-12
| | | | | | Problem: Temporarily changing current window in a script causes CursorMoved to be triggerd. Solution: Don't trigger CursorMoved if neither curwin nor cursor changed between two checks.
* fix(events): trigger VimResume on next UI request (#24426)zeertzjq2023-07-23
|
* refactor: remove longdundargoc2023-07-03
| | | | | long is 32-bits even on 64-bit windows which makes the type suboptimal for a codebase meant to be cross-platform.
* vim-patch:9.0.1665: empty CmdlineEnter autocommand causes errors in Ex modezeertzjq2023-06-26
| | | | | | | | | | Problem: Empty CmdlineEnter autocommand causes errors in Ex mode. Solution: Save and restore ex_pressedreturn. (Christian Brabandt, closes # 12581, closes vim/vim#12578) https://github.com/vim/vim/commit/590aae35575cbd74d80c41d87fc647f2812aad70 Co-authored-by: Christian Brabandt <cb@256bit.org>
* vim-patch:8.2.3833: error from term_start() not caught by try/catchzeertzjq2023-06-26
| | | | | | | | | | Problem: Error from term_start() not caught by try/catch. Solution: save and restore did_emsg when applying autocommands. (Ozaki Kiichi, closes vim/vim#9361) https://github.com/vim/vim/commit/c3f91c0648f4b04a6a9ceb4ccec45ea767a63796 Co-authored-by: ichizok <gclient.gaap@gmail.com>
* fix(events): don't expand non-file as file namezeertzjq2023-06-07
|
* revert: "refactor: eliminate `autocmd_fname_full` global"zeertzjq2023-06-07
| | | | This reverts commit 82cd0be2eaf71c0476e15c66ba3e83c76896d407.
* vim-patch:9.0.1582: :stopinsert may not work in a popup close handler (#23785)zeertzjq2023-05-27
| | | | | | | Problem: :stopinsert may not work in a popup close handler. (Ben Jackson) Solution: Restore stop_insert_mode when appropriate. (closes vim/vim#12452, closes vim/vim#12434) https://github.com/vim/vim/commit/a40c0bcc83c32da02869f59b10538d6327df61c5
* refactor(map): avoid duplicated khash_t types for valuesbfredl2023-05-17
| | | | | | | | | | | | | | | | | | | | | This reduces the total number of khash_t instantiations from 22 to 8. Make the khash internal functions take the size of values as a runtime parameter. This is abstracted with typesafe Map containers which are still specialized for both key, value type. Introduce `Set(key)` type for when there is no value. Refactor shada.c to use Map/Set instead of khash directly. This requires `map_ref` operation to be more flexible. Return pointers to both key and value, plus an indicator for new_item. As a bonus, `map_key` is now redundant. Instead of Map(cstr_t, FileMarks), use a pointer map as the FileMarks struct is humongous. Make `event_strings` actually work like an intern pool instead of wtf it was doing before.
* vim-patch:8.2.4890: inconsistent capitalization in error messageszeertzjq2023-05-05
| | | | | | | | | Problem: Inconsistent capitalization in error messages. Solution: Make capitalization consistent. (Doug Kearns) https://github.com/vim/vim/commit/cf030578b26460643dca4a40e7f2e3bc19c749aa Co-authored-by: Bram Moolenaar <Bram@vim.org>
* fix(events): null dereference in autocmd functionsii142023-04-27
|
* perf(events): store autocommands in flat vectors (#23256)ii142023-04-27
| | | | | | | | | | Instead of nested linked lists, store autocommands in a flat, contiguous kvec_t, with one kvec_t per event type. Previously patterns were stored in each node of the outer linked list, so they can be matched only once on repeating patterns. They are now reference counted and referenced in each autocommand, and matching is skipped if the pattern repeats. Speeds up creation and deletion, execution is not affected. Co-authored-by: ii14 <ii14@users.noreply.github.com>
* refactor: uncrustifydundargoc2023-04-26
| | | | Notable changes: replace all infinite loops to `while(true)` and remove `int` from `unsigned int`.
* vim-patch:9.0.1443: ending Insert mode when accessing a hidden prompt buffer ↵zeertzjq2023-04-10
| | | | | | | | | | (#22984) Problem: Ending Insert mode when accessing a hidden prompt buffer. Solution: Don't stop Insert mode when it was active before. (closes vim/vim#12237) https://github.com/vim/vim/commit/05a627c3d4e42a18f76c14828d68ee4747118211 Co-authored-by: Bram Moolenaar <Bram@vim.org>
* refactor: remove redundant castsii142023-04-07
|
* refactor: remove use of reserved c++ keywordsii142023-04-06
| | | | | | libnvim couldn't be easily used in C++ due to the use of reserved keywords. Additionally, add explicit casts to *alloc function calls used in inline functions, as C++ doesn't allow implicit casts from void pointers.
* vim-patch:9.0.1439: start Insert mode when accessing a hidden prompt buffer ↵zeertzjq2023-04-03
| | | | | | | | | | | | | (#22867) Problem: Start Insert mode when accessing a hidden prompt buffer. Solution: Call leaving_window() in aucmd_restbuf(). (Thorben Tröbst, closes vim/vim#12148, closes vim/vim#12147) https://github.com/vim/vim/commit/cde8de034524d00aba4ff4142e658baff511e12d Cherry-pick test_prompt_buffer.vim changes from patch 9.0.0631. Co-authored-by: orbital <orbital@holgerines.de>
* fix(filetype): make recursive work...again (#22826)Lewis Russell2023-03-30
|
* fix(autocmd): handle recursion for force set (#22820)Lewis Russell2023-03-30
|
* fix(filetype): avoid recursive FileType autocmds (#22813)Lewis Russell2023-03-29
|
* refactor(screen): screen.c delenda estbfredl2023-03-14
| | | | | | | | | | | | | drawscreen.c vs screen.c makes absolutely no sense. The screen exists only to draw upon it, therefore helper functions are distributed randomly between screen.c and the file that does the redrawing. In addition screen.c does a lot of drawing on the screen. It made more sense for vim/vim as our grid.c is their screen.c Not sure if we want to dump all the code for option chars into optionstr.c, so keep these in a optionchar.c for now.
* Merge #22214 move init_default_autocmds to luaJustin M. Keyes2023-02-14
|\
| * refactor: move init_default_autocmds to luaglacambre2023-02-11
| | | | | | | | | | | | | | | | | | The original motivation for this change came from developping https://github.com/neovim/neovim/pull/22159, which will require adding more autocommand creation to Neovim's startup sequence. This change requires lightly editing a test that expected no autocommand to have been created from lua.
* | refactor: replace char_u with char (#21901)dundargoc2023-02-11
|/ | | | | refactor: replace char_u with char Work on https://github.com/neovim/neovim/issues/459
* refactor(ui): don't reimplement redrawing in focus gained handlingbfredl2023-02-09
| | | | | These are just ordinary boring events now. Modes already redraw events themselves.
* vim-patch:9.0.1277: cursor may move with autocmd in Visual mode (#22116)zeertzjq2023-02-04
| | | | | | | Problem: Cursor may move with autocmd in Visual mode. Solution: Restore "VIsual_active" before calling check_cursor(). (closes vim/vim#11939) https://github.com/vim/vim/commit/49f0524fb575bb1cf4881e472afab7d37c579440
* vim-patch:partial:9.0.1166: code is indented more than necessary (#21716)zeertzjq2023-01-10
| | | | | | | | | | | | | | | | | | | | | | Problem: Code is indented more than necessary. Solution: Use an early return where it makes sense. (Yegappan Lakshmanan, closes vim/vim#11792) https://github.com/vim/vim/commit/1cfb14aa972ccf3235ac67f07b7db1175b7c5384 Partial port as some highlight.c changes depend on previous patches. Cherry-pick fname_match() change from patch 8.2.4959. Omit internal_func_check_arg_types(): only used for Vim9 script. N/A patches for version.c: vim-patch:9.0.1167: EditorConfig files do not have their own filetype Problem: EditorConfig files do not have their own filetype. Solution: Add the "editorconfig" filetype. (Gregory Anders, closes vim/vim#11779) https://github.com/vim/vim/commit/d41262ed06564cef98a3800e2928e6e0db91abbf Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
* fix(tui): more work in the TUIbfredl2022-12-31
|
* feat(aucmd_win): allow crazy things with hidden buffers (#21250)zeertzjq2022-12-02
| | | | Problem: Crash when doing crazy things with hidden buffers. Solution: Dynamically allocate the list of autocommand windows.
* fix: clang warnings (#21247)zeertzjq2022-12-01
|
* vim-patch:9.0.0967: leaking memory from autocmd windowszeertzjq2022-11-29
| | | | | | | | | Problem: Leaking memory from autocmd windows. Solution: Free window when auc_win is not NULL. https://github.com/vim/vim/commit/84497cd06f06516f6ce727ea00c47792ce16dc70 Co-authored-by: Bram Moolenaar <Bram@vim.org>
* vim-patch:9.0.0965: using one window for executing autocommands is insufficientzeertzjq2022-11-29
| | | | | | | | | | | | | | | | | | Problem: Using one window for executing autocommands is insufficient. Solution: Use up to five windows for executing autocommands. https://github.com/vim/vim/commit/e76062c078debed0df818f70e4db14ad7a7cb53a N/A patches for version.c: vim-patch:9.0.0966: some compilers don't allow a declaration after a label Problem: Some compilers don't allow a declaration after a label. Solution: Move the declaration to the start of the block. (John Marriott) https://github.com/vim/vim/commit/f86490ed4fdab213a28f667abd055c023a73d645 Co-authored-by: Bram Moolenaar <Bram@vim.org>
* refactor: replace char_u with chardundargoc2022-11-28
| | | | Work on https://github.com/neovim/neovim/issues/459
* vim-patch:partial:9.0.0917: the WinScrolled autocommand event is not enough ↵zeertzjq2022-11-23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | (#21161) Problem: The WinScrolled autocommand event is not enough. Solution: Add WinResized and provide information about what changed. (closes vim/vim#11576) https://github.com/vim/vim/commit/35fc61cb5b5eba8bbb9d8f0700332fbab38f40ca Omit "func_name" comment in tv_dict_extend(): Vim9 script only. Skip layout locking and E1312. Skip list_alloc_with_items() and list_set_item(). Since this overrides remaining changes in patch 9.0.0913, that patch can now be marked as fully ported: vim-patch:9.0.0913: only change in current window triggers the WinScrolled event N/A patches for version.c: vim-patch:9.0.0919: build failure with tiny features Problem: Build failure with tiny features. Solution: Adjust #ifdef's. https://github.com/vim/vim/commit/9c5b7cb4cf67c64648a324e9dfd1e17d793335a4 Co-authored-by: Bram Moolenaar <Bram@vim.org>
* vim-patch:9.0.0915: WinScrolled may trigger immediately when definedzeertzjq2022-11-20
| | | | | | | | | Problem: WinScrolled may trigger immediately when defined. Solution: Initialize the fields in all windows. (closes vim/vim#11582) https://github.com/vim/vim/commit/29967732761d1ffb5592db5f5aa7036f5b52abf1 Co-authored-by: Bram Moolenaar <Bram@vim.org>
* build: allow IWYU to fix includes for all .c filesdundargoc2022-11-15
| | | | | | | | | | Allow Include What You Use to remove unnecessary includes and only include what is necessary. This helps with reducing compilation times and makes it easier to visualise which dependencies are actually required. Work on https://github.com/neovim/neovim/issues/549, but doesn't close it since this only works fully for .c files and not headers.
* vim-patch:8.2.3626: "au! event" cannot be followed by another commandzeertzjq2022-11-07
| | | | | | | | | | | | Problem: "au!" and "au! event" cannot be followed by another command as documented. Solution: When a bar is found set nextcmd. https://github.com/vim/vim/commit/b8e642f7ace5382b4dacb7a8effd86f22b828cc1 Cherry-pick do_autocmd() "eap" argument from patch 8.2.3268. Co-authored-by: Bram Moolenaar <Bram@vim.org>
* vim-patch:9.0.0713: <amatch> of MenuPopup event is expanded like a file name ↵zeertzjq2022-10-10
| | | | | | | (#20572) Problem: <amatch> of MenuPopup event is expanded like a file name. Solution: Do not expand <amatch> for MenuPopup. (closes vim/vim#11328) https://github.com/vim/vim/commit/c601d988b6b1a672f71e3d61f4aaa4f7742a3a21
* Merge pull request #20374 from bfredl/notypebfredl2022-10-05
|\ | | | | screen: refactor old curwin-heavy logic and graduate "msgsep" feature
| * refactor(redraw): no type argument in update_screen()bfredl2022-10-05
| | | | | | | | | | | | | | | | | | | | This was used in the past with assumption that curwin/curbuf is "special" but this has not been true since basically forever at this point. Reduce NOT_VALID/CLEAR panic in options.lua . These should not be set if an effect of the option is causing something which by itself invokes redraw_later().
* | vim-patch:8.2.3886: can define autocmd for every event by using "au!"zeertzjq2022-10-05
|/ | | | | | Problem: Can define autocmd for every event by using "au!". Solution: Check if a command is present also for "au!". https://github.com/vim/vim/commit/b6db1467622be046dbf00b2213fd9f49f4f3cccb
* vim-patch:9.0.0568: autocmd code is indented more than needed (#20318)zeertzjq2022-09-24
| | | | | | Problem: Autocmd code is indented more than needed. Solution: Break out sooner. (Yegappan Lakshmanan, closes vim/vim#11208) Also in user function code. https://github.com/vim/vim/commit/e9dcf13a3007d4f603e007e0526b0005fd026bc5
* fix(redraw): avoid unnecessary redraws and glitches with floats+messagesbfredl2022-09-22
| | | | | fixes #20106 fixes #20229
* refactor: replace char_u with charDundar Göc2022-09-11
| | | | Work on https://github.com/neovim/neovim/issues/459