Skip to content

Commit

Permalink
feat: configurable tick_rate (#123)
Browse files Browse the repository at this point in the history
  • Loading branch information
benlubas authored Jan 6, 2024
1 parent bee4bb5 commit d79f48c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ variable, their values, and a brief description.
| `g:molten_output_win_max_width` | (`999999`) \| int | Max width of the output window |
| `g:molten_output_win_style` | (`false`) \| `"minimal"` | Value passed to the `style` option in `:h nvim_open_win()` |
| `g:molten_save_path` | (`stdpath("data").."/molten"`) \| any path to a folder | Where to save/load data with `:MoltenSave` and `:MoltenLoad` |
| `g:molten_tick_rate` | (`500`) \| `int` | How often (in ms) we poll the kernel for updates. Determines how quickly the ui will update, if you want a snappier experience, you can set this to 150 or 200 |
| `g:molten_use_border_highlights` | `true` \| (`false`) | When true, uses different highlights for output border depending on the state of the cell (running, done, error). see [highlights](#highlights) |
| `g:molten_limit_output_chars` | (`1000000`) \| int | Limit on the number of chars in an output. If you're lagging your editor with too much output text, decrease it |
| `g:molten_virt_lines_off_by_1` | `true` \| (`false`) | Allows the output window to cover exactly one line of the regular buffer when `output_virt_lines` is true, also effects where `virt_text_output` is displayed. (useful for running code in a markdown file where that covered line will just be \`\`\`) |
Expand Down
6 changes: 4 additions & 2 deletions rplugin/python3/molten/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ def _initialize(self) -> None:
self.highlight_namespace = self.nvim.funcs.nvim_create_namespace("molten-highlights")
self.extmark_namespace = self.nvim.funcs.nvim_create_namespace("molten-extmarks")

self.timer = self.nvim.eval("timer_start(500, 'MoltenTick', {'repeat': -1})") # type: ignore
self.timer = self.nvim.eval(
f"timer_start({self.options.tick_rate}, 'MoltenTick', {{'repeat': -1}})"
) # type: ignore

self._setup_highlights()
self._set_autocommands()
Expand Down Expand Up @@ -552,7 +554,7 @@ def kernel_check(self, command: str, buffer: Buffer) -> None:
shared_kernels = [(x, True) for x in self.molten_kernels.keys()]
PROMPT = "You Need to Initialize a Kernel First:"
self.nvim.lua._prompt_init_and_run(available_kernels + shared_kernels, PROMPT, command)
elif not kernels: # and auto_init_behavior == "raise"
elif not kernels: # and auto_init_behavior == "raise"
raise MoltenException(
"Molten is not initialized in this buffer; run `:MoltenInit` to initialize."
)
Expand Down
2 changes: 2 additions & 0 deletions rplugin/python3/molten/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ class MoltenOptions:
output_win_style: Optional[str]
save_path: str
show_mimetype_debug: bool
tick_rate: int
use_border_highlights: bool
virt_lines_off_by_1: bool
virt_text_max_lines: int
Expand Down Expand Up @@ -82,6 +83,7 @@ def __init__(self, nvim: Nvim):
("molten_output_win_style", False),
("molten_save_path", os.path.join(nvim.funcs.stdpath("data"), "molten")),
("molten_show_mimetype_debug", False),
("molten_tick_rate", 500),
("molten_use_border_highlights", False),
("molten_virt_lines_off_by_1", False),
("molten_virt_text_max_lines", 12),
Expand Down

0 comments on commit d79f48c

Please sign in to comment.