add vscode tf snippets, fix tf tree-sitter

This commit is contained in:
Noah Masur 2023-07-06 12:07:29 -06:00
parent 38480e0c0c
commit d4e203a04c
6 changed files with 38 additions and 3 deletions

View File

@ -413,6 +413,7 @@
"telescope-nvim-src": "telescope-nvim-src", "telescope-nvim-src": "telescope-nvim-src",
"telescope-project-nvim-src": "telescope-project-nvim-src", "telescope-project-nvim-src": "telescope-project-nvim-src",
"toggleterm-nvim-src": "toggleterm-nvim-src", "toggleterm-nvim-src": "toggleterm-nvim-src",
"vscode-terraform-snippets": "vscode-terraform-snippets",
"wallpapers": "wallpapers", "wallpapers": "wallpapers",
"wsl": "wsl" "wsl": "wsl"
} }
@ -522,6 +523,22 @@
"type": "github" "type": "github"
} }
}, },
"vscode-terraform-snippets": {
"flake": false,
"locked": {
"lastModified": 1688666727,
"narHash": "sha256-qw6/N1nDPgZXQ2T0DRK2WoNC2KLkNTJRVm5yNqzMcIg=",
"owner": "nmasur",
"repo": "vscode-terraform-snippets",
"rev": "6e37735ef6fdd72352e4b73e2bfaa3706fcff7e0",
"type": "github"
},
"original": {
"owner": "nmasur",
"repo": "vscode-terraform-snippets",
"type": "github"
}
},
"wallpapers": { "wallpapers": {
"flake": false, "flake": false,
"locked": { "locked": {

View File

@ -103,6 +103,10 @@
url = "github:kyazdani42/nvim-tree.lua"; url = "github:kyazdani42/nvim-tree.lua";
flake = false; flake = false;
}; };
vscode-terraform-snippets = {
url = "github:nmasur/vscode-terraform-snippets";
flake = false;
};
}; };

View File

@ -135,6 +135,13 @@
}; };
lua = '' lua = ''
-- Load snippets
-- Check status: :lua require("luasnip").log.open()
require("luasnip.loaders.from_vscode").lazy_load()
require("luasnip.loaders.from_vscode").lazy_load({ paths = { "${
builtins.toString pkgs.vscode-terraform-snippets
}" } })
-- Use buffer source for `/` -- Use buffer source for `/`
require('cmp').setup.cmdline("/", { require('cmp').setup.cmdline("/", {
sources = { sources = {

View File

@ -1,4 +1,4 @@
{ pkgs, ... }: { { pkgs, lib, ... }: {
plugins = [ plugins = [
(pkgs.vimPlugins.nvim-treesitter.withPlugins (_plugins: (pkgs.vimPlugins.nvim-treesitter.withPlugins (_plugins:
@ -49,4 +49,10 @@
}; };
}; };
# Use mkAfter to ensure tree-sitter is already loaded
lua = lib.mkAfter ''
-- Use HCL parser with .tf files
vim.treesitter.language.register('hcl', 'terraform')
'';
} }

View File

@ -4,8 +4,8 @@
vim.filetype.add({ vim.filetype.add({
pattern = { pattern = {
[".*%.tfvars"] = "hcl", [".*%.tfvars"] = "terraform",
[".*%.tf"] = "hcl", [".*%.tf"] = "terraform",
[".*%.rasi"] = "css", [".*%.rasi"] = "css",
}, },
}) })

View File

@ -17,6 +17,7 @@ let
in { in {
nil = inputs.nil.packages.${prev.system}.nil; nil = inputs.nil.packages.${prev.system}.nil;
vscode-terraform-snippets = inputs.vscode-terraform-snippets;
nvim-lspconfig = nvim-lspconfig =
(withSrc prev.vimPlugins.nvim-lspconfig inputs.nvim-lspconfig); (withSrc prev.vimPlugins.nvim-lspconfig inputs.nvim-lspconfig);