Adds sudo writes to nvim

If in nvim and the SUDO_ASKPASS environment variable is set then a WW
mapping will expand to

:w !sudo -A tee % >/dev/null

If in not-neo vim, the -A is omitted.

The environment variable is also set. Some unused environment variables
were also removed.

https://stackoverflow.com/questions/2600783/how-does-the-vim-write-with-sudo-trick-work
https://github.com/neovim/neovim/issues/12103
Jonathan Hodgson 2 years ago
parent ab27433fc4
commit 1daa851d98
  1. 8
      nvim/.config/nvim/plugin/mappings.vim
  2. 15
      shells/shared/environmentVariables

@ -81,3 +81,11 @@ nnoremap ]c :cnext<cr>
" Run proselint and put it in the quickfix list
nnoremap <leader>p :call mine#functions#proselint()<CR>
if has('nvim')
if !empty($SUDO_ASKPASS)
cnoremap WW w !sudo -A tee % > /dev/null
endif
else
cnoremap WW w !sudo tee % > /dev/null
endif

@ -52,16 +52,7 @@ export MSSQL_CLI_TELEMETRY_OPTOUT=1
export DOTNET_CLI_TELEMETRY_OPTOUT=1
export POWERSHELL_CLI_TELEMETRY_OPTOUT=1
#export GTK_THEME=Adapta-Nokto
# Askpass
# I will use this for sudo writes in nvim
[ -f "/usr/lib/seahorse/ssh-askpass" ] && export SUDO_ASKPASS=/usr/lib/seahorse/ssh-askpass
if [ -n "$GTK_MODULES" ]
then
export GTK_MODULES="$GTK_MODULES:unity-gtk-module"
else
export GTK_MODULES="unity-gtk-module"
fi
if [ -z "$UBUNTU_MENUPROXY" ]
then
export UBUNTU_MENUPROXY=1
fi

Loading…
Cancel
Save