2022-08-05 12:08:19 +00:00
|
|
|
{
|
2023-11-06 15:04:08 +01:00
|
|
|
lib,
|
2023-02-20 11:42:13 +01:00
|
|
|
config,
|
2024-06-18 16:39:09 +01:00
|
|
|
options,
|
2023-02-20 11:42:13 +01:00
|
|
|
...
|
|
|
|
}:
|
2024-10-06 10:37:40 -05:00
|
|
|
lib.nixvim.neovim-plugin.mkNeovimPlugin {
|
2024-06-18 16:39:09 +01:00
|
|
|
name = "none-ls";
|
2024-12-13 08:27:14 -06:00
|
|
|
packPathName = "none-ls.nvim";
|
2024-12-13 08:28:39 -06:00
|
|
|
moduleName = "null-ls";
|
2024-09-02 14:05:11 +01:00
|
|
|
package = "none-ls-nvim";
|
2024-06-18 16:39:09 +01:00
|
|
|
|
2024-10-06 10:37:40 -05:00
|
|
|
maintainers = [ lib.maintainers.MattSturgeon ];
|
2024-06-18 16:39:09 +01:00
|
|
|
|
|
|
|
# TODO: introduced 2024-06-18, remove after 24.11
|
|
|
|
deprecateExtraOptions = true;
|
|
|
|
optionsRenamedToSettings = [
|
|
|
|
"border"
|
|
|
|
"cmd"
|
|
|
|
"debounce"
|
|
|
|
"debug"
|
|
|
|
"defaultTimeout"
|
|
|
|
"diagnosticConfig"
|
|
|
|
"diagnosticsFormat"
|
|
|
|
"fallbackSeverity"
|
|
|
|
"logLevel"
|
|
|
|
"notifyFormat"
|
|
|
|
"onAttach"
|
|
|
|
"onInit"
|
|
|
|
"onExit"
|
|
|
|
"rootDir"
|
|
|
|
"shouldAttach"
|
|
|
|
"tempDir"
|
|
|
|
"updateInInsert"
|
2022-08-05 12:08:19 +00:00
|
|
|
];
|
|
|
|
|
2024-06-18 16:39:09 +01:00
|
|
|
imports =
|
|
|
|
let
|
|
|
|
namespace = "plugins";
|
|
|
|
oldPluginPath = [
|
|
|
|
namespace
|
|
|
|
"null-ls"
|
|
|
|
];
|
|
|
|
basePluginPath = [
|
|
|
|
namespace
|
|
|
|
"none-ls"
|
|
|
|
];
|
|
|
|
settingsPath = basePluginPath ++ [ "settings" ];
|
|
|
|
in
|
|
|
|
[
|
2024-07-11 22:54:47 +01:00
|
|
|
./sources.nix
|
2024-10-06 10:37:40 -05:00
|
|
|
(lib.mkRenamedOptionModule oldPluginPath basePluginPath)
|
|
|
|
(lib.mkRenamedOptionModule (basePluginPath ++ [ "sourcesItems" ]) (settingsPath ++ [ "sources" ]))
|
2024-06-18 16:39:09 +01:00
|
|
|
];
|
2023-03-14 22:52:53 +01:00
|
|
|
|
2024-06-18 16:39:09 +01:00
|
|
|
settingsExample = {
|
|
|
|
diagnostics_format = "[#{c}] #{m} (#{s})";
|
|
|
|
on_attach = ''
|
|
|
|
function(client, bufnr)
|
|
|
|
-- Integrate lsp-format with none-ls
|
|
|
|
require('lsp-format').on_attach(client, bufnr)
|
|
|
|
end
|
2024-05-05 19:39:35 +02:00
|
|
|
'';
|
2024-06-18 16:39:09 +01:00
|
|
|
on_exit = ''
|
|
|
|
function()
|
|
|
|
print("Goodbye, cruel world!")
|
|
|
|
end
|
2024-05-05 19:39:35 +02:00
|
|
|
'';
|
2024-06-18 16:39:09 +01:00
|
|
|
on_init = ''
|
|
|
|
function(client, initialize_result)
|
|
|
|
print("Hello, world!")
|
2024-05-05 19:39:35 +02:00
|
|
|
end
|
|
|
|
'';
|
2024-06-18 16:39:09 +01:00
|
|
|
root_dir = ''
|
|
|
|
function(fname)
|
|
|
|
return fname:match("my-project") and "my-project-root"
|
|
|
|
end
|
2024-05-05 19:39:35 +02:00
|
|
|
'';
|
2024-06-18 16:39:09 +01:00
|
|
|
root_dir_async = ''
|
|
|
|
function(fname, cb)
|
|
|
|
cb(fname:match("my-project") and "my-project-root")
|
|
|
|
end
|
2024-05-05 19:39:35 +02:00
|
|
|
'';
|
2024-06-18 16:39:09 +01:00
|
|
|
should_attach = ''
|
|
|
|
function(bufnr)
|
|
|
|
return not vim.api.nvim_buf_get_name(bufnr):match("^git://")
|
|
|
|
end
|
2024-05-05 19:39:35 +02:00
|
|
|
'';
|
2024-06-18 16:39:09 +01:00
|
|
|
temp_dir = "/tmp";
|
|
|
|
update_in_insert = false;
|
2024-05-05 19:39:35 +02:00
|
|
|
};
|
2023-03-14 22:52:53 +01:00
|
|
|
|
2024-09-27 08:07:04 +01:00
|
|
|
settingsOptions = import ./settings.nix lib;
|
2022-08-05 12:08:19 +00:00
|
|
|
|
2024-06-18 16:39:09 +01:00
|
|
|
extraOptions = {
|
2024-10-06 10:37:40 -05:00
|
|
|
enableLspFormat = lib.mkOption {
|
|
|
|
type = lib.types.bool;
|
2024-06-18 16:39:09 +01:00
|
|
|
# TODO: consider default = false and enabling lsp-format automatically instead?
|
|
|
|
default = config.plugins.lsp-format.enable;
|
2024-10-06 10:37:40 -05:00
|
|
|
defaultText = lib.literalExpression "plugins.lsp-format.enable";
|
2024-06-18 16:39:09 +01:00
|
|
|
example = false;
|
|
|
|
description = ''
|
|
|
|
Automatically configure `none-ls` to use the `lsp-format` plugin.
|
2024-05-05 19:39:35 +02:00
|
|
|
|
2024-06-18 16:39:09 +01:00
|
|
|
Enabled automatically when `plugins.lsp-format` is enabled.
|
|
|
|
Set `false` to disable that behavior.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
2024-05-05 19:39:35 +02:00
|
|
|
|
2024-06-18 16:39:09 +01:00
|
|
|
callSetup = false;
|
|
|
|
extraConfig =
|
|
|
|
cfg:
|
|
|
|
let
|
|
|
|
# Set a custom on_attach when enableLspFormat is enabled
|
|
|
|
# FIXME: Using `mkIf (...) (mkDefault "...")` would be better,
|
|
|
|
# but that'd make it difficult to implement the "has no effect" warning.
|
|
|
|
setupOptions =
|
|
|
|
cfg.settings
|
2024-10-06 10:37:40 -05:00
|
|
|
// lib.optionalAttrs (cfg.enableLspFormat && cfg.settings.on_attach == null) {
|
2024-06-18 16:39:09 +01:00
|
|
|
on_attach.__raw = ''
|
|
|
|
require('lsp-format').on_attach
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
in
|
|
|
|
{
|
2024-10-06 10:37:40 -05:00
|
|
|
warnings = lib.optional (cfg.enableLspFormat && cfg.settings.on_attach != null) ''
|
2024-06-18 16:39:09 +01:00
|
|
|
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:
|
2024-10-06 10:37:40 -05:00
|
|
|
${lib.generators.toPretty { } cfg.settings.on_attach}
|
2024-06-18 16:39:09 +01:00
|
|
|
'';
|
2024-05-05 19:39:35 +02:00
|
|
|
|
2024-06-18 16:39:09 +01:00
|
|
|
assertions = [
|
|
|
|
{
|
|
|
|
assertion = cfg.enableLspFormat -> config.plugins.lsp-format.enable;
|
|
|
|
message = ''
|
|
|
|
Nixvim: You have enabled the lsp-format integration with none-ls.
|
|
|
|
However, you have not enabled `plugins.lsp-format` itself.
|
|
|
|
Note: `plugins.none-ls.enableLspFormat` is enabled by default when `plugins.lsp-format` is enabled.
|
|
|
|
`plugins.none-ls.enableLspFormat` definitions: ${lib.options.showDefs options.plugins.none-ls.enableLspFormat.definitionsWithLocations}
|
|
|
|
'';
|
|
|
|
}
|
|
|
|
];
|
|
|
|
|
|
|
|
# We only do this here because of enableLspFormat
|
2024-08-19 23:31:57 +02:00
|
|
|
plugins.none-ls.luaConfig.content = ''
|
2024-10-06 10:37:40 -05:00
|
|
|
require("null-ls").setup(${lib.nixvim.toLuaObject setupOptions})
|
2024-05-05 19:39:35 +02:00
|
|
|
'';
|
2024-06-18 16:39:09 +01:00
|
|
|
};
|
2022-08-05 12:08:19 +00:00
|
|
|
}
|