hook global WinSetOption filetype=python %{
    set-option buffer lsp_servers %{
        [basedpyright] # pretty much a strict upgrade over vanilla pyright
        root_globs = ["requirements.txt", "setup.py", "pyrightconfig.json", ".git", ".hg"]
        command = "basedpyright-langserver"
        args = ["--stdio"]
        [ruff]
        root_globs = ["requirements.txt", "setup.py", "pyrightconfig.json", ".git", ".hg"]
        command = "ruff"
        args = ["server"]
    }
    lsp-enable-buffer
    lsp-semantic-tokens-enable
    softtab-enable
}

hook global ModuleLoaded python %{
    # By default, Kakoune highlights the "import" and "from" keywords in the "meta" face.
    # This is incorrect - they should be highlighted as keywords.
    # So, we override the builtin highlighter with our own.
    add-highlighter shared/python/code/ regex '\b(import|from)\b' 0:keyword
}
