Skip to content

Completion

neo451 edited this page May 24, 2026 · 1 revision

Plugin Completion

This plugin provides plugin-agnostic completion via in-process LSP, you only need to make sure you are triggering LSP completions in markdown buffers.

For blink.cmp, if you have a dedicated per_filetype config for markdown, LSP completion will not attach, use:

require("blink.cmp").setup {
  sources = {
    -- NOTE: no need if you don't have custom markdown stuff
    per_filetype = {
      markdown = {
        "lsp", -- NOTE: explicitly enable lsp
        -- inherit_defaults = true, -- NOTE: if your defaults include lsp
        "dictionary",
      },
    },
  },
}

Neovim Native Completion

To use completions without completion plugin, put this anywhere in your config before an obsidian buffer loads:

-- HACK: to trigger on every ASCII char, unicode will work when the upstream neovim completion respects isIncomplete field properly
local chars = {}
for i = 32, 126 do
  table.insert(chars, string.char(i))
end

vim.api.nvim_create_autocmd("LspAttach", {
  callback = function(ev)
    local buf = ev.buf
    local client = vim.lsp.get_client_by_id(ev.data.client_id)
    if client and client.name == "obsidian-ls" then
      client.server_capabilities.completionProvider.triggerCharacters = chars -- HACK:
      vim.bo[buf].completeopt = "menuone,noselect,fuzzy,nosort" -- noselect to make sure no accidentally accept and create new notes, others are not strictly necessary, adjust to your taste, see `:h completeopt'
      vim.lsp.completion.enable(true, client.id, buf, { autotrigger = true })
    end
  end,
})

Clone this wiki locally