mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-26 02:38:38 +02:00
plugins/nonels: remove with lib and helpers
This commit is contained in:
parent
fb677540e1
commit
33d030d23c
3 changed files with 19 additions and 23 deletions
|
@ -4,7 +4,6 @@ sourceType: sourceName:
|
|||
config,
|
||||
pkgs,
|
||||
lib,
|
||||
helpers,
|
||||
...
|
||||
}:
|
||||
let
|
||||
|
@ -20,7 +19,7 @@ in
|
|||
{
|
||||
enable = lib.mkEnableOption "the ${sourceName} ${sourceType} source for none-ls";
|
||||
# Support strLua for compatibility with the old withArgs option
|
||||
settings = helpers.defaultNullOpts.mkStrLuaOr' {
|
||||
settings = lib.nixvim.defaultNullOpts.mkStrLuaOr' {
|
||||
type = with lib.types; attrsOf anything;
|
||||
description = ''
|
||||
Options provided to the `require('null-ls').builtins.${sourceType}.${sourceName}.with` function.
|
||||
|
@ -82,7 +81,7 @@ in
|
|||
plugins.none-ls.settings.sources = lib.mkDefault [
|
||||
(
|
||||
"require('null-ls').builtins.${sourceType}.${sourceName}"
|
||||
+ lib.optionalString (cfg'.settings != null) ".with(${helpers.toLuaObject cfg'.settings})"
|
||||
+ lib.optionalString (cfg'.settings != null) ".with(${lib.nixvim.toLuaObject cfg'.settings})"
|
||||
)
|
||||
];
|
||||
|
||||
|
|
|
@ -1,18 +1,16 @@
|
|||
{
|
||||
lib,
|
||||
helpers,
|
||||
config,
|
||||
options,
|
||||
...
|
||||
}:
|
||||
with lib;
|
||||
helpers.neovim-plugin.mkNeovimPlugin {
|
||||
lib.nixvim.neovim-plugin.mkNeovimPlugin {
|
||||
name = "none-ls";
|
||||
originalName = "none-ls.nvim";
|
||||
luaName = "null-ls";
|
||||
package = "none-ls-nvim";
|
||||
|
||||
maintainers = [ maintainers.MattSturgeon ];
|
||||
maintainers = [ lib.maintainers.MattSturgeon ];
|
||||
|
||||
# TODO: introduced 2024-06-18, remove after 24.11
|
||||
deprecateExtraOptions = true;
|
||||
|
@ -51,8 +49,8 @@ helpers.neovim-plugin.mkNeovimPlugin {
|
|||
in
|
||||
[
|
||||
./sources.nix
|
||||
(mkRenamedOptionModule oldPluginPath basePluginPath)
|
||||
(mkRenamedOptionModule (basePluginPath ++ [ "sourcesItems" ]) (settingsPath ++ [ "sources" ]))
|
||||
(lib.mkRenamedOptionModule oldPluginPath basePluginPath)
|
||||
(lib.mkRenamedOptionModule (basePluginPath ++ [ "sourcesItems" ]) (settingsPath ++ [ "sources" ]))
|
||||
];
|
||||
|
||||
settingsExample = {
|
||||
|
@ -95,11 +93,11 @@ helpers.neovim-plugin.mkNeovimPlugin {
|
|||
settingsOptions = import ./settings.nix lib;
|
||||
|
||||
extraOptions = {
|
||||
enableLspFormat = mkOption {
|
||||
type = types.bool;
|
||||
enableLspFormat = lib.mkOption {
|
||||
type = lib.types.bool;
|
||||
# TODO: consider default = false and enabling lsp-format automatically instead?
|
||||
default = config.plugins.lsp-format.enable;
|
||||
defaultText = literalExpression "plugins.lsp-format.enable";
|
||||
defaultText = lib.literalExpression "plugins.lsp-format.enable";
|
||||
example = false;
|
||||
description = ''
|
||||
Automatically configure `none-ls` to use the `lsp-format` plugin.
|
||||
|
@ -119,19 +117,19 @@ helpers.neovim-plugin.mkNeovimPlugin {
|
|||
# but that'd make it difficult to implement the "has no effect" warning.
|
||||
setupOptions =
|
||||
cfg.settings
|
||||
// optionalAttrs (cfg.enableLspFormat && cfg.settings.on_attach == null) {
|
||||
// lib.optionalAttrs (cfg.enableLspFormat && cfg.settings.on_attach == null) {
|
||||
on_attach.__raw = ''
|
||||
require('lsp-format').on_attach
|
||||
'';
|
||||
};
|
||||
in
|
||||
{
|
||||
warnings = optional (cfg.enableLspFormat && cfg.settings.on_attach != null) ''
|
||||
warnings = lib.optional (cfg.enableLspFormat && cfg.settings.on_attach != null) ''
|
||||
You have enabled the lsp-format integration with none-ls.
|
||||
However, you have provided a custom value to `plugins.none-ls.settings.on_attach`.
|
||||
This means the `enableLspFormat` option will have no effect.
|
||||
Final value is:
|
||||
${generators.toPretty { } cfg.settings.on_attach}
|
||||
${lib.generators.toPretty { } cfg.settings.on_attach}
|
||||
'';
|
||||
|
||||
assertions = [
|
||||
|
@ -148,7 +146,7 @@ helpers.neovim-plugin.mkNeovimPlugin {
|
|||
|
||||
# We only do this here because of enableLspFormat
|
||||
plugins.none-ls.luaConfig.content = ''
|
||||
require("null-ls").setup(${helpers.toLuaObject setupOptions})
|
||||
require("null-ls").setup(${lib.nixvim.toLuaObject setupOptions})
|
||||
'';
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,13 +1,12 @@
|
|||
{ lib, config, ... }:
|
||||
with lib;
|
||||
let
|
||||
cfg = config.plugins.none-ls.sources.formatting.prettier;
|
||||
ts-ls-cfg = config.plugins.lsp.servers.ts-ls;
|
||||
in
|
||||
{
|
||||
options.plugins.none-ls.sources.formatting.prettier = {
|
||||
disableTsServerFormatter = mkOption {
|
||||
type = with types; nullOr bool;
|
||||
disableTsServerFormatter = lib.mkOption {
|
||||
type = with lib.types; nullOr bool;
|
||||
description = ''
|
||||
Disables the formatting capability of the `ts-ls` language server if it is enabled.
|
||||
'';
|
||||
|
@ -16,8 +15,8 @@ in
|
|||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
warnings = optional ((cfg.disableTsServerFormatter == null) && ts-ls-cfg.enable) ''
|
||||
config = lib.mkIf cfg.enable {
|
||||
warnings = lib.optional ((cfg.disableTsServerFormatter == null) && ts-ls-cfg.enable) ''
|
||||
You have enabled the `prettier` formatter in none-ls.
|
||||
You have also enabled the `ts-ls` language server which also brings a formatting feature.
|
||||
|
||||
|
@ -27,11 +26,11 @@ in
|
|||
'';
|
||||
|
||||
plugins.lsp.servers.ts-ls =
|
||||
mkIf
|
||||
lib.mkIf
|
||||
(
|
||||
cfg.enable
|
||||
&& ts-ls-cfg.enable
|
||||
&& (isBool cfg.disableTsServerFormatter)
|
||||
&& (lib.isBool cfg.disableTsServerFormatter)
|
||||
&& cfg.disableTsServerFormatter
|
||||
)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue