     (setMarginLinePosition [size]
       (proxy-super setMarginLinePosition size))))
 
+(defn get-context
+  [prefix]
+  (when-let [editor (get-selected-editor)]
+    (let [caretpos (.getCaretPosition editor)
+          all-text (.getText editor)
+          first-str (subs all-text 0 (- caretpos (count prefix)))
+          second-str (subs all-text caretpos)]
+      (-> (str first-str "__prefix__" second-str)
+          parser/parse
+          loc-utils/parsed-root-loc
+          (loc-utils/loc-for-offset caretpos)
+          zip/up
+          first
+          loc-utils/node-text
+          read-string))))
+
 (defn get-completion-provider
   [extension]
   (cond

(ns nightcode.editors
  (:require [clojure.java.io :as io]
            [compliment.core :as compliment]
            [flatland.ordered.map :as flatland]
            [nightcode.lein :as lein]
            [nightcode.shortcuts :as shortcuts]
            [nightcode.ui :as ui]
            [nightcode.utils :as utils]
            [paredit-widget.core :as paredit]
            [seesaw.color :as color]
            [seesaw.core :as s])
  (:import [com.camick TextPrompt]

    (proxy [DefaultCompletionProvider] []
      (getCompletions [comp]
        (if-let [prefix (.getAlreadyEnteredText this comp)]
          (for [symbol-str (compliment/completions prefix (get-context prefix))]
            (->> (compliment/documentation symbol-str)
                 (BasicCompletion. this symbol-str nil)))
          '()))
