Skip to content

Commit

Permalink
feat(hover): option to configure floating window (#71)
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewsia98 authored Mar 23, 2023
1 parent b19ba6c commit 01162b0
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 5 deletions.
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",
},
},
})

-- 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

0 comments on commit 01162b0

Please sign in to comment.