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

how to set coc config clangd.path to wsl clangd in windows , because win version clangd.exe always crash #484

Open
WillDawnlll opened this issue Jul 19, 2022 · 4 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@WillDawnlll
Copy link

i test these configs , and all not work :
1 . set "clangd.path" to "wsl clangd" ,
2. set "clangd.path "\wsl$\Debian\usr\local\bin\calngd" ,
3. or "d:/tool/wsl_clangd.bat" (just "wsl clangd")

i not familiar with js , but simply check the code , may be the reason is clangd execute bin path append ".exe" in windows ?

@WillDawnlll WillDawnlll added the enhancement New feature or request label Jul 19, 2022
@sim590
Copy link

sim590 commented Jul 29, 2022

I would like to do something similar. Except that my approach would be to make clangd.exe work since the code base I'm compiling has some windows exclusive instructions, therefore I need Windows' clangd to work. I can't use WSL's.

I get this log when I try to open some C++ file:

CocInfo output
## versions

vim version: VIM - Vi IMproved 8.2 8024793
node version: v16.15.1
coc.nvim version: 0.0.81-093e4300 2022-06-04 17:10:20 -0700
coc.nvim directory: /home/simon/.vim/plugged/coc.nvim
term: dumb
platform: linux

## Log of coc.nvim

2022-07-29T12:22:20.762 INFO (pid:4080) [configurations] - Add folder configuration from cwd: /home/simon/some/project/path/.vim/coc-settings.json
2022-07-29T12:22:20.763 INFO (pid:4080) [configurations] - Change folder configuration from cwd to: /home/simon/some/project/path/.vim/coc-settings.json
2022-07-29T12:22:20.895 INFO (pid:4080) [services] - registered service "languageserver.clangd"
2022-07-29T12:22:20.895 INFO (pid:4080) [services] - registered service "languageserver.haskell"
2022-07-29T12:22:20.896 INFO (pid:4080) [plugin] - coc.nvim initialized with node: v16.15.1 after 38ms
2022-07-29T12:22:24.947 INFO (pid:4080) [services] - clangd state change: stopped => starting
2022-07-29T12:22:25.013 INFO (pid:4080) [services] - clangd state change: starting => stopped
2022-07-29T12:22:25.021 ERROR (pid:4080) [services] - Server languageserver.clangd failed to start: Launching server "languageserver.clangd" using command /mnt/c/Program\ Files/LLVM/bin/clang.exe failed.
2022-07-29T12:22:25.022 ERROR (pid:4080) [language-client-index] - Error: spawn /mnt/c/Program\ Files/LLVM/bin/clang.exe ENOENT
    at Process.ChildProcess._handle.onexit (node:internal/child_process:283:19)
    at onErrorNT (node:internal/child_process:478:16)
    at processTicksAndRejections (node:internal/process/task_queues:83:21) {
  errno: -2,
  code: 'ENOENT',
  syscall: 'spawn /mnt/c/Program\\ Files/LLVM/bin/clang.exe',
  path: '/mnt/c/Program\\ Files/LLVM/bin/clang.exe',
  spawnargs: []
}
2022-07-29T12:22:25.442 INFO (pid:4080) [attach] - receive notification: highlight []
2022-07-29T12:22:33.732 INFO (pid:4080) [attach] - receive notification: highlight []
2022-07-29T12:22:35.658 INFO (pid:4080) [attach] - receive notification: highlight []
2022-07-29T12:22:41.064 INFO (pid:4080) [attach] - Request action: fillDiagnostics [ 1 ]
2022-07-29T12:22:41.385 INFO (pid:4080) [attach] - receive notification: highlight []
2022-07-29T12:22:42.572 INFO (pid:4080) [attach] - receive notification: highlight []
2022-07-29T12:22:42.939 INFO (pid:4080) [attach] - receive notification: highlight []
2022-07-29T12:22:49.109 INFO (pid:4080) [attach] - receive notification: showInfo []

with the following config:

CocLocalConfig
{
    "languageserver": {
        "clangd": {
            "command": "/mnt/c/Program\\ Files/LLVM/bin/clang.exe",
            "rootPatterns": ["compile_flags.txt", "compile_commands.json"],
            "filetypes": ["c", "cc", "cpp", "c++", "objc", "objcpp"]
        }
    }
}

@sim590
Copy link

sim590 commented Jul 29, 2022

I've just realized that my config did not make use of coc-clangd. However, I tried:

{
    "clangd": {
        "path": "clangd.exe"
    }
}

but I got the following message:

[coc.nvim] clangd was not found on your PATH. :CocCommand clangd.install will install 14.0.3.

I also tried with:

"path": "/mnt/c/Program\\ Files/LLVM/bin/clang.exe"

and it didn't change anything.

@fannheyward fannheyward added the help wanted Extra attention is needed label Aug 12, 2022
@fannheyward
Copy link
Member

Sorry I don't have a Window env to test.

@CoreyCole
Copy link

CoreyCole commented Aug 19, 2022

@sim590 if you run nvim server on the wsl, then you can use msys clangd.exe on the windows side

which clangd
/mingw64/bin/clangd

^ On windows powershell shell on Windows Terminal

sim590 added a commit to sim590/dotfiles that referenced this issue Sep 29, 2022
Issues surrounding calling clangd.exe prevents coc.vim to work with
clangd for Windows based projects.

It could be enabled locally for any other non-Windows project with
:CocLocalConfig.

clangd/coc-clangd#484
sim590 added a commit to sim590/dotfiles that referenced this issue Sep 29, 2022
Issues surrounding calling clangd.exe prevents coc.vim to work with
clangd for Windows based projects.

It could be enabled locally for any other non-Windows project with
:CocLocalConfig.

clangd/coc-clangd#484
sim590 added a commit to sim590/dotfiles that referenced this issue Mar 2, 2023
Issues surrounding calling clangd.exe prevents coc.vim to work with
clangd for Windows based projects.

It could be enabled locally for any other non-Windows project with
:CocLocalConfig.

clangd/coc-clangd#484
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

4 participants