aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim/_editor.lua
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/lua/vim/_editor.lua')
-rw-r--r--runtime/lua/vim/_editor.lua17
1 files changed, 17 insertions, 0 deletions
diff --git a/runtime/lua/vim/_editor.lua b/runtime/lua/vim/_editor.lua
index 7f09fc8038..1ba7d6163d 100644
--- a/runtime/lua/vim/_editor.lua
+++ b/runtime/lua/vim/_editor.lua
@@ -1147,11 +1147,28 @@ function vim._init_default_autocmds()
end
end,
})
+
vim.api.nvim_create_autocmd({ 'CmdwinEnter' }, {
pattern = '[:>]',
group = vim.api.nvim_create_augroup('nvim_cmdwin', {}),
command = 'syntax sync minlines=1 maxlines=1',
})
+
+ vim.api.nvim_create_autocmd({ 'SwapExists' }, {
+ pattern = '*',
+ group = vim.api.nvim_create_augroup('nvim_swapfile', {}),
+ callback = function()
+ local info = vim.fn.swapinfo(vim.v.swapname)
+ local user = vim.uv.os_get_passwd().username
+ local iswin = 1 == vim.fn.has('win32')
+ if info.error or info.pid <= 0 or (not iswin and info.user ~= user) then
+ vim.v.swapchoice = '' -- Show the prompt.
+ return
+ end
+ vim.v.swapchoice = 'e' -- Choose "(E)dit".
+ vim.notify(('W325: Ignoring swapfile from Nvim process %d'):format(info.pid))
+ end,
+ })
end
function vim._init_defaults()