From 9048647e2986dfaf643687849b845182c6be7dfc Mon Sep 17 00:00:00 2001 From: sev Date: Thu, 5 Dec 2024 14:04:20 -0600 Subject: [PATCH] add scheme support with g:lastplace_force_schemes --- plugin/vim-lastplace.vim | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/plugin/vim-lastplace.vim b/plugin/vim-lastplace.vim index dac39b7..b63ee8e 100644 --- a/plugin/vim-lastplace.vim +++ b/plugin/vim-lastplace.vim @@ -22,6 +22,10 @@ if !exists('g:lastplace_ignore_buftype') let g:lastplace_ignore_buftype = "help,nofile,quickfix" endif +if !exists('g:lastplace_force_schemes') + let g:lastplace_force_schemes = "suda://" +endif + if !exists('g:lastplace_open_folds') let g:lastplace_open_folds = 1 endif @@ -29,14 +33,22 @@ endif fu! s:lastplace_can_run() if index(split(g:lastplace_ignore_buftype, ","), &buftype) != -1 return 0 - endif + endif if index(split(g:lastplace_ignore, ","), &filetype) != -1 return 0 endif try - "if the file does not exist on disk (a new, unsaved file) then do nothing + "check for schemes to force allow, since checking existence is hard + for s in split(g:lastplace_force_schemes, ',') + if stridx(@%, s) == 0 + return 1 + endif + endfor + + "if the file does not exist on disk, then do nothing + "this could be a new, unsaved file, or a non-filesystem path if empty(glob(@%)) return 0 endif