Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ObsidianFollowLink on link with Chinese heading like[[filename#heading1]] not work very well. #839

Open
OriLiMu opened this issue Mar 11, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@OriLiMu
Copy link

OriLiMu commented Mar 11, 2025

🐛 Describe the bug

Use ObsidianFollowLink or gf on link with chinese heading like [[note_name#中国]].
The function not work very well.
Sometimes it create new one note.
Sometimes do nothing.

Config

Used in lazyvim , here is my customized setting.

return {
  "folke/flash.nvim",
  keys = {
    -- disable the default flash keymap
    { "s", mode = { "n", "x", "o" }, false },
    -- 添加自定义的 f 键映射
    {
      "f",
      mode = { "n" },
      function()
        -- 获取当前文件类型
        local ft = vim.bo.filetype
        if ft == "markdown" then
          -- 在 markdown 文件中使用 Obsidian 链接跳转
          require("flash").jump({
            search = { mode = "search" },
            label = { after = { 0, 0 } },
            pattern = "\\[\\[[^\\]]*\\]\\]",
            action = function(match, state)
              vim.api.nvim_win_set_cursor(match.win, { match.pos[1], match.pos[2] })
              vim.cmd("ObsidianFollowLink")
            end,
          })
        else
          -- 在其他文件类型中使用普通的 f 搜索
          require("flash.plugins.char").jump("f")
        end
      end,
      desc = "Flash f jump (markdown: jump to links)",
    },
  },
  opts = {
    labels = "adfghjklqwertyuzvbnm",
    modes = {
      search = {
        enabled = true,
      },
      char = {
        enabled = true, -- 保持 char 模式启用
        jump_labels = true,
        -- 禁用默认的 f 键映射
        keys = {
          -- "f",  -- 注释掉或删除这一行来禁用默认的 f 键映射
          "F",
          "t",
          "T",
          ";",
          ",",
        },
      },
    },
    label = {
      rainbow = {
        enabled = false,
        shade = 5,
      },
    },
  },
}

Environment

NVIM v0.10.4
Build type: RelWithDebInfo
LuaJIT 2.1.1736781742
Run "nvim -V1 -v" for more info
Obsidian.nvim v3.9.0 (ae1f76a75c7ce36866e1d9342a8f6f5b9c2caf9b)
Status:
  • buffer directory: nil
  • working directory: /home/lizhe/OriNote/notes/Ori
Workspaces:
  ✓ active workspace: Workspace(name='Ori', path='/home/lizhe/OriNote/notes', root='/home/lizhe/OriNote/notes')
Dependencies:
  ✓ plenary.nvim: 857c5ac632080dba10aae49dba902ce3abf91b35
  ✓ nvim-cmp: c27370703e798666486e3064b64d59eaf4bdc6d5
  ✓ telescope.nvim: 814f102cd1da3dc78c7d2f20f2ef3ed3cdf0e6e4
Integrations:
  ✓ picker: TelescopePicker()
  ✓ completion: enabled (nvim-cmp) ✗ refs, ✗ tags, ✗ new
    all sources:
      • lazydev
      • nvim_lsp
      • path
      • buffer
      • snippets
      • emoji
Tools:
  ✓ rg: ripgrep 14.1.1
Environment:
  • operating system: Linux
Config:
  • notes_subdir: notes⏎
@OriLiMu OriLiMu added the bug Something isn't working label Mar 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant