-
Notifications
You must be signed in to change notification settings - Fork 13
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
Add support for C-famaily languages #10
base: master
Are you sure you want to change the base?
Conversation
Add support for C-family languages and did some cosmetic cleanup to match lsp-clangd.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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-client
s 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.