LSP does not work

205 views
Skip to first unread message

Tom M

unread,
Jun 29, 2023, 2:42:15 PM6/29/23
to BBEdit Talk
Hello,

I have installed the clangd language server and symlinked it to /usr/local/bin[1]. The server is also clearly found and “ready to start” according to Preferences:

Screen Shot 2023-06-29 at 10.41.35 AM.png

 When I open a C file in BBEdit, the language server does start, as shown by `pgrep clangd` and by the log file[2]. However, it only shows a gray circle:

Screen Shot 2023-06-29 at 10.44.53 AM.png

According to the BBEdit LSP documentation, this means that “the server has not (yet) returned any diagnostics information for this file.” The problem is that I’m not sure how to get it to produce any such info. I get the same issue with every other language server that I’ve tried, including Python (jedi-language-server) and Go (gopls). All three language servers “just work” in VS Code.

Any help would be much appreciated!


[1] Using the following commands:

brew install llvm
for f in /usr/local/opt/llvm/bin/*; do ln -s "$f" "/usr/local/bin/${f##*/}"; done

`which clangd` shows /usr/local/bin/clangd.


[2] The contents of “~/Library/Containers/com.barebones.bbedit/Data/Library/Logs/BBEdit/LanguageServerProtocol-ANSI C.txt” (via the BBEdit/Folders/Logs menu) from the most recent invocation are shown below. The latter three lines were added when I quit BBEdit.

================================================================================
2023-06-28 23:11:05.536: Application startup: 14.6.6 (14D78), r29014
2023-06-28 23:11:05.536: macOS version: 11.7.7 (20G1345)
2023-06-28 23:11:05.540: Waiting for server startup to complete...
2023-06-28 23:11:05.835: ...completed server startup.
2023-06-29 09:59:52.994: Stopped language server for ANSI C
2023-06-29 09:59:52.994: Cleaning up after normal server shutdown.
2023-06-29 10:00:11.010: CLanguageModule.mm:2607: calling _StartLSPServer.

Rich Siegel

unread,
Jun 29, 2023, 3:08:14 PM6/29/23
to bbe...@googlegroups.com
You will probably need to do some additional configuration. The LSP notes discuss this a bit.

The clangd configuration page describes how to manually configure compile flags and other behaviors using a ".clangd" YAML file at the root level of the directory.

A suitably configured `.clangd` file might have a `CompileFlags:` section which specifies include directories and other things that will help make clangd behave more usefully for you.

The configuration page is here: <https://clangd.llvm.org/config>.

R.

On Jun 29, 2023, at 7:42 PM, Tom M <tom...@themorfords.com> wrote:

Hello,

I have installed the clangd language server and symlinked it to /usr/local/bin[1]. The server is also clearly found and “ready to start” according to Preferences:

<Screen Shot 2023-06-29 at 10.41.35 AM.png>


 When I open a C file in BBEdit, the language server does start, as shown by `pgrep clangd` and by the log file[2]. However, it only shows a gray circle:

<Screen Shot 2023-06-29 at 10.44.53 AM.png>


According to the BBEdit LSP documentation, this means that “the server has not (yet) returned any diagnostics information for this file.” The problem is that I’m not sure how to get it to produce any such info. I get the same issue with every other language server that I’ve tried, including Python (jedi-language-server) and Go (gopls). All three language servers “just work” in VS Code.

Any help would be much appreciated!


[1] Using the following commands:

brew install llvm
for f in /usr/local/opt/llvm/bin/*; do ln -s "$f" "/usr/local/bin/${f##*/}"; done

`which clangd` shows /usr/local/bin/clangd.


[2] The contents of “~/Library/Containers/com.barebones.bbedit/Data/Library/Logs/BBEdit/LanguageServerProtocol-ANSI C.txt” (via the BBEdit/Folders/Logs menu) from the most recent invocation are shown below. The latter three lines were added when I quit BBEdit.

================================================================================
2023-06-28 23:11:05.536: Application startup: 14.6.6 (14D78), r29014
2023-06-28 23:11:05.536: macOS version: 11.7.7 (20G1345)
2023-06-28 23:11:05.540: Waiting for server startup to complete...
2023-06-28 23:11:05.835: ...completed server startup.
2023-06-29 09:59:52.994: Stopped language server for ANSI C
2023-06-29 09:59:52.994: Cleaning up after normal server shutdown.
2023-06-29 10:00:11.010: CLanguageModule.mm:2607: calling _StartLSPServer.

--
This is the BBEdit Talk public discussion group. If you have a feature request or need technical support, please email "sup...@barebones.com" rather than posting here. Follow @bbedit on Twitter: <https://twitter.com/bbedit>
---
You received this message because you are subscribed to the Google Groups "BBEdit Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bbedit+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bbedit/9bb070f7-ab9d-49fd-9980-fd5f0d3bd7f6n%40googlegroups.com.

<Screen Shot 2023-06-29 at 10.41.35 AM.png>

Tom M

unread,
Jul 4, 2023, 8:29:20 AM7/4/23
to BBEdit Talk
Hello Rich,

Thanks for the response.

I don't believe that the compile_commands.json file is the (main) issue. I tried generating the file[1] using cmake[2], but even after restarting BBEdit continues to display a gray dot in the editor (and a green circle in the "Installed Languages" list). The same thing happens for Python (jedi-language-server), Go (gopls), and Fortran (fortran-language-server). Again, these all work after installing the proper extensions in VS Code. BBEdit's logs do list errors for Go and Fortran though; see attached files.

Thanks,
Tom


[1] compile_commands.json contents:
[
{
  "directory": "/tmp/a",
  "command": "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc    -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk -mmacosx-version-min=11.7 -o CMakeFiles/a.dir/a.c.o -c /tmp/a/a.c",
  "file": "/tmp/a/a.c",
  "output": "CMakeFiles/a.dir/a.c.o"
}
]


[2] version 3.26.4; CMakeLists.txt contents:
cmake_minimum_required (VERSION 2.6)
project(A)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
add_executable(a a.c)
LanguageServerProtocol-Go.txt
LanguageServerProtocol-Python.txt
LanguageServerProtocol-Fortran 9x.txt

Rich Siegel

unread,
Jul 4, 2023, 10:20:55 AM7/4/23
to bbe...@googlegroups.com
I have no reason to believe that compile_commands.json is at issue. 

You may need to turn on additional logging in clangd via the command line options.

What if you put the project somewhere on your home directory, rather than in /tmp?

R.

On Jul 4, 2023, at 1:29 PM, Tom M <tom...@themorfords.com> wrote:

Hello Rich,
To view this discussion on the web visit https://groups.google.com/d/msgid/bbedit/bfb3fb44-2ed9-4223-a1c9-254e037cfc63n%40googlegroups.com.
<LanguageServerProtocol-Go.txt>
<LanguageServerProtocol-Python.txt>
<LanguageServerProtocol-Fortran 9x.txt>

Tom M

unread,
Jul 8, 2023, 2:33:39 AM7/8/23
to BBEdit Talk
Resolved! I'm not exactly sure what fixed it, but notably I enabled sandbox access and reinstalled Brew (and, by extension, its packages and npm's packages).

Thanks!
Tom
Reply all
Reply to author
Forward
0 new messages