aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFelipe Morales <hel.sheep@gmail.com>2015-05-16 04:10:38 -0300
committerJustin M. Keyes <justinkz@gmail.com>2016-02-14 15:20:31 -0500
commit50e129f5a70bf291e6ec3afb7927e68e1f98e790 (patch)
treeb74f6484bf69932ceecb42cb8df1645e1c69ea1b /src
parent75f6817a5161949ca2ab08e36b8e0772b8d7da16 (diff)
downloadrneovim-50e129f5a70bf291e6ec3afb7927e68e1f98e790.tar.gz
rneovim-50e129f5a70bf291e6ec3afb7927e68e1f98e790.tar.bz2
rneovim-50e129f5a70bf291e6ec3afb7927e68e1f98e790.zip
defaults: Enable syntax and filetype plugins.
Diffstat (limited to 'src')
-rw-r--r--src/nvim/ex_docmd.c18
-rw-r--r--src/nvim/globals.h4
-rw-r--r--src/nvim/main.c8
3 files changed, 30 insertions, 0 deletions
diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c
index d6976bcb8f..0387bd1ad7 100644
--- a/src/nvim/ex_docmd.c
+++ b/src/nvim/ex_docmd.c
@@ -9299,6 +9299,24 @@ static void ex_filetype(exarg_T *eap)
EMSG2(_(e_invarg2), arg);
}
+/// Same as :filetype plugin indent enable
+/// Updates the state used for :filetype without args.
+void force_enable_filetype(void)
+{
+ if (!filetype_detect) {
+ source_runtime((char_u *)FILETYPE_FILE, true);
+ filetype_detect = true;
+ }
+ if (!filetype_plugin) {
+ source_runtime((char_u *)FTPLUGIN_FILE, true);
+ filetype_plugin = true;
+ }
+ if (!filetype_indent) {
+ source_runtime((char_u *)INDENT_FILE, true);
+ filetype_indent = true;
+ }
+}
+
/*
* ":setfiletype {name}"
*/
diff --git a/src/nvim/globals.h b/src/nvim/globals.h
index 697a4a765a..76ed09cc3a 100644
--- a/src/nvim/globals.h
+++ b/src/nvim/globals.h
@@ -92,6 +92,10 @@
# define SYNTAX_FNAME "$VIMRUNTIME" _PATHSEPSTR "syntax" _PATHSEPSTR "%s.vim"
#endif
+#ifndef SYNTAX_FILE
+# define SYNTAX_FILE "$VIMRUNTIME" _PATHSEPSTR "syntax" _PATHSEPSTR "syntax.vim"
+#endif
+
#ifndef EXRC_FILE
# define EXRC_FILE ".exrc"
#endif
diff --git a/src/nvim/main.c b/src/nvim/main.c
index a8c2cebbbd..97cccb2e25 100644
--- a/src/nvim/main.c
+++ b/src/nvim/main.c
@@ -332,6 +332,14 @@ int main(int argc, char **argv)
/* Source startup scripts. */
source_startup_scripts(&params);
+ // If using the runtime (-u is not NONE), enable syntax and filetype plugins
+ if (params.use_vimrc != NULL && strcmp(params.use_vimrc, "NONE") != 0) {
+ // Do this before syntax/syntax.vim (which calls `:filetype on`).
+ force_enable_filetype();
+ // Enable syntax highlighting.
+ do_source((char_u *)SYNTAX_FILE, false, DOSO_NONE);
+ }
+
/*
* Read all the plugin files.
* Only when compiled with +eval, since most plugins need it.