Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
14 changes: 14 additions & 0 deletions marimo/_config/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,18 @@ class DisplayConfig(TypedDict, total=False):
theme: Literal["light", "dark"]


class BrowserConfig(TypedDict, total=False):
"""Settings related to web browsers.

**Keys.**

- `browser`: `"default"` or a browser registered with Python's
webbrowser module (e.g., `"firefox"` or `"google-chrome"`)
"""

browser: Literal["default"] | str


@mddoc
class MarimoConfig(TypedDict, total=False):
"""Configuration for the marimo editor.
Expand Down Expand Up @@ -116,6 +128,7 @@ class MarimoConfig(TypedDict, total=False):
- `experimental`: a `dict` of experimental features
"""

browser: BrowserConfig
completion: CompletionConfig
save: SaveConfig
keymap: KeymapConfig
Expand All @@ -125,6 +138,7 @@ class MarimoConfig(TypedDict, total=False):


DEFAULT_CONFIG: MarimoConfig = {
"browser": {"browser": "default"},
"completion": {"activate_on_typing": True, "copilot": False},
"save": {
"autosave": "after_delay",
Expand Down
12 changes: 9 additions & 3 deletions marimo/_server/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,13 +318,15 @@ async def start_server(
logger.fatal(type(e).__name__ + ": " + str(e))
shutdown(with_error=True)

if not run and get_configuration()["completion"]["copilot"]:
user_config = get_configuration()
if not run and user_config["completion"]["copilot"]:
logger.debug("GitHub Copilot is enabled")
session_mgr.start_lsp_server()

url = f"http://localhost:{port}"
if not headless:
if which("xdg-open") is not None:
browser = user_config["browser"]["browser"]
if which("xdg-open") is not None and browser == "default":
with open(os.devnull, "w") as devnull:
if sys.platform == "win32" or sys.platform == "cygwin":
preexec_fn = None
Expand All @@ -339,7 +341,11 @@ async def start_server(
stderr=subprocess.STDOUT,
)
else:
webbrowser.open(url)
controller = (
webbrowser if browser == "default" else webbrowser.get(browser)
)
# type ignore: getting an invalid type error
controller.open(url) # type:ignore[attr-defined]

if not session_mgr.quiet:
print()
Expand Down