Giter Site home page Giter Site logo

thaerkh / vim-workspace Goto Github PK

View Code? Open in Web Editor NEW
467.0 5.0 30.0 5.21 MB

📑 Automated Vim session management with file auto-save and persistent undo history

License: Apache License 2.0

Vim Script 100.00%
vim-session autosave trailing-spaces workspace vim session session-management session-manager

vim-workspace's Introduction

- Note: This plugin is considered feature complete, and is no longer being maintained.
" Feel free to use this alternative to the plugin's core autosave and session management features:

" Autosave
set noswapfile
au BufLeave,CursorHold,FocusLost * if(getbufinfo('%')[0].changed) | do BufWritePre | sil! up | do BufWritePost | endif

" Autosession
au VimEnter * nested if (len(v:argv) == 1) | silent! source Session.vim | endif
au VimLeave * if (len(v:argv) == 1) | mksession! | endif
" available since v8.1.2233 (2019-10-28), v:argv doubles for both stdin and argful cases (instead of argc() and a StdinReadPre autocmd flag)
" v:argv length check may need to be 2 if using Neovim since it includes an --embed argument on launch

Features

Workspace Sessions

Persistent Vim Session

Session tracking can be activated automatically (disabled by default):

let g:workspace_autocreate = 1

Toggling the ToggleWorkspace command on will persistently track your session found in a current working directory, and all workspace features will be enabled. Conversely, toggling the command off will remove the session and disable the workspace features.

If Vim is run with a file argument and it's already in the session's workspace, Vim will load the session and go to the tab window that contains it. Otherwise, it will be loaded as a new tab in the session. If you would rather create a new buffer in the existing tab instead of creating a new tab:

let g:workspace_create_new_tabs = 0  " enabled = 1 (default), disabled = 0

It is recommended you bind this command to a convenient shortcut, such as the following:

nnoremap <leader>s :ToggleWorkspace<CR>

The following default can be configured if you wish to change the session name:

let g:workspace_session_name = 'Session.vim'

Use g:workspace_session_directory to save all your session files in a single directory outside of your workspace. Example:

let g:workspace_session_directory = $HOME . '/.vim/sessions/'

Note: this will use the workspace directory as the session file name, overriding g:workspace_sesssion_name.

If you'd like sessions to not load if you're explicitly loading a file in a workspace directory (as opposed to an argument-less vim), the following in your vimrc will provide that behaviour:

let g:workspace_session_disable_on_args = 1

Hidden Buffers

Over time, hidden buffers can build up to a point where most are unnecessary, with only those currently tied to a tab window being important. When called, the command CloseHiddenBuffers will close any hidden buffers meeting this criteria.

Undo History

When in a workspace, file undo history is persisted between sessions, without needing to keep Vim on. Cursor positions will also persist across session reloads.

The following defaults can be configured if you wish to change feature behaviour:

let g:workspace_persist_undo_history = 1  " enabled = 1 (default), disabled = 0
let g:workspace_undodir='.undodir'

Omni Completion

Preview windows will close on InsertLeave, to mitigate the default behaviour of being an orphaned window.

Autosave

Files edited in a workspace session will autosave on InsertLeave, idle (CursorHold), pane switches (FocusLost and FocusGained), or buffer switches (BufLeave).

FocusLost and FocusGained triggers will typically trigger only with GUI versions of Vim. However, there are plugins that enables these for the console version within Tmux (i.e. sjl/vitality.vim).

This autosave feature enforces a last writer wins policy (eventual consistency).

You can manually enable the autosave feature outside of a workspace session with the ToggleAutosave command.

If you would like autosave to be always on, even outside of a session, add the following to your vimrc:

let g:workspace_autosave_always = 1

If you would like to disable autosave for some reason (i.e. too much IO on disk), it can be disabled as shown here:

let g:workspace_autosave = 0

Untrailing Spaces & Untrailing Tabs

By default, all trailing spaces and tabs are trimmed before a buffer is autosaved. If you don't prefer this behaviour, add this line:

let g:workspace_autosave_untrailspaces = 0
let g:workspace_autosave_untrailtabs = 0

Ignore List

Git commit filetypes won't autosave (or trim trailing spaces) by default. You can customize the ignore list with this line:

let g:workspace_autosave_ignore = ['gitcommit']

Indent Guides

This feature has been moved to its own plugin vim-indentguides.

Installation

