Skip to content

Commit

Permalink
Add support to Julia LanguageServer.jl.
Browse files Browse the repository at this point in the history
  • Loading branch information
SpartanJ committed Nov 23, 2024
1 parent 1c6d94e commit 1de8c60
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 16 deletions.
7 changes: 7 additions & 0 deletions bin/assets/plugins/lspclient.json
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,13 @@
"url": "https://github.com/ocaml/ocaml-lsp",
"command": "ocamllsp",
"file_patterns": ["%.ml$", "%.mli$"]
},
{
"language": "julia",
"name": "LanguageServer.jl",
"url": "https://github.com/julia-vscode/LanguageServer.jl",
"command": "julia --project=\"$HOME/.julia/packages/LanguageServer/Fwm1f/src/LanguageServer.jl\" -e \"using LanguageServer; runserver()\"",
"file_patterns": ["%.jl"]
}
]
}
3 changes: 3 additions & 0 deletions include/eepp/system/sys.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,9 @@ class EE_API Sys {

/** @returns The target destination of a windows shortcut path (.lnk files) */
static std::string getShortcutTarget( const std::string& lnkFilePath );

/** @returns The user home directory */
static std::string getUserDirectory();
};

}} // namespace EE::System
Expand Down
2 changes: 1 addition & 1 deletion src/eepp/system/process.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ Process::~Process() {
bool Process::create( const std::string& command, Uint32 options,
const std::unordered_map<std::string, std::string>& environment,
const std::string& workingDirectory ) {
std::vector<std::string> cmdArr = String::split( command, " ", "", "\"", true );
std::vector<std::string> cmdArr = parseArgs( command );
if ( cmdArr.empty() )
return false;
std::string cmd( cmdArr[0] );
Expand Down
20 changes: 20 additions & 0 deletions src/eepp/system/sys.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1619,4 +1619,24 @@ std::string Sys::getShortcutTarget( const std::string& lnkFilePath ) {
return "";
}

std::string Sys::getUserDirectory() {
#ifdef _WIN32
// On Windows, use USERPROFILE or HOMEDRIVE + HOMEPATH
const char* userProfile = std::getenv( "USERPROFILE" );
if ( userProfile ) {
return std::string( userProfile );
} else {
// Fallback to HOMEDRIVE + HOMEPATH
const char* homeDrive = std::getenv( "HOMEDRIVE" );
const char* homePath = std::getenv( "HOMEPATH" );
if ( homeDrive && homePath )
return std::string( homeDrive ) + homePath;
}
return "";
#else
// On Unix-based systems, use HOME
return std::string{ std::getenv( "HOME" ) };
#endif
}

}} // namespace EE::System
26 changes: 12 additions & 14 deletions src/eepp/window/window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -464,20 +464,18 @@ void Window::sendVideoResizeCb() {
}

void Window::logSuccessfulInit( const std::string& BackendName ) {
std::string msg(
"Engine Initialized Succesfully.\n\tVersion: " + Version::getVersionName() +
" (codename: \"" + Version::getCodename() + "\")" +
"\n\tBuild time: " + Version::getBuildTime() + "\n\tPlatform: " + Sys::getPlatform() +
"\n\tOS: " + Sys::getOSName( true ) + "\n\tArch: " + Sys::getOSArchitecture() +
"\n\tCPU Cores: " + String::toString( Sys::getCPUCount() ) +
"\n\tProcess Path: " + Sys::getProcessPath() + "\n\tCurrent Working Directory: " +
FileSystem::getCurrentWorkingDirectory() + "\n\tDisk Free Space: " +
FileSystem::sizeToString( FileSystem::getDiskFreeSpace( Sys::getProcessPath() ) ) +
"\n\tWindow/Input Backend: " + BackendName + "\n\tGL Backend: " + GLi->versionStr() +
"\n\tGL Vendor: " + GLi->getVendor() + "\n\tGL Renderer: " + GLi->getRenderer() +
"\n\tGL Version: " + GLi->getVersion() + "\n\tGL Shading Language Version: " +
GLi->getShadingLanguageVersion() + "\n\tResolution: " + String::toString( getWidth() ) +
"x" + String::toString( getHeight() ) );
std::string msg( String::format(
"Engine Initialized Succesfully.\n\tVersion: %s (codename: \"%s\")\n\tBuild time: "
"%s\n\tPlatform: %s\n\tOS: %s\n\tArch: %s\n\tCPU Cores: %d\n\tProcess Path: %s\n\tCurrent "
"Working Directory: %s\n\tHome Directory: %s\n\tDisk Free Space: %s\n\tWindow/Input "
"Backend: %s\n\tGL Backend: %s\n\tGL Vendor: %s\n\tGL Renderer: %s\n\tGL Version: "
"%s\n\tGL Shading Language Version: %s\n\tResolution: %dx%d",
Version::getVersionName(), Version::getCodename(), Version::getBuildTime(),
Sys::getPlatform(), Sys::getOSName( true ), Sys::getOSArchitecture(), Sys::getCPUCount(),
Sys::getProcessPath(), FileSystem::getCurrentWorkingDirectory(), Sys::getUserDirectory(),
FileSystem::sizeToString( FileSystem::getDiskFreeSpace( Sys::getProcessPath() ) ),
BackendName, GLi->versionStr(), GLi->getVendor(), GLi->getRenderer(), GLi->getVersion(),
GLi->getShadingLanguageVersion(), getWidth(), getHeight() ) );

#ifndef EE_SILENT
Log::info( msg );
Expand Down
5 changes: 4 additions & 1 deletion src/tools/ecode/plugins/lsp/lspclientplugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -308,11 +308,14 @@ static LSPURIAndServer getServerURIFromTextDocumentURI( LSPClientServerManager&
}

static void sanitizeCommand( std::string& cmd, const std::string& workspaceFolder ) {
std::string cpucount( String::toString( Sys::getCPUCount() ) );
static std::string cpucount( String::toString( Sys::getCPUCount() ) );
static std::string userdir = Sys::getUserDirectory();
String::replaceAll( cmd, "$NPROC", cpucount );
String::replaceAll( cmd, "${nproc}", cpucount );
String::replaceAll( cmd, "$PROJECTPATH", workspaceFolder );
String::replaceAll( cmd, "${project_root}", workspaceFolder );
String::replaceAll( cmd, "$HOME", userdir );
String::replaceAll( cmd, "${home}", userdir );
}

LSPPositionAndServer getLSPLocationFromJSON( LSPClientServerManager& manager, const json& data ) {
Expand Down

0 comments on commit 1de8c60

Please sign in to comment.