Vim arduino-language -server integration

Hi, I'm trying to integrate the arduino language server, arduino/arduino-language-server, with vim/ale. I don't know very well how to use an LSP, but i managed, to some extent, to have some form of linting in the editor but lacks of any form of completion

This are the step to reproduce what i have:

  1. Install ale vim via plug
  2. install arduino-cli from repository (my version is 0.18.1-arch)
  3. clone the repository for arduino language server
  4. configure ale to use arduino language server (see below)
  5. i've also put the binaries and libraries for clangd, the indexing and the normal one, clangd/releases/tag/12.0.0 in the /usr/bin and /usr/lib

the configuration, in .vimrc:

let g:ale_completion_enabled = 1
let g:ale_completion_autoimport = 1
set omnifunc=ale#completion#OmniFunc
set completeopt=menu,menuone,popup,noselect,noinsert

let g:ale_linters = { 'cpp': ['clangd'] }
let g:ale_fixers = { 'cpp': [ 'clang-format' ] }
call ale#linter#Define('arduino', {
                        \   'name': 'arduino_LSP',
						\	'lsp': 'stdio',
                        \   'executable': 'MY_PATH/arduino-language-server/arduino-language-server',
                        \   'command': '%e -board-name uno -cli-config $HOME/.arduino15/arduino-cli.yaml -log',
						\   'project_root': FindSessionDirectory(),
						\   'callback': {buffer, lines -> map(lines, '{"text": v:val, "lnum": 1}')},
                        \})

In the log there is a lot of failure to start the arduino language server like:

2021/05/14 06:50:33 arduino-cli output: {
  "compiler_out": "",
  "compiler_err": "",
  "builder_result": {
    "build_path": "/tmp/arduino-language-server778687580"
  },
  "success": false
}

these are the log error:
inols-clangd-err.log
inols-err.log

here is the :ALEInfo result

 Current Filetype: arduino                                                                       
Available Linters: ['arduino_LSP']
  Enabled Linters: ['arduino_LSP']
  Ignored Linters: []
 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_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 = 0
let g:ale_fixers = {'cpp': ['clang-format']}
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 = {'cpp': ['clangd']}
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_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_root = {}
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_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) /home/USER/clone/arduino-language-server/arduino-language-server
(started) ['/usr/bin/zsh', '-c', '''/home/USER/clone/arduino-language-server/arduino-language-server'' -board
-name uno -cli-config $HOME/.arduino15/arduino-cli.yaml -log']

how can i solve or debug this?

there are the other logs

inols.log
inols-clangd.log

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.