Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot format/lint #424

Closed
panosl opened this issue Apr 3, 2021 · 4 comments
Closed

Cannot format/lint #424

panosl opened this issue Apr 3, 2021 · 4 comments
Assignees

Comments

@panosl
Copy link

panosl commented Apr 3, 2021

coc-pyright 1.1.127 with Pyright 1.1.127

This is my local pyrightconfig.json:

{
  "include": [
    "."
  ],
  
  "exclude": [
    "**/node_modules",
    "**/__pycache__"
  ],

  "stubPath": "stubs",
  "venv": ".venv-iss"

}

And these are my coc-settings.json:

{
  "eslint.autoFixOnSave": true,
  "python.formatting.provider": "black",
  "languageserver": {
    "ccls": {
      "command": "ccls",
      "filetypes": ["c", "cpp", "objc", "objcpp"],
      "rootPatterns": [".ccls", "compile_commands.json", ".vim/", ".git/", ".hg/"],
      "initializationOptions": {
         "cache": {
           "directory": "/tmp/ccls"
         }
       }
    }
  }
}

I am unable to format the code (not sure if this is triggered automatically, but I don't see a command to execute it) with black. And I don't see any linting errors.

my Pyright output:

Using python from /Users/panosl/web-projects/inertiasoundsystems.com/inertiasoundsystems/.venv-iss/bin/python

[Info  - 11:57:27 π.μ.] Pyright language server 1.1.127 starting
[Info  - 11:57:27 π.μ.] Server root directory: /Users/panosl/.config/coc/extensions/node_modules/coc-pyright/node_modules/pyright/dist/
[Info  - 11:57:27 π.μ.] Loading configuration file at /Users/panosl/web-projects/inertiasoundsystems.com/inertiasoundsystems/pyrightconfig.json
[Info  - 11:57:27 π.μ.] Assuming Python version 3.7
[Info  - 11:57:27 π.μ.] Assuming Python platform Darwin
[Info  - 11:57:27 π.μ.] Setting pythonPath for service "inertiasoundsystems": "/Users/panosl/web-projects/inertiasoundsystems.com/inertiasoundsystems/.venv-iss/bin/python"
[Warn  - 11:57:27 π.μ.] The stubPath has been specified in both the config file and the client settings. The value in the config file (/Users/panosl/web-projects/inertiasoundsystems.com/inertiasoundsystems/stubs) will take precedence
[Info  - 11:57:27 π.μ.] Searching for source files
[Info  - 11:57:28 π.μ.] Found 2439 source files
[Info  - 11:57:41 π.μ.] Searching for source files
[Info  - 11:57:41 π.μ.] Found 2439 source files

I opened both workspace.showOutput for linting and formatting, and they're both empty.

Not sure how to progress.

@fannheyward
Copy link
Owner

  1. Formatting will not be run automatically, you need to run it manually or set formatOnSave
  2. Do you have black installed?
  3. For lint, it's disabled by default, you need to enabled it in coc-settings.

@panosl
Copy link
Author

panosl commented Apr 3, 2021

1. Formatting will not be run automatically, you need to run it manually or set formatOnSave

I added "coc.preferences.formatOnSaveFiletypes": ["python"]
in my CocConfig. It says [coc.nvim] Formatted with black , but the actual file is not updated. The showOutput shows the actual changes being executed and the diff, but the file itself remains as is. Any ideas?

2. Do you have `black` installed?

Yes, Installed in my local venv

3. For lint, it's disabled by default, you need to enabled it in coc-settings.

I installed flake8 and added it to my CocConfig, now it works.

p.s. Should I create a PR with this information for the README to make it more clear, or are they considered basic enough to omit them?

@fannheyward
Copy link
Owner

fannheyward commented Apr 3, 2021

Try to increase coc.preferences.willSaveHandlerTimeout, the default is 500ms, for large files, coc will cancel the formatting when timeout.

@panosl
Copy link
Author

panosl commented Apr 3, 2021

Thank you so much. Works like a charm <3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants