Skip to content

Commit 716e7d9

Browse files
authored
julia 1.5 compat (#32)
julia 1.5 compat, make the server multi-root, match vscode 1.0.5, add symbol server store path
1 parent b342e5f commit 716e7d9

14 files changed

+227
-27
lines changed

.gitmodules

+6
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,9 @@
2222
[submodule "languageserver/SymbolServer"]
2323
path = languageserver/SymbolServer
2424
url = https://github.com/julia-vscode/SymbolServer.jl.git
25+
[submodule "languageserver/FilePathsBase"]
26+
path = languageserver/FilePathsBase
27+
url = https://github.com/rofinn/FilePathsBase.jl.git
28+
[submodule "languageserver/JSONRPC"]
29+
path = languageserver/JSONRPC
30+
url = https://github.com/julia-vscode/JSONRPC.jl.git

languageserver/FilePathsBase

Submodule FilePathsBase added at a3e2d27

languageserver/JSONRPC

Submodule JSONRPC added at 5f79867

languageserver/LanguageServer

Submodule LanguageServer updated 67 files

languageserver/Manifest.toml

+30-7
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
77
deps = ["Tokenize"]
88
path = "CSTParser"
99
uuid = "00ebfdb7-1f24-5e51-bd34-a7502290713f"
10+
version = "2.5.1-DEV"
1011

1112
[[Dates]]
1213
deps = ["Printf"]
@@ -17,27 +18,45 @@ deps = ["Random", "Serialization", "Sockets"]
1718
uuid = "8ba89e20-285c-5b6f-9357-94700520ee1b"
1819

1920
[[DocumentFormat]]
20-
deps = ["CSTParser", "Tokenize"]
21+
deps = ["CSTParser", "FilePathsBase", "Tokenize"]
2122
path = "DocumentFormat"
2223
uuid = "ffa9a821-9c82-50df-894e-fbcef3ed31cd"
24+
version = "3.2.1-DEV"
25+
26+
[[FilePathsBase]]
27+
deps = ["Dates", "Printf", "Test", "UUIDs"]
28+
path = "FilePathsBase"
29+
uuid = "48062228-2e41-5def-b9a4-89aafe57970f"
30+
version = "0.9.3"
2331

2432
[[InteractiveUtils]]
2533
deps = ["Markdown"]
2634
uuid = "b77e0a4c-d291-57a0-90e8-8db25a27a240"
2735

2836
[[JSON]]
29-
deps = ["Dates", "Distributed", "Mmap", "Sockets", "Test", "Unicode"]
37+
deps = ["Dates", "Mmap", "Unicode"]
3038
path = "JSON"
3139
uuid = "682c06a0-de6a-54ab-a142-c8b1cf79cde6"
40+
version = "0.20.1"
41+
42+
[[JSONRPC]]
43+
deps = ["JSON", "UUIDs"]
44+
path = "JSONRPC"
45+
uuid = "b9b8584e-8fd3-41f9-ad0c-7255d428e418"
46+
version = "1.2.1-DEV"
3247

3348
[[LanguageServer]]
34-
deps = ["CSTParser", "DocumentFormat", "JSON", "REPL", "StaticLint", "SymbolServer", "Tokenize", "URIParser"]
49+
deps = ["CSTParser", "DocumentFormat", "JSON", "JSONRPC", "Markdown", "REPL", "StaticLint", "SymbolServer", "Tokenize", "URIParser", "UUIDs"]
3550
path = "LanguageServer"
3651
uuid = "2b0e0bc5-e4fd-59b4-8912-456d1b03d8d7"
52+
version = "3.2.1-DEV"
3753

3854
[[LibGit2]]
3955
uuid = "76f85450-5226-5b5a-8eaa-529ad045b433"
4056

57+
[[Libdl]]
58+
uuid = "8f399da3-3557-5675-b5ff-fb832c97cbdb"
59+
4160
[[Logging]]
4261
uuid = "56ddb016-857b-54e1-b83d-db4d58db5568"
4362

@@ -49,7 +68,7 @@ uuid = "d6f4376e-aef5-505a-96c1-9c027394607a"
4968
uuid = "a63ad114-7e13-5084-954f-fe012c677804"
5069

5170
[[Pkg]]
52-
deps = ["Dates", "LibGit2", "Markdown", "Printf", "REPL", "Random", "SHA", "UUIDs"]
71+
deps = ["Dates", "LibGit2", "Libdl", "Logging", "Markdown", "Printf", "REPL", "Random", "SHA", "Test", "UUIDs"]
5372
uuid = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
5473

5574
[[Printf]]
@@ -74,14 +93,16 @@ uuid = "9e88b42a-f829-5b0c-bbe9-9e923198166b"
7493
uuid = "6462fe0b-24de-5631-8697-dd941f90decc"
7594

7695
[[StaticLint]]
77-
deps = ["CSTParser", "SymbolServer", "Test"]
96+
deps = ["CSTParser", "Serialization", "SymbolServer"]
7897
path = "StaticLint"
7998
uuid = "b3cc710f-9c33-5bdb-a03d-a94903873e97"
99+
version = "4.5.1-DEV"
80100

81101
[[SymbolServer]]
82-
deps = ["LibGit2", "Pkg", "SHA", "Serialization", "Test"]
102+
deps = ["InteractiveUtils", "LibGit2", "Markdown", "Pkg", "REPL", "SHA", "Serialization", "Sockets", "UUIDs"]
83103
path = "SymbolServer"
84104
uuid = "cf896787-08d5-524d-9de7-132aaa0cb996"
105+
version = "5.1.1-DEV"
85106

86107
[[Test]]
87108
deps = ["Distributed", "InteractiveUtils", "Logging", "Random"]
@@ -90,11 +111,13 @@ uuid = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
90111
[[Tokenize]]
91112
path = "Tokenize"
92113
uuid = "0796e94c-ce3b-5d07-9a54-7f471281c624"
114+
version = "0.5.8"
93115

94116
[[URIParser]]
95-
deps = ["Test", "Unicode"]
117+
deps = ["Unicode"]
96118
path = "URIParser"
97119
uuid = "30578b45-9adc-5946-b283-645ec420af67"
120+
version = "0.4.1"
98121

99122
[[UUIDs]]
100123
deps = ["Random", "SHA"]

languageserver/Project.toml

+2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
[deps]
22
CSTParser = "00ebfdb7-1f24-5e51-bd34-a7502290713f"
33
DocumentFormat = "ffa9a821-9c82-50df-894e-fbcef3ed31cd"
4+
FilePathsBase = "48062228-2e41-5def-b9a4-89aafe57970f"
45
JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6"
6+
JSONRPC = "b9b8584e-8fd3-41f9-ad0c-7255d428e418"
57
LanguageServer = "2b0e0bc5-e4fd-59b4-8912-456d1b03d8d7"
68
StaticLint = "b3cc710f-9c33-5bdb-a03d-a94903873e97"
79
SymbolServer = "cf896787-08d5-524d-9de7-132aaa0cb996"

lsp-julia.el

+179-12
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
;; Guido Kraemer <[email protected]>
1010
;; Keywords: languages, tools
1111
;; Version: 0.2.0
12-
;; Package-Requires: ((emacs "25.1") (lsp-mode "6.0") (julia-mode "0.3"))
12+
;; Package-Requires: ((emacs "25.1") (lsp-mode "6.3") (julia-mode "0.3"))
1313
;; Keywords: languages, tools
1414
;; URL: https://github.com/non-Jedi/lsp-julia
1515

@@ -83,6 +83,15 @@ Set to nil if you want to use the globally installed versions."
8383
:type '(repeat (string :tag "argument"))
8484
:group 'lsp-julia)
8585

86+
(defcustom lsp-julia-symbol-server-store-path "~/.julia/symbolstorev2-lsp-julia"
87+
"The cache directory for `SymbolServer.jl'."
88+
:type 'directory
89+
;; :initialize (lambda (sym expr)
90+
;; (print expr)
91+
;; (when expr (make-directory expr t) expr))
92+
:group 'lsp-julia)
93+
94+
8695
(defcustom lsp-julia-timeout 30
8796
"Time before symbol `lsp-mode' should assume julia just ain't gonna start."
8897
:type 'number
@@ -93,27 +102,184 @@ Set to nil if you want to use the globally installed versions."
93102
:type 'string
94103
:group 'lsp-julia)
95104

105+
;;; Workspace options
106+
(defcustom lsp-julia-format-indent 4
107+
"Indent size for formatting."
108+
:type 'integer
109+
:group 'lsp-julia)
110+
111+
(defcustom lsp-julia-format-indents t
112+
"Format file indents."
113+
:type 'boolean
114+
:group 'lsp-julia)
115+
116+
(defcustom lsp-julia-format-ops t
117+
"Format whitespace around operators."
118+
:type 'boolean
119+
:group 'lsp-julia)
120+
121+
(defcustom lsp-julia-format-tuples t
122+
"Format tuples."
123+
:type 'boolean
124+
:group 'lsp-julia)
125+
126+
(defcustom lsp-julia-format-curly t
127+
"Format braces."
128+
:type 'boolean
129+
:group 'lsp-julia)
130+
131+
(defcustom lsp-julia-format-calls t
132+
"Format function calls."
133+
:type 'boolean
134+
:group 'lsp-julia)
135+
136+
(defcustom lsp-julia-format-iterops t
137+
"Format loop iterators."
138+
:type 'boolean
139+
:group 'lsp-julia)
140+
141+
(defcustom lsp-julia-format-comments t
142+
"Format comments."
143+
:type 'boolean
144+
:group 'lsp-julia)
145+
(defcustom lsp-julia-format-docs t
146+
"Format inline documentation."
147+
:type 'boolean
148+
:group 'lsp-julia)
149+
150+
(defcustom lsp-julia-format-kw t
151+
"Remove spaces around = in function keywords."
152+
:type 'boolean
153+
:group 'lsp-julia)
154+
155+
(defcustom lsp-julia-lint-run t
156+
"Run the linter on active files."
157+
:type 'boolean
158+
:group 'lsp-julia)
159+
160+
(defcustom lsp-julia-lint-missingrefs "all"
161+
"Highlight unknown symbols. The `symbols` option will not mark
162+
unknown fields."
163+
:type 'string
164+
:options '("none" "symbols" "all")
165+
:group 'lsp-julia)
166+
167+
(defcustom lsp-julia-lint-call t
168+
"This compares call signatures against all known methods for
169+
the called function. Calls with too many or too few arguments, or
170+
unknown keyword parameters are highlighted."
171+
:type 'boolean
172+
:group 'lsp-julia)
173+
174+
(defcustom lsp-julia-lint-iter t
175+
"Check iterator syntax of loops. Will identify, for example,
176+
attempts to iterate over single values."
177+
:type 'boolean
178+
:group 'lsp-julia)
179+
180+
(defcustom lsp-julia-lint-constif t
181+
"Check for constant conditionals in if statements that result
182+
in branches never being reached.."
183+
:type 'boolean
184+
:group 'lsp-julia)
185+
186+
(defcustom lsp-julia-lint-lazy t
187+
"Check for deterministic lazy boolean operators."
188+
:type 'boolean
189+
:group 'lsp-julia)
190+
191+
(defcustom lsp-julia-lint-datadecl t
192+
"Check variables used in type declarations are datatypes."
193+
:type 'boolean
194+
:group 'lsp-julia)
195+
196+
(defcustom lsp-julia-lint-typeparam t
197+
"Check parameters declared in `where` statements or datatype
198+
declarations are used."
199+
:type 'boolean
200+
:group 'lsp-julia)
201+
202+
(defcustom lsp-julia-lint-modname t
203+
"Check submodule names do not shadow their parent's name."
204+
:type 'boolean
205+
:group 'lsp-julia)
206+
207+
(defcustom lsp-julia-lint-pirates t
208+
"Check for type piracy - the overloading of external functions
209+
with methods specified for external datatypes. 'External' here
210+
refers to imported code."
211+
:type 'boolean
212+
:group 'lsp-julia)
213+
214+
(defcustom lsp-julia-lint-useoffuncargs t
215+
"Check that all declared arguments are used within the function
216+
body."
217+
:type 'boolean
218+
:group 'lsp-julia)
219+
220+
(defcustom lsp-julia-lint-nothingcomp t
221+
"Check for use of `==` rather than `===` when comparing against
222+
`nothing`."
223+
:type 'boolean
224+
:group 'lsp-julia)
225+
226+
(lsp-register-custom-settings
227+
'(("julia.format.indent" lsp-julia-format-indent)
228+
("julia.format.indents" lsp-julia-format-indents t)
229+
("julia.format.ops" lsp-julia-format-ops t)
230+
("julia.format.tuples" lsp-julia-format-tuples t)
231+
("julia.format.curly" lsp-julia-format-curly t)
232+
("julia.format.calls" lsp-julia-format-calls t)
233+
("julia.format.iterOps" lsp-julia-format-iterops t)
234+
("julia.format.comments" lsp-julia-format-comments t)
235+
("julia.format.docs" lsp-julia-format-docs t)
236+
("julia.format.kw" lsp-julia-format-kw t)
237+
("julia.lint.run" lsp-julia-lint-run t)
238+
("julia.lint.missingrefs" lsp-julia-lint-missingrefs)
239+
("julia.lint.call" lsp-julia-lint-call t)
240+
("julia.lint.iter" lsp-julia-lint-iter t)
241+
("julia.lint.constif" lsp-julia-lint-constif t)
242+
("julia.lint.lazyif" lsp-julia-lint-lazy t)
243+
("julia.lint.datadecl" lsp-julia-lint-datadecl t)
244+
("julia.lint.typeparam" lsp-julia-lint-typeparam t)
245+
("julia.lint.modname" lsp-julia-lint-modname t)
246+
("julia.lint.pirates" lsp-julia-lint-pirates t)
247+
("julia.lint.useoffuncargs" lsp-julia-lint-useoffuncargs t)
248+
("julia.lint.nothingcomp" lsp-julia-lint-nothingcomp t)))
249+
250+
;;; lsp-julia related functions setup
96251
(defun lsp-julia--get-root ()
97252
"Get the (Julia) project root directory of the current file."
98-
(let ((dir (locate-dominating-file default-directory "Project.toml")))
99-
(if dir (expand-file-name dir)
100-
(expand-file-name lsp-julia-default-environment))))
253+
(let* ((dir (locate-dominating-file default-directory "Project.toml"))
254+
(dir2 (if dir dir lsp-julia-default-environment)))
255+
(concat "\"" (expand-file-name dir2) "\"")))
101256

102257
(defun lsp-julia--get-depot-path ()
103258
"Get the (Julia) depot path."
104-
(let ((dp (getenv "JULIA_DEPOT_PATH")))
105-
(if dp dp lsp-julia-default-depot)))
259+
(let* ((dp (getenv "JULIA_DEPOT_PATH"))
260+
(dp2 (if dp dp lsp-julia-default-depot)))
261+
(concat "\"" dp2 "\"")))
262+
263+
(defun lsp-julia--symbol-server-store-path-to-jl ()
264+
"Convert the variable `lsp-julia-symbol-server-store-path' to a
265+
string or \"nothing\" if `nil'"
266+
(if lsp-julia-symbol-server-store-path
267+
(let ((sssp (expand-file-name lsp-julia-symbol-server-store-path)))
268+
(make-directory sssp t)
269+
(concat "\"" sssp "\""))
270+
"nothing"))
106271

107272
(defun lsp-julia--rls-command ()
108273
"The command to lauch the Julia Language Server."
109274
`(,lsp-julia-command
110275
,@lsp-julia-flags
111-
,(concat "-e using LanguageServer, Sockets, SymbolServer;"
276+
,(concat "-e using InteractiveUtils, Sockets, SymbolServer, LanguageServer;"
112277
" server = LanguageServer.LanguageServerInstance("
113-
" stdin, stdout, false,"
114-
" \"" (lsp-julia--get-root) "\","
115-
" \"" (lsp-julia--get-depot-path) "\");"
116-
" server.runlinter = true;"
278+
" stdin, stdout,"
279+
(lsp-julia--get-root) ","
280+
(lsp-julia--get-depot-path) ","
281+
" nothing, "
282+
(lsp-julia--symbol-server-store-path-to-jl) ");"
117283
" run(server);")))
118284

119285
(defconst lsp-julia--handlers
@@ -125,7 +291,8 @@ Set to nil if you want to use the globally installed versions."
125291
(lsp-register-client
126292
(make-lsp-client :new-connection (lsp-stdio-connection 'lsp-julia--rls-command)
127293
:major-modes '(julia-mode ess-julia-mode)
128-
:server-id 'julia-ls))
294+
:server-id 'julia-ls
295+
:multi-root t))
129296

130297
(provide 'lsp-julia)
131298
;;; lsp-julia.el ends here

0 commit comments

Comments
 (0)