mirror of
https://github.com/NotAShelf/nvf.git
synced 2026-05-19 05:24:22 +00:00
languages/env: init
This commit is contained in:
parent
1a482a2437
commit
cf0cd54481
4 changed files with 74 additions and 0 deletions
|
|
@ -80,6 +80,7 @@ isMaximal: {
|
||||||
xml.enable = isMaximal;
|
xml.enable = isMaximal;
|
||||||
tex.enable = isMaximal;
|
tex.enable = isMaximal;
|
||||||
docker.enable = isMaximal;
|
docker.enable = isMaximal;
|
||||||
|
env.enable = isMaximal;
|
||||||
|
|
||||||
# Language modules that are not as common.
|
# Language modules that are not as common.
|
||||||
openscad.enable = false;
|
openscad.enable = false;
|
||||||
|
|
|
||||||
|
|
@ -410,6 +410,8 @@
|
||||||
|
|
||||||
- Add `languages.gettext`. This only provides highlighting.
|
- Add `languages.gettext`. This only provides highlighting.
|
||||||
|
|
||||||
|
- Add `languages.env`. This provides extra filetype hooks and diagnostics.
|
||||||
|
|
||||||
- Add `languages.openscad` using
|
- Add `languages.openscad` using
|
||||||
[`openscad-lsp`](https://github.com/Leathong/openscad-LSP). This currently
|
[`openscad-lsp`](https://github.com/Leathong/openscad-LSP). This currently
|
||||||
relies on neovim builtin syntax for highlighting, and the lsp for formatting
|
relies on neovim builtin syntax for highlighting, and the lsp for formatting
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ in {
|
||||||
./asm.nix
|
./asm.nix
|
||||||
./astro.nix
|
./astro.nix
|
||||||
./bash.nix
|
./bash.nix
|
||||||
|
./env.nix
|
||||||
./cue.nix
|
./cue.nix
|
||||||
./dart.nix
|
./dart.nix
|
||||||
./clang.nix
|
./clang.nix
|
||||||
|
|
|
||||||
70
modules/plugins/languages/env.nix
Normal file
70
modules/plugins/languages/env.nix
Normal file
|
|
@ -0,0 +1,70 @@
|
||||||
|
{
|
||||||
|
config,
|
||||||
|
pkgs,
|
||||||
|
lib,
|
||||||
|
...
|
||||||
|
}: let
|
||||||
|
inherit (lib.options) mkEnableOption literalExpression;
|
||||||
|
inherit (lib.meta) getExe;
|
||||||
|
inherit (lib.modules) mkIf mkMerge;
|
||||||
|
inherit (lib.nvim.types) diagnostics;
|
||||||
|
|
||||||
|
cfg = config.vim.languages.env;
|
||||||
|
|
||||||
|
defaultDiagnosticsProvider = ["dotenv-linter"];
|
||||||
|
diagnosticsProviders = {
|
||||||
|
dotenv-linter = let
|
||||||
|
pkg = pkgs.dotenv-linter;
|
||||||
|
in {
|
||||||
|
package = pkg;
|
||||||
|
config = {
|
||||||
|
cmd = getExe pkg;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
in {
|
||||||
|
options.vim.languages.env = {
|
||||||
|
enable = mkEnableOption "Env language support";
|
||||||
|
|
||||||
|
extraDiagnostics = {
|
||||||
|
enable =
|
||||||
|
mkEnableOption "extra Env diagnostics"
|
||||||
|
// {
|
||||||
|
default = config.vim.languages.enableExtraDiagnostics;
|
||||||
|
defaultText = literalExpression "config.vim.languages.enableExtraDiagnostics";
|
||||||
|
};
|
||||||
|
types = diagnostics {
|
||||||
|
langDesc = "Env";
|
||||||
|
inherit diagnosticsProviders;
|
||||||
|
inherit defaultDiagnosticsProvider;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
config = mkIf cfg.enable (mkMerge [
|
||||||
|
{
|
||||||
|
vim.autocmds = [
|
||||||
|
{
|
||||||
|
event = ["BufRead" "BufNewFile"];
|
||||||
|
pattern = [
|
||||||
|
# support common names like `dist.env`
|
||||||
|
"*.env"
|
||||||
|
# support weird env files names like symfony ones.
|
||||||
|
".env.*"
|
||||||
|
];
|
||||||
|
command = "set filetype=env";
|
||||||
|
}
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
(mkIf cfg.extraDiagnostics.enable {
|
||||||
|
vim.diagnostics.nvim-lint = {
|
||||||
|
enable = true;
|
||||||
|
linters_by_ft.env = cfg.extraDiagnostics.types;
|
||||||
|
linters =
|
||||||
|
mkMerge (map (name: {${name} = diagnosticsProviders.${name}.config;})
|
||||||
|
cfg.extraDiagnostics.types);
|
||||||
|
};
|
||||||
|
})
|
||||||
|
]);
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue