aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/lua
Commit message (Collapse)AuthorAge
* paste: redraw at endJustin M. Keyes2019-09-02
| | | | | | | | | | | | | | | | | | | | | | | Attempt to fix test failure since 976c6667e140 removed per-chunk redraw: ERROR test/functional/terminal/tui_spec.lua: TUI paste: cmdline-mode inserts 1 line test/functional/terminal/tui_spec.lua:367: in function <test/functional/terminal/tui_spec.lua:360 Expected: |*foo | |* | |{4:~ }| |{4:~ }| |{5:[No Name] [+] }| |:"line 1{1:"} | |{3:-- TERMINAL --} | Actual: |* | |*{4:~ }| |{4:~ }| |{4:~ }| |{5:[No Name] [+] }| |:"line 1{1:"} | |{3:-- TERMINAL --} |
* paste: one undo-block per streamJustin M. Keyes2019-09-02
| | | | | | - All "chunks" in a paste-stream should form a single undo-block. Side effect of 7a8579288424 was to create an undo-block for each chunk. - Also: remove old :redraw force logic, irrelevant after 7a8579288424.
* tui/input: defer nvim_paste properly.Björn Linse2019-08-31
| | | | | | | | | Otherwise cursor and redraw code for normal and insert mode will not run. The "tickle" workaround was used for this instead, and can now be removed. The builtin vim.lua got the name [string "-- Nvim-Lua stdlib: thevimmodule (:help l..."] in error messages. Fix it to something reasonable.
* paste: make vim.paste() "public"Justin M. Keyes2019-08-27
|
* paste: implement redo (AKA dot-repeat)Justin M. Keyes2019-08-27
| | | | | | - Normal-mode redo idiom(?): prepend "i" and append ESC. - Insert-mode only needs AppendToRedobuffLit(). - Cmdline-mode: only paste the first line.
* paste: insert text "before" cursor in Insert-modeJustin M. Keyes2019-08-27
|
* API: nvim_pasteJustin M. Keyes2019-08-27
|
* paste: phases, dotsJustin M. Keyes2019-08-27
| | | | | | - Send `phase` parameter to the paste handler. - Redraw at intervals and when paste terminates. - Show "..." throbber during paste to indicate activity.
* API: nvim_put: "follow" parameterJustin M. Keyes2019-08-27
|
* paste: use nvim_put()Justin M. Keyes2019-08-27
|
* paste: use chansend() in Terminal-modeJustin M. Keyes2019-08-27
|
* paste: fixup testsJustin M. Keyes2019-08-27
|
* paste: abort paste if handler does not return trueJustin M. Keyes2019-08-27
|
* TUI/paste: always flush on paste mode-changeJustin M. Keyes2019-08-27
| | | | | | Flush input before entering, not only when leaving, paste mode. Else there could be pending input which will erroneously be sent to the paste handler.
* TUI/paste: define paste function as Lua builtinJustin M. Keyes2019-08-27
| | | | | | | - Define in Lua so that it is compiled-in (available with `-u NONE`). TODO: Eventually we will want a 'pastefunc' option or some other way to override the default paste handler.
* lua/stdlib: cleanupJustin M. Keyes2019-08-27
|
* Merge pull request #10171 from blueyed/vim-8.1.1318Daniel Hahler2019-08-09
|\ | | | | vim-patch:8.1.1318: code for text changes is in a "misc" file
| * includesDaniel Hahler2019-08-07
| |
* | lua: minimal UTF-16 support needed for LSPBjörn Linse2019-08-08
|/
* lua: add vim.in_fast_event() to check if we are in a luv callbackBjörn Linse2019-08-05
|
* lua: do not crash on syntax error in debug.debug()Björn Linse2019-08-05
|
* lua: immediate-callback safe print()Björn Linse2019-08-05
|
* api/lua: make nvim_execute_lua use native lua floats, not special tablesBjörn Linse2019-07-01
| | | | | | | | | | Rationale: the purpose of nvim_execute_lua is to simply call lua code with lua values. If a lua function expects a floating point value, it should be enough to specify a float as argument to nvim_execute_lua. However, make sure to preserve the existing roundtripping behavior of API values when using `vim.api` functions. This is covered by existing lua/api_spec.lua tests.
* make vim.loop == require'luv'Björn Linse2019-06-30
| | | | | This avoids initializing libluv a second time if a plugin invokes require'luv'. It is probably not an issue, but better to be safe.
* libluv: use luv_set_callback to control callback executionBjörn Linse2019-06-30
| | | | | Disable the use of deferred API functions in a fast lua callback Correctly display error messages from a fast lua callback
* api/lua: add on_detach to nvim_buf_attachBjörn Linse2019-06-15
|
* lua: introduce vim.loop (expose libuv event-loop) #10123George Zhao2019-06-10
| | | | | | Co-authored-by: Andrey Popp <8mayday@gmail.com> closes #9546 closes #10084
* lua: docs and tests for vim.scheduleBjörn Linse2019-06-05
|
* lua: add vim.schedule(cb)Andrey Popp2019-06-05
| | | | | This executes Lua callback on main loop's event queue so that nvim API is safe to call.
* api: allow nvim_buf_attach from lua using callbacksBjörn Linse2019-06-04
|
* messages: use proper multiline error message for rpcrequest and API wrappersBjörn Linse2019-05-26
|
* lua/shared: share trim() implJustin M. Keyes2019-05-20
|
* Merge #9709 'fileio: use os_copy to create backups'Justin M. Keyes2019-05-20
|\ | | | | | | ref #8288
* | lua/shared: share more stuffJustin M. Keyes2019-05-19
| | | | | | | | | | Leave trim() in vim.lua, because gen_vimdoc.py needs at least one function in there, else it gets confused...
* | lua/shared: share deepcopy() with test/*Justin M. Keyes2019-05-19
| | | | | | | | deepcopy() was duplicated in test/helpers.lua
* | gen_vimdoc.py: support lua/shared.lua module [ci skip]Justin M. Keyes2019-05-19
| |
* | Document the vim.lua functionsKillTheMule2019-05-18
| |
* | lua/stdlib: Introduce vim.sharedJustin M. Keyes2019-05-18
| | | | | | | | | | | | | | | | | | | | This is where "pure functions" can live, which can be shared by Nvim and test logic which may not have a running Nvim instance available. If in the future we use Nvim itself as the Lua engine for tests, then these functions could be moved directly onto the `vim` Lua module. closes #6580
* | Merge #9686 'win/Lua: monkey-patch os.getenv()'Justin M. Keyes2019-03-16
|\ \ | |/ |/| | | fixes #9681
| * Fix os.getenv of lua on Windowserw72019-03-07
|/ | | | | Change to use os_getenv instead of getenv because environment variable set by uv_os_setenv can not be get with getenv.
* cleanup: reduce some duplicate code, avoid function pointers for a conditionBjörn Linse2019-01-23
| | | | | | | Add 'multiline' flag to history for correct :messages output Use larger buffer size for multiline messages. if this turns out to not be enough, we could do size calculation like api_set_error
* message.c: add msg_echo_attr functions, use it for lua error messagesAlexandre Dubray2019-01-22
| | | | | The added function behaves like the non-echo function but display message in a echo-style way (i.e. tab and newline are preserved)
* lua: expose full interface of vim.inspect and add testBjörn Linse2019-01-14
| | | | | | Implement lazy loading for vim.submodule, this would be over-engineering for inspect only, but we expect to use this solution also for more and larger modules.
* lua/stdlib: Load runtime modules on-demandJustin M. Keyes2019-01-14
| | | | | | | | | | Instead of eager-loading during plugin/* sourcing, define runtime modules such as `vim.inspect` as lazy builtins. Otherwise non-builtin Lua modules such as `vim.inspect` would not be available during startup (init.vim, `-c`, `--cmd`, …). ref #6580 ref #8677
* lua/stdlib: vim.inspect, string functionsKillTheMule2019-01-14
| | | | | ref #6580 ref #8677
* add func_attr_printf in :MichaHoffmann2018-09-24
| | | | | | | | | | | | | | | | | | | | | | log.c message.c strings.c fixed some printf warnings in: src/nvim/undo.c src/nvim/eval.c src/nvim/eval/encode.c src/nvim/eval/typval.c src/nvim/ex_getln.c src/nvim/fileio.c src/nvim/lua/executor.c src/nvim/main.c src/nvim/regexp_nfa.c src/nvim/shada.c src/nvim/spellfile.c src/nvim/tui/terminfo.c src/nvim/garray.h
* API: Remove path prefix from command name in nvim_get_proc()Lucas Hoffmann2018-08-18
| | | | | | On macOS the output from `ps -o comm` might contain the full path of the executable. The `ucomm` would be the basename only but is less portable (see previous commit).
* API: Use `ps -o comm` in nvim_get_proc()Lucas Hoffmann2018-08-15
| | | | | | | | | | | | | - The POSIX version of ps(1) only specifies "comm" for the "-o" option but not "ucomm". See http://pubs.opengroup.org/onlinepubs/9699919799/utilities/ps.html - On Linux (with the procps-ng package) "ucomm" is an alias for "comm". See https://gitlab.com/procps-ng/procps - OpenBSD also has "ucomm" as an alias for "comm" (with the extra note "Name to be used for accounting."). See https://man.openbsd.org/ps - FreeBSD describes "ucomm" as "Name to be used for accounting." but does not say that it should be an alias for "comm". See https://www.freebsd.org/cgi/man.cgi?query=ps
* Merge #8107 'jobs: separate process-group'Justin M. Keyes2018-03-18
|\
| * API: nvim_get_proc()Justin M. Keyes2018-03-18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | TODO: "exepath" field (win32: QueryFullProcessImageName()) On unix-likes `ps` is used because the platform-specific APIs are a nightmare. For reference, below is a (incomplete) attempt: diff --git a/src/nvim/os/process.c b/src/nvim/os/process.c index 09769925aca5..99afbbf290c1 100644 --- a/src/nvim/os/process.c +++ b/src/nvim/os/process.c @@ -208,3 +210,60 @@ int os_proc_children(int ppid, int **proc_list, size_t *proc_count) return 0; } +/// Gets various properties of the process identified by `pid`. +/// +/// @param pid Process to inspect. +/// @return Map of process properties, empty on error. +Dictionary os_proc_info(int pid) +{ + Dictionary pinfo = ARRAY_DICT_INIT; +#ifdef WIN32 + +#elif defined(__APPLE__) + char buf[PROC_PIDPATHINFO_MAXSIZE]; + if (proc_pidpath(pid, buf, sizeof(buf))) { + name = getName(buf); + PUT(pinfo, "exepath", STRING_OBJ(cstr_to_string(buf))); + return name; + } else { + ILOG("proc_pidpath() failed for pid: %d", pid); + } +#elif defined(BSD) +# if defined(__FreeBSD__) +# define KP_COMM(o) o.ki_comm +# else +# define KP_COMM(o) o.p_comm +# endif + struct kinfo_proc *proc = kinfo_getproc(pid); + if (proc) { + PUT(pinfo, "name", cstr_to_string(KP_COMM(proc))); + xfree(proc); + } else { + ILOG("kinfo_getproc() failed for pid: %d", pid); + } + +#elif defined(__linux__) + char fname[256] = { 0 }; + char buf[MAXPATHL]; + snprintf(fname, sizeof(fname), "/proc/%d/comm", pid); + FILE *fp = fopen(fname, "r"); + // FileDescriptor *f = file_open_new(&error, fname, kFileReadOnly, 0); + // ptrdiff_t file_read(FileDescriptor *const fp, char *const ret_buf, + // const size_t size) + if (fp == NULL) { + ILOG("fopen() of /proc/%d/comm failed", pid); + } else { + size_t n = fread(buf, sizeof(char), sizeof(buf) - 1, fp); + if (n == 0) { + WLOG("fread() of /proc/%d/comm failed", pid); + } else { + size_t end = MIN(sizeof(buf) - 1, n); + end = (end > 0 && buf[end - 1] == '\n') ? end - 1 : end; + buf[end] = '\0'; + PUT(pinfo, "name", STRING_OBJ(cstr_to_string(buf))); + } + } + fclose(fp); +#endif + return pinfo; +}