This plugin requires Vim 8.0, follows the standard runtime path structure, and can be installed with a variety of plugin managers.

Using Plug

Paste the following in your ~/.vimrc file:

if empty(glob('~/.vim/autoload/plug.vim'))
  silent execute "!curl -fLo ~/.vim/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim"
  autocmd VimEnter * PlugInstall | source $MYVIMRC
endif

call plug#begin('~/.vim/plugged')
Plug 'thaerkh/vim-workspace'
call plug#end()

If you don't already have Plug, this will auto-download Plug for you and install the workspace plugin.

If you already have Plug, simply paste Plug 'thaerkh/vim-workspace' and call :PlugInstall to install the plugin.

Remember to :PlugUpdate often to get all the latest features and bug fixes!

Using Vundle

Paste this in your ~./vimrc:

Plugin 'thaerkh/vim-workspace'

Using Pathogen

cd into your bundle path and clone the repo:

cd ~/.vim/bundle
git clone https://github.com/thaerkh/vim-workspace

License

License

vim-workspace's People

Contributors

dsakurai avatar guildencrantz avatar gustavokatel avatar jordisantamaria avatar kamilcuk avatar matthias-margush avatar motephyr avatar rummik avatar snaveevans avatar thaerkh avatar triplepointfive avatar williamwu2k12 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

vim-workspace's Issues

Problem with 'compatible' setting in plugin

I was wondering if you could edit the code so that there's a g:workspace_checkcompatible variable that can be set to 0 so the plugin doesn't need to check for whether that variable is set to 'compatible' or 'nocompatible' since setting this setting changes a host of other settings, specifically the whichwrap setting.

Problem:
The plugin doesn't properly store or reset the whichwrap variable, which is reset by set compatible or set nocompatible. I have in my .vimrc: set whichwrap+=<,>,h,l
The whichwrap setting makes the left and right arrows wrap to the previous or next lines when they hit the beginning or end of a line respectively, which is normal behavior in any other modern editor. Without it, vim reverts back to its Vi behavior, stopping the cursor when a h or l is used at the beginning or end of a line (or on a blank line), restricting movement for these keys to just one line.

Lines of Code:

The vim-workspace plugin by default sets vim to 'nocompatible' (g:workspace_nocompatible == 1). This is the best setting, but by default just setting the whichwrap setting again after .vimrc has been loaded wipes out the preset characters for 'whichwrap' set in .vimrc, resetting whichwrap to its defaults (whichwrap=b,s -- for just the backspace and space characters).

In workspace.vim, this global variable is checked for on Line 17. Then, when a previous session is loaded in vim by calling s:LoadWorkspace(), this variable is checked and noncompatible is set on line 127. The problem is that the plugin doesn't save or restore the settings in the whichwrap variable with the session.

Reproduction:

  • To recreate this problem, set the following whichwrap:
    set whichwrap+=<,>,h,l
  • This is the setting that is desired, so entering set whichwrap? will show whichwrap=b,s,<,>,h,l.
  • Save a session with the plugin, close vim, then open the directory in vim with the session.
  • The plugin fails to store whichwrap, so when line 127 is called, it sets the whichwrap setting back to its default: set whichwrap? will show whichwrap=b,s
    What's in the .vimrc is also not taken into account since the plugin is setting set nocompatible after .vimrc is read.

