[gnome-builder] vim: add support for `:set filetype=` command.
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] vim: add support for `:set filetype=` command.
- Date: Sun, 5 Oct 2014 23:41:55 +0000 (UTC)
commit 192387e075b465c6ae5981f138bd4fff1f7792b9
Author: Christian Hergert <christian hergert me>
Date: Sun Oct 5 16:41:50 2014 -0700
vim: add support for `:set filetype=` command.
src/editor/gb-editor-vim.c | 23 +++++++++++++++++++++++
1 files changed, 23 insertions(+), 0 deletions(-)
---
diff --git a/src/editor/gb-editor-vim.c b/src/editor/gb-editor-vim.c
index 905f751..150038f 100644
--- a/src/editor/gb-editor-vim.c
+++ b/src/editor/gb-editor-vim.c
@@ -2620,6 +2620,27 @@ gb_editor_vim_set_text_view (GbEditorVim *vim,
g_object_notify_by_pspec (G_OBJECT (vim), gParamSpecs [PROP_TEXT_VIEW]);
}
+static void
+gb_editor_vim_set_filetype (GbEditorVim *vim,
+ const gchar *name)
+{
+ GtkSourceLanguageManager *manager;
+ GtkSourceLanguage *language;
+ GtkTextBuffer *buffer;
+
+ g_assert (GB_IS_EDITOR_VIM (vim));
+ g_assert (name);
+
+ buffer = gtk_text_view_get_buffer (vim->priv->text_view);
+
+ if (!GTK_SOURCE_IS_BUFFER (buffer))
+ return;
+
+ manager = gtk_source_language_manager_get_default ();
+ language = gtk_source_language_manager_get_language (manager, name);
+ gtk_source_buffer_set_language (GTK_SOURCE_BUFFER (buffer), language);
+}
+
void
gb_editor_vim_execute_command (GbEditorVim *vim,
const gchar *command)
@@ -2641,6 +2662,8 @@ gb_editor_vim_execute_command (GbEditorVim *vim,
if (vim->priv->search_context)
gtk_source_search_context_set_highlight (priv->search_context, FALSE);
}
+ else if (g_str_has_prefix (copy, "set filetype="))
+ gb_editor_vim_set_filetype (vim, copy + strlen ("set filetype="));
else
g_debug (" TODO: Command Execution Support: %s", command);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]