Skip to content

Commit 7fb2791

Browse files
committed
better setting names
1 parent 59cfee7 commit 7fb2791

File tree

3 files changed

+35
-21
lines changed

3 files changed

+35
-21
lines changed

src/languageserverinstance.jl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@ mutable struct LanguageServerInstance
4343
lint_missingrefs::Symbol
4444
lint_disableddirs::Vector{String}
4545
completion_mode::Symbol
46-
inlay_hint_mode::Symbol # :none, :literals, :all
46+
inlay_hints::Bool
47+
inlay_hints_variable_types::Bool
48+
inlay_hints_parameter_names::Symbol
4749

4850
combined_msg_queue::Channel{Any}
4951

@@ -84,6 +86,8 @@ mutable struct LanguageServerInstance
8486
:all,
8587
LINT_DIABLED_DIRS,
8688
:qualify, # options: :import or :qualify, anything else turns this off
89+
true,
90+
true,
8791
:literals,
8892
Channel{Any}(Inf),
8993
err_handler,

src/requests/features.jl

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -578,7 +578,7 @@ function get_selection_range_of_expr(x::EXPR)
578578
end
579579

580580
function textDocument_inlayHint_request(params::InlayHintParams, server::LanguageServerInstance, conn)::Union{Vector{InlayHint},Nothing}
581-
if server.inlay_hint_mode === :none
581+
if !server.inlay_hints
582582
return nothing
583583
end
584584

@@ -590,7 +590,6 @@ function textDocument_inlayHint_request(params::InlayHintParams, server::Languag
590590
end
591591

592592
function collect_inlay_hints(x::EXPR, server::LanguageServerInstance, doc, start, stop, pos=0, hints=InlayHint[])
593-
literals_only = server.inlay_hint_mode === :literals
594593
if x isa EXPR && parentof(x) isa EXPR &&
595594
CSTParser.iscall(parentof(x)) &&
596595
!(
@@ -599,7 +598,10 @@ function collect_inlay_hints(x::EXPR, server::LanguageServerInstance, doc, start
599598
) &&
600599
parentof(x).args[1] != x # function calls
601600

602-
if !literals_only || CSTParser.isliteral(x)
601+
if server.inlay_hints_parameter_names === :all || (
602+
server.inlay_hints_parameter_names === :literals &&
603+
CSTParser.isliteral(x)
604+
)
603605
sigs = collect_signatures(x, doc, server)
604606
if !isempty(sigs)
605607
args = length(parentof(x).args) - 1
@@ -641,21 +643,23 @@ function collect_inlay_hints(x::EXPR, server::LanguageServerInstance, doc, start
641643
CSTParser.isassignment(parentof(x)) &&
642644
parentof(x).args[1] == x &&
643645
StaticLint.hasbinding(x) # assignment
644-
typ = _completion_type(StaticLint.bindingof(x))
645-
if typ !== missing
646-
push!(
647-
hints,
648-
InlayHint(
649-
Position(get_position_from_offset(doc, pos + x.span)...),
650-
string("::", typ),
651-
InlayHintKinds.Type,
652-
missing,
653-
missing,
654-
missing,
655-
missing,
656-
missing
646+
if server.inlay_hints_variable_types
647+
typ = _completion_type(StaticLint.bindingof(x))
648+
if typ !== missing
649+
push!(
650+
hints,
651+
InlayHint(
652+
Position(get_position_from_offset(doc, pos + x.span)...),
653+
string("::", typ),
654+
InlayHintKinds.Type,
655+
missing,
656+
missing,
657+
missing,
658+
missing,
659+
missing
660+
)
657661
)
658-
)
662+
end
659663
end
660664
end
661665
if length(x) > 0

src/requests/workspace.jl

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,9 @@ function request_julia_config(server::LanguageServerInstance, conn)
108108
ConfigurationItem(missing, "julia.lint.missingrefs"),
109109
ConfigurationItem(missing, "julia.lint.disabledDirs"),
110110
ConfigurationItem(missing, "julia.completionmode"),
111-
ConfigurationItem(missing, "julia.inlayHints"),
111+
ConfigurationItem(missing, "julia.inlayHints.static.enabled"),
112+
ConfigurationItem(missing, "julia.inlayHints.static.variableTypes.enabled"),
113+
ConfigurationItem(missing, "julia.inlayHints.static.parameterNames.enabled"),
112114
]))
113115

114116
new_runlinter = something(response[11], true)
@@ -117,7 +119,9 @@ function request_julia_config(server::LanguageServerInstance, conn)
117119
new_lint_missingrefs = Symbol(something(response[12], :all))
118120
new_lint_disableddirs = something(response[13], LINT_DIABLED_DIRS)
119121
new_completion_mode = Symbol(something(response[14], :import))
120-
inlayHints = Symbol(something(response[15], :literals))
122+
inlayHints = something(response[15], true)
123+
inlayHintsVariableTypes = something(response[16], true)
124+
inlayHintsParameterNames = Symbol(something(response[17], :literals))
121125

122126
rerun_lint = begin
123127
any(getproperty(server.lint_options, opt) != getproperty(new_SL_opts, opt) for opt in fieldnames(StaticLint.LintOptions)) ||
@@ -131,7 +135,9 @@ function request_julia_config(server::LanguageServerInstance, conn)
131135
server.lint_missingrefs = new_lint_missingrefs
132136
server.lint_disableddirs = new_lint_disableddirs
133137
server.completion_mode = new_completion_mode
134-
server.inlay_hint_mode = inlayHints
138+
server.inlay_hints = inlayHints
139+
server.inlay_hints_variable_types = inlayHintsVariableTypes
140+
server.inlay_hints_parameter_names = inlayHintsParameterNames
135141

136142
if rerun_lint
137143
relintserver(server)

0 commit comments

Comments
 (0)