diff --git a/plugins/default.nix b/plugins/default.nix index 6236cea6..680128fd 100644 --- a/plugins/default.nix +++ b/plugins/default.nix @@ -170,6 +170,7 @@ ./utils/floaterm.nix ./utils/fzf-lua.nix ./utils/goyo.nix + ./utils/guess-indent.nix ./utils/hardtime.nix ./utils/harpoon.nix ./utils/hop.nix diff --git a/plugins/utils/guess-indent.nix b/plugins/utils/guess-indent.nix new file mode 100644 index 00000000..be7952e4 --- /dev/null +++ b/plugins/utils/guess-indent.nix @@ -0,0 +1,69 @@ +{ + lib, + helpers, + config, + pkgs, + ... +}: +with lib; +helpers.neovim-plugin.mkNeovimPlugin config { + name = "guess-indent"; + originalName = "guess-indent.nvim"; + defaultPackage = pkgs.vimPlugins.guess-indent-nvim; + + maintainers = [ helpers.maintainers.GGORG ]; + + settingsOptions = { + auto_cmd = helpers.defaultNullOpts.mkBool true '' + Whether to create autocommand to automatically detect indentation + ''; + + override_editorconfig = helpers.defaultNullOpts.mkBool false '' + Whether or not to override indentation set by Editorconfig + ''; + + filetype_exclude = + helpers.defaultNullOpts.mkListOf types.str + [ + "netrw" + "tutor" + ] + '' + Filetypes to ignore indentation detection in + ''; + + buftype_exclude = + helpers.defaultNullOpts.mkListOf types.str + [ + "help" + "nofile" + "terminal" + "prompt" + ] + '' + Buffer types to ignore indentation detection in + ''; + + on_tab_options = helpers.defaultNullOpts.mkAttrsOf types.anything { expandtab = false; } '' + A table of vim options when tabs are detected + ''; + + on_space_options = + helpers.defaultNullOpts.mkAttrsOf types.anything + { + expandtab = true; + tabstop = "detected"; + softtabstop = "detected"; + shiftwidth = "detected"; + } + '' + A table of vim options when spaces are detected + ''; + }; + + settingsExample = { + auto_cmd = false; + override_editorconfig = true; + filetype_exclude = [ "markdown" ]; + }; +} diff --git a/tests/test-sources/plugins/utils/guess-indent.nix b/tests/test-sources/plugins/utils/guess-indent.nix new file mode 100644 index 00000000..65f56b5e --- /dev/null +++ b/tests/test-sources/plugins/utils/guess-indent.nix @@ -0,0 +1,47 @@ +{ + empty = { + plugins.guess-indent.enable = true; + }; + + defaults = { + plugins.guess-indent = { + enable = true; + + settings = { + auto_cmd = true; + override_editorconfig = false; + filetype_exclude = [ + "netrw" + "tutor" + ]; + buftype_exclude = [ + "help" + "nofile" + "terminal" + "prompt" + ]; + on_tab_options = { + "expandtab" = false; + }; + on_space_options = { + "expandtab" = true; + "tabstop" = "detected"; + "softtabstop" = "detected"; + "shiftwidth" = "detected"; + }; + }; + }; + }; + + example = { + plugins.guess-indent = { + enable = true; + + settings = { + auto_cmd = false; + override_editorconfig = true; + filetype_exclude = [ "markdown" ]; + }; + }; + }; +}