Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

coc-clangd doesnt start on .ino files #1

Closed
drank40 opened this issue Oct 4, 2022 · 3 comments
Closed

coc-clangd doesnt start on .ino files #1

drank40 opened this issue Oct 4, 2022 · 3 comments

Comments

@drank40
Copy link

drank40 commented Oct 4, 2022

Even after adding

let g:coc_filetype_map = {
  \ 'ino': 'cpp',
  \ }

to my init.vim and generating a valid compile_commands.json inside of the sketch folder coc-clangd doesnt seem to start. Heres my :CocInfo :

vim version: NVIM v0.8.0
node version: v18.10.0
coc.nvim version: 0.0.81-bf505641 2022-07-30 19:03:27 +0800
coc.nvim directory: /home/(me)/.vim/plugged/coc.nvim
term: rxvt-unicode-256color
platform: linux

## Log of coc.nvim

2022-10-04T14:24:56.933 INFO (pid:38688) [plugin] - coc.nvim initialized with node: v18.10.0 after 180ms
2022-10-04T14:24:56.993 INFO (pid:38688) [services] - registered service "clangd"
2022-10-04T14:24:57.046 INFO (pid:38688) [attach] - receive notification: highlight []
2022-10-04T14:24:59.586 INFO (pid:38688) [attach] - receive notification: showInfo []

Am I missing something?

@adamansky
Copy link
Member

adamansky commented Oct 5, 2022

May be interference with other plugins? I've disabled all arduino related plugins like stevearc/vim-arduino. Also check :CocCommand document.echoFileType

Also try the following

augroup user_files
  autocmd!
  autocmd BufNewFile,BufRead *.ino setl filetype=cpp
augroup END

@drank40
Copy link
Author

drank40 commented Oct 5, 2022

:CocCommand document.echoFileType returns [coc.nvim] Error on notification "runCommand" : Command: document.echoFileType not found . I also tried running the same command on .c file where clangd works and it resulted in the same error.

After running the snippet you provided .ino files seem to be acknowledged by clangd (even though highlighting was turned off for some reason), yet I got some errors from clangd:

[clang drv_unknown_argument] [E] Unknown argument : '-fno-tree-switch-conversion'
[clang drv_unknown_argument] [E] Unknown argument : '-fstrict-volatile-bitfields'
[clang drv_unknown_argument] [E] Unknown argument : '-mlongcalls'; did you mean '-mlong-calls'?

These error messages apperared at the very top of my file. It also flagged arduino specific funtions like digitalWrite, aswell as consts like LED_BUILTIN as invalid.

The default compiler for my system is g++, if that bares any relevance.

EDIT:

After manually removing those flags from compile_commands.json the other errors still persist

@drank40 drank40 closed this as completed Nov 7, 2022
@atrosekta
Copy link

atrosekta commented Nov 19, 2022

also had the same issue (just clang not starting, not clang's errors), this snippet in my coc-settings.json fixed it :

"languageserver":{
  "arduino":{
    "command":"clangd",
    "rootPatterns":["compile_commands.json"],
    "filetypes":["arduino"]
  }
}

but removing stevearc/vim-arduino seems to also fix it

( and maybe it will save some time to someone but you need to include Arduino.h to access things like pinMode() or Serial )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants