Skip to content

Commit

Permalink
Hover uses Script.help, not Script.infer
Browse files Browse the repository at this point in the history
  • Loading branch information
pappasam committed Apr 20, 2020
1 parent 19317db commit e5804fd
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 10 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## 0.5.1

### Changed

- Hover uses Jedi's `help` method, instead of `infer`. Provides better help message information.

## 0.5.0

### Added
Expand Down
19 changes: 10 additions & 9 deletions jedi_language_server/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@

@SERVER.feature(COMPLETION, triggerCharacters=["."])
def lsp_completion(server: LanguageServer, params: CompletionParams):
"""Returns completion items."""
"""Returns completion items"""
script = get_jedi_script(server, params.textDocument.uri)
jedi_completions = script.complete(
line=params.position.line + 1, column=params.position.character,
Expand Down Expand Up @@ -83,16 +83,17 @@ def lsp_definition(
def lsp_hover(
server: LanguageServer, params: TextDocumentPositionParams
) -> Hover:
"""Support the hover feature"""
"""Support Hover"""
script = get_jedi_script(server, params.textDocument.uri)
names = script.infer(
line=params.position.line + 1, column=params.position.character,
)
return Hover(
contents=(
names[0].docstring() if names else "No docstring definition found."
try:
_names = script.help(
line=params.position.line + 1, column=params.position.character,
)
)
except Exception: # pylint: disable=broad-except
names = [] # type: List[str]
else:
names = [name for name in (n.docstring() for n in _names) if name]
return Hover(contents=names if names else "jedi: no help docs found")


@SERVER.feature(REFERENCES)
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ include_trailing_comma = true

[tool.poetry]
name = "jedi-language-server"
version = "0.5.0"
version = "0.5.1"
description = "A language server for Jedi!"
authors = ["Sam Roeca <samuel.roeca@gmail.com>"]
readme = "README.md"
Expand Down

0 comments on commit e5804fd

Please sign in to comment.