Skip to content
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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

eddieh
Copy link

@eddieh eddieh commented Aug 20, 2020

Add support for C-family languages and did some cosmetic cleanup to
match lsp-clangd.

Add support for C-family languages and did some cosmetic cleanup to
match lsp-clangd.
Copy link
Collaborator

@danielmartin danielmartin left a 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-clients from a .dir-locals.el file. We should mention how to do that in the documentation because it's a common scenario.

@danielmartin
Copy link
Collaborator

Instead of tweaking client priorities (which are not meant to be configurable per project), we can suggest configuring lsp-enabled-clients per project instead.

@eddieh
Copy link
Author

eddieh commented Aug 23, 2020

I'll take a look at lsp-enabled-clients. I wonder if detecting the .xcodeproj file would be sufficient for picking sourcekit-lsp over clangd? That's what I was going to try in my personal configuration.

: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)
Copy link
Collaborator

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?

Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants