这是indexloc提供的服务,不要输入任何密码
Skip to content

Conversation

@YorikSar
Copy link
Contributor

Allows to configure the server when client doesn't support workspace/configuration method, for example, LanguageClient-neovim.

Copy link
Owner

@oxalica oxalica left a comment

Choose a reason for hiding this comment

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

initialization_options is for arbitrary user data. This loads the whole value and parse it as configuration. Is this a common practice? How do you pass initial configuration through this with LC-neovim?

Not sure if we should put configurations under another layer of indirection, like initialization_options.settings, for future-compatibility. Would it complicate the setup?

};

*Arc::get_mut(&mut self.config).expect("No concurrent access yet") = Config::new(root_path);
*Arc::get_mut(&mut self.config).expect("No concurrent access yet") = {
Copy link
Owner

Choose a reason for hiding this comment

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

Please unwrap the block and move the Arc setting line below.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Allows to configure the server when client doesn't support
`workspace/configuration` method, for example, LanguageClient-neovim.
Copy link
Contributor Author

@YorikSar YorikSar left a comment

Choose a reason for hiding this comment

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

initialization_options is for arbitrary user data. This loads the whole value and parse it as configuration. Is this a common practice? How do you pass initial configuration through this with LC-neovim?

LC-neovim allows to specify these options in global or workspace-specific config: https://github.com/autozimu/LanguageClient-neovim/blob/next/doc/LanguageClient.txt#L99-L112 and https://github.com/autozimu/LanguageClient-neovim/blob/next/doc/LanguageClient.txt#L289-L301. It seems it was intended to have workspace/configuration support, but that didn't happen yet.

Not sure if we should put configurations under another layer of indirection, like initialization_options.settings, for future-compatibility. Would it complicate the setup?

Notice that examples in LanguageClient-neovim docs mention that these are the values that should be expected by workspace/configuration response. I assume that other language servers use same structure for both. For example, gopls uses the same function in initialize and workflow/configuration: https://github.com/golang/tools/blob/master/gopls/internal/lsp/general.go#L60 and https://github.com/golang/tools/blob/master/gopls/internal/lsp/general.go#L517. rust-analyzer loads config directly from that field as well: https://github.com/rust-lang/rust-analyzer/blob/master/crates/rust-analyzer/src/bin/main.rs#L189-L190

};

*Arc::get_mut(&mut self.config).expect("No concurrent access yet") = Config::new(root_path);
*Arc::get_mut(&mut self.config).expect("No concurrent access yet") = {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@YorikSar YorikSar force-pushed the initialization-options branch from 04d67df to c4eee44 Compare May 25, 2023 11:45
@YorikSar YorikSar requested a review from oxalica May 25, 2023 11:45
@oxalica oxalica merged commit ca46218 into oxalica:main May 28, 2023
@oxalica
Copy link
Owner

oxalica commented May 28, 2023

Thanks!

@YorikSar YorikSar deleted the initialization-options branch June 8, 2023 13:05
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