Coc.nvim: How to disable coc locally/per-project?

Created on 24 Jan 2020  路  16Comments  路  Source: neoclide/coc.nvim

Is your feature request related to a problem? Please describe.
I have a haskell/nix project that doesn't play nice with my regualr LSP. I'd like to disable coc for this project.

Describe the solution you'd like
Right now I'm trying to use a $PWD/.vim/coc-settings.json to determine how to suppress all of the errors. Can I use this to disable coc entirely?

Most helpful comment

Or :CocDisable.

All 16 comments

diagnostic.enable set to false will probably do what you want.

Or :CocDisable.

diagnostic.enable set to false will probably do what you want.

This doesn't seem to work. Where is this key meant to go? Is it top level like this?

{
  "diagnostic.enable": false,
  "languageserver": {
    "haskell": {
      "command": "hie-wrapper",
      "args": ["--lsp"],
      "rootPatterns": [
      "*.cabal",
      "cabal.project",
      "package.yaml",
      "stack.yaml",
      "cabal.config"
      ],
      "filetypes": [
        "hs",
        "lhs",
        "haskell"
      ],
      "initializationOptions": {
        "languageServerHaskell": {
          "hlintOn": true,
          "completionSnippetsOn": true
        }
      }
    }
  }
}

There's two options, I think you'll want disableDiagnostics actually. Always check data/schema.json for options:

You may also use the filetypes option: https://github.com/neoclide/coc.nvim/blob/master/data/schema.json#L69, so that it will be loaded for specific filetypes only. I dunno whether it works for local .coc-settings.json. You should give it a try. As ultimate resource, if you don't want coc.nvim to be loaded at all, you should configure lazy loading, with VIM-PLUG for example.

There's two options, I think you'll want disableDiagnostics actually. Always check data/schema.json for options:

* https://github.com/neoclide/coc.nvim/blob/master/data/schema.json#L31

* https://github.com/neoclide/coc.nvim/blob/master/data/schema.json#L474

"disableDiagnostics": true, does not work either.

@drewboardman did you put it in the right place? You're not doing it in your last snippet, hence why I linked description where you're expected to put these settings.

{
  "languageserver": {
    "disableDiagnostics": true,
    "haskell": {
      "command": "hie-wrapper",
      "args": ["--lsp"],
      "rootPatterns": [
      "*.cabal",
      "cabal.project",
      "package.yaml",
      "stack.yaml",
      "cabal.config"
      ],
      "filetypes": [
        "hs",
        "lhs",
        "haskell"
      ],
      "initializationOptions": {
        "languageServerHaskell": {
          "hlintOn": true,
          "completionSnippetsOn": true
        }
      }
    }
  }
}

Wrong place. Please read the schema, in it the option is _at the same level_ as other options you're using....

Wrong place. Please read the schema, in it the option is _at the same level_ as other options you're using....

This also does nothing.

@drewboardman I don't use coc-settings.json for configuration at all, I use the coc#config command to configure all my coc settings. So in my case to disable it for a project I would call coc#config from a localvimrc file, and I just tested that it works:

call coc#config('languageserver.clangd.disableDiagnostics', v:true)

So I can say with confidence there's options that work. So if you have an actual issue, please open a issue with minimum testcase.

I'm having an issue where my haskell ide engine fails, but only in the test directory. Is there a way to make my LSP not run in that dir? Maybe something manipulating the following:

   "filetypes": [
      "hs",
      "lhs",
      "haskell"
    ],

You may check whether the haskell server provide options for ignoring directories which you can pass in initializationOptions. Another thing you may try is just create another .coc-settings.json for the subdir (dunno whether it works), or other form of local settings for subdir by coc#config.

IMO, this looks like a server task/configuration, not client, except for it to allow configuring the server for so.

You may use let b:coc_enabled=0 set in autocmd BufAdd with your additional custom code for filtering files on BufAdd. Check :h b:coc_enabled.

You may use let b:coc_enabled=0 set in autocmd BufAdd with your additional custom code for filtering files on BufAdd. Check :h b:coc_enabled.

Where do these options go? Is this a vim config?

Yes, vim config. Where it should go is in documentation as referred above.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

FrankLA0203 picture FrankLA0203  路  3Comments

zhou13 picture zhou13  路  3Comments

cvlmtg picture cvlmtg  路  3Comments

aareman picture aareman  路  3Comments

tom-james-watson picture tom-james-watson  路  3Comments