At first, I was going to request that the plugin please be edited to include storing and restoring the whichwrap settings. But, I saw that you answered a similar issue here: #4
By including the g:workspace_nocompatible variable, one can set this to 0 and escape the whole problem. But, this confuses the setting in my .vimrc files so that it's not so clear what I'm trying to do (the variable name suggesting that I'm trying to set it to compatible). So my suggestion is to change line 127 to something to the effect of:

    ...
    let l:filename = expand(@%)
    if g:workspace_checkcompatible==1
        if g:workspace_nocompatible | set nocompatible | endif
    endif
    execute 'source ' . escape(s:GetSessionName(), '%')
    ...

This way it's backwards compatible with everyone who has the setting set for the same purpose but also clarifies the compatible setting so that it can be skipped.
Is it possible to add this to the code?

Closing vim without closing the open files

When using cli vim, how do I exit vim without closing the individual files? Closing the files beats the purpose of the plugin.

Closing the terminal is an option, but I prefer not to do that.

Just loading recent files from session file

First of all: Great plugin!

  1. I like to start vim without any arguments in a folder that already contains a file 'session.vim'.
    Current behaviour: workspace is correctly reloaded and there is an additional empty buffer opened.
    It would be great if in this case no empty buffer would be created!

  2. I use the plugin 'fholgado/minibufexpl.vim' and it is normally opened. This causes an error message when I start vim since I use your great plugin: "A buffer with this name already exists."
    Do you have any idea how to solve this issue?

set nocompatible in the LoadWorkspace function reset options to the vim defaults

I was noticed that some of my vim settings are not apply, checking the code of workspace.vim i see this line set nocompatible, this resets some options to the vim defaults, e.g i have set noshowmode in my .vimrc but when start vim and type :set showmode? to see their value it show me that is on. I do not have much experience with vim but i would suggest you change that line to if &compatible | set nocompatible | endif to solve this problem, i hope any response, this plugin is really util for me, thanks for your great contribution!

Autosave error in telescope

Having autosave activated, every time closing nvim telescope buffer, It prompt an error of not able to save telescope, how can I ignore autosave in telescope buffer to avoid this error?

Add option to open new file in buffer instead of tab?

Great plugin, I'd just like to have a setting to be able to open a new file in a buffer instead of a tab. I had to comment out the tabnew line in the FindOrNew function to get it working the way I want.

Thanks!

Plugin causes cedit mode to misbehave, some invalid call in Command mode

Rather significant misdemeanor of the plugin by switching down and on again one-by-one all of my installed plugins. Therefore, most probably it's vim-workspace, but this may not be 100% sure.

cedit command mode is by default invoked with <C-f> from the : command line

Reproduction:

  • Enter Ex-command entering mode by typing :
  • Enter cedit Mode by typing <C-f>
  • in there, inter insert mode by typing i
  • leave insert mode by typing <Esc

This will give you straight in the command entering mode the following error:

Error detected while processing InsertLeave Auto commands for "*":                                           
E11: Invalid in command-line window; <CR> executes, CTRL-C quits: pclose|endif

Other stuff with changing modes misbehaves, too.
Which is kind of cryptic and hard to track down. vim-style command edit mode is kind of an important feature so I think this is not a small issue.

FWIW, my Vim-workspace-related variables:

nnoremap <leader><F10> :ToggleWorkspace<CR>
let g:workspace_autosave_untrailspaces = 0
let g:workspace_autosave = 0
let g:workspace_persist_undo_history = 0

As I have also suffered already from vim-workspace trying to reopen my undotree window (unsuccessfully), I think the blac/whitelist scheme according to which windows are handled could benefit from an update. I really like the plugin though, and it's a shame that I'll have to deactive it for the time being :/ cedit mode is kinda important for me. Wish I could help, but thats beyind my skills, I don't know VimL...

If you know a workaround for the meantime, in case you confirm the issue lies with the plugin, please let me know :) thank you!

Fail to create session storage directory on MS Windows (bugfix provided)

I set my own g:workspace_session_directory in _vimrc , when vim-workspace creates a new session, it fail to create the session storage folder whose name contains opened project path. I looked into code of vim-workspace and figured out this problem is caused by not replacing character : and \ properly in Windows-style path. I modified the function GetSessionDirectoryPath() in plugin/workspace.vim and it's worked.

Modified GetSessionDirectoryPath():

