nvim: change server socket fallback to user dir

This commit is contained in:
tastytea 2022-08-27 17:41:41 +02:00
parent 80a206efbf
commit 5c381ad548
Signed by: tastytea
SSH Key Fingerprint: SHA256:FBkvrOlhq5use1XEttyUGT4bUTDVA1ar9SgIc9P03cM
2 changed files with 5 additions and 4 deletions

View File

@ -1,7 +1,8 @@
require('my/plugins')
local serversock = string.format("%s/nvim.%s.sock",
vim.env['XDG_RUNTIME_DIR'] or '/tmp', vim.env['USER'])
local serversock = (
vim.env['XDG_RUNTIME_DIR'] or vim.env['XDG_STATE_HOME'] or
vim.env['HOME'] .. '/.local/state') .. '/nvim.sock'
if vim.fn.filereadable(serversock) == 0 then
vim.fn.serverstart(serversock);
end

View File

@ -22,8 +22,8 @@ if type nvim >& -; then
# Open files from :terminal in parent instance
VISUAL="${VISUAL} --server ${NVIM} --remote"
else
VISUAL="$(command -v nvim) \
--server ${XDG_RUNTIME_DIR:-/tmp}/nvim.${USER}.sock"
local sockdir="${XDG_RUNTIME_DIR:-${XDG_STATE_HOME:-${HOME}/.local/state}}"
VISUAL="$(command -v nvim) --server ${sockdir}/nvim.sock"
fi
elif command -v emacsclient > /dev/null; then
# Add Defaults env_keep += "SSH_CONNECTION" to /etc/sudoers.d/ssh_vars