Open mnaser opened 7 months ago
Hi, there is a common problem with file detection when using helm-ls and yamlls, described in this issue
The only possible fix I've found is to install the vim-helm plugin via lazy and use this plugin definition: "ft = helm" (like this comment suggest)
Is there a way to achieve this in the context of nixvim ?
The only possible fix I've found is to install the vim-helm plugin via lazy and use this plugin definition: "ft = helm" (like this comment suggest)
Is there a way to achieve this in the context of nixvim ?
Does this section of the docs answer your question?
I'm half asking if our docs are any good and half asking if defining a vim filetype is the solution 😁
The problem with the LSP-config is that it seems you cannot exclude an LSP server for a defined filetype. With the following declaration, opening a helm file (detection of the helm file type is based on the dir of the files, which must be on */template/*.yaml) with yaml file extension will trigger helmls and yamlls, but the expected behaviour, in this context, is to attach only helmls.
{
plugins = {
helm.enable = true;
lsp.servers = {
helm-ls = {
filetypes = ["helm"];
enable = true;
};
yamlls = {
enable = true;
filetypes = ["yaml"];
};
};
};
}
Sadly I cannot find how to exclude a filetype for a specific LSP in LSP-config...
It's really frustrating, is like the only way to have a proper support for helm is to use this "obscure" lazy option.
There is no way to have a similar behavior in Nixvim context ?
Does calling setup
in a ftplugin file help?
You mean like this ?
{
extraFiles = {
"ftplugin/lazy.lua".text = ''
require("lazy").setup({
-- towolf/vim-helm provides basic syntax highlighting and filetype detection
-- ft = 'helm' is important to not start yamlls
{ 'towolf/vim-helm', ft = 'helm' },
})
'';
};
plugins = {
# helm.enable = true;
lazy.enable = true;
lsp.servers = {
helm-ls = {
filetypes = ["helm"];
enable = true;
};
yamlls = {
enable = true;
filetypes = ["yaml"];
};
};
};
}
It doesn't seem to install the vim-helm plugin this way. And uncommenting causes the same issue as before.
(Re-opening as #997 was only ever marked as a "partial" fix)
You mean like this
I was thinking more like:
files."ftplugin/helm.lua" = {
plugins.lsp = {
enable = true;
servers.helm-ls = {
filetypes = ["helm"];
enable = true;
};
};
}
But that seems too simple to actually work, there'd probably be issues with lsp being setup more than once...
Damn, always to protect my eyes when writing/reading helm template, I disable diagnostics by stopping LSP. But this time I missclick and just restart LSP. And in this case I found the expected behavior on helm-ls !
Sadly is for this buffer only, when opening another template file I get yamlls attached too and have to restart LSP for this buffer.
This is really weird, but I think I can deal with a autocmd to restart LSP when opening a yaml file
Yeah a simply autocmd make the job !
{
autoCmd = [
{
event = "FileType";
pattern = "helm";
command = "LspRestart";
}
];
}
vim-helm
+helm-ls
Extra Information
This would be super neat to have! Thank you for the awesome project.