Skip to content

Language server installation menu #1997

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

Open
wants to merge 24 commits into
base: main
Choose a base branch
from
Open

Language server installation menu #1997

wants to merge 24 commits into from

Conversation

FastestMolasses
Copy link
Member

Description

A system to allow users to download and manage LSP servers from the settings menu. This utilizes the mason registry to track the language servers.

Related Issues

Checklist

  • I read and understood the contributing guide as well as the code of conduct
  • The issues this PR addresses are related to each other
  • My changes generate no new warnings
  • My code builds and runs on my machine
  • My changes are all related to the related issue above
  • I documented my code

Screenshots

@FastestMolasses FastestMolasses added enhancement New feature or request language server Issues or Pull Requests related to language servers. labels Feb 25, 2025
@FastestMolasses FastestMolasses marked this pull request as ready for review March 12, 2025 12:17
@FastestMolasses
Copy link
Member Author

Will need to fix lint errors, but besides that it is ready for review.

@austincondiff
Copy link
Collaborator

Fix those SwiftLint errors plz 😬

Copy link
Member

@tom-ludwig tom-ludwig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’ve reviewed the Installation Queue and Package Managers so far. This PR is definitely too large for a single review, so I’ll go through the rest later. In the meantime, could you update your PR description as well?

austincondiff
austincondiff previously approved these changes Apr 2, 2025

extension PackageManagerProtocol {
/// Creates the directory for the language server to be installed in
internal func createDirectoryStructure(for packagePath: URL) throws {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
internal func createDirectoryStructure(for packagePath: URL) throws {
func createDirectoryStructure(for packagePath: URL) throws {

Internal is redundant

}

/// Executes commands in the specified directory
internal func executeInDirectory(in packagePath: String, _ args: [String]) async throws -> [String] {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
internal func executeInDirectory(in packagePath: String, _ args: [String]) async throws -> [String] {
func executeInDirectory(in packagePath: String, _ args: [String]) async throws -> [String] {

}

/// Runs a shell command and returns output
internal func runCommand(_ command: String) async throws -> [String] {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
internal func runCommand(_ command: String) async throws -> [String] {
func runCommand(_ command: String) async throws -> [String] {

}
}

enum PackageManagerError: Error {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All these enums should have their own file

}

private func downloadBinary(_ source: PackageSource, _ url: URL) async throws {
_ = try await URLSession.shared.data(from: url)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this not just throwing away the downloaded data? I think this should be saved to a file here

fail failed: Bool
) {
if failed {
NotificationCenter.default.post(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like this should be a notification instead of an activity view item. cc @austincondiff, you might have a stronger opinion on those semantics.

Comment on lines +70 to +77
case .invalidResponse(let statusCode):
print("Invalid response received: \(statusCode)")
case let .downloadFailed(url, error):
print("Download failed for \(url.absoluteString): \(error.localizedDescription)")
case let .maxRetriesExceeded(url, error):
print("Max retries exceeded for \(url.absoluteString): \(error.localizedDescription)")
case let .writeFailed(error):
print("Failed to write files to disk: \(error.localizedDescription)")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer error messages be in the localizedError variable on the error, rather than in a method somewhere detached from the error type. That would simplify this method as well.

Also, lets use a Logger here and elsewhere for logging errors and status. That'll make these logs easier to track down and we can attach severity to them.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All the uses of internal here are redundant. Methods and variables are internal by default.

@@ -11,6 +11,7 @@ import Foundation
import LanguageClient
import LanguageServerProtocol
import CodeEditLanguages
import SwiftUICore
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
import SwiftUICore
import SwiftUI

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really dislike the addition of SwiftUI in this file, but after trying to solve it we may need to work out a better method for opening windows more generally. We'll keep this for now, and thanks for adding that TODO.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request language server Issues or Pull Requests related to language servers.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants