mirror of
https://github.com/NotAShelf/neovim-flake.git
synced 2026-05-11 07:18:04 +02:00
Merge edce53a85e into e86a92e4b2
This commit is contained in:
commit
a73fb398eb
4 changed files with 74 additions and 0 deletions
|
|
@ -79,6 +79,7 @@ isMaximal: {
|
|||
toml.enable = isMaximal;
|
||||
xml.enable = isMaximal;
|
||||
tex.enable = isMaximal;
|
||||
env.enable = isMaximal;
|
||||
|
||||
# Language modules that are not as common.
|
||||
openscad.enable = false;
|
||||
|
|
|
|||
|
|
@ -400,6 +400,8 @@
|
|||
|
||||
- Add `languages.gettext`. This only provides highlighting.
|
||||
|
||||
- Add `languages.env`. This provides extra filetype hooks and diagnostics.
|
||||
|
||||
- Add `languages.openscad` using
|
||||
[`openscad-lsp`](https://github.com/Leathong/openscad-LSP). This currently
|
||||
relies on neovim builtin syntax for highlighting, and the lsp for formatting
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ in {
|
|||
./asm.nix
|
||||
./astro.nix
|
||||
./bash.nix
|
||||
./env.nix
|
||||
./cue.nix
|
||||
./dart.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
Reference in a new issue