Skip to content

Support nofile buftypes #440

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

Closed
olimorris opened this issue Dec 3, 2024 Discussed in #439 · 1 comment
Closed

Support nofile buftypes #440

olimorris opened this issue Dec 3, 2024 Discussed in #439 · 1 comment

Comments

@olimorris
Copy link

olimorris commented Dec 3, 2024

I'm looking to add a source for my plugin, to blink.

For context, the buffer I would like blink to work in is a custom filetype but with a buftype of nofile. So with my custom source:

-- codecompanion.integrations.blink.init.lua
local M = {}

function M.new()
  return setmetatable({}, { __index = M })
end

function M:get_trigger_characters()
  return { "/" }
end

function M:enabled(context)
  if context then
    return vim.bo[context.bufnr].filetype == "codecompanion"
  end
  return true -- force this to be enabled for the purposes of this demo
end

function M:get_completions(context, callback)
  print("ENABLED")
end

return M

and my lazy config:

{
  "saghen/blink.cmp", -- Better completion
  build = "cargo build --release",
  event = "InsertEnter",
  opts = {
    sources = {
      compat = {},
      completion = {
        enabled_providers = { "lsp", "path", "snippets", "buffer", "codecompanion" },
      },
      providers = {
        codecompanion = {
          name = "CodeCompanion",
          module = "codecompanion.integrations.blink",
          enabled = true,
        },
      },
    },
  },
},

I will only ever see the printed message enabled, if I do :set buftype= and then hit the trigger character in the buffer.

@KarlEricsson
Copy link
Contributor

A simple solution for this could be to add a setting alongside blocked_filetypes that overrides the check for buftype and always enables blink? Maybe something like always_enable_in or always_enable_filetypes. Most plugins I can think of that would need this functionality have their own filetype. I guess sources should be able to add their filetypes and maybe it should be a source setting? But if you want to limit the number of settings, or as temporary solution, you could just add the filetype override setting and instruct the user to add the plugin filetype in the install instructions of the source?

Really looking forward to having blink support in CodeCompanion, it's a great plugin!

@Saghen Saghen closed this as completed in a6636c1 Dec 9, 2024
olimorris added a commit to olimorris/codecompanion.nvim that referenced this issue Dec 9, 2024
Following the resolution to
Saghen/blink.cmp#440, I'm happy to announce
support for blink.cmp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants