Skip to content

feat: implement nvimpager = "float"#608

Open
kkanden wants to merge 3 commits into
R-nvim:mainfrom
kkanden:nvimpager_float
Open

feat: implement nvimpager = "float"#608
kkanden wants to merge 3 commits into
R-nvim:mainfrom
kkanden:nvimpager_float

Conversation

@kkanden

@kkanden kkanden commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

this implements the "float" option for nvimpager for both R help and example. i have added a utils function for creating floating.

in the future, a user config option could be added to customize the location and size of the floating window. by default it just centers the window.

@jalvesaq

jalvesaq commented Jul 7, 2026

Copy link
Copy Markdown
Member

Thank you! It works!

Some ideas (waiting for comments):

  • Limit the maximum width to a not too high value, such as 120?

  • Prefer 80 columns as the width of the float window?

  • Between 60 and 120 columns, choose a value corresponding to the largest line in the document +1?

  • Position of the float window centered on the editor window, not on the full Neovim display?

@kkanden

kkanden commented Jul 7, 2026

Copy link
Copy Markdown
Contributor Author

good ideas, i'll try to implement these changes later today and see what looks good

@kkanden
kkanden force-pushed the nvimpager_float branch from c16708d to 34982e0 Compare July 7, 2026 19:48
@kkanden
kkanden force-pushed the nvimpager_float branch from 34982e0 to cfae62c Compare July 7, 2026 19:49
@kkanden

kkanden commented Jul 7, 2026

Copy link
Copy Markdown
Contributor Author

i have implemented the changes:

  • floating window is centered relative to the code editor
  • if 60 <= cols <= 120 then the width is longest line length + 1, 80 otherwise

one shortcoming (or feature?) compared to the last version is that the example/help window does not get directly overlaid on top of the preview help/example window, but is relative to it. subsequent help->help/example->example windows are overlaid as before.

@jalvesaq

jalvesaq commented Jul 9, 2026

Copy link
Copy Markdown
Member

Thank you, @kkanden!

Some observations:

  • Some variables in utils.open_float_win() are always overridden (width, height, col, and row), and the same code to calculate them is repeated in edit.lua and doc.lua. Hence, you can:
    • Pass lines to utils.open_float_win() and let the values of width, height, col, and row be calculated there.
    • Delete the code that calculates the variables from edit.lua and doc.lua.
  • If the Object Browser is open, the float window will not be centralized in the editor window.

@kkanden

kkanden commented Jul 9, 2026

Copy link
Copy Markdown
Contributor Author
* Some variables in `utils.open_float_win()` are always overridden (`width`, `height`, `col`, and `row`), and the same code to calculate them is repeated in `edit.lua` and `doc.lua`. Hence, you can:
  
  * Pass `lines` to `utils.open_float_win()` and let the values of `width`, `height`, `col`, and `row` be calculated there.
  * Delete the code that calculates the variables from `edit.lua` and `doc.lua`.

so in the open_float_win function we want the window to always be calculated from the line lengths of the text to be displayed (given the previous conditions)? i thought of the function to be a generic utils function.

* If the Object Browser is open, the float window will not be centralized in the editor window.

that happens if the editor window is less than 60 and the width of the floating window defaults to 80 columns. this also makes the window look like it's stuck to the side of the editor instead of centered. i thought this looked better than a centered but small and squished window.

@jalvesaq

Copy link
Copy Markdown
Member

I'm sorry, but I'm on a trip now and will need some time to properly review the code again...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants