mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-21 08:35:43 +02:00
plugins/lsp-format: remove with lib and helpers
This commit is contained in:
parent
b076f006c6
commit
fb1943a673
1 changed files with 16 additions and 18 deletions
|
@ -1,17 +1,15 @@
|
||||||
{
|
{
|
||||||
lib,
|
lib,
|
||||||
helpers,
|
|
||||||
config,
|
config,
|
||||||
pkgs,
|
pkgs,
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
with lib;
|
|
||||||
let
|
let
|
||||||
cfg = config.plugins.lsp-format;
|
cfg = config.plugins.lsp-format;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
options.plugins.lsp-format = helpers.neovim-plugin.extraOptionsOptions // {
|
options.plugins.lsp-format = lib.nixvim.neovim-plugin.extraOptionsOptions // {
|
||||||
enable = mkEnableOption "lsp-format.nvim";
|
enable = lib.mkEnableOption "lsp-format.nvim";
|
||||||
|
|
||||||
package = lib.mkPackageOption pkgs "lsp-format.nvim" {
|
package = lib.mkPackageOption pkgs "lsp-format.nvim" {
|
||||||
default = [
|
default = [
|
||||||
|
@ -20,29 +18,29 @@ in
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
setup = mkOption {
|
setup = lib.mkOption {
|
||||||
type =
|
type =
|
||||||
with types;
|
with lib.types;
|
||||||
attrsOf (submodule {
|
attrsOf (submodule {
|
||||||
# Allow the user to provide other options
|
# Allow the user to provide other options
|
||||||
freeformType = types.attrs;
|
freeformType = types.attrs;
|
||||||
|
|
||||||
options = {
|
options = {
|
||||||
exclude = helpers.mkNullOrOption (listOf str) "List of client names to exclude from formatting.";
|
exclude = lib.nixvim.mkNullOrOption (listOf str) "List of client names to exclude from formatting.";
|
||||||
|
|
||||||
order = helpers.mkNullOrOption (listOf str) ''
|
order = lib.nixvim.mkNullOrOption (listOf str) ''
|
||||||
List of client names. Formatting is requested from clients in the following
|
List of client names. Formatting is requested from clients in the following
|
||||||
order: first all clients that are not in the `order` table, then the remaining
|
order: first all clients that are not in the `order` table, then the remaining
|
||||||
clients in the order as they occur in the `order` table.
|
clients in the order as they occur in the `order` table.
|
||||||
(same logic as |vim.lsp.buf.formatting_seq_sync()|).
|
(same logic as |vim.lsp.buf.formatting_seq_sync()|).
|
||||||
'';
|
'';
|
||||||
|
|
||||||
sync = helpers.defaultNullOpts.mkBool false ''
|
sync = lib.nixvim.defaultNullOpts.mkBool false ''
|
||||||
Whether to turn on synchronous formatting.
|
Whether to turn on synchronous formatting.
|
||||||
The editor will block until formatting is done.
|
The editor will block until formatting is done.
|
||||||
'';
|
'';
|
||||||
|
|
||||||
force = helpers.defaultNullOpts.mkBool false ''
|
force = lib.nixvim.defaultNullOpts.mkBool false ''
|
||||||
If true, the format result will always be written to the buffer, even if the
|
If true, the format result will always be written to the buffer, even if the
|
||||||
buffer changed.
|
buffer changed.
|
||||||
'';
|
'';
|
||||||
|
@ -63,9 +61,9 @@ in
|
||||||
default = { };
|
default = { };
|
||||||
};
|
};
|
||||||
|
|
||||||
lspServersToEnable = mkOption {
|
lspServersToEnable = lib.mkOption {
|
||||||
type =
|
type =
|
||||||
with types;
|
with lib.types;
|
||||||
either (enum [
|
either (enum [
|
||||||
"none"
|
"none"
|
||||||
"all"
|
"all"
|
||||||
|
@ -93,21 +91,21 @@ in
|
||||||
let
|
let
|
||||||
setupOptions = cfg.setup // cfg.extraOptions;
|
setupOptions = cfg.setup // cfg.extraOptions;
|
||||||
in
|
in
|
||||||
mkIf cfg.enable {
|
lib.mkIf cfg.enable {
|
||||||
warnings = mkIf (!config.plugins.lsp.enable) [
|
warnings = lib.mkIf (!config.plugins.lsp.enable) [
|
||||||
"You have enabled `plugins.lsp-format` but have `plugins.lsp` disabled."
|
"You have enabled `plugins.lsp-format` but have `plugins.lsp` disabled."
|
||||||
];
|
];
|
||||||
|
|
||||||
extraPlugins = [ cfg.package ];
|
extraPlugins = [ cfg.package ];
|
||||||
|
|
||||||
plugins.lsp = {
|
plugins.lsp = {
|
||||||
onAttach = mkIf (cfg.lspServersToEnable == "all") ''
|
onAttach = lib.mkIf (cfg.lspServersToEnable == "all") ''
|
||||||
require("lsp-format").on_attach(client)
|
require("lsp-format").on_attach(client)
|
||||||
'';
|
'';
|
||||||
|
|
||||||
servers =
|
servers =
|
||||||
if (isList cfg.lspServersToEnable) then
|
if (lib.isList cfg.lspServersToEnable) then
|
||||||
genAttrs cfg.lspServersToEnable (serverName: {
|
lib.genAttrs cfg.lspServersToEnable (serverName: {
|
||||||
onAttach.function = ''
|
onAttach.function = ''
|
||||||
require("lsp-format").on_attach(client)
|
require("lsp-format").on_attach(client)
|
||||||
'';
|
'';
|
||||||
|
@ -117,7 +115,7 @@ in
|
||||||
};
|
};
|
||||||
|
|
||||||
extraConfigLua = ''
|
extraConfigLua = ''
|
||||||
require("lsp-format").setup(${helpers.toLuaObject setupOptions})
|
require("lsp-format").setup(${lib.nixvim.toLuaObject setupOptions})
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue