From 1545fa0517836b2807cc06a07ebdcec6a6a2a428 Mon Sep 17 00:00:00 2001 From: Soliprem Date: Fri, 27 Sep 2024 21:31:39 +0200 Subject: [PATCH] otter: added setupopts --- modules/plugins/lsp/otter/config.nix | 3 +- modules/plugins/lsp/otter/otter.nix | 55 +++++++++++++++++++++++++++- 2 files changed, 55 insertions(+), 3 deletions(-) diff --git a/modules/plugins/lsp/otter/config.nix b/modules/plugins/lsp/otter/config.nix index ee942e1..e5df92f 100644 --- a/modules/plugins/lsp/otter/config.nix +++ b/modules/plugins/lsp/otter/config.nix @@ -5,6 +5,7 @@ }: let inherit (lib.modules) mkIf mkMerge; inherit (lib.nvim.dag) entryAnywhere; + inherit (lib.nvim.lua) toLuaObject; inherit (lib.nvim.binds) addDescriptionsToMappings mkSetBinding; cfg = config.vim.lsp; @@ -31,7 +32,7 @@ in { pluginRC.otter-nvim = entryAnywhere '' -- Enable otter diagnostics viewer - require("otter").setup() + require("otter").setup({${toLuaObject cfg.otter-nvim.setupOpts}}) ''; }; }; diff --git a/modules/plugins/lsp/otter/otter.nix b/modules/plugins/lsp/otter/otter.nix index 7d47322..79797aa 100644 --- a/modules/plugins/lsp/otter/otter.nix +++ b/modules/plugins/lsp/otter/otter.nix @@ -1,13 +1,64 @@ {lib, ...}: let - inherit (lib.options) mkEnableOption; + inherit (lib.options) mkOption mkEnableOption; inherit (lib.nvim.binds) mkMappingOption; + inherit (lib.types) bool str listOf; + inherit (lib.nvim.types) mkPluginSetupOption; in { options.vim.lsp = { otter-nvim = { - enable = mkEnableOption "Otter LSP Injector"; + enable = mkEnableOption '' + lsp features and a code completion source for code embedded in other documents [otter-nvim] + ''; mappings = { toggle = mkMappingOption "Activate LSP on Cursor Position [otter-nvim]" "lo"; }; + setupOpts = mkPluginSetupOption "otter.nvim" { + lsp = { + diagnostic_update_event = mkOption { + type = listOf str; + default = ["BufWritePost"]; + description = '' + `:h events` that cause the diagnostic to update. + Set to: {"BufWritePost", "InsertLeave", "TextChanged" } + for less performant but more instant diagnostic updates + ''; + }; + }; + buffers = { + set_filetype = mkOption { + type = bool; + default = false; + description = '' + if set to true, the filetype of the otterbuffers will be set. Other wide only + the autocommand of lspconfig that attaches the language server will be + executed without stting the filetype + ''; + }; + write_to_disk = mkOption { + type = bool; + default = false; + description = '' + write .otter. files to disk on save of main buffer. + Useful for some linters that require actual files. + Otter files are deleted on quit or main buffer close + ''; + }; + }; + strip_wrapping_quote_characters = mkOption { + type = listOf str; + default = ["'" ''"'' "`"]; + description = '' + ''; + }; + handle_leading_whitespace = mkOption { + type = bool; + default = false; + description = '' + otter may not work the way you expect when entire code blocks are indented + (eg. in Org files) When true, otter handles these cases fully. + ''; + }; + }; }; }; }