@@ -39,6 +39,7 @@ function! s:Prepare()
39
39
\' config_home' : ' ~/.vim/vim-project-config',
40
40
\' project_base' : [' ~'],
41
41
\' use_session': 0 ,
42
+ \' use_viminfo': 0 ,
42
43
\' open_root_when_use_session': 0 ,
43
44
\' check_branch_when_use_session': 0 ,
44
45
\' project_root' : ' ./',
@@ -76,6 +77,7 @@ function! s:Prepare()
76
77
\' file_mappings',
77
78
\' tasks',
78
79
\' use_session',
80
+ \' use_viminfo',
79
81
\' open_root_when_use_session',
80
82
\' check_branch_when_use_session',
81
83
\' commit_message',
@@ -209,6 +211,7 @@ function! s:InitConfig()
209
211
let s: open_root_when_use_session = s: config .open_root_when_use_session
210
212
let s: check_branch_when_use_session = s: config .check_branch_when_use_session
211
213
let s: use_session = s: config .use_session
214
+ let s: use_viminfo = s: config .use_viminfo
212
215
let s: project_root = s: config .project_root
213
216
let s: project_base = s: RemoveListTrailingSlash (s: config .project_base)
214
217
let s: include = s: config .include
@@ -550,6 +553,7 @@ function! s:InitProjectConfig(project)
550
553
\' " \],',
551
554
\' " \''project_root'': ''./'',',
552
555
\' " \''use_session'': 0,',
556
+ \' " \''use_viminfo'': 0,',
553
557
\' " \''open_root_when_use_session'': 0,',
554
558
\' " \''check_branch_when_use_session'': 0,',
555
559
\' " \}',
@@ -1833,6 +1837,7 @@ function! s:LoadProject()
1833
1837
call s: SourceInitFile ()
1834
1838
call s: WatchOnInitFileChange ()
1835
1839
call s: FindBranch ()
1840
+ call s: LoadViminfo ()
1836
1841
call s: LoadSession ()
1837
1842
endfunction
1838
1843
@@ -1941,6 +1946,7 @@ endfunction
1941
1946
function ! s: QuitProject ()
1942
1947
if project#ProjectExist ()
1943
1948
call s: Info (' Quitted [' .s: project .name.' ]' )
1949
+ call s: SaveViminfo ()
1944
1950
call s: SaveSession ()
1945
1951
call s: SourceQuitFile ()
1946
1952
call s: UnwatchOnInitFileChange ()
@@ -2192,24 +2198,64 @@ function! s:FindBranch()
2192
2198
endfunction
2193
2199
2194
2200
function ! s: GetSessionFolder ()
2195
- if project#ProjectExist ()
2196
- let config = s: GetProjectConfigPath (s: config_home , s: project )
2197
- return config.' /sessions'
2198
- else
2199
- return ' '
2201
+ let config = s: GetProjectConfigPath (s: config_home , s: project )
2202
+ return config.' /sessions'
2203
+ endfunction
2204
+
2205
+ function ! s: GetSessionFile ()
2206
+ let config = s: GetProjectConfigPath (s: config_home , s: project )
2207
+ return config.' /sessions/' .s: branch .' .vim'
2208
+ endfunction
2209
+
2210
+ function ! s: LoadViminfo ()
2211
+ if ! s: use_viminfo
2212
+ return
2213
+ endif
2214
+
2215
+ let file = s: GetViminfoFile ()
2216
+ if filereadable (file )
2217
+ call s: Debug (' Load viminfo file: ' .file )
2218
+ if has (' nvim' )
2219
+ execute ' rshada! ' .file
2220
+ else
2221
+ execute ' rviminfo! ' .file
2222
+ endif
2200
2223
endif
2201
2224
endfunction
2202
2225
2226
+ function ! s: SaveViminfo ()
2227
+ if ! s: use_viminfo
2228
+ return
2229
+ endif
2203
2230
2204
- function ! s: GetSessionFile ()
2205
- if project#ProjectExist ()
2206
- let config = s: GetProjectConfigPath (s: config_home , s: project )
2207
- return config.' /sessions/' .s: branch .' .vim'
2231
+ let folder = s: GetViminfoFolder ()
2232
+ if ! isdirectory (folder) && exists (' *mkdir' )
2233
+ call mkdir (folder, ' p' )
2234
+ endif
2235
+
2236
+ let file = s: GetViminfoFile ()
2237
+ call s: Debug (' Save viminfo to: ' .file )
2238
+ if has (' nvim' )
2239
+ execute ' wshada! ' .file
2208
2240
else
2209
- return ' '
2241
+ execute ' wviminfo! ' . file
2210
2242
endif
2211
2243
endfunction
2212
2244
2245
+ function ! s: GetViminfoFile ()
2246
+ let config = s: GetProjectConfigPath (s: config_home , s: project )
2247
+ if has (' nvim' )
2248
+ return config.' /viminfo/main.shada'
2249
+ else
2250
+ return config.' /viminfo/.viminfo'
2251
+ endif
2252
+ endfunction
2253
+
2254
+ function ! s: GetViminfoFolder ()
2255
+ let config = s: GetProjectConfigPath (s: config_home , s: project )
2256
+ return config.' /viminfo'
2257
+ endfunction
2258
+
2213
2259
function ! s: LoadSession ()
2214
2260
if ! s: use_session
2215
2261
return
@@ -2220,7 +2266,7 @@ function! s:LoadSession()
2220
2266
call s: Debug (' Load session file: ' .file )
2221
2267
execute ' source ' .file
2222
2268
else
2223
- call s: Debug (' Not session file found: ' .file )
2269
+ call s: Debug (' No session file found: ' .file )
2224
2270
endif
2225
2271
endfunction
2226
2272
0 commit comments