local env = require('core.env') return { -- 補完エンジン { 'saghen/blink.cmp', cond = not env.is_vscode(), version = '1.*', dependencies = { 'rafamadriz/friendly-snippets', 'L3MON4D3/LuaSnip', -- Copilot統合のための依存関係 { 'giuxtaposition/blink-cmp-copilot', dependencies = { 'zbirenbaum/copilot.lua' }, }, }, opts = { -- キーマップ設定(nvim-cmpの設定を踏襲しつつカスタマイズ) keymap = { preset = 'none', [''] = { 'select_next', 'fallback' }, [''] = { 'select_prev', 'fallback' }, [''] = { 'scroll_documentation_up', 'fallback' }, [''] = { 'scroll_documentation_down', 'fallback' }, [''] = { 'show', 'fallback' }, [''] = { 'show', 'show_documentation', 'hide_documentation' }, [''] = { 'hide', 'fallback' }, [''] = { 'accept', 'fallback' }, [''] = { 'show_signature', 'hide_signature', 'fallback' }, [''] = { 'select_next', 'fallback' }, [''] = { 'select_prev', 'fallback' }, [''] = { 'hide', 'fallback' }, }, appearance = { nerd_font_variant = 'mono', }, completion = { -- ドキュメント表示設定 documentation = { auto_show = true, auto_show_delay_ms = 200, window = { border = 'rounded', }, }, -- メニュー設定(nvim-cmpの枠線付きスタイルを踏襲) menu = { auto_show = true, border = 'rounded', draw = { columns = { { 'label', 'label_description', gap = 1 }, { 'kind_icon', 'kind', gap = 1 }, }, }, }, -- ゴーストテキスト有効化 ghost_text = { enabled = true, }, -- 補完候補の選択設定 list = { selection = { preselect = true, auto_insert = true, }, }, }, -- 補完ソース設定 sources = { default = { 'lsp', 'path', 'snippets', 'buffer', 'copilot' }, -- ソースごとの詳細設定 providers = { lsp = { name = 'LSP', score_offset = 100, fallbacks = { 'buffer' }, }, path = { name = 'Path', score_offset = 80, opts = { trailing_slash = true, label_trailing_slash = true, }, }, snippets = { name = 'Snippet', score_offset = 90, }, buffer = { name = 'Buffer', score_offset = -3, min_keyword_length = 3, max_items = 5, opts = { -- 表示されているバッファのみから補完 get_bufnrs = function() return vim .iter(vim.api.nvim_list_wins()) :map(function(win) return vim.api.nvim_win_get_buf(win) end) :filter(function(buf) return vim.bo[buf].buftype ~= 'nofile' end) :totable() end, }, }, copilot = { name = 'Copilot', module = 'blink-cmp-copilot', score_offset = 95, async = true, opts = { -- Copilot固有の設定 max_items = 3, }, }, }, }, -- スニペット設定 snippets = { preset = 'luasnip', }, -- シグネチャヘルプ有効化 signature = { enabled = true, window = { border = 'rounded', }, }, -- コマンドライン補完設定 cmdline = { enabled = true, keymap = { preset = 'cmdline' }, sources = { 'buffer', 'cmdline', 'path' }, completion = { list = { selection = { preselect = true, auto_insert = true, }, }, menu = { auto_show = true }, ghost_text = { enabled = true }, }, }, -- Lua実装を使用(frizbee 0.5.0 のバグ回避) -- TODO: frizbee のバグ修正後に 'prefer_rust_with_warning' に戻す fuzzy = { implementation = 'lua', }, }, opts_extend = { 'sources.default' }, }, }