Skip to content

Coc.nvim

Intellisense engine for Vim8 & Neovim, full language server protocol support as VSCode.

How to install

Using vim-plug

" Use release branch (recommend)
Plug 'neoclide/coc.nvim', {'branch': 'release'}

Using NeoBundle

Use this work-around to check out the recommended release branch:

NeoBundle 'neoclide/coc.nvim'

Extensions

  • Extensions directory: $HOME/.config/coc/extensions

전체 목록:

  • Using coc extensions · neoclide/coc.nvim Wiki
  • coc-angular
  • coc-ansible
  • coc-astro
  • coc-black-formatter
  • coc-blade
  • coc-browser
  • coc-calc
  • coc-cfn-lint
  • coc-clangd
  • coc-clang-format-style-options
  • coc-cmake
  • coc-copilot
  • coc-css
  • coc-cssmodules
  • coc-deno
  • coc-diagnostic
  • coc-discord
  • coc-discord-rpc
  • coc-dash-complete
  • coc-dot-complete
  • coc-docker
  • coc-dlang
  • coc-ecdict
  • coc-elixir
  • coc-ember
  • coc-glint
  • coc-emmet
  • coc-erlang_ls
  • coc-esbonio
  • coc-eslint
  • coc-explorer
  • coc-floaterm
  • coc-flow
  • coc-flutter
  • coc-fsharp
  • coc-fzf-preview
  • coc-gist
  • coc-git
  • coc-glslx
  • coc-go
  • coc-golines
  • coc-graphql
  • coc-haxe
  • coc-highlight
  • coc-html
  • coc-htmldjango
  • coc-htmlhint
  • coc-html-css-support
  • coc-intelephense
  • coc-java
  • coc-jedi
  • coc-json
  • coc-julia
  • coc-just-complete
  • coc-laravel
  • coc-lists
  • coc-lightbulb
  • coc-lsp-wl
  • coc-ltex
  • coc-lua
  • coc-markdownlint
  • coc-markdown-preview-enhanced
  • coc-markmap
  • coc-metals
  • coc-mypy
  • coc-nav
  • coc-nginx
  • coc-omnisharp
  • coc-perl
  • coc-phpactor
  • coc-phpls
  • coc-phpstan
  • coc-php-cs-fixer
  • coc-psalm
  • coc-powershell
  • coc-prettier
  • coc-prisma
  • coc-pydocstring
  • coc-pylsp
  • coc-pyright
  • coc-python
  • coc-r-lsp
  • coc-reason
  • coc-rls
  • coc-rome
  • coc-ruff
  • coc-rust-analyzer
  • coc-sh
  • coc-stylelintplus
  • coc-stylelint
  • coc-snippets
  • coc-solargraph
  • coc-solidity
  • coc-sourcekit
  • coc-spell-checker
  • coc-sql
  • coc-sqlfluff
  • coc-stylua
  • coc-sumneko-lua
  • coc-svelte
  • coc-svg
  • coc-swagger
  • coc-symbol-line
  • coc-tabnine
  • coc-tailwindcss
  • coc-tailwindcss3
  • coc-tasks
  • coc-texlab
  • coc-thrift-syntax-support
  • coc-toml
  • coc-translator
  • coc-tsserver
  • coc-twoslash-queries
  • coc-unocss
  • coc-vetur
  • coc-volar
  • coc-vimlsp
  • coc-webview
  • coc-xml
  • coc-yaml
  • coc-yank
  • coc-zig
  • coc-zls

Show Signature Help

파라미터 인자 목록 팝업을 보고싶을 때 사용한다. 주로 Insert Mode 에서 상황이 일어나므로 다음과 같은 키맵을 사용한다:

inoremap <C-P> <C-\><C-O>:call CocActionAsync('showSignatureHelp')<cr>

여기에서 CTRL-\ CTRL-O 는 삽입 모드를 종료하지 않고 일반 모드 명령을 실행하기 위해 사용한다. Vi#Quick command in insert mode 항목 참조.

설정 파일

사용자(User) 설정 파일
파일 경로 - $HOME/.config/nvim/coc-settings.json
파일 열기 명령 - :CocConfig
작업공간(Workspace) 설정 파일
파일 열기 명령 - :CocLocalConfig
파일 경로 - .vim/coc-settings.json

Variables expand

Variables would be expanded in string values of configuration, supported variables:

  • ${userHome} - the path of the user's home folder
  • ${cwd} - current working directory of vim

some additional variables see:

:h coc-configuration-expand

Configuration file resolve

To enable intellisense for coc-settings.json, install the json language extension coc-json by:

:CocInstall coc-json

In your vim.

Built in configurations

Checkout :h coc-config for all built in configurations.

