diff --git a/flake.lock b/flake.lock index 474b6fa..c88e28e 100644 --- a/flake.lock +++ b/flake.lock @@ -82,11 +82,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1697793076, - "narHash": "sha256-02e7sCuqLtkyRgrZmdOyvAcQTQdcXj+vpyp9bca6cY4=", + "lastModified": 1700108881, + "narHash": "sha256-+Lqybl8kj0+nD/IlAWPPG/RDTa47gff9nbei0u7BntE=", "owner": "nixos", "repo": "nixpkgs", - "rev": "038b2922be3fc096e1d456f93f7d0f4090628729", + "rev": "7414e9ee0b3e9903c24d3379f577a417f0aae5f1", "type": "github" }, "original": { diff --git a/modules/languages/default.nix b/modules/languages/default.nix index 31ada73..3e9d9f1 100644 --- a/modules/languages/default.nix +++ b/modules/languages/default.nix @@ -23,6 +23,7 @@ in ./rust.nix ./sclang.nix ./sql.nix + ./tailwindcss.nix ./terraform.nix ./tidal.nix ./ts.nix diff --git a/modules/languages/tailwindcss.nix b/modules/languages/tailwindcss.nix new file mode 100644 index 0000000..f23d65e --- /dev/null +++ b/modules/languages/tailwindcss.nix @@ -0,0 +1,61 @@ +{ pkgs +, config +, lib +, ... +}: +with lib; +with builtins; +let + cfg = config.vim.languages.tailwindcss; + + defaultServer = "tailwindcss-language-server"; + servers = { + tailwindcss-language-server = { + package = [ "tailwindcss-language-server" ]; + + lspConfig = /*lua*/'' + lspconfig.tailwindcss.setup{ + cmd = {"${nvim.languages.commandOptToCmd cfg.lsp.package "tailwindcss-language-server"}", "--stdio"}; + } + ''; + }; + }; +in +{ + options.vim.languages.tailwindcss = { + enable = mkEnableOption "TailwindCSS language support"; + + lsp = { + enable = mkOption { + description = "Enable TailwindCSS LSP support"; + type = types.bool; + default = config.vim.languages.enableLSP; + }; + server = mkOption { + description = "TailwindCSS LSP server to use"; + type = with types; enum (attrNames servers); + default = defaultServer; + }; + package = nvim.options.mkCommandOption pkgs { + description = "TailwindCSS LSP server"; + inherit (servers.${cfg.lsp.server}) package; + }; + }; + + treesitter = { + enable = mkOption { + description = "Enable Tailwind treesitter"; + type = types.bool; + default = config.vim.languages.enableTreesitter; + }; + package = nvim.options.mkGrammarOption pkgs "tailwindcss"; + }; + }; + + config = mkIf cfg.enable (mkMerge [ + (mkIf cfg.lsp.enable { + vim.lsp.lspconfig.enable = true; + vim.lsp.lspconfig.sources.tailwindcss-lsp = servers.${cfg.lsp.server}.lspConfig; + }) + ]); +}