function! s:GetSessionDirectoryPath()
  if !isdirectory(g:workspace_session_directory)
    call mkdir(g:workspace_session_directory)
  endif
  let l:cwd = getcwd()
  if has('win32')
    let l:fileName = substitute(l:cwd, '\', '%', 'g')
    let l:fileName = substitute(l:fileName, ':', '%', 'g')
  else
    let l:fileName = substitute(l:cwd, '/', '%', 'g')
  endif
  let l:fullPath = g:workspace_session_directory . l:fileName
  return l:fullPath
endfunction

Support for git branches need to be considered.

Placing .session.vim and .undodir under the current path is easy to manage sessions, but all git branches have to share the same session, which is not comfortable.

Maybe putting all sessions into a specialized dir is better ?

High CPU usage

I am using Mac, Neovim v0.2.0-1470-g6755262 and Ruby 2.3.0

This problem raised when neovim says there is duplicate buffer on /../../Session.vim when starting it up

The High CPU is caused by fsevent_watch that monitoring current nvim working directory
I found two fsevent_watch process using command ps aux | grep ruby every I activate vim-workspace plugin
So I have installed vim-workspace plugin twice to make sure that the high CPU usage is not caused by other plugin

show error when run vim after created Workspace

mac 10.14.3
VIM - Vi IMproved 8.1 (2018 May 18, compiled Feb 19 2019 11:57:04)
macOS version
包含补丁: 1-950
编译者 Homebrew
巨型版本 无图形界面。 可使用(+)与不可使用(-)的功能:
+acl +extra_search +mouse_netterm +tag_old_static
+arabic -farsi +mouse_sgr -tag_any_white
+autocmd +file_in_path -mouse_sysmouse -tcl
+autochdir +find_in_path +mouse_urxvt +termguicolors
-autoservername +float +mouse_xterm +terminal
-balloon_eval +folding +multi_byte +terminfo
+balloon_eval_term -footer +multi_lang +termresponse
-browse +fork() -mzscheme +textobjects
++builtin_terms +gettext +netbeans_intg +textprop
+byte_offset -hangul_input +num64 +timers
+channel +iconv +packages +title
+cindent +insert_expand +path_extra -toolbar
-clientserver +job +perl +user_commands
+clipboard +jumplist +persistent_undo +vartabs
+cmdline_compl +keymap +postscript +vertsplit
+cmdline_hist +lambda +printer +virtualedit
+cmdline_info +langmap +profile +visual
+comments +libcall -python +visualextra
+conceal +linebreak +python3 +viminfo
+cryptv +lispindent +quickfix +vreplace
+cscope +listcmds +reltime +wildignore
+cursorbind +localmap +rightleft +wildmenu
+cursorshape +lua +ruby +windows
+dialog_con +menu +scrollbind +writebackup
+diff +mksession +signs -X11
+digraphs +modify_fname +smartindent -xfontset
-dnd +mouse +startuptime -xim
-ebcdic -mouseshape +statusline -xpm
+emacs_tags +mouse_dec -sun_workshop -xsmp
+eval -mouse_gpm +syntax -xterm_clipboard
+ex_extra -mouse_jsbterm +tag_binary -xterm_save
系统 vimrc 文件: "$VIM/vimrc"
用户 vimrc 文件: "$HOME/.vimrc"
第二用户 vimrc 文件: "~/.vim/vimrc"
用户 exrc 文件: "$HOME/.exrc"
defaults file: "$VIMRUNTIME/defaults.vim"
$VIM 预设值: "/usr/local/share/vim"
编译方式: clang -c -I. -Iproto -DHAVE_CONFIG_H -DMACOS_X -DMACOS_X_DARWIN -g -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
链接方式: clang -L. -fstack-protector-strong -L/usr/local/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/openssl/lib -L/usr/local/opt/readline/lib -L/usr/local/lib -o vim -lncurses -liconv -lintl -framework AppKit -L/usr/local/opt/lua/lib -llua5.3 -mmacosx-version-min=10.14 -fstack-protector-strong -L/usr/local/lib -L/usr/local/Cellar/perl/5.28.1/lib/perl5/5.28.1/darwin-thread-multi-2level/CORE -lperl -lm -lutil -lc -L/usr/local/opt/python/Frameworks/Python.framework/Versions/3.7/lib/python3.7/config-3.7m-darwin -lpython3.7m -framework CoreFoundation -lruby.2.6

\\\\\\\\\\\
"/.vimrc" 478L, 16405C
处理 function 15_LoadWorkspace 时发生错误:
第 7 行:
E461: 无效的变量名: a:filename
"
/.vimrc" 478L, 16405C
处理 function 15_LoadWorkspace 时发生错误:
第 11 行:
E121: 未定义的变量: a:filename
请按 ENTER 或其它命令继续
处理 function 15_LoadWorkspace 时发生错误:
第 11 行:
E116: Invalid arguments for function 15_FindOrNew

NERD tree seems to cause issues

When using this plugin with NERDtree the extension fails to load the tabs correctly
image
this is the session file

let SessionLoad = 1
let s:so_save = &g:so | let s:siso_save = &g:siso | setg so=0 siso=0 | setl so=-1 siso=-1
let v:this_session=expand("<sfile>:p")
silent only
silent tabonly
cd ~/.config/nvim
if expand('%') == '' && !&modified && line('$') <= 1 && getline(1) == ''
  let s:wipebuf = bufnr('%')
endif
set shortmess=aoO
argglobal
%argdel
edit init.vim
let s:save_splitbelow = &splitbelow
let s:save_splitright = &splitright
set splitbelow splitright
wincmd _ | wincmd |
vsplit
1wincmd h
wincmd w
let &splitbelow = s:save_splitbelow
let &splitright = s:save_splitright
wincmd t
let s:save_winminheight = &winminheight
let s:save_winminwidth = &winminwidth
set winminheight=0
set winheight=1
set winminwidth=0
set winwidth=1
exe 'vert 1resize ' . ((&columns * 31 + 95) / 190)
exe 'vert 2resize ' . ((&columns * 158 + 95) / 190)
argglobal
enew
file NERD_tree_1
setlocal fdm=manual
setlocal fde=0
setlocal fmr={{{,}}}
setlocal fdi=#
setlocal fdl=0
setlocal fml=1
setlocal fdn=20
setlocal nofen
wincmd w
argglobal
balt init.vim
setlocal fdm=manual
setlocal fde=0
setlocal fmr={{{,}}}
setlocal fdi=#
setlocal fdl=0
setlocal fml=1
setlocal fdn=20
setlocal fen
silent! normal! zE
let &fdl = &fdl
let s:l = 1 - ((0 * winheight(0) + 22) / 44)
if s:l < 1 | let s:l = 1 | endif
keepjumps exe s:l
normal! zt
keepjumps 1
normal! 0
wincmd w
2wincmd w
exe 'vert 1resize ' . ((&columns * 31 + 95) / 190)
exe 'vert 2resize ' . ((&columns * 158 + 95) / 190)
tabnext 1
badd +0 init.vim
if exists('s:wipebuf') && len(win_findbuf(s:wipebuf)) == 0 && getbufvar(s:wipebuf, '&buftype') isnot# 'terminal'
  silent exe 'bwipe ' . s:wipebuf
endif
unlet! s:wipebuf
set winheight=1 winwidth=20 shortmess=filnxtToOF
let &winminheight = s:save_winminheight
let &winminwidth = s:save_winminwidth
let s:sx = expand("<sfile>:p:r")."x.vim"
if filereadable(s:sx)
  exe "source " . fnameescape(s:sx)
endif
let &g:so = s:so_save | let &g:siso = s:siso_save
nohlsearch
doautoall SessionLoadPost
unlet SessionLoad
" vim: set ft=vim :

No way to load session if already in vim?

I couldn't find anything about this. Is it possible to open (neo)vim, cd to a folder, and then load the session attached to that folder? It seems like the only way to load workspaces right now is to open (neo)vim with the folder as the cwd on startup.

Work Space not loading up on nvim v0.4.4

I turned on the toggleworkspace and toggleautosave while in nvim on my project directory , it saves a file back to the save directory i had specified i.e ~/.config/nvim/sessions
but upon closing nvim with the buffers open with :q and restarting it the buffers don't restore

any idea what could be the issue here?

Undefined variables

Hi all, I'm having some issues when Toggling a session, I get this errors, any Ideas? Latest Vim 8 here, thanks:

Error detected while processing function <SNR>40_ToggleWorkspace[2]..<SNR>40_RemoveWorkspace[4]..<SNR>40_SetAutosave:
|line   24:
|E121: Undefined variable: s:autoread
|line   25:
|E121: Undefined variable: s:autowriteall
|line   26:
|E121: Undefined variable: s:updatetime
|line   27:
|E121: Undefined variable: s:swapfile
|line   29:
|E121: Undefined variable: s:swapsync
|line   31:
|E216: No such group or event: WorkspaceToggle * *

Add option to remove trailing spaces on manual save?

Hello! First off, I just gotta say that your plugin is a Godsend! It works all the time, every time, and makes changing work environments a breeze! So thank you! fist bump

Could there be an option to remove trailing spaces when the file is saved manually? I run guard for my tests so having vim-workspace regularly save the files I'm working on causes any associated tests to run when I'm not quite ready for it. By using a manual save, I can ensure that all of my additions and modifications are ready before guard kicks off my tests in the background.

Thanks again!
All the best,
Blake

let g:workspace_create_new_tabs = 0 not work properly

the option:

let g:workspace_create_new_tabs = 0

only work correctly if vim argument is the last opened buffer before exit vim, but if it is not the last opened buffer then instead of open new buffer in already existing tab, it open in new tab.

Diff mode doesn't work as expected with existing workspace

Related to xolox/vim-session#171:

When trying to run vim in diff mode, the diff files open as tabs and not in a split pane as expected.

Reproduce:

  1. Open a file and allow workspace to be created
  2. Close vim
  3. Open in diff mode: vim -d a.txt b.txt
  4. Note two tabs are added to the existing session/workspace.

Workaround:

  1. Before using vim diff, delete Session.vim
  2. Open in diff mode and compare files as expected

Is it possible to disable workspaces when vim is opened in diff mode? Don't restore a session or create a session from diff mode? Other option would be to open the files as expected in their own tab and add the to the workspace session.

Extra empty undo action

vim-workspace seems to be creating an extra, empty undo action.

Every time I make a change using insert mode and try to undo it, I find that I have to perform two undo actions. The first time I hit u, a message shows up on the bottom of my screen saying 0 changes; before #14; 1 seconds ago (obviously the #14 changes between invocations), and the edits I just made remain. Then I press u a second time, and the changes are undone. My expected behavior is that I should only have to press u once to remove the edit I just made.

Is this a bug, or is there some feature here that I'm just not aware of? I just installed this plugin because I'm very interested in the persistent undo feature, so please let me know if there's something I'm missing.

This only happens while I have a workspace active. I've also verified that the problem persists even when I disable persistent undo history with let g:workspace_persist_undo_history = 0. This problem doesn't occur when I make a change using d, x, or r, but it does occur when I enter insert mode using c.

I'm running neovim version 0.3.8.

Is it possible to disable autosave on idle

There isn't really any point in it if the file isn't being changed, and it causes rust-analyzer to run again and again causing random flickering in errors/warnings displayed in the file

nerdtree, tagbar, qf cannot be ignored

Version: the latest

Vim Version:
VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Sep 14 2017 09:57:07)
MacOS X (unix) version
Included patches: 1-1098
Compiled by Homebrew
Huge version with MacVim GUI.

