ydjia / vim

Automatically exported from code.google.com/p/vim
0 stars 0 forks source link

Completion for "set ft=" and "set syntax=" #285

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
There is currently no completion for "set filetype=" and "set syntax=".

I've looked a bit into the source and came up with the following patch, which
works basically, but probably needs improvements.

It sets the context to `EXPAND_FILETYPE` in both cases, because there appears
to be no completion/expansion for available syntax definitions yet - or I
have not found it.

For syntax completion, it might be probably better to expand on the `%s` part
of the matching file names 'syntax/%s.vim' and 'syntax/%s/*.vim' in the runtime
path.

This patch also fixes the invalid completion after "set noinv", which currently
completes all boolean settings.

diff --git i/src/option.c w/src/option.c
index 6841d42..9dd7b1c 100644
--- i/src/option.c
+++ w/src/option.c
@@ -10773,12 +10773,31 @@ set_context_in_set_cmd(xp, arg, opt_flags)
        }
        --p;
     }
-    if (STRNCMP(p, "no", 2) == 0 && STRNCMP(p, "novice", 6) != 0)
+    if (STRNCMP(p, "filetype=", 9) == 0)
+    {
+        xp->xp_context = EXPAND_FILETYPE;
+        p += 9;
+    }
+    else if (STRNCMP(p, "ft=", 3) == 0)
+    {
+        xp->xp_context = EXPAND_FILETYPE;
+        p += 3;
+    }
+    else if (STRNCMP(p, "syntax=", 7) == 0)
+    {
+        xp->xp_context = EXPAND_FILETYPE;
+        p += 7;
+    }
+    else if (STRNCMP(p, "syn=", 4) == 0)
+    {
+        xp->xp_context = EXPAND_FILETYPE;
+        p += 4;
+    }
+    else if (STRNCMP(p, "no", 2) == 0 && STRNCMP(p, "novice", 6) != 0)
     {
        xp->xp_context = EXPAND_BOOL_SETTINGS;
        p += 2;
-    }
-    if (STRNCMP(p, "inv", 3) == 0)
+    } else if (STRNCMP(p, "inv", 3) == 0)
     {
        xp->xp_context = EXPAND_BOOL_SETTINGS;
        p += 3;

Original issue reported on code.google.com by dhahler@gmail.com on 15 Nov 2014 at 9:14