feat: add default_workspace setting (#43)

This commit is contained in:
James Hiew 2021-11-23 18:07:11 +00:00 committed by GitHub
parent 4c46d46859
commit ea44b316f4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 0 deletions

View File

@ -105,6 +105,10 @@ See [default configuration](https://github.com/nvim-telescope/telescope.nvim#tel
Path to parent directory of custom database location. Path to parent directory of custom database location.
Defaults to `$XDG_DATA_HOME/nvim` if unset. Defaults to `$XDG_DATA_HOME/nvim` if unset.
- `default_workspace` (default: `nil`)
Default workspace tag to filter by e.g. `'CWD'` to filter by default to the current directory. Can be overridden at query time by specifying another filter like `':*:'`.
- `ignore_patterns` (default: `{"*.git/*", "*/tmp/*"}`) - `ignore_patterns` (default: `{"*.git/*", "*/tmp/*"}`)
Patterns in this table control which files are indexed (and subsequently which you'll see in the finder results). Patterns in this table control which files are indexed (and subsequently which you'll see in the finder results).

View File

@ -29,6 +29,7 @@ local state = {
previous_buffer = nil, previous_buffer = nil,
cwd = nil, cwd = nil,
show_scores = false, show_scores = false,
default_workspace = nil,
user_workspaces = {}, user_workspaces = {},
lsp_workspaces = {}, lsp_workspaces = {},
picker = {}, picker = {},
@ -189,6 +190,7 @@ local frecency = function(opts)
if matched then if matched then
query_text = query_text:sub(matched:len() + 1) query_text = query_text:sub(matched:len() + 1)
end end
new_filter = new_filter or state.default_workspace
local new_finder local new_finder
local results_updated = update_results(new_filter) local results_updated = update_results(new_filter)
@ -274,6 +276,7 @@ return telescope.register_extension {
set_config_state("show_filter_column", ext_config.show_filter_column, true) set_config_state("show_filter_column", ext_config.show_filter_column, true)
set_config_state("user_workspaces", ext_config.workspaces, {}) set_config_state("user_workspaces", ext_config.workspaces, {})
set_config_state("disable_devicons", ext_config.disable_devicons, false) set_config_state("disable_devicons", ext_config.disable_devicons, false)
set_config_state("default_workspace", ext_config.default_workspace, nil)
-- start the database client -- start the database client
db_client.init( db_client.init(