mirror of
https://github.com/NotAShelf/nvf.git
synced 2024-11-22 21:30:51 +00:00
lsp/null-lsp: allow null-ls options to be configured
This should probably still be converted to setupOpts. Missing docs
This commit is contained in:
parent
74c94b8a54
commit
eefc7a9d1d
2 changed files with 51 additions and 18 deletions
|
@ -5,6 +5,7 @@
|
|||
}: let
|
||||
inherit (lib.modules) mkIf mkMerge;
|
||||
inherit (lib.attrsets) mapAttrs;
|
||||
inherit (lib.trivial) boolToString;
|
||||
inherit (lib.nvim.dag) entryAnywhere entryAfter entryBetween;
|
||||
|
||||
cfg = config.vim.lsp;
|
||||
|
@ -12,27 +13,37 @@ in {
|
|||
config = mkIf cfg.null-ls.enable (mkMerge [
|
||||
{
|
||||
vim = {
|
||||
lsp.enable = true;
|
||||
startPlugins = ["none-ls"];
|
||||
startPlugins = [
|
||||
"none-ls"
|
||||
"plenary-nvim"
|
||||
];
|
||||
|
||||
luaConfigRC.null_ls-setup = entryAnywhere ''
|
||||
# null-ls implies LSP already being set up
|
||||
# since it will hook into LSPs to receive information
|
||||
lsp.enable = true;
|
||||
|
||||
luaConfigRC = {
|
||||
# early setup for null-ls
|
||||
null_ls-setup = entryAnywhere ''
|
||||
local null_ls = require("null-ls")
|
||||
local null_helpers = require("null-ls.helpers")
|
||||
local null_methods = require("null-ls.methods")
|
||||
local ls_sources = {}
|
||||
'';
|
||||
|
||||
luaConfigRC.null_ls = entryAfter ["null_ls-setup" "lsp-setup"] ''
|
||||
# null-ls setup
|
||||
null_ls = entryAfter ["null_ls-setup" "lsp-setup"] ''
|
||||
require('null-ls').setup({
|
||||
debug = false,
|
||||
diagnostics_format = "[#{m}] #{s} (#{c})",
|
||||
debounce = 250,
|
||||
default_timeout = 5000,
|
||||
debug = ${boolToString cfg.null-ls.debug},
|
||||
diagnostics_format = "${cfg.null-ls.diagnostics_format}",
|
||||
debounce = ${toString cfg.null-ls.debounce},
|
||||
default_timeout = ${toString cfg.null-ls.default_timeout},
|
||||
sources = ls_sources,
|
||||
on_attach = default_on_attach
|
||||
})
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
||||
{
|
||||
vim.luaConfigRC = mapAttrs (_: v: (entryBetween ["null_ls"] ["null_ls-setup"] v)) cfg.null-ls.sources;
|
||||
|
|
|
@ -1,10 +1,32 @@
|
|||
{lib, ...}: let
|
||||
inherit (lib.options) mkEnableOption mkOption;
|
||||
inherit (lib.types) attrsOf str;
|
||||
inherit (lib.types) attrsOf str int;
|
||||
inherit (lib.generators) mkLuaInline;
|
||||
inherit (lib.nvim.types) luaInline;
|
||||
in {
|
||||
options.vim.lsp.null-ls = {
|
||||
enable = mkEnableOption "null-ls, also enabled automatically";
|
||||
|
||||
debug = mkEnableOption "debugging information for `null-ls";
|
||||
|
||||
diagnostics_format = mkOption {
|
||||
type = luaInline;
|
||||
default = mkLuaInline "[#{m}] #{s} (#{c})";
|
||||
description = "Diagnostic output format for null-ls";
|
||||
};
|
||||
|
||||
debounce = mkOption {
|
||||
type = int;
|
||||
default = 250;
|
||||
description = "Default debounce";
|
||||
};
|
||||
|
||||
default_timeout = mkOption {
|
||||
type = int;
|
||||
default = 5000;
|
||||
description = "Default timeout value, in miliseconds";
|
||||
};
|
||||
|
||||
sources = mkOption {
|
||||
description = "null-ls sources";
|
||||
type = attrsOf str;
|
||||
|
|
Loading…
Reference in a new issue