thaerkh / vim-workspace

📑 Automated Vim session management with file auto-save and persistent undo history
Apache License 2.0
466 stars 30 forks source link

open a file without load workspace #13

Closed yinflying closed 6 years ago

yinflying commented 6 years ago

I find that I would open a file under the directory include workspace session file that would lead to open both file and the session. I should exit twice.

Is there anyway to open a file without loading the workspace session?

superDuperCyberTechno commented 6 years ago

I have a somewhat hacky solution to this problem.

autocmd VimEnter * if argc() != 0 | let g:workspace_session_name='' | endif

On VimEnter, I check if there was any arguments (files) passed on load, if there was (IE: argc() being non-zero), I set workspace_session_name to nothing, so there's nothing to load.

As mentioned, this is a hacky solution. If you try ToggleWorkspace after passing a file as an argument, it will fail because you can't create a session file without a name.

Official support for this would be awesome.

yinflying commented 6 years ago

@superDuperCyberTechno Thank you, it is a good way to solve the problem. but it will make to build workspace session more difficult. ^_^

thaerkh commented 6 years ago

@yinflying can you explain your workflow? this is my current understanding: there's a session under a directory, but you'd like to open a file path in that directory without the session opening? I can add an option to "disable" sessions if opening a file directly, similar to how it behaves if you open from stdout.

thaerkh commented 6 years ago

Added support for what I've described (I like it myself), if you add let g:workspace_session_disable_on_args = 1 using the latest from master, you should get that behaviour.

Let me know if that addresses this issue.

Cheers, Thaer

yinflying commented 6 years ago

Cheers, It works as my expected! (I am sorry I have read the comment just now)