mirror of
https://github.com/NotAShelf/nvf.git
synced 2025-04-03 03:21:52 +00:00
languages/yaml: Init (#676)
This commit is contained in:
parent
749cc793e3
commit
0fdfb9bf3b
3 changed files with 77 additions and 0 deletions
|
@ -192,3 +192,7 @@
|
||||||
- Add formatters for go: [gofmt](https://go.dev/blog/gofmt),
|
- Add formatters for go: [gofmt](https://go.dev/blog/gofmt),
|
||||||
[golines](https://github.com/segmentio/golines) and
|
[golines](https://github.com/segmentio/golines) and
|
||||||
[gofumpt](https://github.com/mvdan/gofumpt)
|
[gofumpt](https://github.com/mvdan/gofumpt)
|
||||||
|
|
||||||
|
[MaxMur](https://github.com/TheMaxMur)
|
||||||
|
|
||||||
|
- Add YAML support under `vim.languages.yaml`.
|
||||||
|
|
|
@ -39,6 +39,7 @@ in {
|
||||||
./nu.nix
|
./nu.nix
|
||||||
./odin.nix
|
./odin.nix
|
||||||
./wgsl.nix
|
./wgsl.nix
|
||||||
|
./yaml.nix
|
||||||
./ruby.nix
|
./ruby.nix
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
72
modules/plugins/languages/yaml.nix
Normal file
72
modules/plugins/languages/yaml.nix
Normal file
|
@ -0,0 +1,72 @@
|
||||||
|
{
|
||||||
|
pkgs,
|
||||||
|
config,
|
||||||
|
lib,
|
||||||
|
...
|
||||||
|
}: let
|
||||||
|
inherit (builtins) attrNames;
|
||||||
|
inherit (lib.options) mkEnableOption mkOption;
|
||||||
|
inherit (lib.modules) mkIf mkMerge;
|
||||||
|
inherit (lib.lists) isList;
|
||||||
|
inherit (lib.types) enum either listOf package str;
|
||||||
|
inherit (lib.nvim.types) mkGrammarOption;
|
||||||
|
inherit (lib.nvim.lua) expToLua;
|
||||||
|
|
||||||
|
cfg = config.vim.languages.yaml;
|
||||||
|
|
||||||
|
defaultServer = "yaml-language-server";
|
||||||
|
servers = {
|
||||||
|
yaml-language-server = {
|
||||||
|
package = pkgs.nodePackages.yaml-language-server;
|
||||||
|
lspConfig = ''
|
||||||
|
lspconfig.yamlls.setup {
|
||||||
|
capabilities = capabilities;
|
||||||
|
on_attach = default_on_attach;
|
||||||
|
cmd = ${
|
||||||
|
if isList cfg.lsp.package
|
||||||
|
then expToLua cfg.lsp.package
|
||||||
|
else ''{"${cfg.lsp.package}/bin/yaml-language-server", "--stdio"}''
|
||||||
|
},
|
||||||
|
}
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
in {
|
||||||
|
options.vim.languages.yaml = {
|
||||||
|
enable = mkEnableOption "YAML language support";
|
||||||
|
|
||||||
|
treesitter = {
|
||||||
|
enable = mkEnableOption "YAML treesitter";
|
||||||
|
|
||||||
|
package = mkGrammarOption pkgs "yaml";
|
||||||
|
};
|
||||||
|
|
||||||
|
lsp = {
|
||||||
|
enable = mkEnableOption "YAML LSP support";
|
||||||
|
|
||||||
|
server = mkOption {
|
||||||
|
type = enum (attrNames servers);
|
||||||
|
default = defaultServer;
|
||||||
|
description = "YAML LSP server to use";
|
||||||
|
};
|
||||||
|
|
||||||
|
package = mkOption {
|
||||||
|
type = either package (listOf str);
|
||||||
|
default = servers.${cfg.lsp.server}.package;
|
||||||
|
description = "YAML 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.yaml-lsp = servers.${cfg.lsp.server}.lspConfig;
|
||||||
|
})
|
||||||
|
]);
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue