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

add option to allow user to configure floating window #71

Merged
merged 6 commits into from
Mar 23, 2023
Merged
Show file tree
Hide file tree
Changes from 5 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
12 changes: 10 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,15 @@ require("jupynium").setup({
-- Dim all cells except the current one
-- Related command :JupyniumShortsightedToggle
shortsighted = false,

-- Configure floating window options
-- Related command :JupyniumKernelHover
kernel_hover = {
floating_win_opts = {
max_width = 84,
border = "none",
}
}
kiyoon marked this conversation as resolved.
Show resolved Hide resolved
})

-- You can link highlighting groups.
Expand Down Expand Up @@ -350,7 +359,7 @@ Any code below this line (and before the next separator) will be the content of
- `#%time`

**Markdown cell:**
Any code below this line will be markdown cell content.
Any code below this line will be markdown cell content.

- `# %% [md]`
- `# %% [markdown]`
Expand Down Expand Up @@ -380,7 +389,6 @@ In other languages like R, you'll need to comment every line.
- If there is no cell, it works as a markdown preview mode.
- It will still open ipynb file but will one have one markdown cell.


## ⌨️ Keybindings

- `<space>x`: Execute selected cells
Expand Down
9 changes: 9 additions & 0 deletions lua/jupynium/options.lua
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,15 @@ M.default_opts = {
-- Dim all cells except the current one
-- Related command :JupyniumShortsightedToggle
shortsighted = false,

-- Configure floating window options
-- Related command :JupyniumKernelHover
kernel_hover = {
floating_win_opts = {
max_width = 84,
border = "none",
},
},
}

return M
11 changes: 8 additions & 3 deletions src/jupynium/lua/helpers.lua
Original file line number Diff line number Diff line change
Expand Up @@ -646,9 +646,14 @@ function Jupynium_kernel_hover(bufnr)

local markdown_lines = vim.lsp.util.convert_input_to_markdown_lines(out)
markdown_lines = vim.lsp.util.trim_empty_lines(markdown_lines)
vim.lsp.util.open_floating_preview(markdown_lines, "markdown", {
max_width = 84,
})

local opts = { max_width = 84 }
local ok, options = pcall(require, "jupynium.options")
if ok then
opts = vim.tbl_extend("force", opts, options.opts.kernel_hover.floating_win_opts)
end

vim.lsp.util.open_floating_preview(markdown_lines, "markdown", opts)
end

local function get_memory_addr(t)
Expand Down