Examples

{
  "clangd.path": "~/.config/coc/extensions/coc-clangd-data/install/14.0.0/clangd_14.0.0/bin/clangd",
  "python.pythonPath": "python",
}

Workspace

VSCode와 달리 vim은 작업 공간을 지원하지 않습니다. 해결책은 열린 파일에서 작업공간 폴더를 확인하는 것입니다.

Resolve workspace folder

파일/폴더 이름 목록은 작업 영역 폴더를 확인하는 데 사용되며 패턴은 다음에서 가져올 수 있습니다.

  • b:coc_root_patterns variable of current buffer.
  • rootPatterns specified for language server used for current buffer.
  • "workspace.rootPatterns" settings, which default to [".git", ".hg", ".projections.json"].

후자는 우선순위가 낮습니다. 즉, 이전 패턴이 작업공간 폴더와 일치하지 않는 경우에만 사용된다는 의미입니다.

작업 공간 전용 설정 파일

작업 공간용 coc-settings.json 파일은 :CocLocalConfig 명령으로 생성 및 열기 가능하고, 경로는 $(repo)/.vim/coc-settings.json 이다.

Usage

Find a references
<Plug>(coc-references)

Troubleshooting

Error on initialize: Error: EEXIST

[coc.nvim] error: Error on initialize: Error: EEXIST: file already exists, mkdir '/home/vim/.config/coc/extensions/.cache'
    at Object.fs.mkdirSync (fs.js:885:18)
    at new ExtensionManager (/home/vim/.local/share/nvim/plugged/coc.nvim/lib/model/extension.js:24:22)
    at Extensions.init (/home/vim/.local/share/nvim/plugged/coc.nvim/lib/extensions.js:59:24)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)

Nodejs 버전이 10.14 이상이면 된다.

error TS5058: The specified path does not exist: 'tsconfig.json'

  error TS5058: The specified path does not exist: 'tsconfig.json'.                                                                                                                                                
  error Command failed with exit code 1.                                                                                                                                                                           
  info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.                                                                                                                                                                                                           
  ERROR: "build" exited with 1.                                                                                                                                                                                    
  error Command failed with exit code 1.

Release 브랜치의 coc.vim 을 사용하면 된다.

javascript bundle not found, please compile typescript code

"[coc.nvim] javascript bundle not found, please compile typescript code."

Release 브랜치의 coc.vim 을 사용하면 된다. 그리고 최신버전 업데이트 후, :call coc#util#install()을 실행하면 된다.

javascript bundle not found, running :call coc#util#install()

[coc.nvim] javascript bundle not found, running :call coc#util#install()

yarn을 설치하고, :call coc#util#install()을 실행하면 된다.

Can't create tmp file

[coc.nvim] Can't create tmp file: The "path" argument must be of type string. Received undefined

???

coc.vim switched to custom popup menu - How to change the keymappings for <tab>

PR: https://github.com/neoclide/coc.nvim/pull/3862

:h coc-completion 또는 :h coc-completion-example로 관련 내용 확인 가능.

간단히, 홈페이지의 Example vim configuration 항목의 코드로 바꾸면 된다.

Launching server "languageserver.csharp-ls" using command csharp-ls failed

[coc.nvim] Server languageserver.csharp-ls failed to start: Error: Launching server "languageserver.csharp-ls" using command csharp-ls failed.

csharp-ls#Troubleshooting 페이지 참조. 간략히 말하면, csharp-ls를 설치해야 한다.

=== The reference assemblies for .NETFramework,Version=v4.7.2 were not found ===

[coc.nvim] csharp-ls: msbuildWorkspace.Diagnostics: [Failure] Msbuild failed when processing the file '/home/user/Project/EduPiano/godot/EduPiano.csproj' with message: /usr/share/dotnet/sdk/7.0.202/Microsoft.Common.CurrentVersion.targets: (1229, 5): The reference assemblies for .NETFramework,Version=v4.7.2 were not found. To resolve this, install the Developer Pack (SDK/Targeting Pack) for this framework version or retarget your application. You can download .NET Framework Developer Packs at https://aka.ms/msbuild/developerpacks

dotnet#Troubleshooting 페이지 참조. 간략히 말하면 .NET Framework v4.7.2을 설치해야 한다.

"openLocalConfig": Can't resolve workspace folder for current file

[coc.nvim] Error on notification "openLocalConfig": Can't resolve workspace folder for current file, consider create one of .git, .hg, .projections.json in your project root.

"openLocalConfig" 알림 오류: 현재 파일의 작업공간 폴더를 확인할 수 없습니다. 프로젝트 루트에 .git, .hg, .projections.json 중 하나를 생성해 보세요.

See also

Favorite site