Skip to content

Commit

Permalink
languages: tailwindcss init
Browse files Browse the repository at this point in the history
  • Loading branch information
vhsconnect committed Nov 16, 2023
1 parent 20aaba9 commit b9437b9
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 3 deletions.
6 changes: 3 additions & 3 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions modules/languages/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ in
./rust.nix
./sclang.nix
./sql.nix
./tailwindcss.nix
./terraform.nix
./tidal.nix
./ts.nix
Expand Down
61 changes: 61 additions & 0 deletions modules/languages/tailwindcss.nix
Original file line number Diff line number Diff line change
@@ -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;
})
]);
}

0 comments on commit b9437b9

Please sign in to comment.