Skip to content

Commit

Permalink
add function to add workspaces after init
Browse files Browse the repository at this point in the history
  • Loading branch information
Will Rogers committed Jun 14, 2022
1 parent 68ac8cf commit 2445361
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
tags
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,20 @@ telescope.setup {
}
```

### Adding workspaces

Workspaces can be added or updated after initialisation by calling `add_workspaces`. See below for an example.
**Note**: If you specify a workspace tag that already exists in the startup configuration, it will be overwritten.

```lua
local frecency = require("telescope").extensions.frecency
frecency.add_workspaces({
["conf"] = "/home/another_user/.config",
["data"] = "/home/another_user/.local/share",
["project"] = "/home/another_user/projects",
})
```

### SQL database location

The default location for the sqlite3 database is `$XDG_DATA_HOME/nvim` (eg `~/.local/share/nvim/` on linux).
Expand Down
7 changes: 7 additions & 0 deletions lua/telescope/_extensions/frecency.lua
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,12 @@ local function checkhealth()
end
end

local function add_user_workspaces(mappings)
local workspaces = state.user_workspaces
for k,v in pairs(mappings) do workspaces[k] = v end
set_config_state("user_workspaces", workspaces, state.user_workspaces)
end

return telescope.register_extension {
setup = function(ext_config)
set_config_state("db_root", ext_config.db_root, nil)
Expand All @@ -294,5 +300,6 @@ return telescope.register_extension {
get_workspace_tags = get_workspace_tags,
validate_db = db_client.validate,
health = checkhealth,
add_workspaces = add_user_workspaces,
},
}

0 comments on commit 2445361

Please sign in to comment.