config/nvim/lua/plugins/completion.lua (view raw)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 |
local plugins = {
-- Autocompletion and Snippets
{
"Saghen/blink.cmp",
version = "1.*", -- Use a stable release version
main = "blink.cmp",
opts = {
keymap = { -- https://cmp.saghen.dev/configuration/keymap.html
preset = "default",
["<Tab>"] = { "accept", "fallback" },
},
sources = {
-- Enable completion from lazydev, LSP, filesystem paths, snippets, buffer
-- (and optionally supermaven)
-- default = { "lazydev", "lsp", "path", "snippets", "buffer", "supermaven" },
default = { "lazydev", "lsp", "path", "snippets", "buffer" },
providers = {
-- Neovim Lua API / plugin spec completions (folke/lazydev.nvim)
lazydev = {
name = "LazyDev",
module = "lazydev.integrations.blink",
score_offset = 100, -- show lazydev items above LSP
},
buffer = {
-- Optional: Configure buffer-specific settings
-- max_async_buffer_size = 200000, -- 200KB default
-- use_cache = true, -- Cache words for better performance
},
-- lsp = { fallbacks = {} }, -- always show the buffer source
supermaven = {
enabled = false,
name = "supermaven",
module = "blink-cmp-supermaven",
async = true,
},
},
},
completion = {
-- Enable ghost text to show completions inline
ghost_text = {
-- enabled = true,
enabled = false,
},
-- Configure the completion menu
menu = {
auto_show = true, -- Automatically show the menu
},
list = {
selection = {
preselect = true,
auto_insert = false,
},
},
-- Avoid unnecessary requests for performance
trigger = {
-- prefetch_on_insert = true, -- When true, will prefetch the completion items when entering insert mode
show_in_snippet = false, -- When false, will not show the completion window automatically when in a snippet
show_on_backspace = false, -- When true, will show completion window after backspacing
show_on_backspace_in_keyword = false, -- When true, will show completion window after backspacing into a keyword
show_on_backspace_after_accept = false, -- When true, will show the completion window after accepting a completion and then backspacing into a keyword
show_on_backspace_after_insert_enter = false, -- When true, will show the completion window after entering insert mode and backspacing into keyword
show_on_keyword = false, -- When true, will show the completion window after typing any of alphanumerics, `-` or `_`
show_on_trigger_character = false, -- When true, will show the completion window after typing a trigger character
show_on_insert = false, -- When true, will show the completion window after entering insert mode
-- LSPs can indicate when to show the completion window via trigger characters
-- however, some LSPs (i.e. tsserver) return characters that would essentially
-- always show the window. We block these by default.
-- show_on_blocked_trigger_characters = { " ", "\n", "\t" },
-- You can also block per filetype with a function:
-- show_on_blocked_trigger_characters = function(ctx)
-- if vim.bo.filetype == 'markdown' then return { ' ', '\n', '\t', '.', '/', '(', '[' } end
-- return { ' ', '\n', '\t' }
-- end,
-- When both this and show_on_trigger_character are true, will show the completion window
-- when the cursor comes after a trigger character after accepting an item
show_on_accept_on_trigger_character = false,
-- When both this and show_on_trigger_character are true, will show the completion window
-- when the cursor comes after a trigger character when entering insert mode
show_on_insert_on_trigger_character = false,
-- List of trigger characters (on top of `show_on_blocked_trigger_characters`) that won't trigger
-- the completion window when the cursor comes after a trigger character when
-- entering insert mode/accepting an item
-- show_on_x_blocked_trigger_characters = { "'", '"', "(" },
-- or a function, similar to show_on_blocked_trigger_character
},
},
signature = {
enabled = true,
window = {
show_documentation = false,
},
},
-- Disable blink.cmp for command-line mode to let native wildmenu work
cmdline = {
enabled = false,
},
},
},
-- Supermaven was acquired (and killed) by Cursor
{
"supermaven-inc/supermaven-nvim",
event = "InsertEnter",
opts = {
keymaps = {
accept_suggestion = "<Tab>",
clear_suggestion = "<C-]>",
accept_word = "<C-j>",
},
ignore_filetypes = {},
disable_inline_completion = false,
disable_keymaps = false,
condition = function()
return false
end,
log_level = "info",
},
config = function(_, opts)
require("supermaven-nvim").setup(opts)
-- Clear supermaven ghost text when entering command-line mode
-- to prevent interference with wildmenu completion
vim.api.nvim_create_autocmd("CmdlineEnter", {
callback = function()
local ok, preview = pcall(require, "supermaven-nvim.completion_preview")
if ok and preview.on_dispose_inlay then
preview.on_dispose_inlay()
end
end,
})
end,
},
{
"huijiro/blink-cmp-supermaven",
},
-- Lua LSP completion + types for the Neovim API and lazy plugin specs.
-- Replaces the old lua_ls `globals` hack for editing this config.
{
"folke/lazydev.nvim",
ft = "lua",
opts = {
library = {
-- Load luvit types when the `vim.uv` word is found
{ path = "${3rd}/luv/library", words = { "vim%.uv" } },
-- Types for snacks.nvim (used throughout this config)
{ path = "snacks.nvim", words = { "Snacks" } },
},
},
},
}
for _, plugin in ipairs(plugins) do
if not plugin.priority then
plugin.priority = 2000
end
end
return plugins
|