dense-analysis / ale

Check syntax in Vim/Neovim asynchronously and fix files, with Language Server Protocol (LSP) support
BSD 2-Clause "Simplified" License
13.38k stars 1.42k forks source link

g:ale_filename_mappings doesn't work for elixir-ls #3492

Open giddie opened 3 years ago

giddie commented 3 years ago

Information

VIM version NVIM v0.4.4 Build type: Release

Operating System: ArchLinux

What went wrong

With the following config:

let g:ale_filename_mappings = {
\  'elixir-ls': [
\    ['/home/dannpg/Work/project', '/opt/app']
\  ]
\}

I see the following output from elixir-ls:

{"jsonrpc":"2.0","method":"window/logMessage","params":{"message":"\n10:29:34.893 [error] GenServer ElixirLS.LanguageServer.Server terminating\n** (File.Error) could not set current working directory to \"/home/dannpg/Work/project\": no such file or directory\n    (elixir 1.10.3) lib/file.ex:1523: File.cd!/1\n    (language_server 0.6.2) lib/language_server/serve ...

If I set:

let g:ale_lsp_root = {'elixir-ls': '/opt/app'}

Then elixir-ls operates OK, but it reports the docker paths (/opt/app), so Vim is unable to jump to the correct file.

:ALEInfo

 Current Filetype: elixir
Available Linters: ['credo', 'dialyxir', 'dogma', 'elixir-ls', 'mix']
  Enabled Linters: ['credo', 'elixir-ls']
  Ignored Linters: []
 Suggested Fixers: 
  'mix_format' - Apply mix format to a file.
  '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:

let g:ale_elixir_elixir_ls_config = {'elixirLS': {'dialyzerEnabled': v:false}}
let g:ale_elixir_elixir_ls_release = '.vim-config/elixir-ls-wrappers'
 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 = v:null
let g:ale_completion_enabled = 0
let g:ale_completion_max_suggestions = v:null
let g:ale_disable_lsp = 0
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 = {'elixir': ['mix_format'], 'ruby': ['rufo'], 'javascript': ['prettier', 'eslint'], 'rust': ['rustfmt']}
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 = {'elixir': ['credo', 'elixir-ls'], 'ruby': ['rubocop', 'ruby'], 'typescript': ['tsserver']}
let g:ale_linters_explicit = 0
let g:ale_linters_ignore = {}
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 = 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 = 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_sign_highlight_linenrs = 0
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:

(executable check - success) mix
(finished - exit code 0) ['/bin/zsh', '-c', 'cd ''/home/dannpg/Work/project'' && mix help credo && mix credo suggest --format=flycheck --read-from-stdin ''/home/dannpg/Work/project/lib/app/model.ex'' < ''/tmp/nvimdGKJSV/3/payments.ex''']

<<<OUTPUT STARTS>>>
# mix credo

Run code analysis (use `--help` for options)

Location: _build/dev/lib/credo/ebin
<<<OUTPUT ENDS>>>

(executable check - success) .vim-config/elixir-ls-wrappers/language_server.sh
giddie commented 3 years ago

Any pointers or ideas where I should start looking in the code to solve this?

vmsh0 commented 1 year ago

I am also seeing this for ccls. I have the following:

let g:ale_c_ccls_executable = "./ccls-wrapper.sh"
let g:ale_linters = ['ccls']
let g:ale_filename_mappings = {
\ 'ccls': [
\   ['/home/random/acc/eit/lpwan/lab2/pingping', '/data'],
\ ],
\}

The following is ccls-wrapper.sh:

#!/bin/sh
exec docker run -i --rm -v "$(pwd):/data" -w "/data" contiki ccls --log-file=ccls.log $@

ccls.log:

15:04:55 ccls           initialize.cc:274 I initialize in directory /home/random/acc/eit/lpwan/lab2/pingping with uri file:///home/random/acc/eit/lpwan/lab2/pingping
15:04:55 ccls           initialize.cc:297 I initializationOptions: {"compilationDatabaseCommand":"","compilationDatabaseDirectory":"/home/random/acc/eit/lpwan/lab2/pingping","cache":{"directory":".ccls-cache","format":"binary","hierarchicalPath":false,"retainInMemory":2},"capabilities":{"documentOnTypeFormattingProvider":{"firstTriggerCharacter":"}","moreTriggerCharacter":[]},"foldingRangeProvider":true,"workspace":{"workspaceFolders":{"supported":true,"changeNotifications":true}}},"clang":{"excludeArgs":[],"extraArgs":[],"pathMappings":[],"resourceDir":""},"client":{"diagnosticsRelatedInformation":true,"hierarchicalDocumentSymbolSupport":true,"linkSupport":true,"snippetSupport":true},"codeLens":{"localVariables":true},"completion":{"caseSensitivity":2,"detailedLabel":true,"dropOldRequests":true,"duplicateOptional":true,"filterAndSort":true,"include":{"blacklist":[],"maxPathSize":30,"suffixWhitelist":[".h",".hpp",".hh",".inc"],"whitelist":[]},"maxNum":100,"placeholder":true},"diagnostics":{"blacklist":[],"onChange":1000,"onOpen":0,"onSave":0,"spellChecking":true,"whitelist":[]},"highlight":{"largeFileSize":2097152,"lsRanges":false,"blacklist":[],"whitelist":[]},"index":{"blacklist":[],"comments":2,"initialNoLinkage":false,"initialBlacklist":[],"initialWhitelist":[],"maxInitializerLines":5,"multiVersion":0,"multiVersionBlacklist":[],"multiVersionWhitelist":[],"name":{"suppressUnwrittenScope":false},"onChange":false,"parametersInDeclarations":true,"threads":0,"trackDependency":2,"whitelist":[]},"request":{"timeout":5000},"session":{"maxNum":10},"workspaceSymbol":{"caseSensitivity":1,"maxNum":1000,"sort":true},"xref":{"maxNum":2000}}
15:04:55 ccls           initialize.cc:329 I use -resource-dir=/usr/include/clang/12
15:04:55 ccls           initialize.cc:363 I workspace folder: /home/random/acc/eit/lpwan/lab2/pingping/ -> /home/random/acc/eit/lpwan/lab2/pingping//
15:04:55 ccls           initialize.cc:386 I start 8 indexers
15:04:55 ccls           initialize.cc:394 I dispatch initial index requests
15:04:55 ccls             pipeline.cc:493 I loaded project. Refresh semantic highlight for all working file.
15:04:55 preamble     sema_manager.cc:763 I create session for /home/random/acc/eit/lpwan/lab2/pingping/node.c
15:04:55 indexer1         pipeline.cc:386 I delete /home/random/acc/eit/lpwan/lab2/pingping/node.c