8000 Respect option `follow_imports` in `goto_assignments` call (#404) · mirror-dump/python-lsp-server@fb500ae · GitHub
[go: up one dir, main page]

Skip to content

Commit fb500ae

Browse files
st4lkgatesn
authored andcommitted
Respect option follow_imports in goto_assignments call (python-lsp#404)
1 parent 249f715 commit fb500ae

File tree

3 files changed

+19
-8
lines changed

3 files changed

+19
-8
lines changed

pyls/plugins/definition.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@
66

77

88
@hookimpl
9-
def pyls_definitions(document, position):
10-
definitions = document.jedi_script(position).goto_assignments()
9+
def pyls_definitions(config, document, position):
10+
params = {k: v for k, v in config.plugin_settings('jedi_definition').items() if v is not None}
11+
definitions = document.jedi_script(position).goto_assignments(**params)
1112

1213
definitions = [
1314
d for d in definitions

test/plugins/test_definitions.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def add_member(self, id, name):
1919
"""
2020

2121

22-
def test_definitions():
22+
def test_definitions(config):
2323
# Over 'a' in print a
2424
cursor_pos = {'line': 3, 'character': 6}
2525

@@ -30,19 +30,19 @@ def test_definitions():
3030
}
3131

3232
doc = Document(DOC_URI, DOC)
33-
assert [{'uri': DOC_URI, 'range': def_range}] == pyls_definitions(doc, cursor_pos)
33+
assert [{'uri': DOC_URI, 'range': def_range}] == pyls_definitions(config, doc, cursor_pos)
3434

3535

36-
def test_builtin_definition():
36+
def test_builtin_definition(config):
3737
# Over 'i' in dict
3838
cursor_pos = {'line': 8, 'character': 24}
3939

4040
# No go-to def for builtins
4141
doc = Document(DOC_URI, DOC)
42-
assert [] == pyls_definitions(doc, cursor_pos)
42+
assert [] == pyls_definitions(config, doc, cursor_pos)
4343

4444

45-
def test_assignment():
45+
def test_assignment(config):
4646
# Over 's' in self.members[id]
4747
cursor_pos = {'line': 11, 'character': 19}
4848

@@ -53,4 +53,4 @@ def test_assignment():
5353
}
5454

5555
doc = Document(DOC_URI, DOC)
56-
assert [{'uri': DOC_URI, 'range': def_range}] == pyls_definitions(doc, cursor_pos)
56+
assert [{'uri': DOC_URI, 'range': def_range}] == pyls_definitions(config, doc, cursor_pos)

vscode-client/package.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,16 @@
4040
"default": true,
4141
"description": "Enable or disable the plugin."
4242
},
43+
"pyls.plugins.jedi_definition.follow_imports": {
44+
"type": "boolean",
45+
"default": null,
46+
"description": "The goto call will follow imports."
47+
},
48+
"pyls.plugins.jedi_definition.follow_builtin_imports": {
49+
"type": "boolean",
50+
"default": null,
51+
"description": "If follow_imports is True will decide if it follow builtin imports."
52+
},
4353
"pyls.plugins.jedi_hover.enabled": {
4454
"type": "boolean",
4555
"default": true,

0 commit comments

Comments
 (0)
0