Settings:

nnoremap <leader>ss :ToggleWorkspace<CR>
let g:workspace_session_name = '.session.vim'
let g:workspace_autosave = 0
let g:workspace_autosave_ignore = ['gitcommit', 'qf', 'nerdtree', 'tagbar']

when session is reloaded, those windows are all opened, while tagbar has content, but location list and nerdtree is empty normal windows.

Opening previous session results in blank buffers

Lately when I open a previously saved session, all my buffers will be blank with zero lines of text. The names, tabs, and window locations all restore correctly but the files act like they're empty. Even if I :wa the files aren't overwritten with nothing; opening them individually (after toggling off the workspace) shows the original content unchanged. Additionally, if I try to open a file via :e it only gives me options from my home directory rather than the project root directory that I launched neovim from.

I tried deleting the session file and starting from scratch, which worked for a while, but started doing the same thing again.

I'm using the latest stable Neovim 0.3.8, and everything is up to date via Plug.

Errors at Neovim start

For some reason I am getting an error when starting Neovim on Linux (just $ nvim):

let g:workspace_autocreate = 1
let g:workspace_autosave_always = 1
let g:workspace_session_directory = $HOME . '/.vim/sessions/'

image

The directory ~/.config/nvim/sessions does exist.

Check if session is already in use

