mirror of
https://github.com/NotAShelf/neovim-flake.git
synced 2024-11-07 16:05:58 +01:00
Merge eb288de4cf
into c957b23aaa
This commit is contained in:
commit
0e23f4eb85
2 changed files with 72 additions and 0 deletions
|
@ -8,6 +8,7 @@ in {
|
|||
./css.nix
|
||||
./elixir.nix
|
||||
./go.nix
|
||||
./hcl.nix
|
||||
./html.nix
|
||||
./java.nix
|
||||
./lua.nix
|
||||
|
|
71
modules/plugins/languages/hcl.nix
Normal file
71
modules/plugins/languages/hcl.nix
Normal file
|
@ -0,0 +1,71 @@
|
|||
{
|
||||
config,
|
||||
pkgs,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (lib.options) mkEnableOption mkOption;
|
||||
inherit (lib.modules) mkIf mkMerge;
|
||||
inherit (lib.types) package;
|
||||
inherit (lib.nvim.types) mkGrammarOption;
|
||||
|
||||
cfg = config.vim.languages.hcl;
|
||||
in {
|
||||
options.vim.languages.hcl = {
|
||||
enable = mkEnableOption "HCL support";
|
||||
|
||||
treesitter = {
|
||||
enable = mkEnableOption "HCL treesitter" // {default = config.vim.languages.enableTreesitter;};
|
||||
package = mkGrammarOption pkgs "hcl";
|
||||
};
|
||||
|
||||
lsp = {
|
||||
enable = mkEnableOption "HCL LSP support (terraform-ls)" // {default = config.vim.languages.enableLSP;};
|
||||
# TODO: it would be cooler to use vscode-extensions.hashicorp.hcl probably, shouldn't be too hard
|
||||
# TODO: formatter, suppied by above or ...
|
||||
# FIXME: or should we somehow integrate this:
|
||||
#` https://git.mzte.de/nvim-plugins/null-ls.nvim/commit/e1fb7e2b2e4400835e23b9603a19813be119852b ??
|
||||
package = mkOption {
|
||||
description = "HCL ls package (terraform-ls)";
|
||||
type = package;
|
||||
default = pkgs.terraform-ls;
|
||||
};
|
||||
};
|
||||
};
|
||||
config = mkIf cfg.enable (mkMerge [
|
||||
{
|
||||
vim.pluginRC.hcl = ''
|
||||
vim.api.nvim_create_autocmd("FileType", {
|
||||
pattern = "hcl",
|
||||
callback = function(opts)
|
||||
local bo = vim.bo[opts.buf]
|
||||
bo.tabstop = 2
|
||||
bo.shiftwidth = 2
|
||||
bo.softtabstop = 2
|
||||
end
|
||||
})
|
||||
|
||||
local ft = require('Comment.ft')
|
||||
ft
|
||||
.set('hcl', '#%s')
|
||||
'';
|
||||
}
|
||||
(mkIf cfg.treesitter.enable {
|
||||
vim.treesitter.enable = true;
|
||||
vim.treesitter.grammars = [cfg.treesitter.package];
|
||||
})
|
||||
|
||||
(mkIf cfg.lsp.enable {
|
||||
vim.lsp.lspconfig.enable = true;
|
||||
vim.lsp.lspconfig.sources = lib.optionalAttrs (! config.vim.languages.terraform.lsp.enable) {
|
||||
terraform-ls = ''
|
||||
lspconfig.terraformls.setup {
|
||||
capabilities = capabilities,
|
||||
on_attach=default_on_attach,
|
||||
cmd = {"${cfg.lsp.package}/bin/terraform-ls", "serve"},
|
||||
}
|
||||
'';
|
||||
};
|
||||
})
|
||||
]);
|
||||
}
|
Loading…
Reference in a new issue