- 
                Notifications
    
You must be signed in to change notification settings  - Fork 5.8k
 
Closed as duplicate of#28091
Copy link
Description
Summary
The latest clangd already [Implement simple folding for preprocessor branches] (llvm/llvm-project#140959), The folding for preprocessor branches still cannot be supported in zed using the latest clangd.
Description
DESCRIPTION_HERE
Steps to reproduce:
- Open a 
Ccode project. - Configure to use the latest clangd language server.
 - cmake generates compile_commands.json.
 
Expected Behavior:
- Support for code folding is expected in areas with precompiled macros.
 
Actual Behavior:
- Can not see any that could fold the precompiled macro area.
 
Analysis
- In the log of clangd LSP, zed didn't send clangd 
textDocument/foldingRangerequest, should use the tree - sitter provide code folding function. - clangd lsp as follows,
 
// Send:
{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"file:///D:/TestProject/src/test.c","languageId":"c","version":0,"text":"\n#include \"uart.h\"\n\n\n#ifdef PRINT_EN\n#if (defined(SDCC) || defined(__SDCC))\nint putchar(int ch)\n#elif (defined(__C51__) || defined(__CX51__))\nchar putchar(char ch)\n#elif (defined(__IAR_SYSTEMS_C__) || defined(__IAR_SYSTEMS_CPP__) || defined(__iar_compiler_version__) || \\\n       defined(__IAR_SYSTEMS_ICC__))\ntypdef FILE void *;\nint fputc(int ch, FILE *f)\n#else\n#error \"Not support compiler!!!\"\n#endif\n{\n    UART1_PutChar(ch);\n    return ch;\n}\n#endif\n#endif\n"}}}
// Receive:
{"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"diagnostics":[{"code":"pp_hash_error","message":"\"Not support compiler!!!\"","range":{"end":{"character":6,"line":14},"start":{"character":1,"line":14}},"relatedInformation":[],"severity":1,"source":"clang"},{"code":"expected_either","message":"Expected identifier or '('","range":{"end":{"character":1,"line":16},"start":{"character":0,"line":16}},"relatedInformation":[],"severity":1,"source":"clang"},{"code":"pp_endif_without_if","message":"#endif without #if","range":{"end":{"character":6,"line":21},"start":{"character":1,"line":21}},"relatedInformation":[],"severity":1,"source":"clang"},{"code":"unused-includes","codeDescription":{"href":"https://clangd.llvm.org/guides/include-cleaner"},"message":"Included header uart.h is not used directly (fix available)","range":{"end":{"character":17,"line":1},"start":{"character":0,"line":1}},"relatedInformation":[],"severity":2,"source":"clangd","tags":[1]}],"uri":"file:///D:/TestProject/src/test.c","version":0}}
// Receive:
{"jsonrpc":"2.0","method":"textDocument/inactiveRegions","params":{"regions":[{"end":{"character":26,"line":12},"start":{"character":0,"line":6}}],"textDocument":{"uri":"file:///D:/TestProject/src/test.c"}}}
// Send:
{"jsonrpc":"2.0","id":272,"method":"textDocument/documentHighlight","params":{"textDocument":{"uri":"file:///D:/TestProject/src/test.c"},"position":{"line":12,"character":26}}}
// Receive:
{"id":272,"jsonrpc":"2.0","result":[]}
// Send:
{"jsonrpc":"2.0","id":273,"method":"textDocument/codeAction","params":{"textDocument":{"uri":"file:///D:/TestProject/src/test.c"},"range":{"start":{"line":12,"character":26},"end":{"line":12,"character":26}},"context":{"diagnostics":[{"range":{"start":{"line":6,"character":0},"end":{"line":12,"character":26}},"severity":3,"source":"clangd","message":"inactive region"}],"only":["quickfix","refactor","info"]}}}
// Receive:
{"id":273,"jsonrpc":"2.0","result":[]}
A screenshot of the result from zed
A screenshot of the result in VScode, using the same clangd server, but only the clangd extension
Zed Version and System Specs
Zed: v0.203.0 (Zed Dev 0a9f407)
OS: Windows 10.0.26100
Memory: 15.7 GiB
Architecture: x86_64
GPU: Intel(R) Iris(R) Xe Graphics || Intel Corporation || 32.0.101.5972
Metadata
Metadata
Assignees
Labels
No labels