I often run in the following issue:

  • Create a workspace sessions
  • [optionally] close vim
  • [optionally] reopen the session
  • in some other terminal open up a different file in the same folder
  • Result: vim-workspace will try to load the session in this second vim too
  • Therefore it opens all the files open in the session
  • Since all the files are already open in the first vim instance vim will ask me for each of them if I anyway want to open them even though they are in use by another vim-instance. If the session is big, this can mean I have to answer for example 15 times.

The disable_on_args option solves this issue – but then I have to remember that there is a session that I'd like to open.
I'd love to see vim-workspace to have some lock-mechanism that checks if the session is already in use.

Disable for Empty filetype

Is there a way to use the g:workspace_autosave_ignore setting to disable buffers that have a blank/empty filetype? I've tried using an empty string like this:

let g:workspace_autosave_ignore = ['gitcommit', '']

However, this seems to prevent the workspace from loading when re-launching nvim. That is, no files are loaded when launching nvim without arguments in my workspace directory.

open a file without load workspace

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?

no matching autocommands

I keep getting "no matching autocommands" in workspaces. I'm not sure what is causing this, but my session doesn't seem to get saved, though the autosave feature seems to be working

files (buffers) not reopening

When opening up Macvim the previous session is semi-loaded. That is, the tabs are reopened, but naming of tabs (using Taboo.vim) is lost and for some reason, any open files from the previous sessions are not reopened.

