Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

How to load specific workspace by name?#643

oschrenk started this conversation inGeneral
Discussion options

I'm trying to build my own keymappings, loading a specific vault and jumping to specific files.

With one workspace the default was always used, so it was quite easy:

        local client = require("obsidian").get_client()        local note = client:daily(0)        client:open_note(note, { sync = true })        -- jump over frontmatter        vim.cmd("2/---/2")        local old_option = vim.opt.scrolloff        vim.opt.scrolloff = 0        vim.cmd("normal! zt")        vim.cmd("normal! 2j")        vim.opt.scrolloff = old_option

But now that I have two I can't find the API call to load a specific "named" workspace.

There is

get_from_opts
get_default_workspace
get_workspace_for_cwd
get_workspace_for_dir

but none offers to select by name.

What am I orerlooking here?

You must be logged in to vote

Replies: 2 comments

Comment options

I now have this

        local obsidian = require("obsidian")        local client = obsidian.get_client()        local workspace_specs = client.opts.workspaces        local workspace = nil        for _, spec in ipairs(workspace_specs) do          if spec.name == "personal" then            workspace = obsidian.Workspace.new_from_spec(spec)          end        end        client:set_workspace(workspace)        local note = client:daily(0)        client:open_note(note, { sync = true })

Comments how to make this better are very welcome

You must be logged in to vote
0 replies
Comment options

Oh....

there isclient:switch_workspace("personal") It "unfortunately" logs a message though.

Edit:
Logs can controlled via a setting:

log_level = vim.log.levels.WARN,
You must be logged in to vote
0 replies
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Category
General
Labels
None yet
1 participant
@oschrenk

[8]ページ先頭

©2009-2025 Movatter.jp