Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds experimental Go spec #904

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 2 additions & 0 deletions python_packages/jupyter_lsp/jupyter_lsp/specs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from .pyright import PyrightLanguageServer
from .python_lsp_server import PythonLSPServer
from .r_languageserver import RLanguageServer
from .gopls import GoLanguageServer
from .sql_language_server import SQLLanguageServer
from .texlab import Texlab
from .typescript_language_server import TypescriptLanguageServer
Expand All @@ -32,6 +33,7 @@
py_lsp_server = PythonLSPServer()
pyright = PyrightLanguageServer()
r = RLanguageServer()
go = GoLanguageServer()
tex = Texlab()
ts_old = JavascriptTypescriptLanguageServer()
ts = TypescriptLanguageServer()
Expand Down
38 changes: 38 additions & 0 deletions python_packages/jupyter_lsp/jupyter_lsp/specs/gopls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
from .utils import ShellSpec
from typing import Union

TROUBLESHOOT = """\
You probably just need to install either *gopls* or the *jupyter-gopls*
just use the commands below.
"""


class GoLanguageServer(ShellSpec):
key = cmd = "gopls"
package = "jupyter_gopls" # Package with parser for golang
args = ["serve"]
is_installed_args = ["version"]
languages = ["go"]

spec = dict(
display_name=key,
mime_types=["text/x-go", "text/go"],
urls=dict(
home="https://pkg.go.dev/golang.org/x/tools/gopls",
),
# config_schema=load_config_schema(key), # TODO Find this options for this server
troubleshoot=TROUBLESHOOT,
shadow_file_ext=".go", # Not implemented yet, may be removed in future. See issue #872
install=dict(
go="go get golang.org/x/tools/gopls@latest", # This may never change
pip="pip install {}".format(package), # This package is not published yet
)
)

def solve(self) -> Union[str, None]:
# Check if python package is installed
pkg = __import__(self.package)
if not pkg:
return
return super().solve()

1 change: 1 addition & 0 deletions python_packages/jupyter_lsp/setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ jupyter_lsp_spec_v1 =
python-lsp-server = jupyter_lsp.specs:py_lsp_server
pyright = jupyter_lsp.specs:pyright
r-languageserver = jupyter_lsp.specs:r
go-language-server = jupyter_lsp.specs:go
texlab = jupyter_lsp.specs:tex
typescript-language-server = jupyter_lsp.specs:ts
sql-language-server = jupyter_lsp.specs:sql
Expand Down