LanguageServer.jl
LanguageServer.jl copied to clipboard
`include` several files and missing variable warings
I am using emacs with lsp-julia which uses the LanguageServer#master, StaticLint#master, and CSTParser#master and julia 1.0.
When in a project where several files are used with include, LanguageServer often complains about missing variables when these are defined in other files.
I won't be able to tell why this is happening or fix it without a replicable example
MyPkg
|- MyPkg.jl
|- a.jl
|- b.jl
MyPkg.jl:
module MyPkg
include("a.jl")
include("b.jl")
end
a.jl:
f(x) = x^2
b.jl:
f2(x) = x * f(x)
then in b.jl LanguageServer.jl thinks that f is a "missing variable".
I could not update to the very latest master because of #295.
Fixed on master
Still not working for me on latest master. I initialized the language server like this:
LanguageServerInstance(stdin, stdout, false, "/path/to/package", "", Dict())
@ZacLN do we want to fix this for the next release, or move to the backlog?
Non blocking for vscode so I'll shift it
Not clear if this is still an issue, moving to backlog for now
Still a big problem on latest version.
Neither hyperlink is working, nor language server is working.
I tried it in neovim (with coc-julia) and atom (with juno) got some weird messages:
OS
linux 5.12.13-arch1-2
julia version 1.6.1
IDE's
neovim
NVIM v0.4.4
node version: v16.4.2
coc.nvim version: 0.0.80-5cd38e9462
atom
atom 1.57.0
Atom.jl 0.12.32
Examples
Example 1) Language server warnings
This is working without any problems.
# a.jl
include("b.jl")
include("c.jl")
function get_function_in_a()
nice_variable_in_a = 123
nice_variable_in_a
end
get_function_in_a()
This is also working without any problems.
# b.jl
function get_function_in_b()
nice_variable_in_b = 123
nice_variable_in_b
end
get_function_in_b()
This is throwing a language server warning: Variable has been assigned but not used.
# c.jl
function get_function_in_c()
nice_variable_in_c = 123
nice_variable_in_c
end
get_function_in_c()
Example 2) Language Server struct
File a.jl and b.jl is the same as above.
And after that, I get the warning Cannot declare constant; it already has a value..
# c.jl
mutable struct SomeAwesomeStruct
field_1
field_2
method_1
method_2
function SomeAwesomeStruct()
this = new()
this.field_1 = "a"
this.field_2 = "b"
this.method_1 = function()
# Some awesome code
end
this.method_d = function()
# Also some awesome code
end
this
end
end
Example 3) Hyperlink in Atom with JUNO (all plugins)
Hyperlink is working, yay! :)
# a.jl
using SomeAwesomeLibrary
include("b.jl")
include("c.jl")
# some epic code blabla
Hyperlink is working, yay! :)
# b.jl
using SomeAwesomeLibrary
# some epic code blabla
Hyperlink is broken. :(
# c.jl
using SomeAwesomeLibrary
# some epic code blabla