mirror of
https://github.com/NotAShelf/nvf.git
synced 2025-04-03 11:31:52 +00:00
language/sql: migrate to conform/nvim-lint
This commit is contained in:
parent
24a3989ddc
commit
0db226be84
1 changed files with 20 additions and 26 deletions
|
@ -6,11 +6,11 @@
|
||||||
}: let
|
}: let
|
||||||
inherit (builtins) attrNames;
|
inherit (builtins) attrNames;
|
||||||
inherit (lib.options) mkEnableOption mkOption;
|
inherit (lib.options) mkEnableOption mkOption;
|
||||||
|
inherit (lib.meta) getExe;
|
||||||
inherit (lib.modules) mkIf mkMerge;
|
inherit (lib.modules) mkIf mkMerge;
|
||||||
inherit (lib.lists) isList;
|
inherit (lib.lists) isList;
|
||||||
inherit (lib.types) enum either listOf package str;
|
inherit (lib.types) enum either listOf package str;
|
||||||
inherit (lib.nvim.lua) expToLua;
|
inherit (lib.nvim.lua) expToLua;
|
||||||
inherit (lib.nvim.languages) diagnosticsToLua;
|
|
||||||
inherit (lib.nvim.types) diagnostics;
|
inherit (lib.nvim.types) diagnostics;
|
||||||
|
|
||||||
cfg = config.vim.languages.sql;
|
cfg = config.vim.languages.sql;
|
||||||
|
@ -41,15 +41,10 @@
|
||||||
formats = {
|
formats = {
|
||||||
sqlfluff = {
|
sqlfluff = {
|
||||||
package = sqlfluffDefault;
|
package = sqlfluffDefault;
|
||||||
nullConfig = ''
|
config = {
|
||||||
table.insert(
|
command = getExe cfg.format.package;
|
||||||
ls_sources,
|
append_args = ["--dialect=${cfg.dialect}"];
|
||||||
null_ls.builtins.formatting.sqlfluff.with({
|
};
|
||||||
command = "${cfg.format.package}/bin/sqlfluff",
|
|
||||||
extra_args = {"--dialect", "${cfg.dialect}"}
|
|
||||||
})
|
|
||||||
)
|
|
||||||
'';
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -57,15 +52,10 @@
|
||||||
diagnosticsProviders = {
|
diagnosticsProviders = {
|
||||||
sqlfluff = {
|
sqlfluff = {
|
||||||
package = sqlfluffDefault;
|
package = sqlfluffDefault;
|
||||||
nullConfig = pkg: ''
|
config = {
|
||||||
table.insert(
|
cmd = getExe sqlfluffDefault;
|
||||||
ls_sources,
|
args = ["lint" "--format=json" "--dialect=${cfg.dialect}"];
|
||||||
null_ls.builtins.diagnostics.sqlfluff.with({
|
};
|
||||||
command = "${pkg}/bin/sqlfluff",
|
|
||||||
extra_args = {"--dialect", "${cfg.dialect}"}
|
|
||||||
})
|
|
||||||
)
|
|
||||||
'';
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
in {
|
in {
|
||||||
|
@ -150,16 +140,20 @@ in {
|
||||||
})
|
})
|
||||||
|
|
||||||
(mkIf cfg.format.enable {
|
(mkIf cfg.format.enable {
|
||||||
vim.lsp.null-ls.enable = true;
|
vim.formatter.conform-nvim = {
|
||||||
vim.lsp.null-ls.sources."sql-format" = formats.${cfg.format.type}.nullConfig;
|
enable = true;
|
||||||
|
setupOpts.formatters_by_ft.sql = [cfg.format.type];
|
||||||
|
setupOpts.formatters.${cfg.format.type} = formats.${cfg.format.type}.config;
|
||||||
|
};
|
||||||
})
|
})
|
||||||
|
|
||||||
(mkIf cfg.extraDiagnostics.enable {
|
(mkIf cfg.extraDiagnostics.enable {
|
||||||
vim.lsp.null-ls.enable = true;
|
vim.diagnostics.nvim-lint = {
|
||||||
vim.lsp.null-ls.sources = diagnosticsToLua {
|
enable = true;
|
||||||
lang = "sql";
|
linters_by_ft.sql = cfg.extraDiagnostics.types;
|
||||||
config = cfg.extraDiagnostics.types;
|
linters =
|
||||||
inherit diagnosticsProviders;
|
mkMerge (map (name: {${name} = diagnosticsProviders.${name}.config;})
|
||||||
|
cfg.extraDiagnostics.types);
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
]);
|
]);
|
||||||
|
|
Loading…
Add table
Reference in a new issue