mirror of
https://github.com/NotAShelf/nvf.git
synced 2024-11-22 13:20:44 +00:00
Compare commits
2 commits
659067a44f
...
bcd36bc460
Author | SHA1 | Date | |
---|---|---|---|
|
bcd36bc460 | ||
|
4d4235e24d |
1 changed files with 9 additions and 8 deletions
|
@ -14,13 +14,13 @@
|
||||||
|
|
||||||
defaultServer = "terraform-ls";
|
defaultServer = "terraform-ls";
|
||||||
servers = {
|
servers = {
|
||||||
terraform-ls = rec {
|
terraform-ls = {
|
||||||
package = pkgs.terraform-ls;
|
package = pkgs.terraform-ls;
|
||||||
lspConfig = ''
|
lspConfig = ''
|
||||||
lspconfig.terraformls.setup {
|
lspconfig.terraformls.setup {
|
||||||
capabilities = capabilities,
|
capabilities = capabilities,
|
||||||
on_attach=default_on_attach,
|
on_attach=default_on_attach,
|
||||||
cmd = {"${lib.getExe package}", "serve"},
|
cmd = {"${lib.getExe cfg.lsp.package}", "serve"},
|
||||||
}
|
}
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
@ -28,13 +28,13 @@
|
||||||
|
|
||||||
defaultFormat = "hclfmt";
|
defaultFormat = "hclfmt";
|
||||||
formats = {
|
formats = {
|
||||||
hclfmt = rec {
|
hclfmt = {
|
||||||
package = pkgs.hclfmt;
|
package = pkgs.hclfmt;
|
||||||
nullConfig = ''
|
nullConfig = ''
|
||||||
table.insert(
|
table.insert(
|
||||||
ls_sources,
|
ls_sources,
|
||||||
null_ls.builtins.formatting.hclfmt.with({
|
null_ls.builtins.formatting.hclfmt.with({
|
||||||
command = "${lib.getExe package}",
|
command = "${lib.getExe cfg.format.package}",
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
'';
|
'';
|
||||||
|
@ -53,33 +53,34 @@ in {
|
||||||
enable = mkEnableOption "HCL LSP support (terraform-ls)" // {default = config.vim.languages.enableLSP;};
|
enable = mkEnableOption "HCL LSP support (terraform-ls)" // {default = config.vim.languages.enableLSP;};
|
||||||
# TODO: (maybe, is it better?) it would be cooler to use vscode-extensions.hashicorp.hcl probably, shouldn't be too hard
|
# TODO: (maybe, is it better?) it would be cooler to use vscode-extensions.hashicorp.hcl probably, shouldn't be too hard
|
||||||
package = mkOption {
|
package = mkOption {
|
||||||
description = "HCL language server package (terraform-ls)";
|
|
||||||
type = package;
|
type = package;
|
||||||
default = servers.${defaultServer}.package;
|
default = servers.${defaultServer}.package;
|
||||||
|
description = "HCL language server package (terraform-ls)";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
format = {
|
format = {
|
||||||
enable = mkOption {
|
enable = mkOption {
|
||||||
description = "Enable HCL formatting";
|
|
||||||
type = bool;
|
type = bool;
|
||||||
default = config.vim.languages.enableFormat;
|
default = config.vim.languages.enableFormat;
|
||||||
|
description = "Enable HCL formatting";
|
||||||
};
|
};
|
||||||
type = mkOption {
|
type = mkOption {
|
||||||
description = "HCL formatter to use";
|
|
||||||
type = enum (attrNames formats);
|
type = enum (attrNames formats);
|
||||||
default = defaultFormat;
|
default = defaultFormat;
|
||||||
|
description = "HCL formatter to use";
|
||||||
};
|
};
|
||||||
package = mkOption {
|
package = mkOption {
|
||||||
description = "HCL formatter package";
|
|
||||||
type = package;
|
type = package;
|
||||||
default = formats.${cfg.format.type}.package;
|
default = formats.${cfg.format.type}.package;
|
||||||
|
description = "HCL formatter package";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
config = mkIf cfg.enable (mkMerge [
|
config = mkIf cfg.enable (mkMerge [
|
||||||
{
|
{
|
||||||
|
# hcl style official: https://developer.hashicorp.com/terraform/language/style#code-formatting
|
||||||
vim.pluginRC.hcl = ''
|
vim.pluginRC.hcl = ''
|
||||||
vim.api.nvim_create_autocmd("FileType", {
|
vim.api.nvim_create_autocmd("FileType", {
|
||||||
pattern = "hcl",
|
pattern = "hcl",
|
||||||
|
|
Loading…
Reference in a new issue