diff options
| author | David Lukes <dafydd.lukes@gmail.com> | 2020-08-30 10:48:25 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-08-30 01:48:25 -0700 |
| commit | 31577e889fe78fe130779e5c7bd9ef03e30849f9 (patch) | |
| tree | c2e697a90fc0eadc9c3b9381dc885fb6a55f5570 /lua/nvim_lsp/util.lua | |
| parent | dartls: prefer flutter path over dart #332 (diff) | |
| download | nvim-lspconfig-31577e889fe78fe130779e5c7bd9ef03e30849f9.tar nvim-lspconfig-31577e889fe78fe130779e5c7bd9ef03e30849f9.tar.gz nvim-lspconfig-31577e889fe78fe130779e5c7bd9ef03e30849f9.tar.bz2 nvim-lspconfig-31577e889fe78fe130779e5c7bd9ef03e30849f9.tar.lz nvim-lspconfig-31577e889fe78fe130779e5c7bd9ef03e30849f9.tar.xz nvim-lspconfig-31577e889fe78fe130779e5c7bd9ef03e30849f9.tar.zst nvim-lspconfig-31577e889fe78fe130779e5c7bd9ef03e30849f9.zip | |
Switch to Lua on_exit callback in util.sh (#302)
With neovim/neovim#12507 merged, we can get rid of the hacky global VimL
callback :tada:
Diffstat (limited to 'lua/nvim_lsp/util.lua')
| -rw-r--r-- | lua/nvim_lsp/util.lua | 24 |
1 files changed, 6 insertions, 18 deletions
diff --git a/lua/nvim_lsp/util.lua b/lua/nvim_lsp/util.lua index c125c33f..7bff215f 100644 --- a/lua/nvim_lsp/util.lua +++ b/lua/nvim_lsp/util.lua @@ -415,24 +415,12 @@ function M.sh(script, cwd) -- and makes it easy and intuitive to cancel the operation with Ctrl-C api.nvim_command("10new | startinsert") local bufnr = api.nvim_get_current_buf() - - -- TODO: The on_exit callback needs to be a VimL function, so here's a quick - -- and dirty way of creating one with a hopefully unique name, so that - -- different runs of M.sh don't stomp on each other's callbacks (or some - -- other VimL functions for that matter). If it ever becomes possible to pass - -- Lua callbacks to termopen/jobstart, switch to a local Lua function closing - -- over bufnr as a much cleaner alternative. - -- See https://github.com/neovim/neovim/issues/7607 - local viml_on_exit = "Nvim_lspUtilShOn_exit"..bufnr - api.nvim_command([[ - function! ]]..viml_on_exit..[[(job_id, code, event_type) - if !a:code - silent bwipeout! ]]..bufnr..[[| - endif - endfunction - ]]) - - fn.termopen({"sh", "-c", script}, {cwd = cwd, on_exit = viml_on_exit}) + local function on_exit(job_id, code, event_type) + if code == 0 then + api.nvim_command("silent bwipeout! "..bufnr) + end + end + fn.termopen({"sh", "-c", script}, {cwd = cwd, on_exit = on_exit}) end function M.format_vspackage_url(extension_name) |