System:
OS: OSX Mojave (10.14.4)
GVim: Version 8.1.950

Example session file:

if &cp | set nocp | endif
let s:so_save = &so | let s:siso_save = &siso | set so=0 siso=0
let v:this_session=expand("<sfile>:p")
let NERDTreeMapPreviewSplit = "gi"
let NERDTreeMapCloseChildren = "X"
let NERDTreeShowHidden = "0"
let NERDTreeMapCloseDir = "x"
let NERDTreeSortHiddenFirst = "1"
let NERDTreeMinimalUI = "0"
let NERDTreeShowLineNumbers = "0"
let NERDTreeRespectWildIgnore = "0"
let NERDTreeAutoDeleteBuffer =  0
let NERDTreeBookmarksFile = "/Users/zeerakw/.NERDTreeBookmarks"
let UltiSnipsJumpForwardTrigger = "<C-j>"
let NERDTreeMapToggleHidden = "I"
let NERDTreeWinSize = "31"
let NERDTreeMapJumpParent = "p"
let UltiSnipsRemoveSelectModeMappings =  1
let NERDTreeMapPreview = "go"
let NERDTreeCascadeSingleChildDir = "1"
let Taboo_tabs = "1	Fake News Code\n"
let NERDTreeNotificationThreshold = "100"
let NERDTreeMapActivateNode = "o"
let NERDTreeDirArrowExpandable = "▸"
let NERDTreeMapMenu = "m"
let NERDTreeStatusline = "%{exists('b:NERDTree')?b:NERDTree.root.path.str():''}"
let NERDTreeMapOpenInTabSilent = "T"
let NERDTreeMapHelp = "?"
let NERDTreeMapToggleFilters = "f"
let NERDTreeMapJumpPrevSibling = "<C-k>"
let NERDTreeShowBookmarks = "0"
let NERDTreeRemoveDirCmd = "rm -rf "
let NERDTreeMouseMode = "1"
let NERDTreeChDirMode = "0"
let NERDTreeCreatePrefix = "silent"
let NERDTreeAutoCenterThreshold = "3"
let NERDTreeShowFiles = "1"
let NERDTreeMapOpenSplit = "i"
let NERDTreeCaseSensitiveSort = "0"
let NERDTreeHijackNetrw = "1"
let NERDTreeMapRefresh = "r"
let NERDTreeBookmarksSort = "1"
let NERDTreeHighlightCursorline = "1"
let UltiSnipsExpandTrigger = "<C-j>"
let NERDTreeMapOpenInTab = "t"
let GPGUsePipes =  1
let NERDTreeMapCWD = "CD"
let NERDTreeNaturalSort = "0"
let UltiSnipsEnableSnipMate =  1
let NERDTreeMapPreviewVSplit = "gs"
let NERDTreeMapUpdir = "u"
let UltiSnipsJumpBackwardTrigger = "<C-x>"
let NERDTreeGlyphReadOnly = "RO"
let NERDTreeMapChdir = "cd"
let NERDTreeMapToggleZoom = "A"
let NERDTreeMarkBookmarks = "1"
let NERDTreeMapRefreshRoot = "R"
let NERDTreeAutoCenter = "1"
let NERDTreeCascadeOpenSingleChildDir = "1"
let NERDTreeMapOpenVSplit = "s"
let NERDTreeMapJumpLastChild = "J"
let NERDTreeWinPos = "left"
let NERDTreeMapDeleteBookmark = "D"
let UltiSnipsListSnippets = "<c-tab>"
let NERDTreeMapJumpNextSibling = "<C-j>"
let NERDTreeMapJumpRoot = "P"
let UltiSnipsEditSplit = "normal"
let NERDTreeCopyCmd = "cp -r "
let NERDTreeMapQuit = "q"
let NERDTreeMapChangeRoot = "C"
let NERDTreeSortDirs = "1"
let NERDTreeMapToggleFiles = "F"
let NERDTreeMapOpenExpl = "e"
let NERDTreeMapJumpFirstChild = "K"
let NERDTreeDirArrowCollapsible = "▾"
let NERDTreeMapOpenRecursively = "O"
let NERDTreeMapToggleBookmarks = "B"
let NERDTreeMapUpdirKeepOpen = "U"
let NERDTreeQuitOnOpen = "0"
silent only
silent tabonly
cd ~/
if expand('%') == '' && !&modified && line('$') <= 1 && getline(1) == ''
  let s:wipebuf = bufnr('%')
