function! s:enable_coc_for_type() let l:filesuffix_whitelist = ['php', 'ts', 'vim', 'sh', 'py', 'shd', 'json', 'changelog', 'md', 'copilot-chat', 'sql', 'txt'] if index(l:filesuffix_whitelist, expand('%:e')) == -1 let b:coc_enabled = 0 endif let l:filename_blacklist = ['tenTask.txt'] if index(l:filename_blacklist,fnamemodify(expand('%:p'), ':t')) == 0 let b:coc_enabled = 0 endif let l:fileprefix_blacklist = ['dev-query-', 'ddc-ff'] for l:prefix in l:fileprefix_blacklist if match(expand('%:t:r'), '^' . l:prefix) != -1 let b:coc_enabled = 1 break endif endfor endfunction autocmd BufRead,BufNewFile * call s:enable_coc_for_type() " .vimrc や任意のVim設定ファイルに追加 " filetypeに基づいてキーバインドを設定する関数 function! SetFileTypeBindings() " filetypeを取得 let l:filetype = &filetype " filetypeがmarkdownの場合 if l:filetype == 'changelog' " for nvim-cmp lua << EOF local cmp = require'cmp' cmp.setup({ snippet = { -- REQUIRED - you must specify a snippet engine expand = function(args) end, }, mapping = cmp.mapping.preset.insert({ [''] = cmp.mapping.scroll_docs(-4), [''] = cmp.mapping.scroll_docs(4), [""] = cmp.mapping.select_prev_item(), [""] = cmp.mapping.select_next_item(), [''] = cmp.mapping.abort(), [""] = cmp.mapping.confirm { select = true }, }), window = { completion = cmp.config.window.bordered(), documentation = cmp.config.window.bordered(), }, sources = { { name = 'buffer' }, { name = 'path' }, }, method = "getCompletionsCycling", }) EOF else " for coc.nvim inoremap coc#pum#visible() ? coc#_select_confirm() \: "\u" . lexima#expand('CR>', 'i') inoremap coc#pum#visible() ? coc#pum#next(1) : "\" inoremap coc#pum#visible() ? coc#pum#prev(1) : "\" inoremap coc#pum#visible() ? coc#pum#next(0) : "\" inoremap coc#pum#visible() ? coc#pum#prev(0) : "\" function! s:check_back_space() abort let col = col('.') - 1 return !col || getline('.')[col - 1] =~ '\s' endfunction " imap " \ coc#pum#visible() ? coc#pum#next(1): " \ check_back_space() ? "\" : " \ coc#refresh() " imap coc#pum#visible() ? coc#pum#prev(1) : "\" let g:coc_snippet_next = '' nmap cd (coc-definition) nmap cy (coc-type-definition) nmap ci (coc-implementation) nmap cr (coc-references) nmap cn (coc-rename) nmap cf (coc-format) vmap cf (coc-format) nmap cR (coc-refactor) nnoremap cla :CocFzfList diagnostics nnoremap clb :CocFzfList diagnostics --current-buf nnoremap clc :CocFzfList commands nnoremap cle :CocFzfList extensions nnoremap cls :CocFzfList symbols nnoremap clS :CocFzfList services nnoremap clp :CocFzfListResume nmap caA (coc-codeaction) nmap cal (coc-codeaction-line) xmap cas (coc-codeaction-selected) nmap caa (coc-codeaction-cursor) autocmd FileType php,typescript,python,markdown,javascript,vim nnoremap co :CocFzfList outline endif endfunction " BufEnterイベントが発生したときにSetFileTypeBindings関数を呼び出す augroup FileTypeBindings autocmd! autocmd BufEnter * call SetFileTypeBindings() augroup END