aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/main.c
Commit message (Collapse)AuthorAge
...
* 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
|
* documentation: Update documentationZyX2015-10-23
| | | | | | | Note about ~/.local/share/nvim/site used in one usr_\* file: this one talks about user-local installation of third-party plugins, and ~/.local/share/nvim/site is the proper place for them. Most other files talk about user own configuration and this is ~/.config.
* shada: Move shada file to a new locationZyX2015-10-23
|
* stdpaths,main: Remove all remaining memory leaksZyX2015-10-23
|
* stdpaths: Rename export functions so that they have common prefixZyX2015-10-23
|
* option,main: Partial support of XDG base directory specificationKeerthan Jaic2015-10-23
| | | | | | | | | | | | - Add functions that are able to query XDG. - Replace defaults for - &runtimepath. Does not follow #78. - &viewdir. - &undodir. - &directory. - &backupdir. Does not follow #78. - vimrc location. - Remove user vimrc file line from :version message.
* *: Fix lint errors found in new code in previously ignored filesZyX2015-10-08
|
* shada: Translate errors and add error codesZyX2015-10-08
| | | | | | | | | | Notes: - E136 code greatly changed its meaning: now it is write error and not read error. - E195 was removed because shada_read_everything will already do all the necessary error reporting. - E886 can be reported by both :rshada and :wshada, but :rshada comes first and AFAIR it is the only error which is not E575 and can be reported by :rshada.
* main: Silence -Wunused-result in main.c for shada_read_fileZyX2015-10-08
|
* Replace references to viminfo in various placesZyX2015-10-08
|
* main: Read marks at startupZyX2015-10-08
| | | | | I do not know why marks were not read originally, but without this change marks are not going to be read at startup when Vim starts without arguments.
* viminfo: First version of ShaDa file dumpingZyX2015-10-08
| | | | | | | | | | | | | | | | | | | | What works: 1. ShaDa file dumping: header, registers, jump list, history, search patterns, substitute strings, variables. 2. ShaDa file reading: registers, global marks, variables. Most was not tested. TODO: 1. Merging. 2. Reading history, local marks, jump and buffer lists. 3. Documentation update. 4. Converting some data from &encoding. 5. Safer variant of dumping viminfo (dump to temporary file then rename). 6. Removing old viminfo code (currently masked with `#if 0` in a ShaDa file for reference).
* encoding: don't allow changing encoding after startup scriptsBjörn Linse2015-09-08
|
* log: Make logging thread-safeThiago de Arruda2015-09-06
|
* Remove instances of TRUE/FALSE macroSteven Oliver2015-09-04
| | | | | | memory.c os_unix.c path.c
* main: Initialize event loop before command_line_scanThiago de Arruda2015-08-21
| | | | | | | | The call to `event_init()` was too late. `command_line_scan()` in `main()` could already need the loop initialized. Ref https://github.com/neovim/neovim/issues/3045#issuecomment-123405833. A consequence of this change is that it was necessary to move the `channel_from_stdio()` call to `command_line_scan()` when embedded_mode is set.
* event: Refactor async event processingThiago de Arruda2015-08-13
| | | | | | | | | | - Improve the implementation of deferred/immediate events. - Use the new queue module to change how/when events are queued/processed by giving a private queue to each emitter. - Immediate events(which only exist to break uv_run recursion) are now represented in the `loop->fast_events` queue. - Events pushed to child queues are propagated to the event loop main queue and processed as K_EVENT keys.
* Source provider at start if &cb is set #3025Marco Hinz2015-07-20
| | | | | | | | | | | | | The main problem is that <c-c> is a default mapping but also sets got_int. Because of the former, normal_cmd() is kicked off which eventually leads to sourcing the clipboard provider. But due to the latter, do_source() throws an error, because got_int is set. This is a temporary workaround and sources the clipboard provider before main_loop(), if &clipboard is set. References #3023.
* job: Replace by a better process abstraction layerThiago de Arruda2015-07-17
| | | | | | | | | | | | | - New libuv/pty process abstraction with simplified API and no globals. - Remove nvim/os/job*. Jobs are now a concept that apply only to programs spawned by vimscript job* functions. - Refactor shell.c/channel.c to use the new module, which brings a number of advantages: - Simplified API, less code - No slots in the user job table are used - Not possible to acidentally receive data from vimscript - Implement job table in eval.c, which is now a hash table with unilimited job slots and unique job ids.
* event loop: New abstraction layer with refactored time/signal APIThiago de Arruda2015-07-17
| | | | | | | | | | - Add event loop abstraction module under src/nvim/event. The src/nvim/event/loop module replaces src/nvim/os/event - Remove direct dependency on libuv signal/timer API and use the new abstraction instead. - Replace all references to uv_default_loop() by &loop.uv, a new global variable that wraps libuv main event loop but allows the event loop functions to be reused in other contexts.
* os/fs: Use module-local uv_loop_t instanceThiago de Arruda2015-07-01
| | | | | | This event loop is just a stub instance used in synchronous libuv function calls, it needs to be decoupled from the main event loop in order to run it from another thread.
* Passing by: Remove X_LOCALE refsMichael Reed2015-05-30
| | | | We don't link to any X11 libs, so this is most likely unneeded.
* main.c:mainerr(): Namespace messagesMichael Reed2015-05-30
| | | | | | | | | | Error messages in general should be namespaced, especially in the context of a shell. Given the possibility of a backgrounded job printing messages to standard output/error, namespacing these messages should avoid any confusion as to where the message came from. Helped-by: Scott Prager <splinterofchaos@gmail.com> Helped-by: oni-link <knil.ino@gmail.com>
* main.c: Simplify error string managementMichael Reed2015-05-30
| | | | | | | | This removes the need for preprocessor defines as array indices, and brings error handling more in line with other files, which for the most most part to use constant strings (also, see `globals.h`). Helped-By: Nicolas Hillegeer <nicolas@hillegeer.com>
* getenv: return NULL if empty #2574Scott Prager2015-05-29
| | | | | | Making an environment variable empty can be a way of unsetting it for platforms that don't support unsetenv(). In most cases, we treat empty variables as having been unset. For all others, use os_env_exists().
* input: rename input_{start,stop}_stdin()Justin M. Keyes2015-05-27
| | | | | - "stdin" is misleading because it may read from stdout or stderr - also remove some unused includes
* input: stream_set_blocking(): libuv implJustin M. Keyes2015-05-27
| | | | | | | | | - Create a private libuv loop instead of re-using uv_default_loop(), to avoid conflict[1] with existing watcher(s) on the fd. - Expose the global "input" fd as a getter instead of a mutable global. [1] .deps/build/src/libuv/src/unix/core.c:833: uv__io_stop: Assertion `loop->watchers[w->fd] == w' failed.
* input: set input stream to blocking on exitJustin M. Keyes2015-05-27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If stdin is non-blocking, many tools (e.g. cat(1), read(1)) which assume that stdin is blocking, will break in odd ways: read: read error: 0: Resource temporarily unavailable cat: -: Resource temporarily unavailable rm: error closing file libuv puts stdin in nonblocking mode, and leaves it that way at exit (this is apparently by design). So, before this commit, this always works (because the shell clobbers O_NONBLOCK): $ nvim --cmd q $ read ...but these forms do _not_ work: $ nvim --cmd q && read $ echo foo | nvim --cmd q && read $ nvim && read After this commit, all of the above forms work. Background: https://github.com/fish-shell/fish-shell/commit/437b4397b9cf273922ce7b414bf6626845f15ad0#diff-41f4d294430cd8c36538999d62681ae2 https://github.com/fish-shell/fish-shell/issues/176#issuecomment-15800155 - bash (and other shells: zsh, tcsh, fish), upon returning to the foreground, always sets fd 0 back to blocking mode. This practice only applies to stdin, _not_ stdout or stderr (in practice these fds may be affected anyways). - bash/zsh/tcsh/fish do _not_ restore the non-blocking status of stdin when _resuming a job_. - We do _not_ save/restore the original flags visible to fcntl(F_[SG]ETFL), because (counterintuitively) that isn't expected. Helped-by: oni-link <knil.ino@gmail.com> Closes #2086 Closes #2377 --- Note: The following implementation of stream_set_blocking() was discarded, because it resulted in a failed libuv assertion[1]: int stream_set_blocking(int fd, bool blocking) { uv_pipe_t stream; uv_pipe_init(uv_default_loop(), &stream, 0); uv_pipe_open(&stream, fd); int retval = uv_stream_set_blocking((uv_stream_t *)&stream, blocking); uv_close((uv_handle_t *)&stream, NULL); return retval; } [1] .deps/build/src/libuv/src/unix/core.c:833: uv__io_stop: Assertion `loop->watchers[w->fd] == w' failed.
* Remove `-T` command-line optionMichael Reed2015-05-18
| | | | | | | It didn't actually do anything after 3baba1e7bc6698e6bc9f1d37fce88b30d6274bc9 Helped-by: Justin M. Keyes <justinkz@gmail.com>
* `nvim --help` text: Unify with manpagesMichael Reed2015-05-13
|
* main.c: Make '-v' synonymous with '--version'Michael Reed2015-05-13
| | | | | | | | This is done for consistency with '-h' and '--help'. While here, also move the mch_exit() call out of usage to make it clear what is being done. Helped-by: Justin M. Keyes <justinkz@gmail.com>
* Remove char_u: ReviewMichael Reed2015-05-13
| | | | Helped-by: Scott Prager <splinterofchaos@gmail.com>
* Remove char_u: main:use_vimrcMichael Reed2015-05-13
|
* Remove char_u: main:process_env()Michael Reed2015-05-13
| | | | In addition, make static and modernize function comment
* Remove char_u: ex_docmd:do_cmdline_cmd()Michael Reed2015-05-13
|
* refactor: remove USR_VIMRC_FILE4 #2580Yamakaky2015-05-07
| | | | It was 1) not used and 2) badly treated, compared to USR_VIMRC_FILE3.
* Remove char_u: concat_fnames()Mark Bainter2015-05-06
|
* Replace VIM_ISDIGIT() and vim_isdigit() with ascii_isdigit() defined in ascii.hFelipe Oliveira Carvalho2015-04-24
|
* Refactor get_env() to respect const qualifierMark Bainter2015-04-18
| | | | | | Without the casts*, the compiler rightly warns about the os_getenv losing the qualifier. This refactor adds a variable to manage this properly, and renames the original variables to increase clarity.
* Remove char_u: vim_getenv()Mark Bainter2015-04-17
|