diff --git a/modules/options.nix b/modules/options.nix index 6149eb49..50efc6a8 100644 --- a/modules/options.nix +++ b/modules/options.nix @@ -12,6 +12,18 @@ with lib; { description = "The configuration options, e.g. line numbers"; }; + globalOptions = mkOption { + type = types.attrsOf types.anything; + default = {}; + description = "The configuration global options"; + }; + + localOptions = mkOption { + type = types.attrsOf types.anything; + default = {}; + description = "The configuration local options"; + }; + globals = mkOption { type = types.attrsOf types.anything; default = {}; @@ -42,6 +54,28 @@ with lib; { end end -- }}} + '' + + optionalString (config.localOptions != {}) '' + -- Set up local options {{{ + do + local nixvim_local_options = ${helpers.toLuaObject config.localOptions} + + for k,v in pairs(nixvim_local_options) do + vim.opt_local[k] = v + end + end + -- }}} + '' + + optionalString (config.globalOptions != {}) '' + -- Set up global options {{{ + do + local nixvim_global_options = ${helpers.toLuaObject config.globalOptions} + + for k,v in pairs(nixvim_global_options) do + vim.opt_global[k] = v + end + end + -- }}} ''; }; } diff --git a/tests/test-sources/modules/options.nix b/tests/test-sources/modules/options.nix new file mode 100644 index 00000000..9595a89a --- /dev/null +++ b/tests/test-sources/modules/options.nix @@ -0,0 +1,32 @@ +{ + options = { + options = { + updatetime = 100; # Faster completion + + # Line numbers + relativenumber = true; # Relative line numbers + number = true; # Display the absolute line number of the current line + hidden = true; # Keep closed buffer open in the background + mouse = "a"; # Enable mouse control + mousemodel = "extend"; # Mouse right-click extends the current selection + }; + + localOptions = { + textwidth = 80; + sidescrolloff = 0; + }; + + globalOptions = { + textwidth = 110; + sidescrolloff = 10; + }; + }; + + globals = { + globals = { + loaded_ruby_provider = 0; + loaded_perl_provider = 0; + loaded_python_provider = 0; + }; + }; +}