-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Separate Pyright language server as one micro service (#3150)
This PR separates the Pyright language server as an independent microservice. To provide support for both Pyright and PyLSP, we have created a python-language-server.sh script to run the Python language server. To run the script: `./python-language-server.sh` By default, it will use PyLSP and run on port 3000. To run Pyright, use the following command: `./python-language-server.sh --server=pyright` For example, to run PyLSP on a different port (e.g., 4000): `./python-language-server.sh --server=pylsp --port=4000`
- Loading branch information
Showing
6 changed files
with
97 additions
and
113 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
92 changes: 0 additions & 92 deletions
92
...la/edu/uci/ics/texera/web/resource/pythonlanguageserver/PythonLanguageServerManager.scala
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 0 additions & 1 deletion
1
...erver/src/pythonLanguageServerConfig.json → core/pyright-language-server/src/config.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
{ | ||
"languageServerDir": "../node_modules/pyright/dist", | ||
"amberConfigFilePath": "../../amber/src/main/resources/application.conf", | ||
"clientPathName": "/python-language-server" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
DEFAULT_PROVIDER="pylsp" | ||
DEFAULT_PORT=3000 | ||
|
||
PROVIDER="" | ||
PORT="" | ||
|
||
BASE_DIR=$(dirname "$0") | ||
PYRIGHT_DIR="$BASE_DIR/../pyright-language-server" | ||
|
||
while [ $# -gt 0 ]; do | ||
case "$1" in | ||
--server=*|--provider=*) | ||
PROVIDER="${1#*=}" | ||
;; | ||
--port=*) | ||
PORT="${1#*=}" | ||
;; | ||
*) | ||
echo "Unknown argument: $1" | ||
echo "Usage: $0 [--server=<pyright|pylsp>] [--port=<port_number>]" | ||
exit 1 | ||
;; | ||
esac | ||
shift | ||
done | ||
|
||
PROVIDER="${PROVIDER:-$DEFAULT_PROVIDER}" | ||
PORT="${PORT:-$DEFAULT_PORT}" | ||
|
||
# Validate port value | ||
if ! [[ "$PORT" =~ ^[0-9]+$ ]]; then | ||
echo "Invalid port: $PORT. Must be a number." | ||
exit 1 | ||
fi | ||
|
||
start_pyright() { | ||
echo "Starting Pyright Language Server on port $PORT..." | ||
cd "$PYRIGHT_DIR" | ||
yarn install --silent | ||
yarn start --port="$PORT" | ||
} | ||
|
||
start_pylsp() { | ||
echo "Starting Pylsp Language Server on port $PORT..." | ||
if ! command -v pylsp &>/dev/null; then | ||
echo "Error: pylsp is not installed. Install it with 'pip install python-lsp-server'." | ||
exit 1 | ||
fi | ||
pylsp --port "$PORT" --ws | ||
} | ||
|
||
case $PROVIDER in | ||
pyright) | ||
start_pyright | ||
;; | ||
pylsp) | ||
start_pylsp | ||
;; | ||
*) | ||
echo "Invalid provider: $PROVIDER. Valid options are: pyright, pylsp." | ||
exit 1 | ||
;; | ||
esac |