Created
April 27, 2013 11:56
-
-
Save Osse/5472846 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From a7cf2ded07bc5651e707075a0ac454cbdf7e3f5c Mon Sep 17 00:00:00 2001 | |
From: =?UTF-8?q?=C3=98ystein=20Walle?= <[email protected]> | |
Date: Sat, 27 Apr 2013 13:53:13 +0200 | |
Subject: [PATCH] Add option to change working dir when opening a file | |
Introduce a new option startify_change_dir to make Startify change the | |
working directory to the directory of the file being opened. The default | |
is 0 so that default behaviour is unchanged. | |
--- | |
doc/startify.txt | 7 +++++++ | |
plugin/startify.vim | 7 ++++++- | |
2 files changed, 13 insertions(+), 1 deletion(-) | |
diff --git a/doc/startify.txt b/doc/startify.txt | |
index 0a63eb4..523955e 100644 | |
--- a/doc/startify.txt | |
+++ b/doc/startify.txt | |
@@ -109,6 +109,13 @@ The amount of files to list. | |
============- | |
+ let g:startify_change_dir = 0 | |
+ | |
+Change the working directory to the directory of the file being opened. | |
+ | |
+ | |
+============- | |
+ | |
let g:startify_bookmarks = [] | |
A list of files to bookmark. Those files will always be shown at the bottom of | |
diff --git a/plugin/startify.vim b/plugin/startify.vim | |
index 3f032fb..b92be0b 100644 | |
--- a/plugin/startify.vim | |
+++ b/plugin/startify.vim | |
@@ -45,6 +45,7 @@ function! s:insane_in_the_membrane() abort | |
if get(g:, 'startify_show_files', 1) && !empty(v:oldfiles) | |
let numfiles = get(g:, 'startify_show_files_number', 10) | |
+ let change_dir = get(g:, 'startify_change_dir', 0) | |
call append('$', '') | |
for fname in v:oldfiles | |
let expfname = expand(fname) | |
@@ -52,7 +53,11 @@ function! s:insane_in_the_membrane() abort | |
continue | |
endif | |
call append('$', ' ['. cnt .']'. repeat(' ', 3 - strlen(string(cnt))) . fname) | |
- execute 'nnoremap <buffer> '. cnt .' :edit '. startify#escape(fname) .'<cr>' | |
+ let mapping = 'nnoremap <silent> <buffer> '. cnt .' :edit '. startify#escape(fname) .'<cr>' | |
+ if change_dir == 1 | |
+ let mapping .= ':lcd %:h<cr>' | |
+ endif | |
+ execute mapping | |
let cnt += 1 | |
if cnt == numfiles | |
break | |
-- | |
1.7.9.5 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment