summaryrefslogtreecommitdiffstats
path: root/debian/patches/debian/Support-sourcing-a-vimrc.tiny-when-Vim-is-invoked-as-vi.patch
blob: b970501bd6783da9fd7e66c23ae8a86a58a65558 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
From: James McCoy <jamessan@debian.org>
Date: Tue, 6 Oct 2015 23:46:30 -0400
Subject: Support sourcing a vimrc.tiny when Vim is invoked as vi

This is used only in the vim-tiny package to allow a specific
configuration for vim-tiny's vi.  The vim-tiny package is substantially
different from other Vim packages, so it does not make sense to
share the same config.

Closes: #222138
Signed-off-by: Stefano Zacchiroli <zack@debian.org>
Signed-off-by: James Vega <jamessan@debian.org>
---
 src/main.c    | 14 +++++++++++++-
 src/os_unix.h |  3 +++
 src/structs.h |  3 +++
 3 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/src/main.c b/src/main.c
index f677066..69b343b 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1775,6 +1775,10 @@ parse_command_name(mparm_T *parmp)
     }
     else if (STRNICMP(initstr, "vim", 3) == 0)
 	initstr += 3;
+#ifdef SYS_TINYRC_FILE
+    else if (STRNICMP(initstr, "vi", 2) == 0)
+	parmp->vi_mode = TRUE;
+#endif
 
     /* Catch "[r][g]vimdiff" and "[r][g]viewdiff". */
     if (STRICMP(initstr, "diff") == 0)
@@ -3018,7 +3022,12 @@ source_startup_scripts(mparm_T *parmp)
 	 * Get system wide defaults, if the file name is defined.
 	 */
 #ifdef SYS_VIMRC_FILE
-	(void)do_source((char_u *)SYS_VIMRC_FILE, FALSE, DOSO_NONE);
+# if defined(SYS_TINYRC_FILE) && defined(TINY_VIMRC)
+	if (parmp->vi_mode)
+	    (void)do_source((char_u *)SYS_TINYRC_FILE, FALSE, DOSO_NONE);
+	else
+# endif
+	    (void)do_source((char_u *)SYS_VIMRC_FILE, FALSE, DOSO_NONE);
 #endif
 #ifdef MACOS_X
 	(void)do_source((char_u *)"$VIMRUNTIME/macmap.vim", FALSE, DOSO_NONE);
@@ -3053,6 +3062,9 @@ source_startup_scripts(mparm_T *parmp)
 		&& do_source((char_u *)USR_EXRC_FILE, FALSE, DOSO_NONE) == FAIL
 #ifdef USR_EXRC_FILE2
 		&& do_source((char_u *)USR_EXRC_FILE2, FALSE, DOSO_NONE) == FAIL
+#endif
+#if defined(SYS_TINYRC_FILE) && defined(TINY_VIMRC)
+		&& !parmp->vi_mode
 #endif
 		&& !has_dash_c_arg)
 	    {
diff --git a/src/os_unix.h b/src/os_unix.h
index 4146529..465153a 100644
--- a/src/os_unix.h
+++ b/src/os_unix.h
@@ -213,6 +213,9 @@ typedef struct dsc$descriptor   DESC;
 /*
  * Unix system-dependent file names
  */
+#ifndef SYS_TINYRC_FILE
+# define SYS_TINYRC_FILE "$VIM/vimrc.tiny"
+#endif
 #ifndef SYS_VIMRC_FILE
 # define SYS_VIMRC_FILE "$VIM/vimrc"
 #endif
diff --git a/src/structs.h b/src/structs.h
index ec109eb..23832ab 100644
--- a/src/structs.h
+++ b/src/structs.h
@@ -3381,6 +3381,9 @@ typedef struct
 #ifdef FEAT_DIFF
     int		diff_mode;		/* start with 'diff' set */
 #endif
+#ifdef SYS_TINYRC_FILE
+    int		vi_mode;		/* started as "vi" */
+#endif
 } mparm_T;
 
 /*