diff --git a/flake-modules/dev/list-plugins/list-plugins.py b/flake-modules/dev/list-plugins/list-plugins.py index dbf095e077..cd67c51e72 100755 --- a/flake-modules/dev/list-plugins/list-plugins.py +++ b/flake-modules/dev/list-plugins/list-plugins.py @@ -94,6 +94,7 @@ class State(Enum): "live-greps-args": False, "manix": False, "media-files": True, + "project": False, "ui-select": False, "undo": True, }.items(): diff --git a/plugins/by-name/telescope/extensions/default.nix b/plugins/by-name/telescope/extensions/default.nix index f3e183f03c..54d73f6c8f 100644 --- a/plugins/by-name/telescope/extensions/default.nix +++ b/plugins/by-name/telescope/extensions/default.nix @@ -7,6 +7,7 @@ ./live-greps-args.nix ./manix.nix ./media-files.nix + ./project.nix ./ui-select.nix ./undo.nix ]; diff --git a/plugins/by-name/telescope/extensions/project.nix b/plugins/by-name/telescope/extensions/project.nix new file mode 100644 index 0000000000..d9a767df7e --- /dev/null +++ b/plugins/by-name/telescope/extensions/project.nix @@ -0,0 +1,34 @@ +let + mkExtension = import ./_mk-extension.nix; +in +mkExtension { + name = "project"; + package = "telescope-project-nvim"; + + settingsExample = { + base_dirs = [ + "~/dev/src" + "~/dev/src2" + { + __unkeyed-1 = "~/dev/src3"; + max_depth = 4; + } + { path = "~/dev/src4"; } + { + path = "~/dev/src5"; + max_depth = 2; + } + ]; + hidden_files = true; + theme = "dropdown"; + order_by = "asc"; + search_by = "title"; + sync_with_nvim_tree = true; + on_project_selected.__raw = '' + function(prompt_bufnr) + require("telescope._extensions.project.actions").change_working_directory(prompt_bufnr, false) + require("harpoon.ui").nav_file(1) + end + ''; + }; +} diff --git a/tests/test-sources/plugins/by-name/telescope/project.nix b/tests/test-sources/plugins/by-name/telescope/project.nix new file mode 100644 index 0000000000..00cd26a1c0 --- /dev/null +++ b/tests/test-sources/plugins/by-name/telescope/project.nix @@ -0,0 +1,104 @@ +{ + empty = { + # Tries to create a file on loading + test.runNvim = false; + plugins.telescope = { + enable = true; + extensions.project.enable = true; + }; + plugins.web-devicons.enable = true; + }; + + default = { + # Tries to create a file on loading + test.runNvim = false; + plugins.telescope = { + enable = true; + + extensions.project = { + enable = true; + + settings = { + base_dirs = null; + cd_scope = [ + "tab" + "window" + ]; + hidden_files = false; + order_by = "recent"; + search_by = "title"; + sync_with_nvim_tree = false; + on_project_selected.__raw = "require('telescope._extensions.project.actions').find_project_files"; + mappings = { + n = { + "d".__raw = "require('telescope._extensions.project.actions').delete_project"; + "r".__raw = "require('telescope._extensions.project.actions').rename_project"; + "c".__raw = "require('telescope._extensions.project.actions').add_project"; + "C".__raw = "require('telescope._extensions.project.actions').add_project_cwd"; + "f".__raw = "require('telescope._extensions.project.actions').find_project_files"; + "b".__raw = "require('telescope._extensions.project.actions').browse_project_files"; + "s".__raw = "require('telescope._extensions.project.actions').search_in_project_files"; + "R".__raw = "require('telescope._extensions.project.actions').recent_project_files"; + "w".__raw = "require('telescope._extensions.project.actions').change_working_directory"; + "o".__raw = "require('telescope._extensions.project.actions').next_cd_scope"; + }; + i = { + "".__raw = "require('telescope._extensions.project.actions').delete_project"; + "".__raw = "require('telescope._extensions.project.actions').rename_project"; + "".__raw = "require('telescope._extensions.project.actions').add_project"; + "".__raw = "require('telescope._extensions.project.actions').add_project_cwd"; + "".__raw = "require('telescope._extensions.project.actions').find_project_files"; + "".__raw = "require('telescope._extensions.project.actions').browse_project_files"; + "".__raw = "require('telescope._extensions.project.actions').search_in_project_files"; + "".__raw = "require('telescope._extensions.project.actions').recent_project_files"; + "".__raw = "require('telescope._extensions.project.actions').change_working_directory"; + "".__raw = "require('telescope._extensions.project.actions').next_cd_scope"; + "".__raw = "require('telescope._extensions.project.actions').change_workspace"; + }; + }; + }; + }; + }; + plugins.web-devicons.enable = true; + }; + + example = { + # Tries to create a file on loading + test.runNvim = false; + plugins.telescope = { + enable = true; + + extensions.project = { + enable = true; + + settings = { + base_dirs = [ + "~/dev/src" + "~/dev/src2" + { + __unkeyed-1 = "~/dev/src3"; + max_depth = 4; + } + { path = "~/dev/src4"; } + { + path = "~/dev/src5"; + max_depth = 2; + } + ]; + hidden_files = true; + theme = "dropdown"; + order_by = "asc"; + search_by = "title"; + sync_with_nvim_tree = true; + on_project_selected.__raw = '' + function(prompt_bufnr) + require('telescope._extensions.project.actions').change_working_directory(prompt_bufnr, false) + require("harpoon.ui").nav_file(1) + end + ''; + }; + }; + }; + plugins.web-devicons.enable = true; + }; +}