clangd / coc-clangd Goto Github PK
View Code? Open in Web Editor NEWclangd extension for coc.nvim
License: Apache License 2.0
clangd extension for coc.nvim
License: Apache License 2.0
Hi there.
since I work in ros platform I want to add the headers of the ros(/opt/ros/kinetic/include/**) to my default include path of language servers for ros projects. with out this option, at the beginning of each project I must add a dummy ros node(is ros node means a cpp file), and compile with catkin_make -DCMAKE_EXPORT_COMPILE_COMMANDS=YES
to generate the compile_commands.json file to get access to ros headers in the completion list.
the contents of my coc-setting file, is as below:
{
"languageserver": {
"clangd": {
"command": "clangd",
"rootPatterns": ["compile_flags.txt", "compile_commands.json"],
"filetypes": ["c", "cpp", "objc", "objcpp"]
},
"cquery": {
"command": "/home/amirrezasadeghi/ManBuildLibs/cquery/build/cquery",
"args": ["--log-file=/tmp/cq.log"],
"filetypes": ["c", "cpp"],
"rootPatterns": ["compile_flags.txt", "compile_commands.json", ".git/", ".hg/"],
"initializationOptions": {
"cacheDirectory": "/tmp/cquery"
}
},
"ccls": {
"command": "ccls",
"filetypes": ["c", "cpp", "objc", "objcpp"],
"rootPatterns": [".ccls", "compile_commands.json", ".git/", ".hg/"],
"initializationOptions": {
"cache": {
"directory": "/tmp/ccls"
}
}
}
},
"clangd.semanticHighlighting": true
}
So my major question is how to add ros include path to these settings. I checked the wiki page of coc.nvim but can't find any option for user include path. also, I checked the option of clangd and tried to add,
"args":["-I/opt/ros/kinetic/include/"]
,
to the corresponding block but it did not work. also, I added .cquery file, but still no effect on the list of the proposed headers.
sorry for long story, and thanks for your time.
Edit: it would be better to use the clangd LSP rather than ccls. because it is faster and has better documentation. thanks!
There is an option in the LSP called initializationOptions.fallbackFlags
which allows you to pass some fallback compile flags via the LSP if no infos is found in the compile_commands.json
.
Would it be possible to enable that?
My problem is that I'm compiling some .cu
files to some .ptx
and CMake doesn't register the compilation flags given to nvcc
for those files into the compile_commands.json
. Therefore clangd
raises a bunch of errors due to missing flags (-std=c++11
among others).
I'm running Coc.nvim in VIM8 and trying to use coc-clangd as the LSP for autocomplete. Autocomplete doesn't seem to work for larger projects with dependencies spread across directories. It works fine with small projects where all .cpp and .h files are in the same directory.
I have created a compile_commands.json file with xcodebuild and xcpretty. But clangd doesn't seem to use it. I have tried putting the .json file all throughout the project directory to no avail.
My :CocConfig is empty as directed by docs to avoid running clangd twice.
Should I be making config entries, and if so how do I do so and avoid the "You should remove it" error?
Clangd version 10.0.0
MacOS: 10.15.5
## versions
vim version: VIM - Vi IMproved 8.1 8012250
node version: v13.13.0
coc.nvim version: 0.0.78-2407993395
coc.nvim directory: /Users/brianarne/.vim/plugged/coc.nvim
term: iTerm.app
platform: darwin
## Output channel: clangd log
I[22:35:52.414] clangd version 10.0.0
I[22:35:52.414] PID: 37798
I[22:35:52.414] Working directory: /Users/brianarne/Projects/Tremelo/Source
I[22:35:52.414] argv[0]: /usr/local/opt/llvm/bin/clangd
I[22:35:52.414] Starting LSP over stdin/stdout
I[22:35:52.415] <-- initialize(0)
I[22:35:52.432] --> reply:initialize(0) 16 ms
I[22:35:52.435] <-- initialized
I[22:35:52.435] unhandled notification initialized
I[22:35:52.437] <-- textDocument/didOpen
I[22:35:52.438] Enqueueing 2 commands for indexing
I[22:35:52.440] --> textDocument/clangd.fileStatus
I[22:35:52.440] Updating file /Users/brianarne/Projects/Tremelo/Source/PluginEditor.h with command inferred from /Users/brianarne/Projects/Tremelo/Source/PluginEditor.cpp
[/]
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -target x86_64-apple-macos10.11 -fmessage-length=0 -fdiagnostics-show-note-include-stack -fmacro-backtrace-limit=0 -stdlib=libc++ -Wno-trigraphs -fpascal-strings -O0 -fno-common -Wno-missing-field-initializers -Wno-missing-prototypes -Wunreachable-code -Wnon-virtual-dtor -Wno-overloaded-virtual -Wno-exit-time-destructors -Wno-missing-braces -Wparentheses -Wswitch -Wunused-function -Wno-unused-label -Wno-unused-parameter -Wunused-variable -Wunused-value -Wempty-body -Wuninitialized -Wno-unknown-pragmas -Wno-shadow -Wno-four-char-constants -Wno-conversion -Wconstant-conversion -Wint-conversion -Wbool-conversion -Wenum-conversion -Wno-float-conversion -Wnon-literal-null-conversion -Wobjc-literal-conversion -Wshorten-64-to-32 -Wno-newline-eof -Wno-c++11-extensions -D_DEBUG=1 -DDEBUG=1 -DJUCER_XCODE_MAC_F6D2F4CF=1 -DJUCE_APP_VERSION=1.0.0 -DJUCE_APP_VERSION_HEX=0x10000 -DJucePlugin_Build_VST=0 -DJucePlugin_Build_VST3=1 -DJucePlugin_Build_AU=1 -DJucePlugin_Build_AUv3=0 -DJucePlugin_Build_RTAS=0 -DJucePlugin_Build_AAX=0 -DJucePlugin_Build_Standalone=1 -DJucePlugin_Build_Unity=0 -DJUCE_SHARED_CODE=1 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk -fasm-blocks -fstrict-aliasing -Wdeprecated-declarations -Winvalid-offsetof -g -fvisibility-inlines-hidden -Wno-sign-conversion -Winfinite-recursion -Wmove -Wcomma -Wblock-capture-autoreleasing -Wstrict-prototypes -Wrange-loop-analysis -Wno-semicolon-before-method-body -I/Users/brianarne/Projects/Tremelo/Builds/MacOSX/build/Debug/include -I/Users/brianarne/JUCE/modules/juce_audio_processors/format_types/VST3_SDK -I../../JuceLibraryCode -I/Users/brianarne/JUCE/modules -I/Users/brianarne/JUCE/modules/juce_audio_plugin_client -I/Users/brianarne/Projects/Tremelo/Builds/MacOSX/build/Tremelo.build/Debug/Tremelo - Shared Code.build/DerivedSources-normal/x86_64 -I/Users/brianarne/Projects/Tremelo/Builds/MacOSX/build/Tremelo.build/Debug/Tremelo - Shared Code.build/DerivedSources/x86_64 -I/Users/brianarne/Projects/Tremelo/Builds/MacOSX/build/Tremelo.build/Debug/Tremelo - Shared Code.build/DerivedSources -Wreorder -F/Users/brianarne/Projects/Tremelo/Builds/MacOSX/build/Debug --serialize-diagnostics /Users/brianarne/Projects/Tremelo/Builds/MacOSX/build/Tremelo.build/Debug/Tremelo - Shared Code.build/Objects-normal/x86_64/PluginEditor.dia -c -x c++-header -std=c++14 /Users/brianarne/Projects/Tremelo/Source/PluginEditor.h -fsyntax-only -resource-dir=/usr/local/Cellar/llvm/10.0.0_3/lib/clang/10.0.0
I[22:35:52.468] --> textDocument/publishDiagnostics
I[22:35:52.468] --> textDocument/clangd.fileStatus
## Output channel: watchman
[Info - 10:35:52 PM] watchman watching project: /Users/brianarne/Projects/Tremelo
[Info - 10:35:52 PM] subscribing "**/{compile_commands.json,compile_flags.txt,.clang-tidy}" in /Users/brianarne/Projects/Tremelo
Every time when I rebuild project (compile_commands.json is modified), I get this messages:
run :CocInstall coc-clangd but return [coc.nvim] clangd is not found, please check it . Thanks&Brs.
When I type :CocInstall coc-clangd, then it shows error:
✗ coc-clangd unable to get local issuer certificate
Also, in case of :CocCommand clangd.install, then it shows that:
[coc.nvim] Command: clangd.install not found
So how can I fix this?
https://asciinema.org/a/mMoz3YPbQ7oxNaFsjhoYYSBoF
https://gist.github.com/zlianon/fa6ebbaf296c97c2ca7cce73e033b663
{
"coc.preferences.extensionUpdateCheck": "never",
"coc.source.around.enable": false,
"coc.source.buffer.enable": false,
"diagnostic.enable": false,
"suggest.minTriggerInputLength": 2,
"suggest.timeout": 15000,
"clangd.showDBChangedNotification": false,
"clangd.arguments": [
"--header-insertion=never",
"--limit-results=50",
"--log=verbose"
],
"clangd.fallbackFlags": [
"-std=c++17"
]
}
let g:coc_global_extensions = [
\ 'coc-clangd',
\ 'coc-cmake',
\ 'coc-json'
\]
Line content gets deleted but not the line itself.
Whenever quitting Insert mode and the cursor happens to be on a line which has content, as if there is a mapping doing something like this:
imap <Esc> <S-v>s<Esc>
Obviously, there is no such mapping.
This happens on .c, .h and .hpp files (not on .cpp), only when coc-clangd is installed and on all lines except the first of the file.
{
"coc.preferences.formatOnInsertLeave": true,
"coc.preferences.formatOnType": true,
"coc.preferences.formatOnSaveFiletypes": [
"json",
"go",
"c",
"py",
"cpp",
"java"
],
"suggest.completionItemKindLabels": {
"keyword": "\uf1de",
"variable": "\ue79b",
"value": "\uf89f",
"operator": "\u03a8",
"function": "\u0192",
"reference": "\ufa46",
"constant": "\uf8fe",
"method": "\uf09a",
"struct": "\ufb44",
"class": "\uf0e8",
"interface": "\uf417",
"text": "\ue612",
"enum": "\uf435",
"enumMember": "\uf02b",
"module": "\uf40d",
"color": "\ue22b",
"property": "\ue624",
"field": "\uf9be",
"unit": "\uf475",
"event": "\ufacd",
"file": "\uf723",
"folder": "\uf114",
"snippet": "\ue60b",
"typeParameter": "\uf728",
"default": "\uf29c"
},
"diagnostic.errorSign": "✘",
"diagnostic.warningSign": "",
"diagnostic.infoSign": "",
"codeLens.enable": true,
"coc.preferences.currentFunctionSymbolAutoUpdate": true,
"git.enableGutters": true,
"git.realtimeGutters": true
}
set nobackup
set nowritebackup
set cmdheight=2
set updatetime=300
set shortmess+=c
set signcolumn=yescommand! -nargs=0 Prettier :CocCommand prettier.formatFile
inoremap
\ pumvisible() ? coc#_select_confirm() :
\ coc#expandableOrJumpable() ? "<C-r>=coc#rpc#request('doKeymap', ['snippets-expand-jump',''])<CR>" :
\ check_back_space() ? "<TAB>" :
\ coc#refresh()
inoremap pumvisible() ? "<C-n>" : "<C-h>"function! s:check_back_space() abort
let col = col('.') - 1
return !col || getline('.')[col - 1] =~# '\s'
endfunctionlet g:coc_snippet_next = ''
inoremap coc#refresh()
nmap [g (coc-diagnostic-prev)
nmap ]g (coc-diagnostic-next)nmap gd (coc-definition)
nmap gy (coc-type-definition)
nmap gi (coc-implementation)
nmap gr (coc-references)nnoremap K :call show_documentation()
function! s:show_documentation()
if (index(['vim', 'help'], &filetype) >= 0)
execute 'h '.expand('')
else
call CocAction('doHover')
endif
endfunctionautocmd CursorHold * silent call CocActionAsync('highlight')
nmap rn (coc-rename)
xmap f (coc-format-selected)
nmap f (coc-format-selected)nmap ca (coc-codeaction)
nmap cf (coc-fix-current)xmap if (coc-funcobj-i)
xmap af (coc-funcobj-a)
omap if (coc-funcobj-i)
omap af (coc-funcobj-a)nmap (coc-range-select)
xmap (coc-range-select)command! -nargs=0 Format :call CocAction('format')
command! -nargs=? Fold :call CocAction('fold', )
command! -nargs=0 OR :call CocAction('runCommand', 'editor.action.organizeImport')
OS: Void Linux, nvim v0.4.3, node v13.2.0
I'm using
## versions
vim version: NVIM v0.4.3
node version: v10.19.0
coc.nvim version: 0.0.78-030aef2f6d
term: xterm-256color
platform: linux
## Output channel: clangd log
I[10:09:10.793] clangd version 9.0.1-6+build1
I[10:09:10.793] Working directory: /home/jgm/github/devjgm/1.google-cloud-cpp
I[10:09:10.793] argv[0]: /usr/bin/clangd-9
I[10:09:10.793] argv[1]: --clang-tidy
I[10:09:10.793] Starting LSP over stdin/stdout
I[10:09:10.793] <-- initialize(0)
I[10:09:10.793] --> reply:initialize(0) 0 ms
I[10:09:10.796] <-- initialized
I[10:09:10.796] unhandled notification initialized
I[10:09:10.800] <-- textDocument/didOpen
I[10:09:10.837] Enqueueing 0 commands for indexing
I[10:09:10.838] --> textDocument/clangd.fileStatus
I[10:09:10.838] Updating file /home/jgm/github/devjgm/1.google-cloud-cpp/google/cloud/storage/examples/storage_object_samples.cc with command
[/home/jgm/.cache/bazel/_bazel_jgm/4093e63c64f71d5f52e8106e868bfd84/execroot/com_github_googleapis_google_cloud_cpp]
/usr/bin/clang -U_FORTIFY_SOURCE -fstack-protector -Wall -Wthread-safety -Wself-assign -fno-omit-frame-pointer -std=c++0x -DGRPC_BAZEL_BUILD -no-canonical-prefixes -Wno-builtin-macro-redefined -D__DATE__=redacted -D__TIMESTAMP__=redacted -D__TIME__=redacted -DCURL_STATICLIB -isystem google/cloud/storage -isystem bazel-out/k8-fastbuild/bin/google/cloud/storage -isystem external/boringssl/src/include -isystem bazel-out/k8-fastbuild/bin/external/boringssl/src/include -isystem external/com_github_curl_curl/include -isystem bazel-out/k8-fastbuild/bin/external/com_github_curl_curl/include -isystem external/zlib -isystem bazel-out/k8-fastbuild/bin/external/zlib -isystem external/com_github_google_crc32c/include -isystem bazel-out/k8-fastbuild/bin/external/com_github_google_crc32c/include -isystem external/com_google_googletest/googlemock -isystem bazel-out/k8-fastbuild/bin/external/com_google_googletest/googlemock -isystem external/com_google_googletest/googlemock/include -isystem bazel-out/k8-fastbuild/bin/external/com_google_googletest/googlemock/include -isystem external/com_google_googletest/googletest -isystem bazel-out/k8-fastbuild/bin/external/com_google_googletest/googletest -isystem external/com_google_googletest/googletest/include -isystem bazel-out/k8-fastbuild/bin/external/com_google_googletest/googletest/include -iquote . -iquote bazel-out/k8-fastbuild/bin -iquote external/boringssl -iquote bazel-out/k8-fastbuild/bin/external/boringssl -iquote external/com_github_curl_curl -iquote bazel-out/k8-fastbuild/bin/external/com_github_curl_curl -iquote external/zlib -iquote bazel-out/k8-fastbuild/bin/external/zlib -iquote external/com_github_google_crc32c -iquote bazel-out/k8-fastbuild/bin/external/com_github_google_crc32c -iquote external/com_google_googletest -iquote bazel-out/k8-fastbuild/bin/external/com_google_googletest -iquote external/bazel_tools -iquote bazel-out/k8-fastbuild/bin/external/bazel_tools -I /usr/local/include -I /usr/lib/llvm-8/lib/clang/8.0.1/include -I /usr/include/x86_64-linux-gnu -I /usr/include -I /usr/lib/llvm-8/lib/clang/8.0.1/share -I /usr/include/c++/9 -I /usr/include/x86_64-linux-gnu/c++/9 -I /usr/include/c++/9/backward -I /usr/include/clang/8.0.1/include -I /usr/lib/clang/8.0.1/include -x c++ -c google/cloud/storage/examples/storage_object_samples.cc -fsyntax-only -resource-dir=/usr/lib/llvm-9/lib/clang/9.0.1
I[10:09:12.434] --> textDocument/publishDiagnostics
I[10:09:12.437] --> textDocument/clangd.fileStatus
I[10:09:24.185] <-- textDocument/documentHighlight(1)
I[10:09:24.189] --> reply:textDocument/documentHighlight(1) 4 ms
I[10:09:24.189] --> textDocument/clangd.fileStatus
and coc-clangd 0.3.4
.
I have gy
mapped to nmap <silent> gy <Plug>(coc-type-definition)
And in a C++ file, when the cursor is on a symbol, and I type gy
, I get the error:
[coc.nvim] Type definition provider not found for current document
The behavior I would expect is that I'd see the type information for the symbol under the cursor. This behavior works in clangd + YCM. Is it expected to work with coc-clangd as well?
I'm struggling with this problem for hours.
As far as I know, clangd doesn't have -style
option unlike clang-format and there's no way to set my custom format in my coc.nvim + coc-clang environment (I found -fallback-style
option but it is not customizable because it is a kind of presets).
So, is there any way to set a global formating option like vim-clang-format?
My clangd executable is available under /usr/bin, but coc-clangd is unable to locate the executable, telling me that it is not in the PATH. It is similar to #32 but is slightly different because in my case clangd is in one of the standard binary locations. I suspect the issue comes from the choice of shell (I use fish and my bashrc is empty) and that something uses bash exclusively without reading the proper PATH; however I am not sure because I use fish as login shell and PATH should therefore theoretically be available to all subsequent commands.
If that is the case and there is no other way around it, my workaround in mind is to somehow let bash exec fish then exec bash to get the PATH definitions from fish.
Logs
The log from :CocList output
is empty.
System information
/usr/bin/clangd: 10.0.0
coc-clangd version: (it does not show in CocInfo, got it from CocUpdate) 0.4.10
node: 14.4.0
nvim: 0.4.3
coc.nvim: 0.0.78-2407993395
shell: fish 3.1.2 (login shell), bash 5.0.17-1
uname -mrs
: Linux 5.7.2-zen1-1-zen x86_64
Here's the documentation from lsp spec:
/**
* The list of all possible characters that commit a completion. This field can be used
* if clients don't support individual commit characters per completion item. See
* `ClientCapabilities.textDocument.completion.completionItem.commitCharactersSupport`.
*
* If a server provides both `allCommitCharacters` and commit characters on an individual
* completion item the ones on the completion item win.
*
* @since 3.2.0
*/
allCommitCharacters?: string[];
clangd started sending this out in its completionProvider
field recently, but it seems like CoC doesn't fall back to allCommitCharacters
when completionItem
doesn't have individual commit characters.
This results in only being able to commit a completion with hitting enter.
OS: win10
gcc version 7.3.0 (x86_64-posix-sjlj-rev0, Built by MinGW-W64 project)
clangd version 7.0.0 (tags/RELEASE_700/final)
compile_flags.txt
-isystem
D:\Program\mingw64\lib\gcc\x86_64-w64-mingw32\7.3.0\include\c++
-isystem
D:\Program\mingw64\lib\gcc\x86_64-w64-mingw32\7.3.0\include\c++\profile
-isystem
D:\Program\mingw64\lib\gcc\x86_64-w64-mingw32\7.3.0\include\c++\debug
-isystem
D:\Program\mingw64\lib\gcc\x86_64-w64-mingw32\7.3.0\include\c++\experimental
ex: clangd.disableSnippet
, default false
?
I tired :CocCommand clangd.install to get clangd rather than using apt-get. It installed, but could not run because of the following error:
## Output channel: clangd
[Error - 2:27:16 PM] /mnt/harmonix_vol2/soporifix_vol3/user/home/john/.config/coc/extensions/coc-clangd-data/install/10rc3/clangd_10rc3/bin/clangd exited with code: 1
/mnt/harmonix_vol2/soporifix_vol3/user/home/john/.config/coc/extensions/coc-clangd-data/install/10rc3/clangd_10rc3/bin/clangd: /lib/x86_64-linux-gnu/libm.so.6: version `GLIBC_2.27' not found (required by /mnt/harmonix_vol2/ soporifix_vol3/user/home/john/.config/coc/extensions/coc-clangd-data/install/10rc3/clangd_10rc3/bin/clangd)
Hi,
Is there a way to set clangd only work with c++ 17 standard?
best
Currently I see:
[clang(Semantic Issue) ovl_no_viable_function_in_call] [E] No matching function for call to 'foo'
The diagnostic text is the most important but it starts on column 59, and is the first thing to get truncated/wrapped.
A big contributor is clang/clangd which use long strings for the code. I think they have some value but display needs to be done carefully.
Another contributor is the (Semantic Issue) category, which I'm not sure is pulling its weight.
I'd like to try making the source/code styled differently, placed at the end of the diagnostic, and dropping the [E] in upstream coc.
Since this is the first issue in the repo, let me clarify why I(and possibly others) will file bugs in here:
This extension might not be the right place to fix most of those issues, it might even be the case that these are not issues but just people having different taste, but we are rather trying to keep track of annoying/suboptimal behaviours we face.
This one is about signature help floating window, when the documentation is too long for a signature, the signature itself gets lost. Even though there is a scrollbar, at least I have no idea how to scroll it. It might make sense to always put the signature first, and then put documentation below it.
Semantic highlighting is disable between the false branch of #if/#endif, however it's better to have those code grayed out.
I am trying to use coc-clangd
at work where we have a firewall, preventing access to external resources (like github). There is however a way to have a local mirror of github repos. This is where i have copies of coc.nvim
and clangd/coc-clangd
:
Installing this extension, however, doesnt work out of the box:
First method
:CocInstall http://companymirror/github/clangd/coc-clangd.git
results in is not supported, coc.nvim support github.com only
Second method:
Plug 'clangd/coc-clangd', {'do': 'yarn install --frozen-lockfile'}
results in an error:
warning package.json: License should be a valid SPDX license expression
warning [email protected]: License should be a valid SPDX license expression
[1/5] Validating package.json...
warning [email protected]: License should be a valid SPDX license expression
warning [email protected]: The engine "coc" appears to be invalid.
[2/5] Resolving packages...
[3/5] Fetching packages...
error An unexpected error occurred: "https://registry.yarnpkg.com/readdirp/-/readdirp-3.4.0.tgz: self signed certificate in certificate chain".
info If you think this is a bug, please open a bug report with the information provided in "/home/user/.vim/plugged/coc-clangd/yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
Logs
Arguments:
/usr/local/node-v12.18.0-linux-x64/bin/node /usr/share/yarn/bin/yarn.js install --frozen-lockfile
PATH:
/usr/local/node-v12.18.0-linux-x64/bin:/software/centos7/binutils/2.30/bin:/software/centos7/ccache/3.2.2/bin:/software/centos7/cmake/3.13.2/bin:/software/centos7/gdb/8.1/bin:/software/centos7/gcc/8.2.0/bin:/home/user/bin/fzf/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/home/user/.fzf/bin:/usr/lib/llvm10/10.0.0/bin/:/home/user/.local/bin:/home/user/bin/fzf-0.17.5/:/home/user/bin
Yarn version:
1.22.4
Node version:
12.18.0
Platform:
linux x64
Trace:
Error: self signed certificate in certificate chain
at TLSSocket.onConnectSecure (_tls_wrap.js:1506:34)
at TLSSocket.emit (events.js:315:20)
at TLSSocket._finishInit (_tls_wrap.js:948:8)
at TLSWrap.ssl.onhandshakedone (_tls_wrap.js:706:12)
System information
Clangd version: 10.0.0
clangd extension version (from :CocInfo
):
Operating system: CentOS 7.3
I am trying Coc for the first time so I am sure I am just doing something stupid, so I apologize if that is indeed the case.
To describe my enviroment. I am using CMake to create my compilation database, and because it's build in a build
folder I copy it to the root of the project. I also have 2 subprojects in the root folder, core
and gui
.
Now for the actual issue, all diagnostics seem to work fine, code navigation work fine as well. But whenever autocompletetion is expected to pop up nothing happens. Instead if you don't do anything for 5 seconds an error message appears at the bottom saying source clangd timeout after 5000ms
. I don't have any other information to provide as I couldn't find any logs emmited by the plugin.
Hi:
I notice that clang has formatting feature, but I don't know how to set it up. Is there any docs for this?
best regards
Peiyun Jin
When you trigger a completion via a commit character instead of hitting enter (for example parentheses or dot) completion text gets inserted after updatetime
delay or as soon as you hit any other character.
When i run nvim with coc-clangd a ./clangd/
is created in my project. It looks like to contain some index cache, i want those files in another location for example /tmp/clangd
is that possible?
(coc-codeaction) sends the whole line, which doesn't work with clangd - it needs finer-grained location, like vscode provides.
(coc-codeaction-selected) works properly but only in visual/select mode I think.
Ideally we'd just change coc-codeaction to send {begin=cursor, end=cursor} - servers that want to promote this to "whole line" can easily do so, and that's what vscode does.
But if maintainers aren't happy with that we can probably do something clangd-specific or add a new binding.
I am on Windows, and I am developing an ARM MCU project, so it's a cross-platform project, and it's makefile-based. I try to use msys2/mingw to create my vim IDE. I succeeded installing coc.nvim and coc-clangd and all their requirements, and I use compiledb
to generate compile_commands.json
for my project. But it seems coc.nvim cannot find header I include in my source code. For example, I include the header main.h
in main.c
, and coc.nvim complained main.h file not found [clangd:]
, also, for struct defined in header, coc.nvim complained 'unknown type name XXX [clangd:]'. Is there anyone here could help me debug this problem?
Here is the part of compile_commands.json related to main.c
{
"directory": "/c/Users/XXXX/Desktop/XXXX_project",
"arguments": [
"arm-none-eabi-gcc",
"-c",
"-mcpu=cortex-m7",
"-mthumb",
"-mfpu=fpv5-d16",
"-mfloat-abi=hard",
"-DUSE_HAL_DRIVER",
"-DSTM32F765xx",
"-IInc",
"-IDrivers/STM32F7xx_HAL_Driver/Inc",
"-IDrivers/STM32F7xx_HAL_Driver/Inc/Legacy",
"-IMiddlewares/ST/STM32_USB_Device_Library/Core/Inc",
"-IMiddlewares/ST/STM32_USB_Device_Library/Class/CDC/Inc",
"-IDrivers/CMSIS/Device/ST/STM32F7xx/Include",
"-IDrivers/CMSIS/Include",
"-O0",
"-Wall",
"-fdata-sections",
"-ffunction-sections",
"-g",
"-gdwarf-2",
"-MMD",
"-MP",
"-MFbuild/main.d",
"-Wa,-a,-ad,-alms=build/main.lst",
"Src/main.c",
"-o",
"build/main.o"
],
"file": "Src/main.c"
},
vim version: VIM - Vi IMproved 8.2 8020717
node version: v14.2.0
coc.nvim version: 0.0.78-42353685a1
term: dumb
platform: linux
0.4.3
Completion doesn't show in .cu file.
-xcuda
-std=c++11
--cuda-path=/opt/cuda
--cuda-gpu-arch=sm_50
-I./include
-I/opt/cuda/include
Just trying to get autocompletion for C but can't make it work. So far I've taken the following steps:
Plug 'neoclide/coc.nvim', {'branch': 'release'}
, save file, reload and :PlugInstall
:CocInstall coc-clangd
and :CocCommand clangd.install
:chechhealth
, everything under health#coc#check is OK and green.compile_commands.json
, not sure how to do that. My "project" is basically a bunch of loose files (I'm learning C) but do I really need a compile_commands.json for getting basic autocompletion?normally clangd inserts missing includes via additionaledits attached to code completion items, this doesn't seem to be triggered when you commit the completion with any other key than enter though.
I'm following the "Quick Start" guide and have run into problems on the :CocCommand clangd.install
step. The guide claims coc-clangd
will try to find clangd
in my $PATH
. I know that clangd
is not in my $PATH
, but I see no output from :CocInstall coc-clangd
that it looked and failed to find it. I only see a single line with a green check that it installed into .config/coc/extensions/node_modules/coc-clangd
.
When I run :CocCommand clangd.install
to have it fetch the latest release, it returns [coc.nvim] Command: clangd.install not found
.
is there a way to turn off code formating when using coc-rename? Or can i change the style of the format?
Hi,
Please add cuda (.cu) and arduino (.ino) file types to coc-clangd's automatic activation list.
Coc-clangd doesn't detect my clangd binary installed with homebrew at /usr/local/Cellar/llvm/10.0.0_3/bin/clangd
that I symlinked to ~/.local/bin/clangd
and I added ~/.local/bin/
to my $PATH
. I can run clangd from inside neovim as :!clangd
without a problem but coc-clangd can't detect it without hardcoding the path in coc-settings.json
with "clangd.path": "/usr/local/opt/llvm/10.0.0_3/bin/clangd"
. If I symlink the binary to /usr/local/bin
instead it just works.
I would like to avoid hardcoding the path to coc-settings.json since it wouldn't be portable to my Linux computer. So my question is: where does coc-clangd search for clangd
and why is it not using my $PATH
?
From #27 (comment), clangd 10+ will do incremental highlighting support.
This should fix jackguo380/vim-lsp-cxx-highlight#20
Maybe having coc-clangd cache previous highlighting messages then calling lsp_cxx_hl#hl#notify_symbols would fix this issue.
I don't know if this is a coc issue or a coc-clangd issue, but when I get hover information about a symbol, the documentation is shown with escaped punctuation making it quite hard to read. See screenshot.
## versions
vim version: NVIM v0.5.0-dev
node version: v14.1.0
coc.nvim version: 0.0.78-57637bb44c
term: screen-256color
platform: linux
## Output channel: clangd log
I[14:23:11.272] clangd version 9.0.1-8+hrt1hrt9.1
This feature is handy, but my project is currently set to watch my sources and automatically re-compile (working on a WASM project and it reloads in the browser) and also regenerate 'compile_commands.json' (to keep it up to date in case files were added / removed), and this causes this prompt to come up whenever I save. I could perhaps make the toolchain account for this case better, but maybe there could be an option to opt into 'always yes' automatically? I think the prompt still makes sense to have by default.
Referring to this prompt:
372af93#diff-0355b99bc606e1e80a00902fe3abca07R77
Let's assume that we have a directory structure:
foo1/foo2/foo3/src
and a .cpp file in src. I create a compile_commands.json with cmake and store in src. When I start vim I get no feedback whether the compile_commands.json is used or not.
In order to understand its behaviour I take the valid compile_commands.json I have created, let's assume that looks like:
[
{ "directory": "/home/user/llvm/build",
"command": "/usr/bin/clang++ -Irelative -DSOMEDEF=\"With spaces, quotes and \\-es.\" -c -o file.o file.cc",
"file": "file.cc" },
]
and I invalidate it by adding random characters:
[
adfgadgadfadgasdgadga
{ "directory": "/home/user/llvm/build",
"command": "/usr/bin/clang++ -Irelative -DSOMEDEF=\"With spaces, quotes and \\-es.\" -c -o file.o file.cc",
"file": "file.cc" },
...
]
I restart vim or I do CocRestart
and I get no feedback that something is wrong. Moreover, CocOpenLog or :CocCommand workspace.showOutput
does not show anything. I have also updated my .vimrc
with:
let $NVIM_COC_LOG_LEVEL = 'debug'
Trying "clangd.trace.server": "verbose" in coc-settings returns that this property is not allowed
Same with compile_flags.txt. No response that it is loaded correctly or that contains errors when I add invalid flags on purpose.
I try to understand what happens in such scenarios but I have no feedback or log messages to help me on that.
Is there a way to configure coc-clangd (or clangd) so that the header extension ".h" is interpreted as a C++ header by default, or is the language (C/C++) determined exclusively by the file extension in clangd and coc-clangd? I was at least unable to find a way to force the language to C++, but it could be that I am missing something. According to the CppCoreGuidelines: "The specific names .h and .cpp are not required (just recommended as a default) and other names are in widespread use. Examples are .hh, .C, and .cxx. Use such names equivalently". Since people often cannot choose the header extensions for the projects they are working on, I am guessing that there must be a way to configure this on the language server side?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.