mirror of
https://github.com/NotAShelf/neovim-flake.git
synced 2024-12-19 12:09:48 +01: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
|
}: 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,27 +13,37 @@ in {
|
||||||
config = mkIf cfg.null-ls.enable (mkMerge [
|
config = mkIf cfg.null-ls.enable (mkMerge [
|
||||||
{
|
{
|
||||||
vim = {
|
vim = {
|
||||||
lsp.enable = true;
|
startPlugins = [
|
||||||
startPlugins = ["none-ls"];
|
"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_ls = require("null-ls")
|
||||||
local null_helpers = require("null-ls.helpers")
|
local null_helpers = require("null-ls.helpers")
|
||||||
local null_methods = require("null-ls.methods")
|
local null_methods = require("null-ls.methods")
|
||||||
local ls_sources = {}
|
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({
|
require('null-ls').setup({
|
||||||
debug = false,
|
debug = ${boolToString cfg.null-ls.debug},
|
||||||
diagnostics_format = "[#{m}] #{s} (#{c})",
|
diagnostics_format = "${cfg.null-ls.diagnostics_format}",
|
||||||
debounce = 250,
|
debounce = ${toString cfg.null-ls.debounce},
|
||||||
default_timeout = 5000,
|
default_timeout = ${toString cfg.null-ls.default_timeout},
|
||||||
sources = ls_sources,
|
sources = ls_sources,
|
||||||
on_attach = default_on_attach
|
on_attach = default_on_attach
|
||||||
})
|
})
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
};
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
vim.luaConfigRC = mapAttrs (_: v: (entryBetween ["null_ls"] ["null_ls-setup"] v)) cfg.null-ls.sources;
|
vim.luaConfigRC = mapAttrs (_: v: (entryBetween ["null_ls"] ["null_ls-setup"] v)) cfg.null-ls.sources;
|
||||||
|
|
|
@ -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;
|
||||||
|
|
Loading…
Reference in a new issue