Launch gopls with the right arguments

Co-authored-by: Antonio Scandurra <me@as-cii.com>
This commit is contained in:
Max Brunsfeld 2022-06-08 10:25:58 -07:00
parent 8f4387a252
commit a41f164ffe
2 changed files with 12 additions and 2 deletions

View File

@ -28,6 +28,11 @@ pub fn build_language_registry(login_shell_env_loaded: Task<()>) -> LanguageRegi
tree_sitter_cpp::language(),
Some(Arc::new(c::CLspAdapter) as Arc<dyn LspAdapter>),
),
(
"go",
tree_sitter_go::language(),
Some(Arc::new(go::GoLspAdapter) as Arc<dyn LspAdapter>),
),
(
"json",
tree_sitter_json::language(),

View File

@ -26,6 +26,10 @@ impl super::LspAdapter for GoLspAdapter {
LanguageServerName("gopls".into())
}
fn server_args(&self) -> &[&str] {
&["-mode=stdio"]
}
fn fetch_latest_server_version(
&self,
http: Arc<dyn HttpClient>,
@ -99,8 +103,9 @@ impl super::LspAdapter for GoLspAdapter {
let version_stdout = str::from_utf8(&version_output.stdout)
.map_err(|_| anyhow!("gopls version produced invalid utf8"))?;
let version = GOPLS_VERSION_REGEX
.shortest_match(version_stdout)
.ok_or_else(|| anyhow!("failed to parse gopls version output"))?;
.find(version_stdout)
.ok_or_else(|| anyhow!("failed to parse gopls version output"))?
.as_str();
let binary_path = container_dir.join(&format!("gopls_{version}"));
fs::rename(&installed_binary_path, &binary_path).await?;