前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >CocConfig参数设置说明

CocConfig参数设置说明

作者头像
潇洒
发布2023-10-23 08:43:18
4100
发布2023-10-23 08:43:18
举报
文章被收录于专栏:石头岛石头岛

前言

如果常用vim的程序员的话,coc 这个插件即使没用过也听说过,这真是个强到没边的插件。 之所以写这个文件是因为用了一段coc发现真是个强大的插件,可以对每次项功能做到非常精细的配置。 自己在用的过程中每一项都一点一点验证,把这个过程记录下来,可能会有很多朋友能用的上。

CocConfig

编辑CocConfig的方式有两种:

1.在vim输入: :CocConfig,保存后生成文件 2.编辑文件,默认不存在该文件:

~/.config/nvim/coc-settings.json

完整配置,下面标逐渐分析每个配置的说明,每个配置都是在使用中,一点一点验证。

代码语言:javascript
复制
{
    "coc.preferences.semanticTokensHighlights": false,
    "coc.preferences.enableFloatHighlight": true,
    "coc.preferences.snippetStatusText": "Ⓢ ",
    "coc.preferences.extensionUpdateCheck": "daily",
    "coc.preferences.messageLevel": "error",
    "coc.source.around.firstMatch": false,
    "coc.source.buffer.firstMatch": false,
    "coc.source.syntax.firstMatch": false,
    "suggest.detailMaxLength": 60,
    "suggest.noselect": true,
    "suggest.enablePreselect": false,
    "suggest.triggerAfterInsertEnter": true,
    "suggest.autoTrigger": "always",
    "suggest.timeout": 5000,
    "suggest.enablePreview": true,
    "suggest.floatEnable": true,
    "suggest.detailField": "preview",
    "suggest.snippetIndicator": "",
    "suggest.triggerCompletionWait": 100,
    "suggest.echodocSupport": true,
    "suggest.completionItemKindLabels": {
        "class": "\uf0e8",
        "color": "\ue22b",
        "constant": "\uf8fe",
        "default": "\uf29c",
        "enum": "\uf435",
        "enumMember": "\uf02b",
        "event": "\ufacd",
        "field": "\uf93d",
        "file": "\uf723",
        "folder": "\uf115",
        "function": "\u0192",
        "interface": "\uf417",
        "keyword": "\uf1de",
        "method": "\uf6a6",
        "module": "\uf40d",
        "operator": "\uf915",
        "property": "\ue624",
        "reference": "\ufa46",
        "snippet": "\ue60b",
        "struct": "\ufb44",
        "text": "\ue612",
        "typeParameter": "\uf728",
        "unit": "\uf475",
        "value": "\uf89f",
        "variable": "\ue71b"
    },
    "diagnostic.signOffset": 1,
    "diagnostic.errorSign": "\uf467",
    "diagnostic.warningSign": "\uf071",
    "diagnostic.infoSign": "\uf129",
    "diagnostic.hintSign": "\uf864",
    "diagnostic.displayByAle": false,
    "diagnostic.refreshOnInsertMode": false,
    "diagnostic.checkCurrentLine": true,
    "diagnostic.virtualTextPrefix": " ❯❯❯ ",
    "diagnostic.virtualText": false,
    "codeLens.enable": true,
    "list.previewHighlightGroup": "Statement",
    "list.nextKeymap": "<C-e>",
    "list.previousKeymap": "<C-u>",
    "importCost.bundleSizeDecoration": "both",
    "importCost.typescriptExtensions": [
        "\\.tsx?$"
    ],
    "importCost.javascriptExtensions": [
        "\\.jsx?$"
    ],
    "importCost.showCalculatingDecoration": true,
    "importCost.debug": false,
    "snippets.ultisnips.directories": [
        "$HOME/.config/nvim/Ultisnips/",
        "$HOME/.config/nvim/plugged/vim-snippets/UltiSnips/"
    ],
    "coc.preferences.formatOnSaveFiletypes": [
        "javascript",
        "typescript",
        "html",
        "css",
        "json",
        "java",
        "python",
        "vue",
        "svelte",
        "c",
        "cs",
        "prisma"
    ],
    "yaml.format.enable": true,
    "signature.target": "float",
    "yank.enableCompletion": false,
    "jest.watch": false,
    "explorer.width": 38,
    "explorer.quitOnOpen": true,
    "explorer.sources": [
        {
            "name": "buffer",
            "expand": false
        },
        {
            "name": "file",
            "expand": true
        }
    ],
    "explorer.file.column.indent.indentLine": true,
    "explorer.file.showHiddenFiles": true,
    "explorer.icon.enableNerdfont": true,
    "explorer.file.column.git.showIgnored": true,
    "explorer.keyMappingMode": "none",
    "explorer.buffer.showHiddenBuffers": false,
    "explorer.keyMappings.global": {
        "u": "nodePrev",
        "e": "nodeNext",
        "h": "toggleSelection",
        "<tab>": "actionMenu",
        "gl": "expandRecursive",
        "gh": "collapseRecursive",
        "i": [
            "wait",
            "expandable?",
            "expand",
            "open"
        ],
        "<cr>": [
            "wait",
            "expandable?",
            "cd",
            "open"
        ],
        "I": "open:vsplit",
        "o": [
            "wait",
            "expanded?",
            "collapse",
            "expand"
        ],
        "O": "open:tab",
        "n": "collapse",
        "l": "gotoParent",
        "yp": "copyFilepath",
        "yn": "copyFilename",
        "yy": "copyFile",
        "dd": "cutFile",
        "pp": "pasteFile",
        "dD": "deleteForever",
        "a": "addFile",
        "k": "addFile",
        "M": "addDirectory",
        "cw": "rename",
        ".": "toggleHidden",
        "zh": "toggleHidden",
        "R": "refresh",
        "?": "help",
        "q": "quit",
        "X": "systemExecute",
        "gd": "listDrive",
        "f": "search",
        "F": "searchRecursive",
        "B": "gotoSource:file",
        "b": "gotoSource:buffer",
        "[[": "sourcePrev",
        "]]": "sourceNext",
        "[d": "diagnosticPrev",
        "]d": "diagnosticNext",
        "[c": "gitPrev",
        "]c": "gitNext",
        "<<": "gitStage",
        ">>": "gitUnstage"
    },
    "tslint.autoFixOnSave": false,
    "python.autoComplete.addBrackets": true,
    "python.jediEnabled": false,
    "python.formatting.provider": "yapf",
    "python.formatting.yapfArgs": [
        "--style",
        "{SPACES_AROUND_POWER_OPERATOR: True, SPACES_BEFORE_COMMENT: 1}"
    ],
    "html.format.enable": true,
    "javascript.referencesCodeLens.enable": true,
    "javascript.showUnused": true,
    "javascript.suggest.names": true,
    "javascript.suggestionActions.enabled": true,
    "json.format.enable": true,
    "eslint.autoFixOnSave": false,
    "prettier.printWidth": 100,
    "prettier.disableLanguages": [],
    "prettier.formatterPriority": 1,
    "prettier.useTabs": true,
    "prettier.trailingComma": "all",
    "prettier.singleQuote": false,
    "todolist.autoUpload": true,
    "todolist.promptForReminder": false,
    "coc-actions.hideCursor": false,
    "coc-actions.showActionKind": true,
    "diagnostic-languageserver.filetypes": {
        "vim": "vint",
        "email": "languagetool",
        "markdown": [
            "write-good",
            "markdownlint"
        ],
        "sh": "shellcheck",
        "elixir": [
            "mix_credo",
            "mix_credo_compile"
        ],
        "eelixir": [
            "mix_credo",
            "mix_credo_compile"
        ],
        "php": [
            "phpstan",
            "psalm"
        ]
    },
    "diagnostic-languageserver.formatFiletypes": {
        "elixir": "mix_format",
        "eelixir": "mix_format"
    },
    "languageserver": {
        "lua": {
            "command": "lua-lsp",
            "filetypes": [
                "lua"
            ]
        },
        "golang": {
            "command": "gopls",
            "rootPatterns": [
                "go.mod"
            ],
            "filetypes": [
                "go"
            ],
            "initializationOptions": {
                "gocodeCompletionEnabled": true,
                "diagnosticsEnabled": true,
                "lintTool": "golint"
            }
        },
        "bash": {
            "command": "bash-language-server",
            "args": [
                "start"
            ],
            "filetypes": [
                "sh"
            ],
            "ignoredRootPaths": []
        },
        "ccls": {
            "command": "ccls",
            "filetypes": [
                "c",
                "cpp",
                "cuda",
                "objc",
                "objcpp"
            ],
            "rootPatterns": [
                ".ccls",
                ".ccls-root",
                "compile_commands.json",
                ".git/",
                ".hg/"
            ],
            "initializationOptions": {
                "cache": {
                    "directory": "/tmp/ccls"
                }
            }
        }
    },
    "java.enabled": true,
    "java.configuration.runtimes": [
        {
            "name": "JavaSE-17",
            "path": "/Users/liukai/workspaces/application/jdk-17.0.2.jdk/Contents/Home"
        },
        {
            "name": "JavaSE-17",
            "path": "/Library/Java/JavaVirtualMachines/temurin-17.jdk/Contents/Home",
            "default": true
        }
    ],
    "java.configuration.maven.userSettings": "/Users/liukai/.m2/settings.xml",
    "java.import.gradle.enabled": true,
    "java.jdt.ls.lombokSupport.enabled": false,
    "java.jdt.ls.statusIcons": "ready",
    "java.imports.gradle.wrapper.checksums": [
        {
            "sha256": "6246ebc8a7be938275282bf9c3ec79238e08e6b442d38a66633731ae8daffd5d",
            "allowed": false
        }
    ],
    "java.import.gradle.home": "/Users/liukai/workspaces/application/gradle-6.6.1/bin",
    "java.import.gradle.java.home": "/Library/Java/JavaVirtualMachines/jdk1.8.0_261.jdk/Contents/Home",
    "rust-analyzer.enable": true
}

coc 自身配置

参数名

作用

默认值

coc.preferences.semanticTokensHighlights

coc.preferences.enableFloatHighlight

coc.preferences.snippetStatusText

coc.preferences.extensionUpdateCheck

coc.preferences.messageLevel

coc.source.around.firstMatch

coc.source.buffer.firstMatch

coc.source.syntax.firstMatch

suggest 补全

参数名

作用

默认值

suggest.detailMaxLength

最大详情长度

suggest.noselect

补全自动选中第一个,很有用!

false

suggest.enablePreselect

关掉预选第一个,这个不关,按tab就会选中第二个

true

suggest.enablePreselect相关问题: https://github.com/neoclide/coc.nvim/issues/1339

diagnostic

java

rust

go

json

参考链接

coc官方文档: https://github.com/neoclide/coc.nvim/blob/master/doc/coc.txt

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2020-03-04,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 前言
  • CocConfig
    • coc 自身配置
      • suggest 补全
        • diagnostic
          • java
            • rust
              • go
                • json
                • 参考链接
                领券
                问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档