aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/main.c
Commit message (Collapse)AuthorAge
* vim-patch:7.4.1909 (#5748)Shougo2016-12-10
| | | | | | Problem: Doubled semicolons. Solution: Reduce to one. (Dominique Pelle) https://github.com/vim/vim/commit/945ec093cd4ddefab930239990564b12eb232153
* os/shell: Throttle :! output, pulse "..." message.Justin M. Keyes2016-12-09
| | | | | | | | | | | | | | | | | | | | | | | | | | Periodically skip :! spam. This is a "cheat" that works for all UIs and greatly improves responsiveness when :! spams MB or GB of output: :!yes :!while true; do date; done :!git grep '' :grep -r '' * After ~10KB of data is seen from a single :! invocation, output will be skipped for ~1s and three dots "..." will pulse in the bottom-left. Thereafter the behavior alternates at every: * 10KB received * ~1s throttled This also avoids out-of-memory which could happen with large :! outputs. Note: This commit does not change the behavior of execute(':!foo'). execute(':!foo') returns the string ':!foo^M', it captures *only* Vim messages, *not* shell command output. Vim behaves the same way. Use system('foo') for capturing shell command output. Closes #1234 Helped-by: oni-link <knil.ino@gmail.com>
* Add v:exitingMarco Hinz2016-12-01
| | | | | | | | | Contains the exit value nvim will use. Before exiting, it is v:null. That way jobs or autocmds (in VimLeavePre or VimLeave) can check if Neovim is about to quit and with what exit value. Closes #4666.
* lintJames McCoy2016-11-14
|
* vim-patch:7.4.1658James McCoy2016-11-14
| | | | | | | | Problem: A plugin does not know when VimEnter autocommands were already triggered. Solution: Add the v:vim_did_enter variable. https://github.com/vim/vim/commit/1473551a4457d4920b235eeeb9f279e196ee7225
* encoding: cleanup mbyte.c given fixed encoding=utf-8Björn Linse2016-11-05
| | | | | | | | | Eliminate mb_init(): Set "enc_utf" and "has_mbyte" early. Eliminate "enc_unicode" and "enc_latin1like". init_chartab() and screenalloc() are already invoked elsewhere in the initialization process. The EncodingChanged autocmd cannot be triggered. At initialization, there is no spellfiles to reload
* startup: Remove 'N files to edit' message. #5481Linda_pp2016-10-14
| | | | | | | | | | Problem: When '--embed' passed to command line arguments, stdin and stdout are used for IPC. But when multiple files are passed as arguments, nvim wrongly sends 'N files to edit' message to its stdout. As the result, attaching to process from frontend failed. Solution: Remove the message because it doesn't fill any purpose.
* main.c: "BufReadCmd term://": Skip existing terminal.Justin M. Keyes2016-10-12
| | | | | | | | | Check `exists('b:term_title')` to avoid the BufReadCmd for already-initialized :terminal buffers. Move the test for `:argadd`. Add a test for `:edit<CR>`. Tweak comments and code style.
* event/multiqueue.c: Rename "queue" to "multiqueue".Justin M. Keyes2016-10-02
| | | | | | | | | | | | | | `lib/queue.h` implements a basic queue. `event/queue.c` implements a specialized data structure on top of lib/queue.h; it is not a "normal" queue. Rename the specialized multi-level queue implemented in event/queue.c to "multiqueue", to avoid confusion when reading the code. Before this change one can eventually notice that "macros (uppercase symbols) are for the normal queue, lowercase operations are for the multi-level queue", but that is unnecessary friction for new developers (or existing developers just visiting this part of the codebase).
* tui.c: Do not wait for tui loop on teardown. (#4789)Justin M. Keyes2016-09-24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Because terminfo_stop() already ran, there is not much reason to wait for the loop to teardown. Helped-by: Björn Linse <bjorn.linse@gmail.com> Helped-by: oni-link <knil.ino@gmail.com> Closes #4778 References #3541 --- Bug report: > After pressing `ZZ` I can find two threads freezing, occupying 100% CPU: |-systemd-+ |-nvim,11567 /home/lz/code/1.rs +set title | `-{nvim},11574 > 11567 has two threads: (gdb) info threads Id Target Id Frame * 1 Thread 0x7f7622907780 (LWP 11567) "nvim" 0x00007f76222e66bd in pthread_join () from /usr/lib/libpthread.so.0 2 Thread 0x7f761f5ff700 (LWP 11574) "nvim" 0x00007ffcec9e9c59 in clock_gettime () (gdb) thread apply all bt Thread 2 (Thread 0x7f761f5ff700 (LWP 11574)): #0 0x00007ffcec9e9c59 in clock_gettime () #1 0x00007f76210b9356 in clock_gettime () from /usr/lib/libc.so.6 #2 0x00007f7622513e3c in ?? () from /usr/lib/libuv.so.1 #3 0x00007f7622505e94 in uv_run () from /usr/lib/libuv.so.1 #4 0x00000000004822ed in loop_close (loop=loop@entry=0x7f761f5fe870) at /tmp/yaourt-tmp-lz/aur-neovim-git/src/neovim-git/src/nvim/event/loop.c:87 #5 0x00000000005a7ec0 in tui_main (bridge=0x7f761f6ac000, ui=0x7f761f69ace0) at /tmp/yaourt-tmp-lz/aur-neovim-git/src/neovim-git/src/nvim/tui/tui.c:234 #6 0x00000000005a9b47 in ui_thread_run (data=<optimized out>) at /tmp/yaourt-tmp-lz/aur-neovim-git/src/neovim-git/src/nvim/ui_bridge.c:87 #7 0x00007f7622510d07 in ?? () from /usr/lib/libuv.so.1 #8 0x00007f76222e5474 in start_thread () from /usr/lib/libpthread.so.0 #9 0x00007f76210ac69d in clone () from /usr/lib/libc.so.6 Thread 1 (Thread 0x7f7622907780 (LWP 11567)): #0 0x00007f76222e66bd in pthread_join () from /usr/lib/libpthread.so.0 #1 0x00007f7622510dae in uv_thread_join () from /usr/lib/libuv.so.1 #2 0x00000000005aac9e in ui_bridge_stop (b=0x7f761f6ac000) at /tmp/yaourt-tmp-lz/aur-neovim-git/src/neovim-git/src/nvim/ui_bridge.c:104 #3 0x00000000005a90e4 in ui_builtin_stop () at /tmp/yaourt-tmp-lz/aur-neovim-git/src/neovim-git/src/nvim/ui.c:91 #4 0x000000000052be09 in mch_exit (r=r@entry=1) at /tmp/yaourt-tmp-lz/aur-neovim-git/src/neovim-git/src/nvim/os_unix.c:143 #5 0x00000000004db1cc in getout (exitval=exitval@entry=1) at /tmp/yaourt-tmp-lz/aur-neovim-git/src/neovim-git/src/nvim/main.c:623 #6 0x00000000004fa43c in preserve_exit () at /tmp/yaourt-tmp-lz/aur-neovim-git/src/neovim-git/src/nvim/misc1.c:2652 #7 0x000000000052b77a in deadly_signal (signum=1) at /tmp/yaourt-tmp-lz/aur-neovim-git/src/neovim-git/src/nvim/os/signal.c:120 #8 0x000000000052b7cf in on_signal (handle=<optimized out>, signum=<optimized out>, data=<optimized out>) at /tmp/yaourt-tmp-lz/aur-neovim-git/src/neovim-git/src/nvim/os/signal.c:145 #9 0x0000000000484178 in signal_event (argv=<optimized out>) at /tmp/yaourt-tmp-lz/aur-neovim-git/src/neovim-git/src/nvim/event/signal.c:44 #10 0x0000000000483b7f in queue_process_events (queue=0x7f7620417360) at /tmp/yaourt-tmp-lz/aur-neovim-git/src/neovim-git/src/nvim/event/queue.c:142 #11 0x0000000000482208 in loop_poll_events (loop=0x84dec0 <loop>, ms=ms@entry=4000) at /tmp/yaourt-tmp-lz/aur-neovim-git/src/neovim-git/src/nvim/event/loop.c:56 #12 0x000000000052a364 in input_poll (ms=ms@entry=4000) at /tmp/yaourt-tmp-lz/aur-neovim-git/src/neovim-git/src/nvim/os/input.c:325 #13 0x000000000052a3e2 in inbuf_poll (ms=4000) at /tmp/yaourt-tmp-lz/aur-neovim-git/src/neovim-git/src/nvim/os/input.c:347 #14 0x000000000052a839 in os_inchar (buf=buf@entry=0x0, maxlen=maxlen@entry=0, ms=ms@entry=-1, tb_change_cnt=tb_change_cnt@entry=0) at /tmp/yaourt-tmp-lz/aur-neovim-git/src/neovim-git/src/nvim/os/input.c:107 #15 0x0000000000592eeb in state_enter (s=s@entry=0x7ffcec9d3560) at /tmp/yaourt-tmp-lz/aur-neovim-git/src/neovim-git/src/nvim/state.c:46 #16 0x0000000000508533 in normal_enter (cmdwin=cmdwin@entry=false, noexmode=noexmode@entry=false) at /tmp/yaourt-tmp-lz/aur-neovim-git/src/neovim-git/src/nvim/normal.c:464 #17 0x00000000004dc17e in main (argc=<optimized out>, argv=<optimized out>) at /tmp/yaourt-tmp-lz/aur-neovim-git/src/neovim-git/src/nvim/main.c:538
* refactor: eliminate misc2.cJustin M. Keyes2016-09-13
| | | | | | | | | | move `call_shell` to misc1.c Move some fns to state.c Move some fns to option.c Move some fns to memline.c Move `vim_chdir*` fns to file_search.c Move some fns to new module, bytes.c Move some fns to fileio.c
* api: rename "msgpack_rpc/defs.h" to "api/private/dispatch.h" and use the ↵Björn Linse2016-08-31
| | | | header generator.
* Fix vim-patch:7.4.689Rui Abreu Ferreira2016-08-07
|
* vim-patch:7.4.1147 (#5005)prollings2016-07-10
| | | | | | | Problem: Conflict for "chartab". (Kazunobu Kuriyama) Solution: Rename the global one to something less obvious. Move it into src/chartab.c. https://github.com/vim/vim/commit/88e8f9f14434a7cd538d0c159dc432bea869a5bd
* lintJames McCoy2016-07-08
|
* vim-patch:7.4.1552James McCoy2016-07-08
| | | | | | | Problem: ":colorscheme" does not use 'packpath'. Solution: Also use in "start" and "opt" directories in 'packpath'. https://github.com/vim/vim/commit/7f8989dd8a627af2185df381195351a913f3777f
* vim-patch:7.4.1550James McCoy2016-07-08
| | | | | | | Problem: Cannot load packages early. Solution: Add the ":packloadall" command. https://github.com/vim/vim/commit/2d8f56acb32428d0f965d42dd13b27100b46fa15
* vim-patch:7.4.1384James McCoy2016-07-08
| | | | | | | Problem: It is not easy to use a set of plugins and their dependencies. Solution: Add packages, ":loadopt", 'packpath'. https://github.com/vim/vim/commit/f6fee0e2d4341c0c2f5339c1268e5877fafd07cf
* options: Default t_Co to 256.Justin M. Keyes2016-07-02
| | | | | | | | This commit doesn't change any behavior, only moves the init out of main.c We _could_ move some initialization from tui.c:terminfo_start to an earlier phase, in order to avoid mis-reporting 't_Co' during startup. But this will be messy, and gains very little: TERM=linux works "good enough" as long as we correct t_Co in tui.c:terminfo_start (c5b02d5a7).
* vim-patch:7.4.1716Marco Hinz2016-07-01
| | | | | | | Problem: 'autochdir' doesn't work for the first file. (Rob Hoelz) Solution: Call DO_AUTOCHDIR after startup. (Christian Brabandt) https://github.com/vim/vim/commit/baec5c1768098f9dd867b465aaabfdfb294f10c2
* timers: stop all timers on teardownBjörn Linse2016-06-01
|
* *: Rename main loop variable from loop to main_loopZyX2016-05-30
| | | | | | | | | | | | | | | | Current name is inappropriate for the following reasons: 1. It is often masked by local `loop` variables. 2. It cannot be searched for. There are many `loop` variables where `loop` is some local variable. There are many cases when “loop” word is used in a comment. 3. It is in any case bad idea to use a generic name as a name of the global variable. Best if global has module prefix: this is why it is in `main.h`: `main_loop` both stands for “a main loop” and “a loop defined in `main.*`”. Since I have no idea how to list every occurrence of this variable method used to rename it is “remove it from globals.h, try to compile, fix errors”. Thus if some occurrence was hidden under false `#if` branch it was not replaced.
* *: Make set_vim_var_\* functions have proper argument typesZyX2016-04-18
|
* defaults: Enable syntax/filetype for real.Justin M. Keyes2016-04-15
| | | | | Fixes a bug in #4252: we enabled filetype/syntax if -u was passed, but not otherwise. So it did not work for an empty or missing vimrc.
* main.c: Free msgpack packer in --api-info handler to make ASAN happyThiago de Arruda2016-04-11
|
* main: Move term:// protocol name to a macrosZyX2016-02-28
|
* main: Make using :edit term:// run TermOpen eventZyX2016-02-28
| | | | Ref #4306
* Revert "Merge pull request #4362 from justinmk/termopen"ZyX2016-02-28
| | | | | This reverts commit b01db02de4753908b3595b5ada0a6929e595e930, reversing changes made to 62321e5132ed29b11f79c8a56ca172d56b9ac042.
* term: publish TermOpen in "e term://" handler.Justin M. Keyes2016-02-23
| | | | | | | | After 87a49405b00b38b58c4c1d8fc4069d1a254a621d, terminal_open() is not nested by default. The default "term://" handler depended on that, but it should instead explicitly raise TermOpen. References #4306
* build: install *.mo into the "standard" directoryJun T2016-02-23
| | | | | | | Change POROJECT_NAME to 'nvim', and use it as the gettext domain name. The *.mo files, previously installed as $runtime/lang/xx/LC_MESSAGES/nvim.mo, are now installed as $prefix/locale/xx/LC_MESSAGES/nvim.mo.
* startup: Avoid VimL global. Introduce TriState enum.Justin M. Keyes2016-02-14
| | | | | | | - `syntax_on` is documented. Rather than introduce a new undocumented VimL global `g:syntax_off`, use a module-local flag. - Rename "maybe" functions to follow style guidelines (use standard module prefix)
* startup: respect earlier :filetype and :syntax.Felipe Morales2016-02-14
| | | | | If user invokes :filetype or :syntax before startup defaults are applied, don't clobber their choices.
* ex_docmd: rename force_enable_filetype().Justin M. Keyes2016-02-14
| | | | It is no longer forcing anything.
* syntax: don't override user settingsFelipe Morales2016-02-14
|
* syntax: avoid extra global macroJustin M. Keyes2016-02-14
|
* defaults: Enable syntax and filetype plugins.Felipe Morales2016-02-14
|
* vim-patch:7.4.689watiko2016-02-07
| | | | | | | | | | | | | | Problem: On MS-Windows, when 'autochdir' is set, diff mode with files in different directories does not work. (Axel Bender) Solution: Remember the current directory and use it where needed. (Christian Brabandt) https://github.com/vim/vim/commit/d87c36ea5eae50580f3c733734669250cc969019 --- see: "autochdir + encoding=utf8 messes up diff" https://groups.google.com/d/msg/vim_dev/QrE4Y2LMJR8/uxigns5KGxYJ
* src/*: Remove `VIM - Vi improved ...` headerMichael Reed2015-11-27
| | | | | | | | | | | | | | | | | | | Regarding the individual items in the header: `Vim - Vi improved by Bram Moolenar` Bram Moolenar is already mentioned throughout the documentation, as well as the intro screen. `:help uganda` It's already shown to all users who don't use `shortmess+=I` upon starting nvim, and is already placed prominently in help.txt, i.e., `:help` run with no arguments. `:help credits` Already mentioned near the top of help.txt. `README.md` Already mentioned in develop.txt.
* Remove unnecessary includes for errno.hRui Abreu Ferreira2015-11-25
|
* src: README.txt -> README.mdMichael Reed2015-11-23
| | | | | The former no longer exists in this repo; see the top of src/nvim/README.md.
* Merge pull request #3651 from mhinz/remove-nvimrc-refsJustin M. Keyes2015-11-11
|\ | | | | Remove all invalid nvimrc references
| * Remove all invalid nvimrc and ngvimrc referencesMarco Hinz2015-11-11
| | | | | | | | | | | | | | | | | | | | "vimrc" refers to all files that are used to configure Neovim. The main configuration file is init.vim nowadays. All nvimrc references that are left refer to a local ".nvimrc" which is read if 'exrc' is set. ".ngvimrc" references were completely wiped. Closes #3552.
* | Be more explicit about the lack of X11 integrationMichael Reed2015-11-10
|/ | | | | I don't want anyone getting the idea that the `-X` flag they might have used has anything to do with why the `+` is working for them
* Fix 'exrc' optionOvidiu Curcan2015-10-29
| | | | | `do_user_initialization()` ignored changes to the value of the `exrc` option caused by the processing of environment variables or sourcing of files.
* main: Start modeling Nvim as pushdown automatonThiago de Arruda2015-10-26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | From a very high level point of view, Vim/Nvim can be described as state machines following these instructions in a loop: - Read user input - Peform some action. The action is determined by the current state and can switch states. - Possibly display some feedback to the user. This is not immediately visible because these instructions spread across dozens of nested loops and function calls, making it very hard to modify the state machine(to support more event types, for example). So far, the approach Nvim has taken to allow more events is this: - At the very core function that blocks for input, poll for arbitrary events. - If the event received from the OS is user input, just return it normally to the callers. - If the event is not direct result of user input(possibly a vimscript function call coming from a msgpack-rpc socket or a job control callback), return a special key code(`K_EVENT`) that is handled by callers where it is safer to perform arbitrary actions. One problem with this approach is that the `K_EVENT` signal is being sent across multiple states that may be unaware of it. This was partially fixed with the `input_enable_events`/`input_disable_events` functions, which were added as a mechanism that the upper layers can use to tell the core input functions that it is ready to accept `K_EVENT`. Another problem is that the mapping engine is implemented in getchar.c which is called from every state, but the mapping engine is not aware of `K_EVENT` so events can break mappings. While it is theoretically possible to modify getchar.c to make it aware of `K_EVENT`, this commit fixes the problem with a different approach: Model Nvim as a pushdown automaton(https://en.wikipedia.org/wiki/Pushdown_automaton). This design has many advantages which include: - Decoupling the event loop from the states reponsible for handling events. - Better control of state transition with less dependency on global variable hacks(eg: 'restart_edit' global variable). - Easier removal of global variables and function splitting. That is because many variables are for state-specific information, and probably ended up being global to simplify communication between functions, which we fix by storing state-specific information in specialized structures. The final goal is to let Nvim have a single top-level event loop represented by the following pseudo-code: ``` while not quitting let event = read_event current_state(event) update_screen() ``` This closely mirrors the state machine description above and makes it easier to understand, extend and debug the program. Note that while the pseudo code suggests an explicit stack of states that doesn't rely on return addresses(as suggested by the principles of automata-based programming: https://en.wikipedia.org/wiki/Automata-based_programming), for now we'll use the call stack as a structure to manage state transitioning as it would be very difficult to refactor Nvim to use an explicit stack of states, and the benefits would be small. While this change may seem like an endless amount of work, it is possible to do it incrementally as was shown in the previous commits. The general procedure is: 1- Find a blocking `vgetc()`(or derivatives) call. This call represents an implicit state of the program. 2- Split the code before and after the `vgetc()` call into functions that match the signature of `state_check_callback` and `state_execute_callback. Only `state_execute_callback` is required. 3- Create a `VimState` "subclass" and a initializer function that sets the function pointers and performs any other required initialization steps. If the state has no local variables, just use `VimState` without subclassing. 4- Instead of calling the original function containing the `vgetc()`, initialize a stack-allocated `VimState` subclass, then call `state_enter` to begin processing events in the state. 5- The check/execute callbacks can return 1 to continue normally, 0 to break the loop or -1 to skip to the next iteration. These callbacks contain code that execute before and after the old `vgetc()` call. The functions created in step 2 may contain other `vgetc()` calls. These represent implicit sub-states of the current state, but it is fine to remove them later in smaller steps since we didn't break compatibility with existing code.
* main: Extract `normal_check` from `main_loop`Thiago de Arruda2015-10-26
| | | | | | The new function contains logic that must be executed after handling input in normal mode and also before the first main loop iteration. Also rename `main_loop` to `normal_enter` and move it to normal.c
* main: Check init.vim files also in other XDG directoriesZyX2015-10-24
|
* *: Fix linter errorsZyX2015-10-23
|
* main,version: Remove USR_EXRC_FILE*ZyX2015-10-23
|
* main,os/env: Fix lint errorsZyX2015-10-23
|