Add support for C-famaily languages#10
Conversation
Add support for C-family languages and did some cosmetic cleanup to match lsp-clangd.
danielmartin
left a comment
There was a problem hiding this comment.
Thanks for the patch! I'll give it a try this weekend. I think we need to add a bit of documentation about how to handle C++/Obj-C files when both sourcekit-lsp and clangd are installed.
For example, in a hybrid project Obj-C/Swift I'd expect lsp-sourcekit to handle the workspace. In a C++ project, I'd expect lsp-clangd to handle the workspace.
I think it should be possible to achieve this by tweaking the priorities of the lsp-clients from a .dir-locals.el file. We should mention how to do that in the documentation because it's a common scenario.
|
Instead of tweaking client priorities (which are not meant to be configurable per project), we can suggest configuring |
|
I'll take a look at |
| :server-id 'sourcekit-ls)) | ||
| (make-lsp-client :new-connection (lsp-stdio-connection | ||
| 'lsp-sourcekit--lsp-command) | ||
| :major-modes '(swift-mode c-mode c++-mode objc-mode) |
There was a problem hiding this comment.
I'm thinking that, instead of using :major-modes, we could use :activation-fn with a custom function. Inside that custom function we can be more precise for when sourcekit-lsp should activate:
Require that the major mode is either swift-mode, c-mode, c++-mode, or objc-mode AND that the project contains a Package.swift or .xcodeproj/.xcworkspace file. You can use Emacs's locate-dominating-file function to do this.
I think this will do the right thing in almost all cases, without the user having to configure existing or new projects that contain C++ code. What do you think?
There was a problem hiding this comment.
That sounds like the best option. Thanks for the pointers.
Add support for C-family languages and did some cosmetic cleanup to
match lsp-clangd.