From 570e79b07612dae926fed40591128b81a13e62f2 Mon Sep 17 00:00:00 2001 From: kalmenn Date: Thu, 29 Feb 2024 18:55:10 +0100 Subject: [PATCH] fix(lsp): Properly recognize wgsl files --- lua/plugins/lsp.lua | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/lua/plugins/lsp.lua b/lua/plugins/lsp.lua index 1037e0d..babad16 100644 --- a/lua/plugins/lsp.lua +++ b/lua/plugins/lsp.lua @@ -1,3 +1,17 @@ +--- Automatically set the filetype for all buffers matching a pattern. +--- Uses an autocommand under the hood +--- @param pattern string|string[] What buffers to match on. +--- @see vim.api.nvim_create_autocmd +--- @param filetype string The filetype to set for the matching buffers +local function bind_filetype(pattern, filetype) + vim.api.nvim_create_autocmd({ "BufNewFile", "BufRead" }, { + pattern = pattern, + callback = function() + vim.bo.filetype = filetype + end, + }) +end + return { { import = "plugins/languages" }, { @@ -50,6 +64,8 @@ return { local capabilities = require("cmp_nvim_lsp").default_capabilities() local lspconfig = require("lspconfig") + bind_filetype("*.wgsl", "wgsl") + require("mason-lspconfig").setup({ handlers = { -- default handler