From ba3254bd6514737024532dc8fae66cb509a4af9c Mon Sep 17 00:00:00 2001 From: jdhao Date: Sun, 8 Nov 2020 22:20:40 +0800 Subject: [PATCH] refactor: move titlestring method to autoload dir --- autoload/utils.vim | 14 ++++++++++++++ core/options.vim | 15 +-------------- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/autoload/utils.vim b/autoload/utils.vim index 34ba3fc..c0eab5f 100644 --- a/autoload/utils.vim +++ b/autoload/utils.vim @@ -131,3 +131,17 @@ function! utils#MoveSelection(direction) abort normal gv endif endfunction + + +function! utils#Get_titlestr() abort + let l:title_str = '' + if g:is_linux + let l:title_str = hostname() . ' ' + endif + let l:title_str = l:title_str . expand('%:p:~') . ' ' + if &buflisted + let l:title_str = l:title_str . strftime('%Y-%m-%d %H:%M',getftime(expand('%'))) + endif + + return l:title_str +endfunction diff --git a/core/options.vim b/core/options.vim index 1e918d6..88fb2dd 100644 --- a/core/options.vim +++ b/core/options.vim @@ -104,20 +104,7 @@ set autowrite " lastmod time is drawn from https://stackoverflow.com/q/8426736/6064933 set title set titlestring= -set titlestring=%{Get_titlestr()} - -function! Get_titlestr() abort - let l:title_str = '' - if g:is_linux - let l:title_str = hostname() . ' ' - endif - let l:title_str = l:title_str . expand('%:p:~') . ' ' - if &buflisted - let l:title_str = l:title_str . strftime('%Y-%m-%d %H:%M',getftime(expand('%'))) - endif - - return l:title_str -endfunction +set titlestring=%{utils#Get_titlestr()} " Persistent undo even after you close a file and re-open it set undofile