-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
ClangD support for Eclipse Che #7516
Merged
vparfonov
merged 11 commits into
eclipse-che:master
from
hkolvenbach:kolvenbach.clangd_v3
Feb 15, 2018
Merged
Changes from 9 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
d18da95
ClangD ported to Che6
4238b40
removed launch scripts
1dea818
added scripts for ubuntu and debian
84d8907
moved command to launch script. hide error messages
fecbb6b
fixing wrong positioning of code completion items
a876ac5
removed comments, updated script for other OS
ce05ba8
updated language server script
35ee27b
added new line
b7e86a6
merged master and updated version
a67e17d
updated version
9baa64a
fixed newline
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
|
||
Copyright (c) 2012-2018 Red Hat, Inc. | ||
All rights reserved. This program and the accompanying materials | ||
are made available under the terms of the Eclipse Public License v1.0 | ||
which accompanies this distribution, and is available at | ||
http://www.eclipse.org/legal/epl-v10.html | ||
|
||
Contributors: | ||
Red Hat, Inc. - initial API and implementation | ||
|
||
--> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<artifactId>che-agents-parent</artifactId> | ||
<groupId>org.eclipse.che</groupId> | ||
<version>6.0.0-M5-SNAPSHOT</version> | ||
</parent> | ||
<artifactId>ls-clang-agent</artifactId> | ||
<name>Language Server Clang Agent</name> | ||
</project> |
8 changes: 8 additions & 0 deletions
8
agents/ls-clang/src/main/resources/installers/1.0.0/org.eclipse.che.ls.clang.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"id": "org.eclipse.che.ls.clangd", | ||
"version": "1.0.0", | ||
"name": "Clangd language server", | ||
"description": "Clangd intellisense for C/C++ projects.", | ||
"dependencies": [], | ||
"properties": {} | ||
} |
172 changes: 172 additions & 0 deletions
172
agents/ls-clang/src/main/resources/installers/1.0.0/org.eclipse.che.ls.clang.script.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,172 @@ | ||
# | ||
# Copyright (c) 2012-2018 Red Hat, Inc. | ||
# All rights reserved. This program and the accompanying materials | ||
# are made available under the terms of the Eclipse Public License v1.0 | ||
# which accompanies this distribution, and is available at | ||
# http://www.eclipse.org/legal/epl-v10.html | ||
# | ||
# Contributors: | ||
# Red Hat, Inc. - initial API and implementation | ||
# | ||
|
||
is_current_user_root() { | ||
test "$(id -u)" = 0 | ||
} | ||
|
||
is_current_user_sudoer() { | ||
sudo -n true > /dev/null 2>&1 | ||
} | ||
|
||
set_sudo_command() { | ||
if is_current_user_sudoer && ! is_current_user_root; then SUDO="sudo -E"; else unset SUDO; fi | ||
} | ||
|
||
set_sudo_command | ||
unset PACKAGES | ||
command -v tar >/dev/null 2>&1 || { PACKAGES=${PACKAGES}" tar"; } | ||
command -v curl >/dev/null 2>&1 || { PACKAGES=${PACKAGES}" curl"; } | ||
command -v wget >/dev/null 2>&1 || { PACKAGES=${PACKAGES}" wget"; } | ||
|
||
CHE_DIR=$HOME/che | ||
LS_DIR=${CHE_DIR}/ls-clangd | ||
LS_LAUNCHER=${LS_DIR}/launch.sh | ||
CLANGD_VERSION=6.0 | ||
CLANGD_BINARY=clangd-${CLANGD_VERSION} | ||
|
||
if [ -f /etc/centos-release ]; then | ||
FILE="/etc/centos-release" | ||
LINUX_TYPE=$(cat $FILE | awk '{print $1}') | ||
elif [ -f /etc/redhat-release ]; then | ||
FILE="/etc/redhat-release" | ||
LINUX_TYPE=$(cat $FILE | cut -c 1-8) | ||
else | ||
FILE="/etc/os-release" | ||
LINUX_TYPE=$(cat $FILE | grep ^ID= | tr '[:upper:]' '[:lower:]') | ||
LINUX_VERSION=$(cat $FILE | grep ^VERSION_ID=) | ||
fi | ||
|
||
MACHINE_TYPE=$(uname -m) | ||
|
||
mkdir -p ${CHE_DIR} | ||
mkdir -p ${LS_DIR} | ||
|
||
######################### | ||
#### Install packages ### | ||
######################### | ||
# | ||
# Red Hat Enterprise Linux 7 | ||
############################ | ||
if echo ${LINUX_TYPE} | grep -qi "rhel"; then | ||
test "${PACKAGES}" = "" || { | ||
${SUDO} yum install ${PACKAGES}; | ||
} | ||
|
||
command -v ${CLANGD_BINARY} >/dev/null 2>&1 || { | ||
echo "LLVM / Clang ${CLANGD_VERSION} not supported on Red Hat Enterprise Linux 7."; | ||
exit 1; | ||
} | ||
|
||
# Red Hat Enterprise Linux 6 | ||
############################ | ||
elif echo ${LINUX_TYPE} | grep -qi "Red Hat"; then | ||
test "${PACKAGES}" = "" || { | ||
${SUDO} yum install ${PACKAGES}; | ||
} | ||
|
||
command -v ${CLANGD_BINARY} >/dev/null 2>&1 || { | ||
echo "LLVM / Clang ${CLANGD_VERSION} not supported on Red Hat Enterprise Linux 6."; | ||
exit 1; | ||
} | ||
|
||
|
||
# Ubuntu 14.04 16.04 / Linux Mint 17 | ||
#################################### | ||
elif echo ${LINUX_TYPE} | grep -qi "ubuntu"; then | ||
test "${PACKAGES}" = "" || { | ||
${SUDO} apt-get update; | ||
${SUDO} apt-get -y install ${PACKAGES}; | ||
} | ||
|
||
command -v ${CLANGD_BINARY} >/dev/null 2>&1 || { | ||
{ | ||
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key|sudo apt-key add -; | ||
# Fingerprint: 6084 F3CF 814B 57C1 CF12 EFD5 15CF 4D18 AF4F 7421 | ||
${SUDO} apt-add-repository "deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-${CLANGD_VERSION} main"; | ||
}; | ||
|
||
${SUDO} apt-get update; | ||
${SUDO} apt-get install -y clang-tools-${CLANGD_VERSION}; | ||
${SUDO} ln -s /usr/bin/clangd-${CLANGD_VERSION} /usr/bin/clangd | ||
} | ||
|
||
|
||
# Debian 8 | ||
########## | ||
elif echo ${LINUX_TYPE} | grep -qi "debian"; then | ||
test "${PACKAGES}" = "" || { | ||
${SUDO} apt-get update; | ||
${SUDO} apt-get -y install ${PACKAGES}; | ||
} | ||
|
||
command -v ${CLANGD_BINARY} >/dev/null 2>&1 || { | ||
{ | ||
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key|sudo apt-key add -; | ||
# Fingerprint: 6084 F3CF 814B 57C1 CF12 EFD5 15CF 4D18 AF4F 7421 | ||
${SUDO} apt-add-repository "deb http://apt.llvm.org/jessie/ llvm-toolchain-jessie-${CLANGD_VERSION} main"; | ||
}; | ||
|
||
${SUDO} apt-get update; | ||
${SUDO} apt-get install -y clang-tools-${CLANGD_VERSION}; | ||
${SUDO} ln -s /usr/bin/clangd-${CLANGD_VERSION} /usr/bin/clangd | ||
} | ||
|
||
## Fedora 23 | ||
############ | ||
elif echo ${LINUX_TYPE} | grep -qi "fedora"; then | ||
test "${PACKAGES}" = "" || { | ||
${SUDO} dnf -y install ${PACKAGES}; | ||
} | ||
|
||
command -v ${CLANGD_BINARY} >/dev/null 2>&1 || { | ||
echo "LLVM / Clang ${CLANGD_VERSION} not supported on Fedora 23."; | ||
exit 1; | ||
} | ||
|
||
## CentOS 7.1 & Oracle Linux 7.1 | ||
################################ | ||
elif echo ${LINUX_TYPE} | grep -qi "centos"; then | ||
test "${PACKAGES}" = "" || { | ||
${SUDO} yum -y install ${PACKAGES}; | ||
} | ||
|
||
command -v ${CLANGD_BINARY} >/dev/null 2>&1 || { | ||
echo "LLVM / Clang ${CLANGD_VERSION} not supported on CentOS."; | ||
exit 1; | ||
} | ||
|
||
## openSUSE 13.2 | ||
################ | ||
elif echo ${LINUX_TYPE} | grep -qi "opensuse"; then | ||
test "${PACKAGES}" = "" || { | ||
${SUDO} zypper install -y ${PACKAGES}; | ||
} | ||
|
||
command -v ${CLANGD_BINARY} >/dev/null 2>&1 || { | ||
echo "LLVM / Clang ${CLANGD_VERSION} not supported on OpenSUSE 13.2."; | ||
exit 1; | ||
} | ||
|
||
else | ||
>&2 echo "Unrecognized Linux Type" | ||
>&2 cat $FILE | ||
exit 1 | ||
fi | ||
|
||
|
||
######################### | ||
### Install Clangd LS ### | ||
######################### | ||
|
||
touch ${LS_LAUNCHER} | ||
chmod +x ${LS_LAUNCHER} | ||
echo "tee -a /home/user/clangd-input.log | clangd -disable-symbolication -pretty -resource-dir=/usr/include/ -enable-snippets | tee -a /home/user/clangd-output.log" > ${LS_LAUNCHER} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
plugins/plugin-clangd/che-plugin-clangd-lang-server/pom.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
|
||
Copyright (c) 2012-2018 Red Hat, Inc. | ||
All rights reserved. This program and the accompanying materials | ||
are made available under the terms of the Eclipse Public License v1.0 | ||
which accompanies this distribution, and is available at | ||
http://www.eclipse.org/legal/epl-v10.html | ||
|
||
Contributors: | ||
Red Hat, Inc. - initial API and implementation | ||
|
||
--> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<artifactId>che-plugin-clangd-parent</artifactId> | ||
<groupId>org.eclipse.che.plugin</groupId> | ||
<version>6.0.0-M5-SNAPSHOT</version> | ||
</parent> | ||
<artifactId>che-plugin-clangd-lang-server</artifactId> | ||
<name>Che Plugin :: ClangD C/C++ :: Extension Server</name> | ||
<properties> | ||
<findbugs.failonerror>false</findbugs.failonerror> | ||
</properties> | ||
<dependencies> | ||
<dependency> | ||
<groupId>com.google.inject</groupId> | ||
<artifactId>guice</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.google.inject.extensions</groupId> | ||
<artifactId>guice-multibindings</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.eclipse.che.core</groupId> | ||
<artifactId>che-core-api-languageserver</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.eclipse.che.core</groupId> | ||
<artifactId>che-core-api-languageserver-shared</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.eclipse.che.core</groupId> | ||
<artifactId>che-core-api-project</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.eclipse.che.core</groupId> | ||
<artifactId>che-core-commons-inject</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.eclipse.che.plugin</groupId> | ||
<artifactId>che-plugin-cpp-lang-server</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.eclipse.lsp4j</groupId> | ||
<artifactId>org.eclipse.lsp4j</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.eclipse.lsp4j</groupId> | ||
<artifactId>org.eclipse.lsp4j.jsonrpc</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.slf4j</groupId> | ||
<artifactId>slf4j-api</artifactId> | ||
</dependency> | ||
</dependencies> | ||
</project> |
58 changes: 58 additions & 0 deletions
58
...plugin-clangd-lang-server/src/main/java/org/eclipse/plugin/clangd/inject/ClangModule.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/* | ||
* Copyright (c) 2012-2018 Red Hat, Inc. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
* | ||
* Contributors: | ||
* Red Hat, Inc. - initial API and implementation | ||
*/ | ||
package org.eclipse.plugin.clangd.inject; | ||
|
||
import static java.util.Arrays.asList; | ||
|
||
import com.google.inject.AbstractModule; | ||
import com.google.inject.multibindings.Multibinder; | ||
import org.eclipse.che.api.languageserver.launcher.LanguageServerLauncher; | ||
import org.eclipse.che.api.languageserver.shared.model.LanguageDescription; | ||
import org.eclipse.che.api.project.server.type.ProjectTypeDef; | ||
import org.eclipse.che.inject.DynaModule; | ||
import org.eclipse.che.plugin.cpp.projecttype.CProjectType; | ||
import org.eclipse.che.plugin.cpp.projecttype.CppProjectType; | ||
import org.eclipse.plugin.clangd.languageserver.ClangDLanguageServerLauncher; | ||
|
||
/** @author Alexander Andrienko */ | ||
/** @author Hanno Kolvenbach */ | ||
@DynaModule | ||
public class ClangModule extends AbstractModule { | ||
public static final String LANGUAGE_ID = "clangd"; | ||
private static final String[] EXTENSIONS = | ||
new String[] { | ||
"c", "h", "cpp", "hpp", "cc", "hh", "hxx", "cxx", "C", "H", "CPP", "HPP", "CC", "HH", "CXX", | ||
"HXX" | ||
}; | ||
private static final String MIME_TYPE = "text/x-cpp"; | ||
|
||
@Override | ||
protected void configure() { | ||
Multibinder<ProjectTypeDef> projectTypeMultibinder = | ||
Multibinder.newSetBinder(binder(), ProjectTypeDef.class); | ||
|
||
projectTypeMultibinder.addBinding().to(CProjectType.class); | ||
projectTypeMultibinder.addBinding().to(CppProjectType.class); | ||
|
||
Multibinder.newSetBinder(binder(), LanguageServerLauncher.class) | ||
.addBinding() | ||
.to(ClangDLanguageServerLauncher.class); | ||
|
||
LanguageDescription description = new LanguageDescription(); | ||
description.setFileExtensions(asList(EXTENSIONS)); | ||
description.setLanguageId(LANGUAGE_ID); | ||
description.setMimeType(MIME_TYPE); | ||
|
||
Multibinder.newSetBinder(binder(), LanguageDescription.class) | ||
.addBinding() | ||
.toInstance(description); | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Seems like copy/pasted author?
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.
No :)