VIM version:
VIM - Vi IMproved 8.1 (2018 May 18, compiled Oct 3 2018 05:41:36)
macOS version
Operating System: OS X 10.14.2 (18C54)
vim config:
"ALE
let g:ale_julia_executable = '/Applications/Julia-1.0.app/Contents/Resources/julia/bin/julia'
let g:ale_completion_enabled = 1
ALE not work actually. When I start .jl file and start edit I see that vim try to start language server:
ps aux |grep -i julia
jamm 40076 77,3 1,4 4751668 230220 ?? Rs 3:50 0:02.12 /Applications/Julia-1.0.app/Contents/Resources/julia/bin/julia -Cnative -J/Applications/Julia-1.0.app/Contents/Resources/julia/lib/julia/sys.dylib --compile=yes --depwarn=yes -O0 --output-ji /Users/jamm/.julia/compiled/v1.0/LanguageServer/ite7n.ji --output-incremental=yes --startup-file=no --history-file=no --warn-overwrite=yes --color=no --eval while !eof(stdin)\012 code = readuntil(stdin, '\0')\012 eval(Meta.parse(code))\012end\012
jamm 40078 0,0 0,0 4268020 780 s008 S+ 3:50 0:00.00 grep -i julia
jamm 40064 0,0 0,9 4713968 157096 ?? Ss 3:50 0:01.09 /Applications/Julia-1.0.app/Contents/Resources/julia/bin/julia --startup-file=no --history-file=no -e using LanguageServer; server = LanguageServer.LanguageServerInstance(isdefined(Base, :stdin) ? stdin : STDIN, isdefined(Base, :stdout) ? stdout : STDOUT, false); server.runlinter = true; run(server);
So, the process hangs, and if I type the command in to the bash I get:
/Applications/Julia-1.0.app/Contents/Resources/julia/bin/julia --startup-file=no --history-file=no -e "using LanguageServer; server = LanguageServer.LanguageServerInstance(isdefined(Base, :stdin) ? stdin : STDIN, isdefined(Base, :stdout) ? stdout : STDOUT, false); server.runlinter = true; run(server);"
ERROR: MethodError: no method matching LanguageServerInstance(::Base.TTY, ::Base.TTY, ::Bool)
Closest candidates are:
LanguageServerInstance(::Any, ::Any, ::Bool, !Matched::Any, !Matched::Any, !Matched::Any) at /Users/jamm/.julia/packages/LanguageServer/pbcUe/src/languageserverinstance.jl:21
Stacktrace:
[1] top-level scope at none:0
Just install ALE via PlugInstall and set the executable on OSX/Linux, add packages in julia:
add LanguageServer
add DocumentFormat#master
Current Filetype: julia
Available Linters: ['languageserver']
Enabled Linters: ['languageserver']
Suggested Fixers:
'remove_trailing_lines' - Remove all blank lines at the end of a file.
'trim_whitespace' - Remove all trailing whitespace characters at the end of every line.
Linter Variables:
Global Variables:
let g:ale_cache_executable_check_failures = v:null
let g:ale_change_sign_column_color = 0
let g:ale_command_wrapper = ''
let g:ale_completion_delay = 100
let g:ale_completion_enabled = 1
let g:ale_completion_max_suggestions = 50
let g:ale_echo_cursor = 1
let g:ale_echo_msg_error_str = 'Error'
let g:ale_echo_msg_format = '%code: %%s'
let g:ale_echo_msg_info_str = 'Info'
let g:ale_echo_msg_warning_str = 'Warning'
let g:ale_enabled = 1
let g:ale_fix_on_save = 0
let g:ale_fixers = {}
let g:ale_history_enabled = 1
let g:ale_history_log_output = 1
let g:ale_keep_list_window_open = 0
let g:ale_lint_delay = 200
let g:ale_lint_on_enter = 1
let g:ale_lint_on_filetype_changed = 1
let g:ale_lint_on_insert_leave = 0
let g:ale_lint_on_save = 1
let g:ale_lint_on_text_changed = 'always'
let g:ale_linter_aliases = {}
let g:ale_linters = {}
let g:ale_linters_explicit = 0
let g:ale_list_vertical = 0
let g:ale_list_window_size = 10
let g:ale_loclist_msg_format = '%code: %%s'
let g:ale_max_buffer_history_size = 20
let g:ale_max_signs = -1
let g:ale_maximum_file_size = v:null
let g:ale_open_list = 0
let g:ale_pattern_options = v:null
let g:ale_pattern_options_enabled = v:null
let g:ale_set_balloons = 0
let g:ale_set_highlights = 1
let g:ale_set_loclist = 1
let g:ale_set_quickfix = 0
let g:ale_set_signs = 1
let g:ale_sign_column_always = 0
let g:ale_sign_error = '>>'
let g:ale_sign_info = '--'
let g:ale_sign_offset = 1000000
let g:ale_sign_style_error = '>>'
let g:ale_sign_style_warning = '--'
let g:ale_sign_warning = '--'
let g:ale_statusline_format = v:null
let g:ale_type_map = {}
let g:ale_use_global_executables = v:null
let g:ale_virtualtext_cursor = 0
let g:ale_warn_about_trailing_blank_lines = 1
let g:ale_warn_about_trailing_whitespace = 1
Command History:
(started) ['/bin/bash', '-c', '''/Applications/Julia-1.0.app/Contents/Resources/julia/bin/julia'' --startup-file=no --history-file=no -e ''using LanguageServer; server = LanguageServer.LanguageServerInstance(isdefined(Base, :stdin) ? stdin : STDIN, isdefined(Base, :stdout) ? stdout : STDOUT, false); server.runlinter = true; run(server);''']
I'm sorry, there is a bit wrong info about command line arguments. I have updated the issue.
^^^^ It seems that is not ALE issue...
The language server works if it switch to add DocumentFormat#master, but now I get this error:
/Applications/Julia-1.0.app/Contents/Resources/julia/bin/julia --startup-file=no --history-file=no -e "using LanguageServer; server = LanguageServer.LanguageServerInstance(isdefined(Base, :stdin) ? stdin : STDIN, isdefined(Base, :stdout) ? stdout : STDOUT, false); server.runlinter = true; run(server);"
ERROR: MethodError: no method matching LanguageServerInstance(::Base.TTY, ::Base.TTY, ::Bool)
Closest candidates are:
LanguageServerInstance(::Any, ::Any, ::Bool, !Matched::Any, !Matched::Any, !Matched::Any) at /Users/jamm/.julia/packages/LanguageServer/pbcUe/src/languageserverinstance.jl:21
Stacktrace:
[1] top-level scope at none:0
and this seems the ALE issue.
I updated the issue again.
Maybe some breaking changes have been added to the LanguageServer. Someone might have to patch the linter command so it's compatible with Julia 1.0 and so on.
This issue https://github.com/JuliaEditorSupport/LanguageServer.jl/issues/318 picks that doc is wrong, so we have to follow vscode experience
We need to call the function/class with more arguments. https://github.com/JuliaEditorSupport/julia-vscode/blob/master/scripts/languageserver/main.jl#L25
If someone knows how to introspect things in the Julia language to find out how many arguments something accepts, do that and add more arguments.
Correct parameters are:
.vim/plugged/ale/ale_linters/julia/languageserver.vim
let l:cmd_string = 'using LanguageServer,SymbolServer; server = LanguageServer.LanguageServerInstance(stdin, stdout, true, expanduser("~/.julia/environments/v1.0"), "", Dict()); server.runlinter = true; run(server);'
but it seems not enough for correct working ALE
This command-line test worked for me:
julia --startup-file=no --history-file=no -e 'using LanguageServer; using Pkg;
server = LanguageServer.LanguageServerInstance(isdefined(Base, :stdin) ? stdin : STDIN,
isdefined(Base, :stdout) ? stdout : STDOUT, false,
dirname(Pkg.Types.Context().env.project_file), "", Dict());
server.runlinter = true; run(server);'
but I don't know how to get ALE to use it.
It would be nice if they can provide a command line tool for executing the language server, so we don't have to update the call signature each time they push out breaking changes.
cc @zacln @davidanthoff
Can you open an issue over at LanguageServer.jl? That would be the best way to track this.
Can you open an issue over at LanguageServer.jl?
On it.
@w0rp in the meantime, could you give some guidance on how to get the languageserver (using the above command) to work with ALE? I've tried modifying ale_linters/julia/languageserver.vim to use the command but it's not doing anything (not showing any output, either) so I don't know what's wrong.
Diff: https://gist.github.com/sbromberger/8d984627a7dedc8c327dd920b33d0947
I'm not sure myself. Run it in Vim after using the ch_logfile function to set up logging, and have a look at the output.
It seems that using Sockets; using SymbolServer; should be added to julia cmd_string (as discussed in https://github.com/julia-vscode/LanguageServer.jl/issues/375).
I've modified my ale_linters/julia/languageserver.vim to be the following:
" Author: Bartolomeo Stellato <[email protected]>
" Description: A language server for Julia
" Set julia executable variable
echom "Setup for Julia Linter"
call ale#Set('julia_executable', 'julia')
function! ale_linters#julia#languageserver#GetCommand(buffer) abort
echom "In Julia Linter"
let l:julia_executable = ale#Var(a:buffer, 'julia_executable')
let l:cmd_string = 'using LanguageServer; using Pkg; import StaticLint; import SymbolServer; env_path = dirname(Pkg.Types.Context().env.project_file); debug=false; server = LanguageServer.LanguageServerInstance(stdin, stdout, debug, env_path, "", Dict()); server.runlinter = true; run(server);'
return ale#Escape(l:julia_executable) . ' --startup-file=no --history-file=no -e ' . ale#Escape(l:cmd_string)
endfunction
call ale#linter#Define('julia', {
\ 'name': 'languageserver',
\ 'lsp': 'stdio',
\ 'executable': {b -> ale#Var(b, 'julia_executable')},
\ 'command': function('ale_linters#julia#languageserver#GetCommand'),
\ 'language': 'julia',
\ 'project_root': function('ale#julia#FindProjectRoot'),
\})
and have confirmed that the cmd_string works within a Julia REPL. But even when I explicitly call ALELint, I get no messages output. ALEInfo shows:
Current Filetype: julia
Available Linters: ['languageserver']
Enabled Linters: ['languageserver']
Suggested Fixers:
'remove_trailing_lines' - Remove all blank lines at the end of a file.
'trim_whitespace' - Remove all trailing whitespace characters at the end of every line.
Linter Variables:
Global Variables:
let g:ale_cache_executable_check_failures = v:null
let g:ale_change_sign_column_color = 0
let g:ale_command_wrapper = v:null
let g:ale_completion_delay = v:null
let g:ale_completion_enabled = 0
let g:ale_completion_max_suggestions = v:null
let g:ale_echo_cursor = 1
let g:ale_echo_msg_error_str = 'Error'
let g:ale_echo_msg_format = '%code: %%s'
let g:ale_echo_msg_info_str = 'Info'
let g:ale_echo_msg_warning_str = 'Warning'
let g:ale_enabled = 1
let g:ale_fix_on_save = 1
let g:ale_fixers = {'go': ['gofmt', 'goimports'], 'python': ['autopep8']}
let g:ale_history_enabled = 1
let g:ale_history_log_output = 1
let g:ale_keep_list_window_open = 0
let g:ale_lint_delay = 200
let g:ale_lint_on_enter = 1
let g:ale_lint_on_filetype_changed = 1
let g:ale_lint_on_insert_leave = 1
let g:ale_lint_on_save = 1
let g:ale_lint_on_text_changed = 'normal'
let g:ale_linter_aliases = {}
let g:ale_linters = {'go': ['gopls', 'golangci-lint'], 'julia': ['languageserver'], 'python': ['pyls'], 'md': ['mdl']}
let g:ale_linters_explicit = 0
let g:ale_list_vertical = 0
let g:ale_list_window_size = 10
let g:ale_loclist_msg_format = '%code: %%s'
let g:ale_lsp_root = {}
let g:ale_max_buffer_history_size = v:null
let g:ale_max_signs = -1
let g:ale_maximum_file_size = v:null
let g:ale_open_list = 0
let g:ale_pattern_options = v:null
let g:ale_pattern_options_enabled = v:null
let g:ale_set_balloons = 0
let g:ale_set_highlights = 1
let g:ale_set_loclist = 1
let g:ale_set_quickfix = 0
let g:ale_set_signs = 1
let g:ale_sign_column_always = 1
let g:ale_sign_error = 'â–º'
let g:ale_sign_info = 'â–º'
let g:ale_sign_offset = 1000000
let g:ale_sign_style_error = 'â–º'
let g:ale_sign_style_warning = 'â–º'
let g:ale_sign_warning = 'â–º'
let g:ale_statusline_format = v:null
let g:ale_type_map = {}
let g:ale_use_global_executables = v:null
let g:ale_virtualtext_cursor = 0
let g:ale_warn_about_trailing_blank_lines = 1
let g:ale_warn_about_trailing_whitespace = 1
Command History:
OK, if the directory in which the source file does not have .git, the linter won't start.
@sbromberger could not get it working in vim.
any directions?
@dchatterjee172 see above for the code I used in languageserver.vim. It's launching julia but it doesn't appear to actually be linting anything. I'm not sure how to debug this further.
Could we ask the Julia language server authors to please package a CLI for their language server so we don't have to keep constantly updating Julia code on our end to deal with breaking changes that seem to happen quite often?
So, I think the latest versions of LanguageServer and ALE work nicely together, but I don't know what functionality is exposed. Is there a way to test this? Autocompletion and ALEGoToDefinition, the two things I've tried, don't seem to be having any effect.
Here are a few of the channel messages (There are dozens of these that change only in the name of the Julia package):
7.400950 : looking for messages on channels
7.400968 on 0: Dropping message '[ Info: Tried to load OrderedCollections but failed to load from disc, re-caching.
'
7.400976 : SafeState: back to waiting, triggering SafeStateAgain
7.547185 RECV on 0(err): '[ Info: Tried to load Serialization but failed to load from disc, re-caching.
'
7.547199 : looking for messages on channels
7.547216 on 0: Dropping message '[ Info: Tried to load Serialization but failed to load from disc, re-caching.
'
For what it's worth, with LanguageServer 1.0.0 and the latest ALE, if I modify ale_linters/julia/languageserver.vim to, instead of using LanguageServer; do using LanguageServer, LanguageServer.SymbolServer;, I can at least get LanguageServer to run and spit something out into the channel.
It doesn't actually work though, and I often get this in my vim messages:
Error detected while processing function <SNR>79_VimOutputCallback[6]..<lambda>4[1]..ale#lsp#HandleMessage[30]..ale#lsp_linter#HandleLS
PResponse[8]..<SNR>74_HandleLSPDiagnostics[14]..ale#lsp#response#ReadDiagnostics:
line 35:
E712: Argument of map() must be a List or Dictionary
E712: Argument of map() must be a List or Dictionary
E712: Argument of map() must be a List or Dictionary
I suspect that might because of lines like this in the ch_logfile:
202.059395 RECV on 1(out): 'eference: s","relatedInformation":null}]},"jsonrpc":"2.0"}'
Here's an example of the kind of ch_logfiles I get:
https://gist.github.com/mhauru/546e13f851cbec56c8738d815b3348d3
I have (almost) exactly the same output with Elixir-LS.
VIM : 8.2.510
ALE commit : bbe5153f (master right now)
ElixirLS commit : 95c021f (master right now)
Error detected while processing function <SNR>89_VimOutputCallback[6]..<lambda>2[1]..ale#lsp#HandleMessage[30]..ale#lsp_linter#HandleLS
PResponse[8]..<SNR>84_HandleLSPDiagnostics[14]..ale#lsp#response#ReadDiagnostics:
line 5:
E712: Argument of map() must be a List or Dictionary
Can I help you with anything ? Logs ? Config ?
I don't know if this helps, but i have (neo)vim with LSP support working with Julia (1.3.1) working through Coc with the config below. Also reported here.
{
"languageserver":{
"julia":{
"command":"/usr/bin/julia",
"args":[
"--startup-file=no",
"--history-file=no",
"-e",
"using LanguageServer, Pkg, Sockets, SymbolServer; env_path = dirname(Pkg.Types.Context().env.project_file); server = LanguageServer.LanguageServerInstance(stdin, stdout, true, env_path, \"\"); server.runlinter = true; run(server);"
],
"filetypes":[
"julia"
]
}
}
}
In a terminal with following command works as well:
julia --startup-file=no --history-file=no -e 'using LanguageServer, Pkg, Sockets, SymbolServer; env_path = dirname(Pkg.Types.Context().env.project_file); server = LanguageServer.LanguageServerInstance(stdin, stdout, true, env_path, ""); server.runlinter = true; run(server);'
The boolean debug_mode argument has been removed from LanguageServerInstance.
julia-vscode/LanguageServer.jl@34d5bc6
Most helpful comment
Could we ask the Julia language server authors to please package a CLI for their language server so we don't have to keep constantly updating Julia code on our end to deal with breaking changes that seem to happen quite often?