Skip to content

Commit cb3d4dd

Browse files
authored
Format files using DocumentFormat
1 parent 0cbf628 commit cb3d4dd

32 files changed

+325
-332
lines changed

docs/make.jl

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,16 @@ makedocs(;
77
repo="https://github.com/julia-vscode/LanguageServer.jl/blob/{commit}{path}#L{line}",
88
sitename="LanguageServer.jl",
99
format=Documenter.HTML(;
10-
prettyurls=prettyurls = get(ENV, "CI", nothing) == "true",
10+
prettyurls=prettyurls = get(ENV, "CI", nothing) == "true"
1111
# canonical="https://www.julia-vscode.org/LanguageServer.jl",
1212
# assets=String[],
1313
),
1414
pages=[
1515
"Home" => "index.md",
1616
"Syntax Reference" => "syntax.md",
17-
],
17+
]
1818
)
1919

2020
deploydocs(;
21-
repo="github.com/julia-vscode/LanguageServer.jl",
21+
repo="github.com/julia-vscode/LanguageServer.jl"
2222
)

src/document.jl

+12-12
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ function get_offset(doc::Document, line::Integer, character::Integer)
7777
line_offsets = get_line_offsets(doc)
7878
io = IOBuffer(get_text(doc))
7979
try
80-
seek(io, line_offsets[line + 1])
80+
seek(io, line_offsets[line+1])
8181
while character > 0
8282
c = read(io, Char)
8383
character -= 1
@@ -102,7 +102,7 @@ get_offset(doc, p::Position) = get_offset(doc, p.line, p.character)
102102
get_offset(doc, r::Range) = get_offset(doc, r.start):get_offset(doc, r.stop)
103103

