mirror of
https://github.com/nix-community/nixvim.git
synced 2025-07-22 11:45:28 +02:00
treewide: Reformat with nixfmt
This commit is contained in:
parent
c6281260dc
commit
62f32bfc71
459 changed files with 28139 additions and 26377 deletions
|
@ -5,117 +5,131 @@
|
|||
pkgs,
|
||||
...
|
||||
}:
|
||||
with lib; let
|
||||
with lib;
|
||||
let
|
||||
cfg = config.plugins.none-ls;
|
||||
in {
|
||||
in
|
||||
{
|
||||
imports = [
|
||||
./servers.nix
|
||||
(
|
||||
mkRenamedOptionModule
|
||||
["plugins" "null-ls"]
|
||||
["plugins" "none-ls"]
|
||||
(mkRenamedOptionModule
|
||||
[
|
||||
"plugins"
|
||||
"null-ls"
|
||||
]
|
||||
[
|
||||
"plugins"
|
||||
"none-ls"
|
||||
]
|
||||
)
|
||||
];
|
||||
|
||||
options.plugins.none-ls =
|
||||
helpers.neovim-plugin.extraOptionsOptions
|
||||
// {
|
||||
enable = mkEnableOption "none-ls";
|
||||
options.plugins.none-ls = helpers.neovim-plugin.extraOptionsOptions // {
|
||||
enable = mkEnableOption "none-ls";
|
||||
|
||||
package = mkOption {
|
||||
type = types.package;
|
||||
default = pkgs.vimPlugins.none-ls-nvim;
|
||||
description = "Plugin to use for none-ls";
|
||||
};
|
||||
package = mkOption {
|
||||
type = types.package;
|
||||
default = pkgs.vimPlugins.none-ls-nvim;
|
||||
description = "Plugin to use for none-ls";
|
||||
};
|
||||
|
||||
enableLspFormat = mkOption {
|
||||
type = types.bool;
|
||||
default = config.plugins.lsp-format.enable;
|
||||
description = ''
|
||||
Automatically enable the `lsp-format` plugin and configure `none-ls` accordingly.
|
||||
'';
|
||||
example = true;
|
||||
};
|
||||
|
||||
border = helpers.defaultNullOpts.mkBorder "null" "`:NullLsInfo` UI window." ''
|
||||
Uses `NullLsInfoBorder` highlight group (see [Highlight Groups](#highlight-groups)).
|
||||
enableLspFormat = mkOption {
|
||||
type = types.bool;
|
||||
default = config.plugins.lsp-format.enable;
|
||||
description = ''
|
||||
Automatically enable the `lsp-format` plugin and configure `none-ls` accordingly.
|
||||
'';
|
||||
example = true;
|
||||
};
|
||||
|
||||
cmd = helpers.defaultNullOpts.mkNullable (types.listOf types.str) ''["nvim"]'' ''
|
||||
Defines the command used to start the null-ls server. If you do not have an
|
||||
`nvim` binary available on your `$PATH`, you should change this to an absolute
|
||||
path to the binary.
|
||||
'';
|
||||
border = helpers.defaultNullOpts.mkBorder "null" "`:NullLsInfo` UI window." ''
|
||||
Uses `NullLsInfoBorder` highlight group (see [Highlight Groups](#highlight-groups)).
|
||||
'';
|
||||
|
||||
debounce = helpers.defaultNullOpts.mkInt 250 ''
|
||||
The `debounce` setting controls the amount of time between the last change to a buffer and the
|
||||
next `textDocument/didChange` notification.
|
||||
These notifications cause null-ls to generate diagnostics, so this setting indirectly controls
|
||||
the rate of diagnostic generation (affected by `update_in_insert`, described below).
|
||||
cmd = helpers.defaultNullOpts.mkNullable (types.listOf types.str) ''["nvim"]'' ''
|
||||
Defines the command used to start the null-ls server. If you do not have an
|
||||
`nvim` binary available on your `$PATH`, you should change this to an absolute
|
||||
path to the binary.
|
||||
'';
|
||||
|
||||
Lowering `debounce` will result in quicker diagnostic refreshes at the cost of running
|
||||
diagnostic sources more frequently, which can affect performance.
|
||||
The default value should be enough to provide near-instantaneous feedback from most sources
|
||||
without unnecessary resource usage.
|
||||
'';
|
||||
debounce = helpers.defaultNullOpts.mkInt 250 ''
|
||||
The `debounce` setting controls the amount of time between the last change to a buffer and the
|
||||
next `textDocument/didChange` notification.
|
||||
These notifications cause null-ls to generate diagnostics, so this setting indirectly controls
|
||||
the rate of diagnostic generation (affected by `update_in_insert`, described below).
|
||||
|
||||
debug = helpers.defaultNullOpts.mkBool false ''
|
||||
Displays all possible log messages and writes them to the null-ls log, which you
|
||||
can view with the command `:NullLsLog`. This option can slow down Neovim, so
|
||||
it's strongly recommended to disable it for normal use.
|
||||
Lowering `debounce` will result in quicker diagnostic refreshes at the cost of running
|
||||
diagnostic sources more frequently, which can affect performance.
|
||||
The default value should be enough to provide near-instantaneous feedback from most sources
|
||||
without unnecessary resource usage.
|
||||
'';
|
||||
|
||||
`debug = true` is the same as setting `logLevel` to `"trace"`.
|
||||
'';
|
||||
debug = helpers.defaultNullOpts.mkBool false ''
|
||||
Displays all possible log messages and writes them to the null-ls log, which you
|
||||
can view with the command `:NullLsLog`. This option can slow down Neovim, so
|
||||
it's strongly recommended to disable it for normal use.
|
||||
|
||||
defaultTimeout = helpers.defaultNullOpts.mkInt 5000 ''
|
||||
Sets the amount of time (in milliseconds) after which built-in sources will time out.
|
||||
Note that built-in sources can define their own timeout period and that users can override the
|
||||
timeout period on a per-source basis, too (see [BUILTIN_CONFIG.md](BUILTIN_CONFIG.md)).
|
||||
`debug = true` is the same as setting `logLevel` to `"trace"`.
|
||||
'';
|
||||
|
||||
Specifying a timeout with a value less than zero will prevent commands from timing out.
|
||||
'';
|
||||
defaultTimeout = helpers.defaultNullOpts.mkInt 5000 ''
|
||||
Sets the amount of time (in milliseconds) after which built-in sources will time out.
|
||||
Note that built-in sources can define their own timeout period and that users can override the
|
||||
timeout period on a per-source basis, too (see [BUILTIN_CONFIG.md](BUILTIN_CONFIG.md)).
|
||||
|
||||
diagnosticConfig = helpers.defaultNullOpts.mkNullable types.attrs "null" ''
|
||||
Specifies diagnostic display options for null-ls sources, as described in
|
||||
`:help vim.diagnostic.config()`.
|
||||
(null-ls uses separate namespaces for each source, so server-wide configuration will not work
|
||||
as expected.)
|
||||
Specifying a timeout with a value less than zero will prevent commands from timing out.
|
||||
'';
|
||||
|
||||
You can also configure `diagnostic_config` per built-in by using the `with` method, described
|
||||
in BUILTIN_CONFIG.md.
|
||||
'';
|
||||
diagnosticConfig = helpers.defaultNullOpts.mkNullable types.attrs "null" ''
|
||||
Specifies diagnostic display options for null-ls sources, as described in
|
||||
`:help vim.diagnostic.config()`.
|
||||
(null-ls uses separate namespaces for each source, so server-wide configuration will not work
|
||||
as expected.)
|
||||
|
||||
diagnosticsFormat = helpers.defaultNullOpts.mkStr "#{m}" ''
|
||||
Sets the default format used for diagnostics. The plugin will replace the following special
|
||||
components with the relevant diagnostic information:
|
||||
You can also configure `diagnostic_config` per built-in by using the `with` method, described
|
||||
in BUILTIN_CONFIG.md.
|
||||
'';
|
||||
|
||||
- `#{m}`: message
|
||||
- `#{s}`: source name (defaults to `null-ls` if not specified)
|
||||
- `#{c}`: code (if available)
|
||||
diagnosticsFormat = helpers.defaultNullOpts.mkStr "#{m}" ''
|
||||
Sets the default format used for diagnostics. The plugin will replace the following special
|
||||
components with the relevant diagnostic information:
|
||||
|
||||
For example, setting `diagnostics_format` to the following:
|
||||
- `#{m}`: message
|
||||
- `#{s}`: source name (defaults to `null-ls` if not specified)
|
||||
- `#{c}`: code (if available)
|
||||
|
||||
```lua
|
||||
diagnostics_format = "[#{c}] #{m} (#{s})"
|
||||
```
|
||||
For example, setting `diagnostics_format` to the following:
|
||||
|
||||
Formats diagnostics as follows:
|
||||
```lua
|
||||
diagnostics_format = "[#{c}] #{m} (#{s})"
|
||||
```
|
||||
|
||||
```txt
|
||||
[2148] Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive. (shellcheck)
|
||||
```
|
||||
Formats diagnostics as follows:
|
||||
|
||||
You can also configure `diagnostics_format` per built-in by using the `with`
|
||||
method, described in [BUILTIN_CONFIG](BUILTIN_CONFIG.md).
|
||||
'';
|
||||
```txt
|
||||
[2148] Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive. (shellcheck)
|
||||
```
|
||||
|
||||
fallbackSeverity = helpers.defaultNullOpts.mkSeverity "error" ''
|
||||
Defines the severity used when a diagnostic source does not explicitly define a severity.
|
||||
See `:help diagnostic-severity` for available values.
|
||||
'';
|
||||
You can also configure `diagnostics_format` per built-in by using the `with`
|
||||
method, described in [BUILTIN_CONFIG](BUILTIN_CONFIG.md).
|
||||
'';
|
||||
|
||||
logLevel =
|
||||
helpers.defaultNullOpts.mkEnum ["off" "error" "warn" "info" "debug" "trace"] "warn"
|
||||
fallbackSeverity = helpers.defaultNullOpts.mkSeverity "error" ''
|
||||
Defines the severity used when a diagnostic source does not explicitly define a severity.
|
||||
See `:help diagnostic-severity` for available values.
|
||||
'';
|
||||
|
||||
logLevel =
|
||||
helpers.defaultNullOpts.mkEnum
|
||||
[
|
||||
"off"
|
||||
"error"
|
||||
"warn"
|
||||
"info"
|
||||
"debug"
|
||||
"trace"
|
||||
]
|
||||
"warn"
|
||||
''
|
||||
Enables or disables logging to file.
|
||||
|
||||
|
@ -125,102 +139,98 @@ in {
|
|||
- neovim's notification area.
|
||||
'';
|
||||
|
||||
notifyFormat = helpers.defaultNullOpts.mkStr "[null-ls] %s" ''
|
||||
Sets the default format for `vim.notify()` messages.
|
||||
Can be used to customize 3rd party notification plugins like
|
||||
[nvim-notify](https://github.com/rcarriga/nvim-notify).
|
||||
'';
|
||||
notifyFormat = helpers.defaultNullOpts.mkStr "[null-ls] %s" ''
|
||||
Sets the default format for `vim.notify()` messages.
|
||||
Can be used to customize 3rd party notification plugins like
|
||||
[nvim-notify](https://github.com/rcarriga/nvim-notify).
|
||||
'';
|
||||
|
||||
onAttach = helpers.defaultNullOpts.mkStr "null" ''
|
||||
Defines an `on_attach` callback to run whenever null-ls attaches to a buffer.
|
||||
If you have a common `on_attach` you're using for LSP servers, you can reuse that here, use a
|
||||
custom callback for null-ls, or leave this undefined.
|
||||
'';
|
||||
onAttach = helpers.defaultNullOpts.mkStr "null" ''
|
||||
Defines an `on_attach` callback to run whenever null-ls attaches to a buffer.
|
||||
If you have a common `on_attach` you're using for LSP servers, you can reuse that here, use a
|
||||
custom callback for null-ls, or leave this undefined.
|
||||
'';
|
||||
|
||||
onInit = helpers.defaultNullOpts.mkLuaFn "null" ''
|
||||
Defines an `on_init` callback to run when null-ls initializes. From here, you
|
||||
can make changes to the client (the first argument) or `initialize_result` (the
|
||||
second argument, which as of now is not used).
|
||||
'';
|
||||
onInit = helpers.defaultNullOpts.mkLuaFn "null" ''
|
||||
Defines an `on_init` callback to run when null-ls initializes. From here, you
|
||||
can make changes to the client (the first argument) or `initialize_result` (the
|
||||
second argument, which as of now is not used).
|
||||
'';
|
||||
|
||||
onExit = helpers.defaultNullOpts.mkLuaFn "null" ''
|
||||
Defines an `on_exit` callback to run when the null-ls client exits.
|
||||
'';
|
||||
onExit = helpers.defaultNullOpts.mkLuaFn "null" ''
|
||||
Defines an `on_exit` callback to run when the null-ls client exits.
|
||||
'';
|
||||
|
||||
rootDir = helpers.defaultNullOpts.mkLuaFn "null" ''
|
||||
Determines the root of the null-ls server. On startup, null-ls will call
|
||||
`root_dir` with the full path to the first file that null-ls attaches to.
|
||||
rootDir = helpers.defaultNullOpts.mkLuaFn "null" ''
|
||||
Determines the root of the null-ls server. On startup, null-ls will call
|
||||
`root_dir` with the full path to the first file that null-ls attaches to.
|
||||
|
||||
```lua
|
||||
local root_dir = function(fname)
|
||||
return fname:match("my-project") and "my-project-root"
|
||||
end
|
||||
```
|
||||
```lua
|
||||
local root_dir = function(fname)
|
||||
return fname:match("my-project") and "my-project-root"
|
||||
end
|
||||
```
|
||||
|
||||
If `root_dir` returns `nil`, the root will resolve to the current working
|
||||
directory.
|
||||
'';
|
||||
If `root_dir` returns `nil`, the root will resolve to the current working
|
||||
directory.
|
||||
'';
|
||||
|
||||
shouldAttach = helpers.defaultNullOpts.mkLuaFn "null" ''
|
||||
A user-defined function that controls whether to enable null-ls for a given
|
||||
buffer. Receives `bufnr` as its first argument.
|
||||
shouldAttach = helpers.defaultNullOpts.mkLuaFn "null" ''
|
||||
A user-defined function that controls whether to enable null-ls for a given
|
||||
buffer. Receives `bufnr` as its first argument.
|
||||
|
||||
To cut down potentially expensive calls, null-ls will call `should_attach` after
|
||||
its own internal checks pass, so it's not guaranteed to run on each new buffer.
|
||||
To cut down potentially expensive calls, null-ls will call `should_attach` after
|
||||
its own internal checks pass, so it's not guaranteed to run on each new buffer.
|
||||
|
||||
```lua
|
||||
require("null-ls.nvim").setup({
|
||||
should_attach = function(bufnr)
|
||||
return not vim.api.nvim_buf_get_name(bufnr):match("^git://")
|
||||
end,
|
||||
})
|
||||
```
|
||||
'';
|
||||
```lua
|
||||
require("null-ls.nvim").setup({
|
||||
should_attach = function(bufnr)
|
||||
return not vim.api.nvim_buf_get_name(bufnr):match("^git://")
|
||||
end,
|
||||
})
|
||||
```
|
||||
'';
|
||||
|
||||
tempDir = helpers.defaultNullOpts.mkStr "null" ''
|
||||
Defines the directory used to create temporary files for sources that rely on them (a
|
||||
workaround used for command-based sources that do not support `stdio`).
|
||||
tempDir = helpers.defaultNullOpts.mkStr "null" ''
|
||||
Defines the directory used to create temporary files for sources that rely on them (a
|
||||
workaround used for command-based sources that do not support `stdio`).
|
||||
|
||||
To maximize compatibility, null-ls defaults to creating temp files in the same directory as
|
||||
the parent file.
|
||||
If this is causing issues, you can set it to `/tmp` (or another appropriate directory) here.
|
||||
Otherwise, there is no need to change this setting.
|
||||
To maximize compatibility, null-ls defaults to creating temp files in the same directory as
|
||||
the parent file.
|
||||
If this is causing issues, you can set it to `/tmp` (or another appropriate directory) here.
|
||||
Otherwise, there is no need to change this setting.
|
||||
|
||||
**Note**: some null-ls built-in sources expect temp files to exist within a project for
|
||||
context and so will not work if this option changes.
|
||||
**Note**: some null-ls built-in sources expect temp files to exist within a project for
|
||||
context and so will not work if this option changes.
|
||||
|
||||
You can also configure `temp_dir` per built-in by using the `with` method, described in
|
||||
BUILTIN_CONFIG.md.
|
||||
'';
|
||||
You can also configure `temp_dir` per built-in by using the `with` method, described in
|
||||
BUILTIN_CONFIG.md.
|
||||
'';
|
||||
|
||||
updateInInsert = helpers.defaultNullOpts.mkBool false ''
|
||||
Controls whether diagnostic sources run in insert mode.
|
||||
If set to `false`, diagnostic sources will run upon exiting insert mode, which greatly
|
||||
improves performance but can create a slight delay before diagnostics show up.
|
||||
Set this to `true` if you don't experience performance issues with your sources.
|
||||
updateInInsert = helpers.defaultNullOpts.mkBool false ''
|
||||
Controls whether diagnostic sources run in insert mode.
|
||||
If set to `false`, diagnostic sources will run upon exiting insert mode, which greatly
|
||||
improves performance but can create a slight delay before diagnostics show up.
|
||||
Set this to `true` if you don't experience performance issues with your sources.
|
||||
|
||||
Note that by default, Neovim will not display updated diagnostics in insert mode.
|
||||
Together with the option above, you need to pass `update_in_insert = true` to
|
||||
`vim.diagnostic.config` for diagnostics to work as expected.
|
||||
See `:help vim.diagnostic.config` for more info.
|
||||
'';
|
||||
Note that by default, Neovim will not display updated diagnostics in insert mode.
|
||||
Together with the option above, you need to pass `update_in_insert = true` to
|
||||
`vim.diagnostic.config` for diagnostics to work as expected.
|
||||
See `:help vim.diagnostic.config` for more info.
|
||||
'';
|
||||
|
||||
sourcesItems =
|
||||
helpers.mkNullOrOption
|
||||
(with types; listOf (attrsOf str))
|
||||
"The list of sources to enable, should be strings of lua code. Don't use this directly";
|
||||
};
|
||||
sourcesItems = helpers.mkNullOrOption (
|
||||
with types; listOf (attrsOf str)
|
||||
) "The list of sources to enable, should be strings of lua code. Don't use this directly";
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
warnings =
|
||||
optional
|
||||
(cfg.enableLspFormat && (cfg.onAttach != null))
|
||||
''
|
||||
You have enabled the lsp-format integration with none-ls.
|
||||
However, you have provided a custom value to `plugins.none-ls.onAttach`.
|
||||
warnings = optional (cfg.enableLspFormat && (cfg.onAttach != null)) ''
|
||||
You have enabled the lsp-format integration with none-ls.
|
||||
However, you have provided a custom value to `plugins.none-ls.onAttach`.
|
||||
|
||||
-> The `enableLspFormat` option will thus not be able to add the `require('lsp-format').on_attach` snippet to `none-ls`.
|
||||
'';
|
||||
-> The `enableLspFormat` option will thus not be able to add the `require('lsp-format').on_attach` snippet to `none-ls`.
|
||||
'';
|
||||
|
||||
assertions = [
|
||||
{
|
||||
|
@ -232,43 +242,47 @@ in {
|
|||
}
|
||||
];
|
||||
|
||||
extraPlugins = [cfg.package];
|
||||
extraPlugins = [ cfg.package ];
|
||||
|
||||
extraConfigLua = let
|
||||
onAttach' =
|
||||
if (cfg.onAttach == null) && cfg.enableLspFormat
|
||||
then ''
|
||||
require('lsp-format').on_attach
|
||||
''
|
||||
else cfg.onAttach;
|
||||
extraConfigLua =
|
||||
let
|
||||
onAttach' =
|
||||
if (cfg.onAttach == null) && cfg.enableLspFormat then
|
||||
''
|
||||
require('lsp-format').on_attach
|
||||
''
|
||||
else
|
||||
cfg.onAttach;
|
||||
|
||||
setupOptions = with cfg;
|
||||
{
|
||||
inherit
|
||||
border
|
||||
cmd
|
||||
debounce
|
||||
debug
|
||||
;
|
||||
default_timeout = defaultTimeout;
|
||||
diagnostic_config = diagnosticConfig;
|
||||
diagnostics_format = diagnosticsFormat;
|
||||
fallback_severity = fallbackSeverity;
|
||||
log_level = logLevel;
|
||||
notify_format = notifyFormat;
|
||||
on_attach = helpers.mkRaw onAttach';
|
||||
on_init = onInit;
|
||||
on_exit = onExit;
|
||||
root_dir = rootDir;
|
||||
should_attach = shouldAttach;
|
||||
temp_dir = tempDir;
|
||||
update_in_insert = updateInInsert;
|
||||
setupOptions =
|
||||
with cfg;
|
||||
{
|
||||
inherit
|
||||
border
|
||||
cmd
|
||||
debounce
|
||||
debug
|
||||
;
|
||||
default_timeout = defaultTimeout;
|
||||
diagnostic_config = diagnosticConfig;
|
||||
diagnostics_format = diagnosticsFormat;
|
||||
fallback_severity = fallbackSeverity;
|
||||
log_level = logLevel;
|
||||
notify_format = notifyFormat;
|
||||
on_attach = helpers.mkRaw onAttach';
|
||||
on_init = onInit;
|
||||
on_exit = onExit;
|
||||
root_dir = rootDir;
|
||||
should_attach = shouldAttach;
|
||||
temp_dir = tempDir;
|
||||
update_in_insert = updateInInsert;
|
||||
|
||||
sources = sourcesItems;
|
||||
}
|
||||
// cfg.extraOptions;
|
||||
in ''
|
||||
require("null-ls").setup(${helpers.toLuaObject setupOptions})
|
||||
'';
|
||||
sources = sourcesItems;
|
||||
}
|
||||
// cfg.extraOptions;
|
||||
in
|
||||
''
|
||||
require("null-ls").setup(${helpers.toLuaObject setupOptions})
|
||||
'';
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,12 +1,10 @@
|
|||
{
|
||||
lib,
|
||||
config,
|
||||
...
|
||||
}:
|
||||
with lib; let
|
||||
{ lib, config, ... }:
|
||||
with lib;
|
||||
let
|
||||
cfg = config.plugins.none-ls.sources.formatting.prettier;
|
||||
tsserver-cfg = config.plugins.lsp.servers.tsserver;
|
||||
in {
|
||||
in
|
||||
{
|
||||
options.plugins.none-ls.sources.formatting.prettier = {
|
||||
disableTsServerFormatter = mkOption {
|
||||
type = with types; nullOr bool;
|
||||
|
@ -19,33 +17,27 @@ in {
|
|||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
warnings =
|
||||
optional
|
||||
(
|
||||
(cfg.disableTsServerFormatter == null)
|
||||
&& tsserver-cfg.enable
|
||||
)
|
||||
''
|
||||
You have enabled the `prettier` formatter in none-ls.
|
||||
You have also enabled the `tsserver` language server which also brings a formatting feature.
|
||||
warnings = optional ((cfg.disableTsServerFormatter == null) && tsserver-cfg.enable) ''
|
||||
You have enabled the `prettier` formatter in none-ls.
|
||||
You have also enabled the `tsserver` language server which also brings a formatting feature.
|
||||
|
||||
- To disable the formatter built-in the `tsserver` language server, set
|
||||
`plugins.none-ls.sources.formatting.prettier.disableTsServerFormatter` to `true`.
|
||||
- Else, to silence this warning, explicitly set the option to `false`.
|
||||
'';
|
||||
- To disable the formatter built-in the `tsserver` language server, set
|
||||
`plugins.none-ls.sources.formatting.prettier.disableTsServerFormatter` to `true`.
|
||||
- Else, to silence this warning, explicitly set the option to `false`.
|
||||
'';
|
||||
|
||||
plugins.lsp.servers.tsserver =
|
||||
mkIf
|
||||
(
|
||||
cfg.enable
|
||||
&& tsserver-cfg.enable
|
||||
&& (isBool cfg.disableTsServerFormatter)
|
||||
&& cfg.disableTsServerFormatter
|
||||
)
|
||||
{
|
||||
onAttach.function = ''
|
||||
client.server_capabilities.documentFormattingProvider = false
|
||||
'';
|
||||
};
|
||||
(
|
||||
cfg.enable
|
||||
&& tsserver-cfg.enable
|
||||
&& (isBool cfg.disableTsServerFormatter)
|
||||
&& cfg.disableTsServerFormatter
|
||||
)
|
||||
{
|
||||
onAttach.function = ''
|
||||
client.server_capabilities.documentFormattingProvider = false
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
@ -5,7 +5,8 @@
|
|||
helpers,
|
||||
...
|
||||
}:
|
||||
with lib; let
|
||||
with lib;
|
||||
let
|
||||
noneLsBuiltins = builtins.fromJSON (
|
||||
builtins.readFile "${pkgs.vimPlugins.none-ls-nvim.src}/doc/builtins.json"
|
||||
);
|
||||
|
@ -15,8 +16,7 @@ with lib; let
|
|||
# - null if the source is not present in nixpkgs
|
||||
# - false if this source does not need a package
|
||||
builtinPackages = {
|
||||
inherit
|
||||
(pkgs)
|
||||
inherit (pkgs)
|
||||
actionlint
|
||||
alejandra
|
||||
asmfmt
|
||||
|
@ -91,28 +91,11 @@ with lib; let
|
|||
zprint
|
||||
zsh
|
||||
;
|
||||
inherit
|
||||
(pkgs.nodePackages)
|
||||
alex
|
||||
prettier
|
||||
;
|
||||
inherit
|
||||
(pkgs.python3.pkgs)
|
||||
black
|
||||
;
|
||||
inherit
|
||||
(pkgs.phpPackages)
|
||||
phpmd
|
||||
phpstan
|
||||
;
|
||||
inherit
|
||||
(pkgs.rubyPackages)
|
||||
htmlbeautifier
|
||||
;
|
||||
inherit
|
||||
(pkgs.ocamlPackages)
|
||||
ocamlformat
|
||||
;
|
||||
inherit (pkgs.nodePackages) alex prettier;
|
||||
inherit (pkgs.python3.pkgs) black;
|
||||
inherit (pkgs.phpPackages) phpmd phpstan;
|
||||
inherit (pkgs.rubyPackages) htmlbeautifier;
|
||||
inherit (pkgs.ocamlPackages) ocamlformat;
|
||||
ansiblelint = pkgs.ansible-lint;
|
||||
bean_check = pkgs.beancount;
|
||||
bean_format = pkgs.beancount;
|
||||
|
@ -243,129 +226,102 @@ with lib; let
|
|||
};
|
||||
|
||||
# Check if the package is set to `false` or not
|
||||
hasBuiltinPackage = source:
|
||||
if builtins.hasAttr source builtinPackages
|
||||
then !(builtins.isBool builtinPackages.${source})
|
||||
else true;
|
||||
hasBuiltinPackage =
|
||||
source:
|
||||
if builtins.hasAttr source builtinPackages then
|
||||
!(builtins.isBool builtinPackages.${source})
|
||||
else
|
||||
true;
|
||||
|
||||
builtinPackage = source: builtinPackages.${source} or null;
|
||||
in {
|
||||
imports = [
|
||||
./prettier.nix
|
||||
];
|
||||
in
|
||||
{
|
||||
imports = [ ./prettier.nix ];
|
||||
|
||||
options.plugins.none-ls.sources =
|
||||
options.plugins.none-ls.sources = builtins.mapAttrs (
|
||||
sourceType: sources:
|
||||
builtins.mapAttrs (
|
||||
sourceType: sources:
|
||||
builtins.mapAttrs
|
||||
(source: _:
|
||||
{
|
||||
enable = mkEnableOption "the ${source} ${sourceType} source for none-ls";
|
||||
withArgs = helpers.mkNullOrOption helpers.nixvimTypes.strLua ''
|
||||
Raw Lua code passed as an argument to the source's `with` method.
|
||||
'';
|
||||
}
|
||||
// lib.optionalAttrs (hasBuiltinPackage source) {
|
||||
package = let
|
||||
pkg = builtinPackage source;
|
||||
in
|
||||
mkOption ({
|
||||
type = types.nullOr types.package;
|
||||
description =
|
||||
"Package to use for ${source} by none-ls. "
|
||||
+ (
|
||||
lib.optionalString (pkg == null) ''
|
||||
Not handled in nixvim, either install externally and set to null or set the option with a derivation.
|
||||
''
|
||||
);
|
||||
}
|
||||
// optionalAttrs (pkg != null) {
|
||||
default = pkg;
|
||||
});
|
||||
})
|
||||
sources
|
||||
)
|
||||
noneLsBuiltins;
|
||||
source: _:
|
||||
{
|
||||
enable = mkEnableOption "the ${source} ${sourceType} source for none-ls";
|
||||
withArgs = helpers.mkNullOrOption helpers.nixvimTypes.strLua ''
|
||||
Raw Lua code passed as an argument to the source's `with` method.
|
||||
'';
|
||||
}
|
||||
// lib.optionalAttrs (hasBuiltinPackage source) {
|
||||
package =
|
||||
let
|
||||
pkg = builtinPackage source;
|
||||
in
|
||||
mkOption (
|
||||
{
|
||||
type = types.nullOr types.package;
|
||||
description =
|
||||
"Package to use for ${source} by none-ls. "
|
||||
+ (lib.optionalString (pkg == null) ''
|
||||
Not handled in nixvim, either install externally and set to null or set the option with a derivation.
|
||||
'');
|
||||
}
|
||||
// optionalAttrs (pkg != null) { default = pkg; }
|
||||
);
|
||||
}
|
||||
) sources
|
||||
) noneLsBuiltins;
|
||||
|
||||
config = let
|
||||
cfg = config.plugins.none-ls;
|
||||
gitsignsEnabled = cfg.sources.code_actions.gitsigns.enable;
|
||||
config =
|
||||
let
|
||||
cfg = config.plugins.none-ls;
|
||||
gitsignsEnabled = cfg.sources.code_actions.gitsigns.enable;
|
||||
|
||||
flattenedSources = lib.flatten (
|
||||
lib.mapAttrsToList (
|
||||
sourceType: sources: (lib.mapAttrsToList (sourceName: source:
|
||||
source
|
||||
// {
|
||||
inherit sourceType sourceName;
|
||||
})
|
||||
sources)
|
||||
)
|
||||
cfg.sources
|
||||
);
|
||||
flattenedSources = lib.flatten (
|
||||
lib.mapAttrsToList (
|
||||
sourceType: sources:
|
||||
(lib.mapAttrsToList (sourceName: source: source // { inherit sourceType sourceName; }) sources)
|
||||
) cfg.sources
|
||||
);
|
||||
|
||||
enabledSources = builtins.filter (source: source.enable) flattenedSources;
|
||||
in
|
||||
enabledSources = builtins.filter (source: source.enable) flattenedSources;
|
||||
in
|
||||
mkIf cfg.enable {
|
||||
# ASSERTIONS FOR DEVELOPMENT PURPOSES: Any failure should be caught by CI before deployment.
|
||||
# Ensure that the keys of the manually declared `builtinPackages` match the ones from upstream.
|
||||
warnings = let
|
||||
upstreamToolNames = unique (
|
||||
flatten
|
||||
(
|
||||
mapAttrsToList
|
||||
(_: attrNames)
|
||||
noneLsBuiltins
|
||||
)
|
||||
);
|
||||
localToolNames = attrNames builtinPackages;
|
||||
warnings =
|
||||
let
|
||||
upstreamToolNames = unique (flatten (mapAttrsToList (_: attrNames) noneLsBuiltins));
|
||||
localToolNames = attrNames builtinPackages;
|
||||
|
||||
undeclaredToolNames =
|
||||
filter
|
||||
# Keep tool names which are not declared locally
|
||||
(toolName: !(elem toolName localToolNames))
|
||||
upstreamToolNames;
|
||||
undeclaredToolNames =
|
||||
filter
|
||||
# Keep tool names which are not declared locally
|
||||
(toolName: !(elem toolName localToolNames))
|
||||
upstreamToolNames;
|
||||
|
||||
uselesslyDeclaredToolNames =
|
||||
filter
|
||||
# Keep tool names which are not in upstream
|
||||
(toolName: !(elem toolName upstreamToolNames))
|
||||
localToolNames;
|
||||
in
|
||||
(
|
||||
optional
|
||||
((length undeclaredToolNames) > 0)
|
||||
''
|
||||
[DEV] Nixvim (plugins.none-ls): Some tools from upstream are not declared locally in `builtinPackages`.
|
||||
-> [${concatStringsSep ", " undeclaredToolNames}]
|
||||
''
|
||||
)
|
||||
++ (
|
||||
optional
|
||||
((length uselesslyDeclaredToolNames) > 0)
|
||||
''
|
||||
[DEV] Nixvim (plugins.none-ls): Some tools are declared locally but are not in the upstream list of supported plugins.
|
||||
-> [${concatStringsSep ", " uselesslyDeclaredToolNames}]
|
||||
''
|
||||
);
|
||||
uselesslyDeclaredToolNames =
|
||||
filter
|
||||
# Keep tool names which are not in upstream
|
||||
(toolName: !(elem toolName upstreamToolNames))
|
||||
localToolNames;
|
||||
in
|
||||
(optional ((length undeclaredToolNames) > 0) ''
|
||||
[DEV] Nixvim (plugins.none-ls): Some tools from upstream are not declared locally in `builtinPackages`.
|
||||
-> [${concatStringsSep ", " undeclaredToolNames}]
|
||||
'')
|
||||
++ (optional ((length uselesslyDeclaredToolNames) > 0) ''
|
||||
[DEV] Nixvim (plugins.none-ls): Some tools are declared locally but are not in the upstream list of supported plugins.
|
||||
-> [${concatStringsSep ", " uselesslyDeclaredToolNames}]
|
||||
'');
|
||||
|
||||
plugins.none-ls.sourcesItems =
|
||||
builtins.map (
|
||||
source: let
|
||||
sourceItem = "${source.sourceType}.${source.sourceName}";
|
||||
withArgs =
|
||||
if source.withArgs == null
|
||||
then sourceItem
|
||||
else "${sourceItem}.with(${source.withArgs})";
|
||||
in
|
||||
helpers.mkRaw ''
|
||||
require("null-ls").builtins.${withArgs}
|
||||
''
|
||||
)
|
||||
enabledSources;
|
||||
plugins.none-ls.sourcesItems = builtins.map (
|
||||
source:
|
||||
let
|
||||
sourceItem = "${source.sourceType}.${source.sourceName}";
|
||||
withArgs = if source.withArgs == null then sourceItem else "${sourceItem}.with(${source.withArgs})";
|
||||
in
|
||||
helpers.mkRaw ''
|
||||
require("null-ls").builtins.${withArgs}
|
||||
''
|
||||
) enabledSources;
|
||||
plugins.gitsigns.enable = mkIf gitsignsEnabled true;
|
||||
extraPackages =
|
||||
map
|
||||
(source: source.package or null)
|
||||
enabledSources;
|
||||
extraPackages = map (source: source.package or null) enabledSources;
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue