languages: add css and tailwind language support

This commit is contained in:
NotAShelf 2024-01-24 20:39:07 +03:00
parent f2c8413407
commit d47f45729f
No known key found for this signature in database
GPG key ID: 02D1DD3FA08B6B29
5 changed files with 157 additions and 18 deletions

View file

@ -56,15 +56,8 @@ inputs: let
nix.enable = true; nix.enable = true;
html.enable = isMaximal; html.enable = isMaximal;
clang = { css.enable = isMaximal;
enable = isMaximal;
lsp.server = "clangd";
};
sql.enable = isMaximal; sql.enable = isMaximal;
rust = {
enable = isMaximal;
crates.enable = true;
};
java.enable = isMaximal; java.enable = isMaximal;
ts.enable = isMaximal; ts.enable = isMaximal;
svelte.enable = isMaximal; svelte.enable = isMaximal;
@ -72,9 +65,19 @@ inputs: let
zig.enable = isMaximal; zig.enable = isMaximal;
python.enable = isMaximal; python.enable = isMaximal;
dart.enable = isMaximal; dart.enable = isMaximal;
elixir.enable = false; elixir.enable = isMaximal;
bash.enable = isMaximal; bash.enable = isMaximal;
terraform.enable = isMaximal; terraform.enable = isMaximal;
tailwind.enable = isMaximal;
clang = {
enable = isMaximal;
lsp.server = "clangd";
};
rust = {
enable = isMaximal;
crates.enable = true;
};
}; };
vim.visuals = { vim.visuals = {

View file

@ -22,6 +22,9 @@ Release notes for release 0.6
a warning if used. You are recommended to rewrite your neocord config from scratch based on the a warning if used. You are recommended to rewrite your neocord config from scratch based on the
[official documentation](https://github.com/IogaMaster/neocord) [official documentation](https://github.com/IogaMaster/neocord)
- Added support for css and tailwindcss through vscode-language-servers-extracted & tailwind-language-server.
Those can be enabled through `vim.languages.css` and `vim.languages.tailwind`
[donnerinoern](https://github.com/donnerinoern): [donnerinoern](https://github.com/donnerinoern):
- Added Gruvbox theme - Added Gruvbox theme

74
modules/languages/css.nix Normal file
View file

@ -0,0 +1,74 @@
{
config,
pkgs,
lib,
...
}: let
inherit (builtins) attrNames;
inherit (lib) mkEnableOption mkOption mkIf mkMerge isList types nvim;
cfg = config.vim.languages.css;
defaultServer = "vscode-langservers-extracted";
servers = {
vscode-langservers-extracted = {
package = pkgs.nodePackages.vscode-langservers-extracted;
lspConfig = ''
-- enable (broadcasting) snippet capability for completion
-- see <https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#cssls>
local css_capabilities = vim.lsp.protocol.make_client_capabilities()
css_capabilities.textDocument.completion.completionItem.snippetSupport = true
-- cssls setup
lspconfig.cssls.setup {
capabilities = css_capabilities;
on_attach = default_on_attach;
cmd = ${
if isList cfg.lsp.package
then nvim.lua.expToLua cfg.lsp.package
else ''{"${cfg.lsp.package}/bin/vscode-css-language-server", "--stdio"}''
}
}
'';
};
};
in {
options.vim.languages.css = {
enable = mkEnableOption "CSS language support";
treesitter = {
enable = mkEnableOption "CSS treesitter" // {default = config.vim.languages.enableTreesitter;};
package = nvim.types.mkGrammarOption pkgs "css";
};
lsp = {
enable = mkEnableOption "CSS LSP support" // {default = config.vim.languages.enableLSP;};
server = mkOption {
description = "CSS LSP server to use";
type = with types; enum (attrNames servers);
default = defaultServer;
};
package = mkOption {
description = "CSS LSP server package, or the command to run as a list of strings";
example = ''[lib.getExe pkgs.jdt-language-server " - data " " ~/.cache/jdtls/workspace "]'';
type = with types; either package (listOf str);
default = servers.${cfg.lsp.server}.package;
};
};
};
config = mkIf cfg.enable (mkMerge [
(mkIf cfg.treesitter.enable {
vim.treesitter.enable = true;
vim.treesitter.grammars = [cfg.treesitter.package];
})
(mkIf cfg.lsp.enable {
vim.lsp.lspconfig.enable = true;
vim.lsp.lspconfig.sources.tailwindcss-lsp = servers.${cfg.lsp.server}.lspConfig;
})
]);
}

View file

@ -2,26 +2,28 @@
inherit (lib.nvim.languages) mkEnable; inherit (lib.nvim.languages) mkEnable;
in { in {
imports = [ imports = [
./markdown ./bash
./tidal
./dart ./dart
./elixir ./elixir
./bash ./markdown
./tidal
./clang.nix ./clang.nix
./css.nix
./go.nix ./go.nix
./html.nix
./java.nix
./lua.nix
./nix.nix ./nix.nix
./php.nix
./python.nix ./python.nix
./rust.nix ./rust.nix
./sql.nix ./sql.nix
./svelte.nix
./tailwind.nix
./terraform.nix
./ts.nix ./ts.nix
./zig.nix ./zig.nix
./html.nix
./svelte.nix
./java.nix
./lua.nix
./php.nix
./terraform.nix
]; ];
options.vim.languages = { options.vim.languages = {

View file

@ -0,0 +1,57 @@
{
config,
pkgs,
lib,
...
}: let
inherit (builtins) attrNames;
inherit (lib) mkEnableOption mkOption mkIf mkMerge isList types nvim;
cfg = config.vim.languages.tailwind;
defaultServer = "tailwindcss-language-server";
servers = {
tailwindcss-language-server = {
package = pkgs.tailwindcss-language-server;
lspConfig = ''
lspconfig.tailwindcss.setup {
capabilities = capabilities;
on_attach = default_on_attach;
cmd = ${
if isList cfg.lsp.package
then nvim.lua.expToLua cfg.lsp.package
else ''{"${cfg.lsp.package}/bin/tailwindcss-language-server", "--stdio"}''
}
}
'';
};
};
in {
options.vim.languages.tailwind = {
enable = mkEnableOption "Tailwindcss language support";
lsp = {
enable = mkEnableOption "Tailwindcss LSP support" // {default = config.vim.languages.enableLSP;};
server = mkOption {
description = "Tailwindcss LSP server to use";
type = with types; enum (attrNames servers);
default = defaultServer;
};
package = mkOption {
description = "Tailwindcss LSP server package, or the command to run as a list of strings";
example = ''[lib.getExe pkgs.jdt-language-server " - data " " ~/.cache/jdtls/workspace "]'';
type = with types; either package (listOf str);
default = servers.${cfg.lsp.server}.package;
};
};
};
config = mkIf cfg.enable (mkMerge [
(mkIf cfg.lsp.enable {
vim.lsp.lspconfig.enable = true;
vim.lsp.lspconfig.sources.css-lsp = servers.${cfg.lsp.server}.lspConfig;
})
]);
}