104104
# 1-based. Basically the index at which (line, character) can be found in the document.
105-
get_offset2(doc::Document, p::Position, forgiving_mode=false) = get_offset2(doc, p.line, p.character, forgiving_mode)
105+
get_offset2(doc::Document, p::Position, forgiving_mode=false) = get_offset2(doc, p.line, p.character, forgiving_mode)
106106
function get_offset2(doc::Document, line::Integer, character::Integer, forgiving_mode=false)
107107
line_offsets = get_line_offsets2!(doc)
108108
text = get_text(doc)
@@ -114,9 +114,9 @@ function get_offset2(doc::Document, line::Integer, character::Integer, forgiving
114114
throw(LSOffsetError("get_offset2 crashed. More diagnostics:\nline=$line\nline_offsets='$line_offsets'"))
115115
end
116116

117-
line_offset = line_offsets[line + 1]
117+
line_offset = line_offsets[line+1]
118118

119-
next_line_offset = line + 1 < length(line_offsets) ? line_offsets[line + 2] : nextind(text, lastindex(text))
119+
next_line_offset = line + 1 < length(line_offsets) ? line_offsets[line+2] : nextind(text, lastindex(text))
120120

121121
pos = line_offset
122122

@@ -177,16 +177,16 @@ function get_line_offsets(doc::Document, force=false)
177177
doc._line_offsets = Int[0]
178178
text = get_text(doc)
179179
ind = firstindex(text)
180-
while ind <= lastindex(text)
180+
while ind <= lastindex(text)
181181
c = text[ind]
182182
nl = c == '\n' || c == '\r'
183-
if c == '\r' && ind + 1 <= lastindex(text) && text[ind + 1] == '\n'
183+
if c == '\r' && ind + 1 <= lastindex(text) && text[ind+1] == '\n'
184184
ind += 1
185185
end
186186
nl && push!(doc._line_offsets, ind)
187187
ind = nextind(text, ind)
188188
end
189-
end
189+
end
190190
return doc._line_offsets
191191
end
192192

@@ -195,10 +195,10 @@ function get_line_offsets2!(doc::Document, force=false)
195195
doc._line_offsets2 = Int[1]
196196
text = get_text(doc)
197197
ind = firstindex(text)
198-
while ind <= lastindex(text)
198+
while ind <= lastindex(text)
199199
c = text[ind]
200200
if c == '\n' || c == '\r'
201-
if c == '\r' && ind + 1 <= lastindex(text) && text[ind + 1] == '\n'
201+
if c == '\r' && ind + 1 <= lastindex(text) && text[ind+1] == '\n'
202202
ind += 1
203203
end
204204
push!(doc._line_offsets2, ind + 1)
@@ -218,12 +218,12 @@ function get_line_of(line_offsets::Vector{Int}, offset::Integer)
218218
else
219219
line = 1
220220
while line < nlines
221-
if line_offsets[line] <= offset < line_offsets[line + 1]
221+
if line_offsets[line] <= offset < line_offsets[line+1]
222222
break
223223
end
224224
line += 1
225225
end
226-
end
226+
end
227227
return line, line_offsets[line]
228228
end
229229

@@ -244,7 +244,7 @@ function get_position_at(doc::Document, offset::Integer)
244244
c = read(io, Char)
245245
character += 1
246246
if UInt32(c) >= 0x010000
247-
character += 1
247+
character += 1
248248
end
249249
end
250250
close(io)

src/extensions/messagedefs.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
const julia_getModuleAt_request_type = JSONRPC.RequestType("julia/getModuleAt", VersionedTextDocumentPositionParams, String)
2-
const julia_getCurrentBlockRange_request_type = JSONRPC.RequestType("julia/getCurrentBlockRange", VersionedTextDocumentPositionParams, Tuple{Position, Position, Position})
2+
const julia_getCurrentBlockRange_request_type = JSONRPC.RequestType("julia/getCurrentBlockRange", VersionedTextDocumentPositionParams, Tuple{Position,Position,Position})
33
const julia_getDocAt_request_type = JSONRPC.RequestType("julia/getDocAt", VersionedTextDocumentPositionParams, String)
44
const julia_getDocFromWord_request_type = JSONRPC.RequestType("julia/getDocFromWord", NamedTuple{(:word,),Tuple{String}}, String)

src/languageserverinstance.jl

+8-8
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,14 @@ mutable struct LanguageServerInstance
6363

6464
shutdown_requested::Bool
6565

66-
function LanguageServerInstance(pipe_in, pipe_out, env_path="", depot_path="", err_handler=nothing, symserver_store_path=nothing, download=true, symbolcache_upstream = nothing)
66+
function LanguageServerInstance(pipe_in, pipe_out, env_path="", depot_path="", err_handler=nothing, symserver_store_path=nothing, download=true, symbolcache_upstream=nothing)
6767
new(
6868
JSONRPC.JSONRPCEndpoint(pipe_in, pipe_out, err_handler),
6969
Set{String}(),
7070
Dict{URI2,Document}(),
7171
env_path,
7272
depot_path,
73-
SymbolServer.SymbolServerInstance(depot_path, symserver_store_path; symbolcache_upstream = symbolcache_upstream),
73+
SymbolServer.SymbolServerInstance(depot_path, symserver_store_path; symbolcache_upstream=symbolcache_upstream),
7474
Channel(Inf),
7575
StaticLint.ExternalEnv(deepcopy(SymbolServer.stdlibs), SymbolServer.collect_extended_methods(SymbolServer.stdlibs), collect(keys(SymbolServer.stdlibs))),
7676
Dict(),
@@ -179,7 +179,7 @@ function trigger_symbolstore_reload(server::LanguageServerInstance)
179179
ssi_ret, payload = SymbolServer.getstore(
180180
server.symbol_server,
181181
server.env_path,
182-
function (msg, percentage = missing)
182+
function (msg, percentage=missing)
183183
if server.clientcapability_window_workdoneprogress && server.current_symserver_progress_token !== nothing
184184
msg = ismissing(percentage) ? msg : string(msg, " ($percentage%)")
185185
JSONRPC.send(
@@ -193,7 +193,7 @@ function trigger_symbolstore_reload(server::LanguageServerInstance)
193193
end
194194
end,
195195
server.err_handler,
196-
download = server.symserver_use_download
196+
download=server.symserver_use_download
197197
)
198198

199199
server.number_of_outstanding_symserver_requests -= 1
@@ -269,7 +269,7 @@ function Base.run(server::LanguageServerInstance)
269269
@debug "LS: Starting client listener task."
270270
while true
271271
msg = JSONRPC.get_next_message(server.jr_endpoint)
272-
put!(server.combined_msg_queue, (type = :clientmsg, msg = msg))
272+
put!(server.combined_msg_queue, (type=:clientmsg, msg=msg))
273273
end
274274
catch err
275275
bt = catch_backtrace()
@@ -282,7 +282,7 @@ function Base.run(server::LanguageServerInstance)
282282
end
283283
finally
284284
if isopen(server.combined_msg_queue)
285-
put!(server.combined_msg_queue, (type = :close,))
285+
put!(server.combined_msg_queue, (type=:close,))
286286
close(server.combined_msg_queue)
287287
end
288288
@debug "LS: Client listener task done."
@@ -292,7 +292,7 @@ function Base.run(server::LanguageServerInstance)
292292
@debug "LS: Starting symbol server listener task."
293293
while true
294294
msg = take!(server.symbol_results_channel)
295-
put!(server.combined_msg_queue, (type = :symservmsg, msg = msg))
295+
put!(server.combined_msg_queue, (type=:symservmsg, msg=msg))
296296
end
297297
catch err
298298
bt = catch_backtrace()
@@ -305,7 +305,7 @@ function Base.run(server::LanguageServerInstance)
305305
end
306306
finally
307307
if isopen(server.combined_msg_queue)
308-
put!(server.combined_msg_queue, (type = :close,))
308+
put!(server.combined_msg_queue, (type=:close,))
309309
close(server.combined_msg_queue)
310310
end
311311
@debug "LS: Symbol server listener task done."

src/multienv.jl

+4-4
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const project_names = ("JuliaProject.toml", "Project.toml")
1010
const manifest_names = ("JuliaManifest.toml", "Manifest.toml")
1111

1212
# return nothing or the project file at env
13-
function env_file(env::String, names = project_names)::Union{Nothing,String}
13+
function env_file(env::String, names=project_names)::Union{Nothing,String}
1414
if isdir(env)
1515
for proj in names
1616
project_file = joinpath(env, proj)
@@ -49,7 +49,7 @@ function get_env_for_root(doc::Document, server::LanguageServerInstance)
4949
(safe_isfile(env_proj_file) && safe_isfile(env_manifest_file)) || return
5050

5151
# Find which workspace folder the doc is in.
52-
parent_workspaceFolders = sort(filter(f->startswith(doc._path, f), collect(server.workspaceFolders)), by = length, rev = true)
52+
parent_workspaceFolders = sort(filter(f -> startswith(doc._path, f), collect(server.workspaceFolders)), by=length, rev=true)
5353

5454
isempty(parent_workspaceFolders) && return
5555
# arbitrarily pick one
@@ -94,11 +94,11 @@ function get_env_for_root(doc::Document, server::LanguageServerInstance)
9494
msg
9595
))
9696
end
97-
@error msg exception=(err, catch_backtrace())
97+
@error msg exception = (err, catch_backtrace())
9898
end
9999
end
100100

101-
function complete_dep_tree(uuid, env_manifest, alldeps = Dict{Base.UUID,Pkg.Types.PackageEntry}())
101+
function complete_dep_tree(uuid, env_manifest, alldeps=Dict{Base.UUID,Pkg.Types.PackageEntry}())
102102
haskey(alldeps, uuid) && return alldeps
103103
alldeps[uuid] = env_manifest[uuid]
104104
for dep_uuid in values(alldeps[uuid].deps)

src/protocol/basic.jl

+12-12
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,14 @@ end
6363
##############################################################################
6464
# Diagnostics
6565
const DiagnosticSeverity = Int
66-
const DiagnosticSeverities = (Error = 1,
67-
Warning = 2,
68-
Information = 3,
69-
Hint = 4)
66+
const DiagnosticSeverities = (Error=1,
67+
Warning=2,
68+
Information=3,
69+
Hint=4)
7070

7171
const DiagnosticTag = Int
72-
const DiagnosticTags = (Unnecessary = 1,
73-
Deprecated = 2)
72+
const DiagnosticTags = (Unnecessary=1,
73+
Deprecated=2)
7474

7575
@dict_readable struct DiagnosticRelatedInformation
7676
location::Location
@@ -104,8 +104,8 @@ end
104104
##############################################################################
105105
# Markup
106106
const MarkupKind = String
107-
const MarkupKinds = (PlainText = "plaintext",
108-
Markdown = "markdown")
107+
const MarkupKinds = (PlainText="plaintext",
108+
Markdown="markdown")
109109

110110
mutable struct MarkupContent
111111
kind::MarkupKind
@@ -126,10 +126,10 @@ Base.hash(x::MarkedString) = hash(x.value) # for unique
126126
##############################################################################
127127
# Window
128128
const MessageType = Int
129-
const MessageTypes = (Error = 1,
130-
Warning = 2,
131-
Info = 3,
132-
Log = 4)
129+
const MessageTypes = (Error=1,
130+
Warning=2,
131+
Info=3,
132+
Log=4)
133133

134134
struct ShowMessageParams <: Outbound
135135
type::MessageType

src/protocol/completion.jl

+30-30
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,41 @@
11
const CompletionItemKind = Int
2-
const CompletionItemKinds = (Text = 1,
3-
Method = 2,
4-
Function = 3,
5-
Constructor = 4,
6-
Field = 5,
7-
Variable = 6,
8-
Class = 7,
9-
Interface = 8,
10-
Module = 9,
11-
Property = 10,
12-
Unit = 11,
13-
Value = 12,
14-
Enum = 13,
15-
Keyword = 14,
16-
Snippet = 15,
17-
Color = 16,
18-
File = 17,
19-
Reference = 18,
20-
Folder = 19,
21-
EnumMember = 20,
22-
Constant = 21,
23-
Struct = 22,
24-
Event = 23,
25-
Operator = 24,
26-
TypeParameter = 25)
2+
const CompletionItemKinds = (Text=1,
3+
Method=2,
4+
Function=3,
5+
Constructor=4,
6+
Field=5,
7+
Variable=6,
8+
Class=7,
9+
Interface=8,
10+
Module=9,
11+
Property=10,
12+
Unit=11,
13+
Value=12,
14+
Enum=13,
15+
Keyword=14,
16+
Snippet=15,
17+
Color=16,
18+
File=17,
19+
Reference=18,
20+
Folder=19,
21+
EnumMember=20,
22+
Constant=21,
23+
Struct=22,
24+
Event=23,
25+
Operator=24,
26+
TypeParameter=25)
2727

2828
const CompletionItemTag = Int
2929
const CompletionItemTags = (Deprecated = 1)
3030

3131
const CompletionTriggerKind = Int
32-
const CompletionTriggerKinds = (Invoked = 1,
33-
TriggerCharacter = 2,
34-
TriggerForIncompleteCompletion = 3)
32+
const CompletionTriggerKinds = (Invoked=1,
33+
TriggerCharacter=2,
34+
TriggerForIncompleteCompletion=3)
3535

3636
const InsertTextFormat = Int
37-
const InsertTextFormats = (PlainText = 1,
38-
Snippet = 2)
37+
const InsertTextFormats = (PlainText=1,
38+
Snippet=2)
3939

4040
@dict_readable struct CompletionTagClientCapabilities
4141
valueSet::Vector{CompletionItemTag}

src/protocol/configuration.jl

+6-6
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,14 @@ end
3030
##############################################################################
3131
# File watching
3232
const FileChangeType = Int
33-
const FileChangeTypes = (Created = 1,
34-
Changed = 2,
35-
Deleted = 3)
33+
const FileChangeTypes = (Created=1,
34+
Changed=2,
35+
Deleted=3)
3636

3737
const WatchKind = Int
38-
const WatchKinds = (Create = 1,
39-
Change = 2,
40-
Delete = 4)
38+
const WatchKinds = (Create=1,
39+
Change=2,
40+
Delete=4)
4141

4242

4343
@dict_readable struct FileEvent

src/protocol/document.jl

+4-4
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ end
7676
textDocument::TextDocumentItem
7777
end
7878

79-
@dict_readable struct TextDocumentContentChangeEvent <: Outbound
79+
@dict_readable struct TextDocumentContentChangeEvent <: Outbound
8080
range::Union{Range,Missing}
8181
rangeLength::Union{Int,Missing}
8282
text::String
@@ -97,9 +97,9 @@ end
9797
end
9898

9999
const TextDocumentSaveReason = Int
100-
const TextDocumentSaveReasons = (Manual = 1,
101-
AfterDelay = 2,
102-
FocusOut = 3)
100+
const TextDocumentSaveReasons = (Manual=1,
101+
AfterDelay=2,
102+
FocusOut=3)
103103

104104
@dict_readable struct WillSaveTextDocumentParams
105105
textDocument::TextDocumentIdentifier

0 commit comments

Comments
 (0)