-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Implement LSP workspace/configuration
and workspace/didChangeConfiguration
#1684
Implement LSP workspace/configuration
and workspace/didChangeConfiguration
#1684
Conversation
helix-term/src/application.rs
Outdated
let doc = self.editor.documents().find(|doc| { | ||
if let Some(server) = doc.language_server() { | ||
if server.id() != server_id { | ||
return false; | ||
} | ||
// The server may request the config for a specific document. | ||
// Currently, the configs should all be the same but we might | ||
// suport per-document configuration in the future. | ||
if let Some(scope) = &item.scope_uri { | ||
if Some(scope) != doc.url().as_ref() { | ||
return false; | ||
} | ||
} | ||
true | ||
} else { | ||
false | ||
} | ||
})?; | ||
let mut config = doc.language_config()?.config.as_ref()?; | ||
if let Some(section) = item.section.as_ref() { | ||
for part in section.split('.') { | ||
config = config.get(part)?; | ||
} | ||
} | ||
Some(config) |
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.
I'd check scope uri first, look up the doc like this:
helix/helix-term/src/application.rs
Lines 587 to 588 in 5cfdb6d
let path = params.uri.to_file_path().unwrap(); | |
let doc = self.editor.document_by_path_mut(&path); |
helix-term/src/application.rs
Outdated
let config = self.editor.documents().find_map(|doc| { | ||
if doc.language_server().map(|server| server.id()) == Some(server_id) { | ||
doc.language_config() | ||
.and_then(|config| config.config.clone()) | ||
} else { | ||
None | ||
} | ||
}); |
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.
We register language servers by language_config.scope
:
Lines 309 to 314 in 5cfdb6d
let config = match &language_config.language_server { | |
Some(config) => config, | |
None => return Err(Error::LspNotDefined), | |
}; | |
match self.inner.entry(language_config.scope.clone()) { |
I'd add a reverse lookup method that can scan over (scope, server) in language_servers.iter()
return scope where server.id() == id
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.
I just saw that the LSP Client
struct stores the config. I added a getter for it, that makes it a lot simpler.
helix-lsp/src/client.rs
Outdated
pub fn config(&self) -> &Option<Value> { | ||
&self.config | ||
} |
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.
pub fn config(&self) -> &Option<Value> { | |
&self.config | |
} | |
pub fn config(&self) -> Option<&Value> { | |
self.config.as_ref() | |
} |
helix-term/src/application.rs
Outdated
let config = language_server.config(); | ||
if let Some(config) = config { |
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.
let config = language_server.config(); | |
if let Some(config) = config { | |
if let Some(config) = language_server.config() { |
helix-term/src/application.rs
Outdated
None => self.editor.documents().find(|doc| { | ||
doc.language_server() | ||
.map(|server| server.id() == server_id) | ||
.unwrap_or(false) | ||
})?, |
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.
This should be simplifiable now too by just using language_server.config()
?
I am trying to setup the HTML language server, but it won't accept the
It is documented here I can't find any examples of using
Neovim settings are https://github.com/neovim/nvim-lspconfig/blob/master/lua/lspconfig/server_configurations/html.lua |
I think the issue is that you have to provide the config in the config = { settings = { "html.format.enable" = true } } This should probably be documented somewhere, it can be a bit unexpected. |
@Triton171 Cheers! I am afraid it doesn't work, but I think that is because what is actually needed is https://microsoft.github.io/language-server-protocol/specification#initialize Looking at the Neovim Wiki https://github.com/neovim/nvim-lspconfig/wiki/Understanding-setup-%7B%7D I see: init_options
The HTML server is Neovim uses:
Is there a way to do this in Helix? |
@David-Else The contents of the [[language]]
name = "html"
config = { html.format.enable = true } In Neovim only the contents of the
[[langauge]]
name = "html"
[language.config]
provideFormatter = true
embeddedLanguages = { css = true, javascript = true }
configurationSection = { "html", "css", "javascript" } might work. |
This partially fixes #1268, LSP configuration should now work with all servers (tested with texlab). Even though we don't yet allow for changing settings on the fly, providing the
workspace/didChangeConfiguration
capability has some advantages: