Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make the frame's top position user configurable. #205

Merged
merged 2 commits into from
Mar 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,20 @@ Notes:
By default, images are used to display icons.
You can also use [font icons](https://github.com/sebastiencs/company-box/wiki/icons)
With images, you can't change icons colors

### Top margin

You can position the frame downwards by setting the variable `company-box-frame-top-margin` to a positive number. This is useful if your base code/text has an enlarged line height, and company box is intruding into the line above. It's also useful, if you're using copilot and want to see a few lines of suggested code unobscured by the company box. See [PR #205](https://github.com/sebastiencs/company-box/pull/205) for details.

You can set the top margin mode-dependent via mode hooks, if you want. E.g. in Doom Emacs:

``` el
(use-package! company-box
:defer t
:config
(setq-hook! 'prog-mode-hook
company-box-frame-top-margin 20)
(setq-hook! 'text-mode-hook
company-box-frame-top-margin 75)
)
```
10 changes: 9 additions & 1 deletion company-box.el
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,14 @@ character (see `frame-char-width'), set `0.5' to get half width of a character."
:type 'number
:group 'company-box)

(defcustom company-box-frame-top-margin 0
"Set extra space above the top of the frame, in pixels.
This is useful if the company box intrudes on the code/text above it.
For example, set '70' if you're using copilot, to make sure
the frame doesn't overlap with the first lines of copilot suggestions."
:type 'number
:group 'company-box)

(make-obsolete-variable 'company-box-highlight-prefix nil nil)

(defcustom company-box-highlight-prefix nil
Expand Down Expand Up @@ -582,7 +590,7 @@ It doesn't nothing if a font icon is used."
(window-tab-line-height (if (fboundp 'window-tab-line-height)
(window-tab-line-height)
0))
(top (+ top window-tab-line-height))
(top (+ top window-tab-line-height company-box-frame-top-margin))
(char-height (frame-char-height frame))
(char-width (frame-char-width frame))
(height (* (min company-candidates-length company-tooltip-limit) char-height))
Expand Down