endif
set shortmess=aoO
argglobal
%argdel
tabnew
tabnew
tabnew
tabnew
tabrewind
edit ~/NERD_tree_2
set splitbelow splitright
wincmd _ | wincmd |
vsplit
1wincmd h
wincmd w
set nosplitright
wincmd t
set winminheight=0
set winheight=1
set winminwidth=0
set winwidth=1
exe 'vert 1resize ' . ((&columns * 31 + 117) / 235)
exe 'vert 2resize ' . ((&columns * 203 + 117) / 235)
argglobal
setlocal fdm=marker
setlocal fde=0
setlocal fmr={{{,}}}
setlocal fdi=
setlocal fdl=1
setlocal fml=1
setlocal fdn=3
setlocal fen
let s:l = 1 - ((0 * winheight(0) + 31) / 63)
if s:l < 1 | let s:l = 1 | endif
exe s:l
normal! zt
1
normal! 0
wincmd w
argglobal
enew
setlocal fdm=marker
setlocal fde=0
setlocal fmr={{{,}}}
setlocal fdi=
setlocal fdl=1
setlocal fml=1
setlocal fdn=3
setlocal fen
wincmd w
exe 'vert 1resize ' . ((&columns * 31 + 117) / 235)
exe 'vert 2resize ' . ((&columns * 203 + 117) / 235)
tabnext
set splitbelow splitright
set nosplitright
wincmd t
set winminheight=0
set winheight=1
set winminwidth=0
set winwidth=1
argglobal
enew
setlocal fdm=marker
setlocal fde=0
setlocal fmr={{{,}}}
setlocal fdi=
setlocal fdl=1
setlocal fml=1
setlocal fdn=3
setlocal fen
tabnext
set splitbelow splitright
set nosplitright
wincmd t
set winminheight=0
set winheight=1
set winminwidth=0
set winwidth=1
argglobal
enew
setlocal fdm=marker
setlocal fde=0
setlocal fmr={{{,}}}
setlocal fdi=
setlocal fdl=1
setlocal fml=1
setlocal fdn=3
setlocal fen
tabnext
set splitbelow splitright
set nosplitright
wincmd t
set winminheight=0
set winheight=1
set winminwidth=0
set winwidth=1
argglobal
enew
setlocal fdm=marker
setlocal fde=0
setlocal fmr={{{,}}}
setlocal fdi=
setlocal fdl=1
setlocal fml=1
setlocal fdn=3
setlocal fen
tabnext
set splitbelow splitright
set nosplitright
wincmd t
set winminheight=0
set winheight=1
set winminwidth=0
set winwidth=1
argglobal
enew
setlocal fdm=marker
setlocal fde=0
setlocal fmr={{{,}}}
setlocal fdi=
setlocal fdl=1
setlocal fml=1
setlocal fdn=3
setlocal fen
tabnext 1
badd +0 ~/NERD_tree_2
badd +98 ~/.vim/settings/plsettings.vim
badd +2 ~/.vim/vimrc
badd +32 ~/.vim/settings/config.vim
if exists('s:wipebuf') && len(win_findbuf(s:wipebuf)) == 0
  silent exe 'bwipe ' . s:wipebuf
endif
unlet! s:wipebuf
set winheight=1 winwidth=20 shortmess=filnxtToOc
set winminheight=1 winminwidth=1
let s:sx = expand("<sfile>:p:r")."x.vim"
if file_readable(s:sx)
  exe "source " . fnameescape(s:sx)
endif
let &so = s:so_save | let &siso = s:siso_save
doautoall SessionLoadPost
unlet SessionLoad
" vim: set ft=vim :```

"Unknown option: swapsync"

I am using Neovim on Ubuntu 16.04. Whenever I toggle a workspace (ToggleWorkspace), an error message saying "Unknown option: swapsync" comes up.

It still autosaves just fine, though.

Restoring unnamed buffers

I use VSCode to keep temporary notes/snippets without saving them:

This happened when I tried reproducing my use case in vim-workspace:

Am I doing it wrong or is this unsupported?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.