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

Completion wipes out unrelated text #722

Open
mscott99 opened this issue Sep 22, 2024 · 0 comments
Open

Completion wipes out unrelated text #722

mscott99 opened this issue Sep 22, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@mscott99
Copy link
Contributor

🐛 Describe the bug

If I write [[Note name this is now unrelated text, completing when my cursor is at the position will wipe out the end of the line, included unrelated text.

Config

    'epwalsh/obsidian.nvim',
    enabled = true,
    lazy = true,
    event = 'BufReadPre ' .. vim.fn.expand '~' .. '/Obsidian/**.md',
    cmd = { 'ObsidianOpen', 'ObsidianQuickSwitch', 'ObsidianSearch' },
    -- If you want to use the home shortcut '~' here you need to call 'vim.fn.expand':
    -- event = { "BufReadPre " .. vim.fn.expand "~" .. "/my-vault/**.md" },
    dependencies = {
      -- Required.
      'nvim-lua/plenary.nvim',

      -- Optional, for completion.
      'hrsh7th/nvim-cmp',

      -- Optional, for search and quick-switch functionality.
      'nvim-telescope/telescope.nvim',

      -- Optional, alternative to nvim-treesitter for syntax highlighting.
      'godlygeek/tabular',
      -- "preservim/vim-markdown",
      'ixru/nvim-markdown',
    },
    opts = {
      dir = '~/Obsidian/myVault/', -- no need to call 'vim.fn.expand' here

      -- Optional, if you keep notes in a specific subdirectory of your vault.
      notes_subdir = 'Zettelkasten/',
      daily_notes = {
        -- Optional, if you keep daily notes in a separate directory.
        folder = 'Temporal/Daily Notes/',
        -- Optional, if you want to change the date format for daily notes.
        date_format = '%Y-%m-%d',
      },

      -- Optional, completion.
      completion = {
        nvim_cmp = true, -- if using nvim-cmp, otherwise set to false
      },

      -- -- Optional, customize how names/IDs for new notes are created.
      note_id_func = function(title)
        return title
      end,
      --
      -- Optional, set to true if you don't want Obsidian to manage frontmatter.
      disable_frontmatter = true,

      -- Optional, alternatively you can customize the frontmatter data.
      note_frontmatter_func = function(note)
        -- This is equivalent to the default frontmatter function.
        -- local out = { id = note.id, aliases = note.aliases, tags = note.tags }
        local out = {}
        -- `note.metadata` contains any manually added fields in the frontmatter.
        -- So here we just make sure those fields are kept in the frontmatter.
        if note.metadata ~= nil and require('obsidian').util.table_length(note.metadata) > 0 then
          for k, v in pairs(note.metadata) do
            out[k] = v
          end
        end
        return out
      end,

      -- -- Optional, for templates (see below).
      -- templates = {
      --   subdir = "templates",
      --   date_format = "%Y-%m-%d-%a",
      --   time_format = "%H:%M",
      -- },
      --
      -- Optional, by default when you use `:ObsidianFollowLink` on a link to an external
      -- URL it will be ignored but you can customize this behavior here.
      follow_url_func = function(url)
        -- Open the URL in the default web browser.
        vim.fn.jobstart { 'open', url } -- Mac OS
        -- vim.fn.jobstart({"xdg-open", url})  -- linux
      end,

      -- Optional, set to true if you use the Obsidian Advanced URI plugin.
      -- https://github.com/Vinzent03/obsidian-advanced-uri
      use_advanced_uri = true,

      -- Optional, set to true to force ':ObsidianOpen' to bring the app to the foreground.
      open_app_foreground = true,

      -- Optional, by default commands like `:ObsidianSearch` will attempt to use
      -- telescope.nvim, fzf-lua, and fzf.nvim (in that order), and use the
      -- first one they find. By setting this option to your preferred
      -- finder you can attempt it first. Note that if the specified finder
      -- is not installed, or if it the command does not support it, the
      -- remaining finders will be attempted in the original order.
      finder = 'telescope.nvim',
    },
    config = function(_, opts)
      require 'setup.export_obsidian' -- load personal export function.
      require('obsidian').setup(opts)

      -- Optional, override the 'gf' keymap to utilize Obsidian's search functionality.
      -- see also: 'follow_url_func' config option above.
      vim.keymap.set('n', 'gf', function()
        if require('obsidian').util.cursor_on_markdown_link() then
          return '<cmd>ObsidianFollowLink<CR>'
        else
          return 'gf'
        end
      end, { noremap = false, expr = true })
    end,
    keys = {
      { '<leader>of', '<cmd>ObsidianQuickSwitch<CR>', desc = 'Open Obsidian File' },
      { '<leader>oo', '<cmd>ObsidianOpen<CR>', desc = 'Open Note in Obsidian' },
      { '<leader>ob', '<cmd>ObsidianBacklinks<CR>', desc = 'Open Backlinks' },
    },
  }```

### Environment

NVIM v0.10.1
Build type: Release
LuaJIT 2.1.1724512491
Run "nvim -V1 -v" for more info
Obsidian.nvim v3.9.0 (14e0427)
Status:
• buffer directory: nil
• working directory: /Users/matthewscott/Obsidian/myVault
Workspaces:
✓ active workspace: Workspace(name='myVault', path='/Users/matthewscott/Obsidian/myVault', root='/Users/matthewscott/Obsidian/myVault')
Dependencies:
✓ plenary.nvim: ec289423a1693aeae6cd0d503bac2856af74edaa
✓ nvim-cmp: ae644feb7b67bf1ce4260c231d1d4300b19c6f30
✓ telescope.nvim: a0bbec21143c7bc5f8bb02e0005fa0b982edc026
Integrations:
✓ picker: TelescopePicker()
✓ completion: enabled (nvim-cmp) ✗ refs, ✗ tags, ✗ new
all sources:
• copilot
• nvim_lsp
• luasnip
• path
• otter
• treesitter
Tools:
✓ rg: ripgrep 14.1.0
Environment:
• operating system: Darwin
Config:
• notes_subdir: Zettelkasten/%

@mscott99 mscott99 added the bug Something isn't working label Sep 22, 2024
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