From a6eb51e5b5897749bed8721ce98cd2491b2ea8e2 Mon Sep 17 00:00:00 2001 From: Halibut Git Wiz <19535471+HalibutGitWiz@users.noreply.github.com> Date: Mon, 20 Oct 2025 08:19:38 +0000 Subject: [PATCH] feat(extras): added twig language (#5464) ## Description Adds Twig templates language support as en extra. Explanation for the tools choices: - Linter/formatter: Twigcs and Twig-cs-fixer both follow the [coding standards](https://twig.symfony.com/doc/3.x/coding_standards.html) recommended by the Symfony Project, maintainers of Twig. - LSP: I don't know it Twiggy is considered a standard in the community. I picked it because it's the only server specific to Twig. The other options are HTML servers that also include support for several templates languages. I've been using it for a while and it works fine. It adds much needed snippets (Twig syntax involves tags that are difficult to type on most keyboards) and does not conflict with Twigcs diagnostics. ## Checklist - [x] I've read the [CONTRIBUTING](https://github.com/LazyVim/LazyVim/blob/main/CONTRIBUTING.md) guidelines. --------- Co-authored-by: tw --- lua/lazyvim/plugins/extras/lang/twig.lua | 58 ++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 lua/lazyvim/plugins/extras/lang/twig.lua diff --git a/lua/lazyvim/plugins/extras/lang/twig.lua b/lua/lazyvim/plugins/extras/lang/twig.lua new file mode 100644 index 00000000..ad2f260f --- /dev/null +++ b/lua/lazyvim/plugins/extras/lang/twig.lua @@ -0,0 +1,58 @@ +return { + recommended = function() + return LazyVim.extras.wants({ + ft = "twig", + }) + end, + { + "nvim-treesitter/nvim-treesitter", + opts = { ensure_installed = { "twig" } }, + }, + { + "williamboman/mason.nvim", + opts = { + ensure_installed = { + "twigcs", + "twig-cs-fixer", + }, + }, + }, + { + "neovim/nvim-lspconfig", + opts = { + servers = { + twiggy_language_server = { + enabled = true, + }, + }, + }, + }, + { + "nvimtools/none-ls.nvim", + optional = true, + opts = function(_, opts) + local nls = require("null-ls") + opts.sources = opts.sources or {} + table.insert(opts.sources, nls.builtins.diagnostics.twigcs) + -- Twig-CS-Fixer builtin not available in none-ls + end, + }, + { + "mfussenegger/nvim-lint", + optional = true, + opts = { + linters_by_ft = { + twig = { "twigcs" }, + }, + }, + }, + { + "stevearc/conform.nvim", + optional = true, + opts = { + formatters_by_ft = { + twig = { "twig-cs-fixer" }, + }, + }, + }, +}