[gnome-builder] Revert "GVls: Implementing Ide.Identer"
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] Revert "GVls: Implementing Ide.Identer"
- Date: Sat, 14 Dec 2019 20:42:09 +0000 (UTC)
commit 0fd3acc59d9f9fd36aa1a3e5ca2447f0296d3372
Author: Christian Hergert <chergert redhat com>
Date: Sat Dec 14 12:41:39 2019 -0800
Revert "GVls: Implementing Ide.Identer"
This reverts commit 22c740e789b8b78b3aa469ca69abb50c6c15b442.
src/plugins/gvls/gvls.plugin | 1 -
src/plugins/gvls/gvls_plugin.py | 93 -----------------------------------------
2 files changed, 94 deletions(-)
---
diff --git a/src/plugins/gvls/gvls.plugin b/src/plugins/gvls/gvls.plugin
index a1d48c8a1..8695ed0da 100644
--- a/src/plugins/gvls/gvls.plugin
+++ b/src/plugins/gvls/gvls.plugin
@@ -13,4 +13,3 @@ X-Completion-Provider-Languages-Priority=0
X-Highlighter-Languages=vala
X-Symbol-Resolver-Languages=vala
X-Diagnostic-Provider-Languages=vala
-X-Indenter-Languages=vala
diff --git a/src/plugins/gvls/gvls_plugin.py b/src/plugins/gvls/gvls_plugin.py
index 416cd9b92..88d22d812 100644
--- a/src/plugins/gvls/gvls_plugin.py
+++ b/src/plugins/gvls/gvls_plugin.py
@@ -31,8 +31,6 @@ from gi.repository import GLib
from gi.repository import Gio
from gi.repository import GObject
from gi.repository import Ide
-from gi.repository import Gdk
-from gi.repository import Gtk
DEV_MODE = True
@@ -226,94 +224,3 @@ class GVlsSymbolResolver(Ide.LspSymbolResolver):
class GVlsDiagnosticProvider(Ide.LspDiagnosticProvider):
def do_load(self):
GVlsService.bind_client(self)
-
-#
-# Stolen from src/plugins/vala-pack/ide-vala-identer.vala
-# Copyright 2015 Christian Hergert <christian hergert me>
-#
-class GVlsIdenter (Ide.Identer):
- def is_trigger (self, evkey):
- val = evkey.get_keyval ()
- if val == Gdk.KEY_Return or val == Gdk.KEY_KP_Enter:
- return True
- if val == Gdk.KDEY_slash:
- return True
- return False
- def format (self, textView, begin, end, evkey):
- source_view = text_view
- was_newline = self.is_newline_keyval (evkey.keyval)
- copy = end
- cursor_offset = 0
- # Move us back to the just inserted character
- copy.backward_char ()
- # If we are in a comment, continue the indentation
- if (in_comment (text_view, copy)):
- # maybe close a multiline comment
- if (copy.get_char () == '/'):
- close = copy
- if (close.backward_char () and close.get_char () == ' ' and close.backward_char () and
close.get_char () == '*'):
- begin.backward_char ();
- begin.backward_char ();
- return ("/", cursor_offset);
- if (was_newline):
- return indent_comment (text_view, copy);
- if (is_newline_in_braces (copy)):
- prefix = copy_indent (text_view, copy);
- if (source_view.insert_spaces_instead_of_tabs):
- indent = " "
- else:
- indent = "\t"
- cursor_offset = -prefix.length - 1
- return (prefix + indent + "\n" + prefix, cursor_offset)
- if (was_newline):
- return (copy_indent (text_view, copy), cursor_offset)
- return null
- def copy_indent (self, text_view, iter):
- begin = iter
- begin.set_line_offset (0)
- end = begin
- while (not end.ends_line () and end.get_char ().isspace () and end.forward_char ()):
- # Do nothing
- pass
- return begin.get_slice (end)
- def get_line_text (self, iter):
- begin = iter
- end = iter
- begin.set_line_offset (0)
- if (not end.ends_line ()):
- end.forward_to_line_end ()
- return begin.get_slice (end)
- def indent_comment (self, text_view, iter):
- line = get_line_text (iter).strip ();
- # continue with another single line comment
- if line.has_prefix ("//"):
- return copy_indent (text_view, iter) + "// "
- # comment is closed, copy indent, possibly trimming extra space
- if (line.has_suffix ("*/")):
- if (line.has_prefix ("*")):
- s = GLib.String.new (copy_indent (text_view, iter))
- if (str(s).endswith (" ")):
- s.truncate (len (s) - 1)
- return str(s);
- if (line.endswith ("/*") and not line.endswith ("*/")):
- return copy_indent (text_view, iter) + " * "
- elif (line.has_prefix ("*")):
- return copy_indent (text_view, iter) + "* "
- return copy_indent (text_view, iter)
- def in_comment (self, text_view, iter):
- buffer = text_view.buffer
- copy = iter
- copy.backward_char ()
- return buffer.iter_has_context_class (copy, "comment")
- def is_newline_keyval (self, keyval):
- if keyval == Gdk.KEY_Return or keyval == Gdk.KEY_KP_Enter:
- return true
- return false
- def is_newline_in_braces (self, iter):
- prev = iter
- next = iter
- prev.backward_char ()
- next.forward_char ()
- ret = (prev.get_char () == '{') and (iter.get_char () == '\n')
- return ret and (next.get_char () == '}')
-
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]