 
 (defun get-json-from-file (filePath)
   "Return json object from filePath's content"
-  (let* ((json-key-type 'string)
-	 (str (get-string-from-file filePath)))
-    (json-read-from-string str)))
-
-;; Global variable holding the annotations
-(defvar liquid-annot-table)
-
-;; -----------------------------------------------------------------------------------------------
-;; API for getting annots -- alist
-;; -----------------------------------------------------------------------------------------------
-;; (setq liquid-annot-table (get-json-from-file "/Users/rjhala/tmp/.liquid/flycheck_Foo.hs.json"))
-;; 
-;; (defun liquid-annot (table row col)
-;;   "Get annotation from table from identifier at row, col"
-;;   (let* ((r    (format "%d" row))
-;; 	 (c    (format "%d" col))
-;; 	 (tys  (assoc "types" table))
-;; 	 (ro   (assoc r tys)))
-;;     (cdr (assoc "ann" (assoc c ro)))))
-;; -----------------------------------------------------------------------------------------------
-
-;; -----------------------------------------------------------------------------------------------
-;; API for getting annots -- hash-table 
-;; -----------------------------------------------------------------------------------------------
-
-(setq liquid-annot-table 
-      (let ((json-object-type 'hash-table))
-	(get-json-from-file "/Users/rjhala/tmp/.liquid/flycheck_Foo.hs.json")))
+  (if (file-exists-p filePath)
+      (let* ((json-key-type 'string)
+	     (str (get-string-from-file filePath)))
+	(json-read-from-string str))
+      nil))
+
+;; ------------------------------------------------------------------------
+;; get/set annot information 
+;; ------------------------------------------------------------------------
 
 (defun gethash-nil (key table) 
   (if table 
       (gethash key table nil)
       nil))
 
+(defun liquid-annot-filepath-prefix (mode)
+  "Return prefix of annotation file using mode"
+  (if (equal mode 'flycheck)
+      "flycheck_"
+      nil))
+
+;; (liquid-annot 'flycheck "/path/to/file.hs") 
+;;    ==> "/path/to/.liquid/flycheck_file.hs.json"
+;;
+;; (liquid-annot nil       "/path/to/file.hs") 
+;;    ==> "/path/to/.liquid/file.hs.json"
+
+(defun liquid-annot-filepath (mode file)
+  "Return name of annotation file"
+  (let* ((dir    (file-name-directory file))
+	 (name   (file-name-nondirectory file))
+	 (prefix (liquid-annot-filepath-prefix mode)))
+    (concat dir ".liquid/" prefix name ".json")))
+
+(defvar liquid-annot-table (make-hash-table :test 'equal))
+
+;; API
+(defun liquid-annot-set (file mode)
+  "Load information for file into liquid-annot-table"
+  (let* ((file-path        (liquid-annot-filepath mode file))
+	 (json-object-type 'hash-table)
+	 (file-info        (get-json-from-file file-path)))
+    (if file-info (puthash file file-info liquid-annot-table))))
+
+;; API
 (defun liquid-annot-get (file row col)
   "Get annotation for identifier at row, col in file"
   (let* ((table (gethash-nil file liquid-annot-table))

;;; Code:
(eval-when-compile (require 'cl))
(require 'auto-complete)
(require 'json-mode)
(require 'json)
(require 'ring)
(require 'etags)
;; (require 'flymake)
;; (require 'eldoc)
(require 'pos-tip nil t)
;; (require 'log4e)
;; (require 'yaxception)
(require 'thingatpt)
(require 'button-lock)



(cl-defstruct position file row col)

(defun get-string-from-file (filePath)
  "Return filePath's file content."

	 (ro    (gethash-nil r tys)))
    (gethash-nil "ann" (gethash-nil c ro))))

;; ------------------------------------------------------------------------
;; Display Annot in Tooltip 
;; ------------------------------------------------------------------------

;; For simple, ascii popups, use:
;;    (setq liquid-tip-mode 'ascii) 
;;
;; For emacs', balloon based popups, use:
;;    (setq liquid-tip-mode 'balloon)

(defvar liquid-tip-mode 'balloon)

(defun pad-line (str)
  (concat " " str " "))

(defun popup-tip-pad (text)
  (let* ((lines     (split-string text "\n"))
         (pad-lines (mapcar 'pad-line lines))
	 (pad-text  (concat "\n" (mapconcat 'identity pad-lines "\n") "\n")))
    (popup-tip pad-text)))

(defun liquid-tip-popup-balloon (text)
  "Display text in a balloon popup"
  (if (and (functionp 'ac-quick-help-use-pos-tip-p)
           (ac-quick-help-use-pos-tip-p))
      (pos-tip-show text 'popup-tip-face nil nil 300 popup-tip-max-width)
    (popup-tip-pad text)))

(defun liquid-tip-popup-ascii (text)
 "Display text in ascii popup"
  (popup-tip-pad text))

(defun liquid-tip-popup (text)
  (if (equal liquid-tip-mode 'ascii)
      (liquid-tip-popup-ascii   text)
      (liquid-tip-popup-balloon text)))

;; -- Compute range ---------------------------------------------------------

