tumashu / company-posframe

121 stars 24 forks source link

Configure child frame position #62

Open gjm opened 1 year ago

gjm commented 1 year ago

I have set up a bigger line height because I like my code to breathe.

(setq-local default-text-properties '(line-spacing 0.50 line-height 1.50))

With this config the child frame overlaps the current line:

Screenshot from 2023-06-16 15-00-10

Is there a way to configure the child frame position?

tumashu commented 1 year ago

you can try to hack the below function

(defun company-posframe-show-at-prefix (info)
  "Poshandler showing `company-posframe' at `company-prefix'."
  (let* ((parent-window (plist-get info :parent-window))
         (point (with-current-buffer (window-buffer parent-window)
                  (- (plist-get info :position)
                     (plist-get info :company-prefix-length))))
         (posn (posn-at-point point parent-window))
         ;; TODO: Strictly speaking, if company-posframe-font is not nil, that
         ;; should be used to find the default width...
         (expected-margin-width (* (plist-get info :company-margin) (default-font-width)))
         (xy (posn-x-y posn)))
    (setcar xy (- (car xy) expected-margin-width))
    (posframe-poshandler-point-bottom-left-corner (plist-put info :position posn))))
gjm commented 1 year ago

My Emacs Lisp fu is awful! I wouldn't know where to begin...