Merge pull request #553 from kaktu5/main
Some checks are pending
Set up binary cache / cachix (default) (push) Waiting to run
Set up binary cache / cachix (maximal) (push) Waiting to run
Set up binary cache / cachix (nix) (push) Waiting to run
Validate flake & check documentation / Validate Flake Documentation (docs) (push) Waiting to run
Validate flake & check documentation / Validate Flake Documentation (docs-html) (push) Waiting to run
Validate flake & check documentation / Validate Flake Documentation (docs-json) (push) Waiting to run
Validate flake & check documentation / Validate Flake Documentation (docs-manpages) (push) Waiting to run
Validate flake & check documentation / Validate hyperlinks in documentation sources (push) Waiting to run
Validate flake & check formatting / Validate Flake (push) Waiting to run
Validate flake & check formatting / Formatting via Alejandra (push) Waiting to run
Build and deploy documentation / Check latest commit (push) Waiting to run
Build and deploy documentation / publish (push) Blocked by required conditions
Check for typos in the source tree / check-typos (push) Waiting to run

languages/wgsl: init module
This commit is contained in:
raf 2025-01-13 12:57:36 +03:00 committed by GitHub
commit dc5fc8c6a4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 84 additions and 0 deletions

View file

@ -53,3 +53,7 @@
issue with setting the workspace directory.
- Add `vim.snippets.luasnip.setupOpts`, which was previously missing.
- Add `"prettierd"` as a formatter option in `vim.languages.markdown.format.type`.
[kaktu5](https://github.com/kaktu5):
- Add WGSL support under `vim.languages.wgsl`.

View file

@ -38,6 +38,7 @@ in {
./julia.nix
./nu.nix
./odin.nix
./wgsl.nix
];
options.vim.languages = {

View file

@ -0,0 +1,79 @@
{
config,
lib,
pkgs,
...
}: let
inherit (builtins) attrNames;
inherit (lib.lists) isList;
inherit (lib.modules) mkIf mkMerge;
inherit (lib.nvim.lua) expToLua;
inherit (lib.nvim.types) mkGrammarOption;
inherit (lib.options) literalExpression mkEnableOption mkOption;
inherit (lib.types) either enum listOf package str;
cfg = config.vim.languages.wgsl;
defaultServer = "wgsl-analyzer";
servers = {
wgsl-analyzer = {
package = pkgs.wgsl-analyzer;
internalFormatter = true;
lspConfig = ''
lspconfig.wgsl_analyzer.setup {
capabilities = capabilities,
on_attach = default_on_attach,
cmd = ${
if isList cfg.lsp.package
then expToLua cfg.lsp.package
else "{'${cfg.lsp.package}/bin/wgsl_analyzer'}"
}
}
'';
};
};
in {
options.vim.languages.wgsl = {
enable = mkEnableOption "WGSL language support";
treesitter = {
enable = mkEnableOption "WGSL treesitter" // {default = config.vim.languages.enableTreesitter;};
package = mkGrammarOption pkgs "wgsl";
};
lsp = {
enable = mkEnableOption "WGSL LSP support" // {default = config.vim.languages.enableLSP;};
server = mkOption {
type = enum (attrNames servers);
default = defaultServer;
description = "WGSL LSP server to use";
};
package = mkOption {
description = "wgsl-analyzer package, or the command to run as a list of strings";
example = literalExpression "[(lib.getExe pkgs.wgsl-analyzer)]";
type = either package (listOf str);
default = pkgs.wgsl-analyzer;
};
};
};
config = mkIf cfg.enable (mkMerge [
(mkIf cfg.treesitter.enable {
vim.treesitter = {
enable = true;
grammars = [cfg.treesitter.package];
};
})
(mkIf cfg.lsp.enable {
vim = {
lsp.lspconfig = {
enable = true;
sources.wgsl_analyzer = servers.${cfg.lsp.server}.lspConfig;
};
};
})
]);
}