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:
NotAShelf 2024-05-16 19:09:20 +03:00
parent 74c94b8a54
commit eefc7a9d1d
No known key found for this signature in database
GPG Key ID: 02D1DD3FA08B6B29
2 changed files with 51 additions and 18 deletions

View File

@ -5,6 +5,7 @@
}: let }: let
inherit (lib.modules) mkIf mkMerge; inherit (lib.modules) mkIf mkMerge;
inherit (lib.attrsets) mapAttrs; inherit (lib.attrsets) mapAttrs;
inherit (lib.trivial) boolToString;
inherit (lib.nvim.dag) entryAnywhere entryAfter entryBetween; inherit (lib.nvim.dag) entryAnywhere entryAfter entryBetween;
cfg = config.vim.lsp; cfg = config.vim.lsp;
@ -12,26 +13,36 @@ in {
config = mkIf cfg.null-ls.enable (mkMerge [ config = mkIf cfg.null-ls.enable (mkMerge [
{ {
vim = { vim = {
startPlugins = [
"none-ls"
"plenary-nvim"
];
# null-ls implies LSP already being set up
# since it will hook into LSPs to receive information
lsp.enable = true; lsp.enable = true;
startPlugins = ["none-ls"];
luaConfigRC.null_ls-setup = entryAnywhere '' luaConfigRC = {
local null_ls = require("null-ls") # early setup for null-ls
local null_helpers = require("null-ls.helpers") null_ls-setup = entryAnywhere ''
local null_methods = require("null-ls.methods") local null_ls = require("null-ls")
local ls_sources = {} 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
require('null-ls').setup({ null_ls = entryAfter ["null_ls-setup" "lsp-setup"] ''
debug = false, require('null-ls').setup({
diagnostics_format = "[#{m}] #{s} (#{c})", debug = ${boolToString cfg.null-ls.debug},
debounce = 250, diagnostics_format = "${cfg.null-ls.diagnostics_format}",
default_timeout = 5000, debounce = ${toString cfg.null-ls.debounce},
sources = ls_sources, default_timeout = ${toString cfg.null-ls.default_timeout},
on_attach = default_on_attach sources = ls_sources,
}) on_attach = default_on_attach
''; })
'';
};
}; };
} }
{ {

View File

@ -1,10 +1,32 @@
{lib, ...}: let {lib, ...}: let
inherit (lib.options) mkEnableOption mkOption; 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 { in {
options.vim.lsp.null-ls = { options.vim.lsp.null-ls = {
enable = mkEnableOption "null-ls, also enabled automatically"; 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 { sources = mkOption {
description = "null-ls sources"; description = "null-ls sources";
type = attrsOf str; type = attrsOf str;