Giter Club home page Giter Club logo

coc-prettier's Introduction

Neoclide

Neoclide is a rework of Nyaovim, the reason is I want it have best user experience.

Neoclide is an editor built with web technologies while emebed with neovim.

Neoclide is in early development, which means it could break easily, and you should not take it seriously.

Since I use Mac only, something could break on other platform, I need your help!

What have done

  • Global session save and restore
  • Fixed copy/paste behaviour
  • Fixed drag and click position calculate
  • Fixed trigger of VimLeave event
  • Background transparent support
  • Improved input method support
  • Improved cursor support
  • Accessable editor state object
  • Automatic resize handler, no screen blink

How to use

Since it's in early age, no prebuild currently avaiable, you have to use it from souce code.

  • Clone this repository

  • Run following commands to install dependencies and build code

    npm run dep
    npm run build
    
  • To start the app, use:

    npm run app
    

LICENSE

Copyright 2016 [email protected]

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

coc-prettier's People

Contributors

abalmos avatar alexlafroscia avatar butterywombat avatar chemzqm avatar christopher-francisco avatar clyfish avatar danandreasson avatar desmap avatar diartyz avatar fannheyward avatar gabeduartem avatar hjdivad avatar joemckenney avatar kneasle avatar kovetskiy avatar leafrogers avatar lfilho avatar lumakernel avatar navel3 avatar okitoxo avatar qiuxiang avatar shirayu avatar sudoerwx avatar taylon avatar wadkar avatar weirongxu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

coc-prettier's Issues

prettifying .scss has ended up with an error.

Hi while i am trying to format my .scss files i am getting this error below when i run :CocCommand prettier.open-output command:

.config/coc/extensions/node_modules/prettier-stylelint/node_modules/stylelint/lib/getConfigForFile.js:46:15

When i checked the file as far as i see, it needs a config file for this action but the file could not found.

Thx...

coc-prettier not formatting markdown files

This is similar to #8 but different root cause.

I think the problem boils down to using an specific markdown parser when running prettier on markdown files.

I have opened this issue with Prettier: prettier/prettier#7827

But thought that maybe, in the meantime, coc-prettier could explicitly pass the parser flag for us :)

prettier incorrectly reports error after breaking & then fixing syntax in JSON

I've noticed that after I edit a .json file and make it invalid, then fix the bug so the .json is valid again, I get weird behavior from coc-prettier. It appears to print an error after I've fixed the json file, almost like it's printing results from the last action, as it also prints a successful formatted by prettier message after I've broken the json file.

Steps to Reproduce

  1. Install coc.nvim and coc-prettier
  2. Enable "coc.preferences.formatOnSaveFiletypes": ["json"] in coc-settings.json
  3. Edit valid json file (I just used project package.json file) and remove comma after one entry (making it invalid json) and save.
  4. Message [coc.nvim] Formatted by prettier appears in message line
  5. Add comma back so json is valid, and save again. Now the message [coc.nvim] languageserver error on willSaveUntil Unexpected string in JSON at position 150 while parsing '{ "name": "random", "test' in package.json is output in red in message line even though JSON is valid

Details

  1. coc.nvim version - 0.0.61

Example

coc-prettier-bug

Graphlql isn't not formatted on save

I tried graphql code as template string preceded with gql and as dedicated .graphql file but nothing happens on save.

I have set "coc.preferences.formatOnSaveFiletypes": ["*"] in my config.

配置项里如何设置 支持 php 和 scss 或者其他格式的文件,像vim-prettier一样?

vim-prettier 在选择的时候可以支持 其他的语言

https://github.com/prettier/vim-prettier

Plug 'prettier/vim-prettier', {
  \ 'do': 'yarn install',
  \ 'branch': 'release/1.x',
  \ 'for': [
    \ 'javascript',
    \ 'typescript',
    \ 'css',
    \ 'less',
    \ 'scss',
    \ 'json',
    \ 'graphql',
    \ 'markdown',
    \ 'vue',
    \ 'lua',
    \ 'php',
    \ 'python',
    \ 'ruby',
    \ 'html',
    \ 'swift' ] }

但是这个插件我没有找到选项,
目前只支持 js,ts?

error: { parser: "postcss" } is deprecated; we now treat it as { parser: "css" }.

I'm seeing this error whenever stylelintIntegration is set to true.

In my CocInfo I see this exception a bunch of times

SyntaxError: Unexpected token {
    at createScript (vm.js:80:10)
    at Object.runInThisContext (vm.js:139:10)
    at Module._compile (module.js:617:28)
    at Object.Module._extensions..js (module.js:664:10)
    at Module.load (module.js:566:32)
    at tryModuleLoad (module.js:506:12)
    at Function.Module._load (module.js:498:3)
    at Function.Module.runMain (module.js:694:10)
    at startup (bootstrap_node.js:204:16)
    at bootstrap_node.js:625:3
[Info  - 09:53:00] Connection to server got closed. Server will restart.
/Users/kevin/.config/coc/extensions/node_modules/coc-stylelint/lib/server.js:6404
		} catch {

when using prettier-eslint via prettier.eslintIntegration should be able to pass also the eslintConfig

Scenario:

/myApp
|_someGoCode
|_somePythonCode
|_someJSCode
  |_.eslintrc
  |_.prettierrc
  |_node_modules

coc-settings.json with "prettier.eslintIntegration": true

I usually open neovim from the root to have all the folders available and work on different languages, when I run :Prettier on a js/ts file it throws this error:
[coc.nvim] error: prettier-eslint [ERROR]: eslint fix failed due to an eslint error, if I open neovim in myApp/someJSCode everything works as expected, I guess it's beacuse prettier-eslint is not resolving the node_modules folder within someJSCode this is also confermed running CocInfo:

## Output channel: prettier


[Error - 7/19/2019, 11:22:25 AM:] Failed to load plugin 'jest' declared in 'CLIOptions'/path/to/myApp/someJSCode/src/pages/index.tsx:: Cannot find module 'eslint-plugin-jest'
Require stack:
- /path/to/myApp/__placeholder__.js <== here should be /path/to/myApp/someJSCode/__placeholder__.js 

Is there a way to specify the nodePath for the prettier-eslint integration as per https://github.com/prettier/prettier-eslint#eslintconfig-object? Is there a better/easier way to do that?

Thanks

[bug] prettier-eslint failed

Symptom

After upgrading prettier-eslint to 10.1.1, coc-prettier fails to format with prettier-eslint by either running :Format or formatOnSave. Running prettier-eslint CLI succeeds with no problem.

Diagnostics

:messages outputs:

[coc.nvim] error: prettier-eslint [ERROR]: eslint fix failed due to an eslint error

:CocInfo outputs:

## Output channel: prettier                                                                                                                                                                                      
                                                                                                                                                                                                                   
[Error - 2020/5/27 上午1:57:28:] Failed to load parser '/git/react-bim/node_modules/prettier-eslint/node_modules/@typescript-eslint/parser/dist/index.js' declared in 'CLIOptions'/git/react-bim/src/Canvas/useControl.ts:: Class extends value undefined is not a constructor or null                                                                                                                                            
                                                                                                                                                                                                                   
                                                                                                                                                                                                                   
[Trace - 2020/5/27 上午1:57:28:] Formatted file: file:///git/react-bim/src/Canvas/useControl.ts

Alternative Solutions

coc-prettier functions as normal with prettier-eslint 9.0.1

My Guess

As reported in the :CocInfo output, the problem may be rooted at a recent change in @typescript-eslint. In prettier-eslint ver. 9.0.1, file prettier-eslint/node_modules/@typescript-eslint/parser/dist/index.js did not exist. But it is found in prettier-eslint ver 10.1.1

Environment

OS: CentOS 8
node: 14.3.0
neovim: v0.4.3 Features: +acl +iconv +tui

[Bug] Prettier-eslint takes presidence

I have a elsintrc config in my project but although I have some rules I don't want them to apply automatically when save, but only prettier to kicks in.

extension uses incorrect version of prettier

I work on a project with other people, and we're currently using an older version of prettier (which is run on changed files on every commit). When I run this plugin, I expected that the local version would be used, but instead, it is using some other version (probably a more recent one, bundled with the plugin). Because of that, every time I commit I have to run again the local version of prettier with npx prettier --write, so that it correctly formats according to our project.

With this in mind, two ideas popped up:

  1. Always prefer the local version (I think that's more reasonable to expect instead of the bundled one, given that we already have prettier installed on the project). Maybe there could be an option to specify otherwise, but I'm not sure if that's needed...

  2. An option to only run prettier if the project has the package installed (it is on the package.json devDependencies). Some projects do not use and do not have any intention on installing prettier on it, so its annoying to have to disable the extension every time I want to submit a PR to one of those projects. If there was an option like forceUsingLocalVersion, It could be done something like coc-prettier simply do nothing, or maybe show a warning when the file is opened (like it is done with eslint)

image

What do you think? 😃

Filetype aliases (pandoc)

Currently files with ft=pandoc aren't formatted using the markdown formatter. Could we add filetype aliases to support this?

Formatting output is not as expected

So I am trying to use this addon and I did a test to compare how it looks in VScode vs vim. Now maybe VScode is wrong but thought I would ask. So I typed the following:

if(1===1){

When I hit enter it was formatted to

if(1===1) {

}

If I do the same example in VScode I get

if (1 === 1) {

}

Notice how it added the space around the triple equal and between the if and (?

Here is my .prettierrc

{
  "bracketSpacing": true,
  "singleQuote": true,
  "trailingComma": "es5"
}

My project does have an .editorconfig

This extension is getting published and installed without a yarn.lock file, is this desired?

Hi, I noticed that coc-prettier has a yarn.lock file that is not getting published in the npm package, if I run:

$ npm pack coc-prettier
$ tar -xzf coc-prettier-1.1.14.tgz
$ ls package   
> lib  CHANGELOG.md  package.json  package-json-schema.json  Readme.md

I see this is intentional from npm 6.9 and forward, see: yarn.lock not published by npm publish anymore - 🐞 bugs - npm forum

When I run :CocInstall coc-prettier I notice that CoC installs with npm install --ignore-scripts --no-lockfile --production, isn't this dangerous? lock files are there to prevent security and functionality issues with transitive dependencies changing under our feets.

I was checking npm-shrinkwrap.json | npm Documentation:

npm-shrinkwrap.json is a file created by npm shrinkwrap. It is identical to package-lock.json, with one major caveat: Unlike package-lock.json, npm-shrinkwrap.json may be included when publishing a package.

The recommended use-case for npm-shrinkwrap.json is applications deployed through the publishing process on the registry...

Maybe you should publish a npm-shrinkwrap.json in your packages? I don't know if this will work with yarn though.

We can move this discussion to Coc main repo if you want to, thanks.

Formatting Java

Hi,

is it possible to use coc-prettier to format Java files? There is https://github.com/jhipster/prettier-java that let's me format via command-line, but i was wondering if coc-prettier could handle it as well in order to format on save.

Right now when trying :CocCommand prettier.formatFile I get Command error: cannot read property 'replace' of undefined.

Any solution?

CocInfo:

## versions

vim version: NVIM v0.4.3
node version: v14.3.0
coc.nvim version: 0.0.78-0c973a7a47
coc.nivm directory: /home/andrej/.config/nvim/bundle/coc.nvim
term: xterm-256color
platform: linux

## Output channel: prettier


## Output channel: snippets

[Info 6:37:54 PM] Using ultisnips directories: UltiSnips /home/andrej/.config/coc/ultisnips
[Info 6:37:54 PM] Using ultisnips python command: pyx

## Output channel: java

[Info  - 6:38:01 PM] JDT Language Server started
[object Object]

Regards

Error: Cannot read property getSupportInfo of null - on coc-prettier startup

On Vim startup, as coc-nvim initializes, I'm getting the following error:
image

I'm using vim-plug to manage coc-nvim plugins. The error is happening in a project (my dotfiles) where I don't have a prettier config file, but I do have some random JSON files (like coc-settings.json 😄). I also don't have an .eslintrc or .eslintignore file in the project.

Interestingly, the error doesn't happen on startup in a javascript project where there are .eslintrc and prettier config files.

Huge props for making such an amazing tool for Vim! I really love it and the plugin system is amazing and perfect.

Here's the output of CocInfo:

## versions

vim version: NVIM v0.3.8
node version: v12.9.1
coc.nvim version: 0.0.74
term: iTerm.app
platform: darwin

## Messages
coc.nvim initialized!
[coc.nvim] Error on active extension coc-prettier: TypeError: Cannot read property 'getSupportInfo' of null
## Output channel: watchman

[Info] watchman watching project: <project>
[Info] subscribing "**/.eslintr{c.js,c.yaml,c.yml,c,c.json}" in <project>
[Info] subscribing "**/.eslintignore" in <project>
[Info] subscribing "**/package.json" in <project>

Error: Cannot find module 'prettier'

Directly after installing (and after that when I restart vim) I'm getting
[coc.nvim] Error on load extension coc-prettier from /Users/MyUser/.config/coc/extensions/node_modules/coc-prettier/lib/index.js: Error: Cannot find module 'prettier''

Log from CocInfo:

## versions

vim version: VIM - Vi IMproved 8.1 (2018 May 18 kompiliert am Mar 26 2019 01:54:18)
node version: v12.8.1
coc.nvim version: 0.0.74-c97d41aa1e
term: iTerm.app
platform: darwin

## Messages
Übersetzt von Christian Brabandt <[email protected]>
[coc.nvim] Error on load extension coc-prettier from /Users/MyUser/.config/coc/extensions/node_modules/coc-prettier/lib/index.js: Error: Cannot find module 'prettier'
Require stack:
- /Users/MyUser/.config/coc/extensions/node_modules/coc-prettier/lib/index.js
- /Users/MyUser/.config/coc/extensions/node_modules/coc-prettier/lib/index.js
## Output channel: highlight

[Info  - 4:28:06 PM] Highlight server running in node v12.8.1

Unable to install coc-prettier

When I try to install coc-prettier via let g:coc_global_extensions, I get this error:

Screenshot_20200503_184020

Screenshot_20200503_184344

I debug the npm log and I found this

1845 verbose stack SyntaxError: Unexpected end of JSON input while parsing near '...2","esprima":"git://g'
1845 verbose stack     at JSON.parse (<anonymous>)
1845 verbose stack     at parseJson (/home/hello/n/lib/node_modules/npm/node_modules/json-parse-better-errors/index.js:7:17)
1845 verbose stack     at /home/hello/n/lib/node_modules/npm/node_modules/node-fetch-npm/src/body.js:96:50
1845 verbose stack     at runMicrotasks (<anonymous>)
1845 verbose stack     at processTicksAndRejections (internal/process/task_queues.js:97:5)
1846 verbose cwd /tmp/coc-prettier-qKGAyH
1847 verbose Linux 5.6.8-1-MANJARO
1848 verbose argv "/home/hello/n/bin/node" "/home/hello/n/bin/npm" "install" "--ignore-scripts" "--no-lockfile" "--production"
1849 verbose node v12.16.1
1850 verbose npm  v6.13.4
1851 error Unexpected end of JSON input while parsing near '...2","esprima":"git://g'
1852 verbose exit [ 1, true ]

Re: Range format NOT using prettier

Hello,

Thanks for the plugin. It's good!

I've coc.nvim installed and this extension (coc-prettier) along with other extensions like eslint and json.

With these settings below, whenever I try and save the file in vim (:write), I get a clear message that prettier formatted the file and it works as expected.

{
  "prettier.eslintIntegration": true,
  "coc.preferences.formatOnSaveFiletypes": ["javascript", "css", "json"],
  "coc.preferences.formatOnType": false
}

However, when I do "range formatting" as suggested in coc-prettier readme, it doesn't seem to be using prettier and formats it in a very different way. It shows the command executed to be

:call CocAction('formatSelected', visualmode())

Here are my mappings (as per coc-prettier readme)

vmap <leader>f  <Plug>(coc-format-selected)
nmap <leader>f  <Plug>(coc-format-selected)

formatOnSaveFileTypes option seems to be of coc.nvim (not prettier) and yet it's handled by prettier when I save the file. So I expected the format selections also to be overridden by prettier to be consistent? It doesn't seem to be the case. Am I missing something?

Below command works fine as when I save/write the file. It's calling prettier directly and works as expected.

:call CocAction('runCommand', 'prettier.formatFile')

I just find the range format getting it wrong - inconsistent with my prettier config settings. Is that expected?

And btw, what's the default formatting style for coc.nvim. What does it use as it's base for formatting (if prettier isn't installed or isn't being triggered like in above case)

Thanks in advance.

Please let me know if anything is unclear.

Vue parser not available

Prettier added my other valid parsers.
I'm looking to use the vue parser

"vue" (same parser as "html", but also formats vue-specific syntax) First available in 1.10.0

Is this available here?

formatOnSave doesn't work for typescript.tsx

Hello! Thanks for the plugin !

It seems that the plugin doesn't work when using compound filetypes such as typescript.tsx (however it works when I manually set the filetype to typescript after opening the file).

Here is a simple config that makes it possible to reproduce :

config

The filetype typescript.tsx is set by vim-polyglot which uses yats.vim : https://github.com/HerringtonDarkholme/yats.vim/blob/master/ftdetect/tsx.vim

Am I doing anything wrong ?
Thanks ! 😄

Prettier not being run when saving files

I have coc-prettier installed and have setup coc-nvim as follows:

  "coc.preferences.formatOnSaveFiletypes": [
      "markdown",
      "javascript",
      "javascriptreact",
      "typescript",
      "typescriptreact",
      "json",
      "graphql",
      "elixir",
      "eelixir"
    ]

when I save a js, jsx, ts, or tsx file, coc-prettier does nothing. For many months it was working as expected but suddenly has stopped.

Here is the output of CocInfo:

## versions

vim version: NVIM v0.4.2
node version: v10.15.3
coc.nvim version: 0.0.74-bc017b02e6
term: iTerm.app
platform: darwin

## Messages

## Output channel: watchman

[Info  - 10:48:04 AM] watchman watching project: /Users/thedelchop/Workspace/daydream
[Info  - 10:48:04 AM] subscribing "**/.eslintr{c.js,c.yaml,c.yml,c,c.json}" in /Users/thedelchop/Workspace/daydream
[Info  - 10:48:04 AM] subscribing "**/.eslintignore" in /Users/thedelchop/Workspace/daydream
[Info  - 10:48:04 AM] subscribing "**/package.json" in /Users/thedelchop/Workspace/daydream
[Info  - 10:48:04 AM] subscribing "**/{.prettierrc,.prettierrc.json,.prettierrc.yaml,.prettierrc.yml,.prettierrc.js,package.json,prettier.config.js}" in /Users/thedelchop/Workspace/daydream
[Info  - 10:48:05 AM] subscribing "**/[tj]sconfig.json" in /Users/thedelchop/Workspace/daydream
[Info  - 10:48:05 AM] subscribing "**/package.json" in /Users/thedelchop/Workspace/daydream
[Info  - 10:48:05 AM] subscribing "**/*.{ts,tsx}" in /Users/thedelchop/Workspace/daydream
[Info  - 10:48:05 AM] subscribing "**/*.{js,jsx}" in /Users/thedelchop/Workspace/daydream

## Output channel: prettier


## Output channel: git

Looking for git in: git
> git rev-parse --show-toplevel
resolved root: /Users/thedelchop/Workspace/daydream
resolved root: /Users/thedelchop/Workspace/daydream
> git symbolic-ref --short HEAD
> git diff --name-status
> git diff --staged --name-status
> git ls-files --others --exclude-standard
resolved root: /Users/thedelchop/Workspace/daydream
resolved root: /Users/thedelchop/Workspace/daydream
> git symbolic-ref --short HEAD
> git diff --name-status
> git diff --staged --name-status
> git ls-files --others --exclude-standard
resolved root: /Users/thedelchop/Workspace/daydream
> git ls-files -- assets/js/components/Authentication.tsx
resolved root: /Users/thedelchop/Workspace/daydream
> git symbolic-ref --short HEAD
> git diff --name-status
> git diff --staged --name-status
> git ls-files --others --exclude-standard
> git --no-pager show :assets/js/components/Authentication.tsx
resolved root: /Users/thedelchop/Workspace/daydream
resolved root: /Users/thedelchop/Workspace/daydream
> git symbolic-ref --short HEAD
> git ls-files -- assets/js/components/Authentication.tsx
> git diff --name-status
> git diff --staged --name-status
> git ls-files --others --exclude-standard
> git --no-pager show :assets/js/components/Authentication.tsx

## Output channel: tsserver

[Info  - 10:48:05 AM] Forking TSServer
PATH: /Users/thedelchop/.asdf/installs/nodejs/10.15.3/bin:/Users/thedelchop/.asdf/installs/nodejs/10.15.3/.npm/bin:/Users/thedelchop/.asdf/shims:/Users/thedelchop/.local/share/asdf/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/thedelchop/.asdf/installs/ruby/2.6.3/bin:/Users/thedelchop/.SpaceVim/bin:/Users/thedelchop/.config/oh-my-zsh/plugins/desk:/Users/thedelchop/.config/oh-my-zsh/plugins/diff-so-fancy/bin:/Users/thedelchop/.config/oh-my-zsh/plugins/desk 
[Info  - 10:48:05 AM] Started TSServer
{
  "path": "/Users/thedelchop/Workspace/daydream/node_modules/typescript/lib",
  "_api": {
    "versionString": "3.6.2",
    "version": "3.6.2"
  }
}

## Output channel: eslint

[Info  - 10:48:05 AM] ESLint server running in node v10.15.3
[Info  - 10:48:06 AM] ESLint library loaded from: /Users/thedelchop/Workspace/daydream/node_modules/eslint/lib/api.js

and the output of CocOpenLog:

2019-11-18T10:48:04.153 INFO (pid:74765) [services] - registed service "eslint"
2019-11-18T10:48:04.366 INFO (pid:74765) [plugin] - coc 0.0.74-bc017b02e6 initialized with node: v10.15.3
2019-11-18T10:48:04.411 INFO (pid:74765) [watchman] - watchman watching project: /Users/thedelchop/Workspace/daydream
2019-11-18T10:48:05.461 INFO (pid:74765) [services] - eslint langserver state change: stopped => starting
2019-11-18T10:48:05.495 INFO (pid:74765) [services] - registed service "tsserver"
2019-11-18T10:48:05.522 INFO (pid:74765) [language-client-index] - eslint started with 74949
2019-11-18T10:48:05.606 INFO (pid:74765) [services] - service tsserver started
2019-11-18T10:48:05.637 INFO (pid:74765) [services] - eslint langserver state change: starting => running
2019-11-18T10:48:05.642 INFO (pid:74765) [services] - service eslint started

Can anyone point me in the right direction to figure out why its not working anymore?

Cannot read property 'parse' of undefined while installing the extension

Hi,
while installing the extension I'm getting the following error message:

[coc.nvim] Error on active extension coc-prettier: Cannot read property 'parse' of und efined

CocInfo doesn't list any other error though:

## versions

vim version: NVIM v0.4.2
node version: v8.9.0
coc.nvim version: 0.0.57
term: xterm-kitty
platform: linux

## Error messages
## Output channel: prettier

Formatting no longer working

Noticed my files stopped formatting with prettier on save recently. Tried manually:

:CocCommand prettier.formatFile

Also does nothing.

Error when trying to format css file.

Hi!

I installed coc-prettier and added

"coc.preferences.formatOnSaveFiletypes": ["css", "Markdown", "python"],

When I save a css file I get.

[coc.nvim] Formatted by prettier
[coc.nvim] error: UnhandledRejection: No configuration provided for /home/mike/test.css
Error: No configuration provided for /home/,ole/testi.css
    at module.exports (/home/mike/.config/coc/extensions/node_modules/coc-prettier/node_modules/stylelint/lib/utils/configurationError.js:8:28)

Any clue why it gives such error?

can't format with coc, but with cli prettier (with older version)

Hello,

I found a bug about coc-prettier which doesn't format my file because of a recent feature of ecmascript: object?.doSomething();, to check if an object is null before using his props.

But with the cli prettier that I have which use the version 1.9, it can format the file.
Is there a way to fix this ? like use the global prettier installed on the environment.

Thanks.

Error "Ignored unknown option `{ "endOfLine": "lf" }`." after saving

After updating to the latest version, I started getting this error every time I save the file: Ignored unknown option `{ "endOfLine": "lf" }`.. It apparently still formats everything fine, but it is annoying because it requires me to press ENTER to confirm, every time I save the file.

I'm guessing this is a conflict between prettier versions, as the endOfLine property is a rather recent config, and the prettier version I'm using is 1.11.1.

Below is the error:
image

Allow to configure where to read prettier binary?

For a folder structure:

project
├── .git
├── server
│   ├── ...
├── client
│   ├── .pretteric.js
│   ├── package.json
│   ├── node_modules
│   │   ├── prettier

When open vim, coc's workspace folder would be set at project, so the local prettier binary cannot be resolved. It would be nice to have a way to configure exactly where to read the prettier binary.

prettier isn't formatting markdown (.md) file on save

I'm not sure what I'm doing wrong. When I write any markdown files, like README.md, prettier doesn't format the file. If I run Prettier from the command line, it does format the file.

editor: NeoVim
version: NVIM v0.3.6

CocConfig, coc-settings.json:

{
  "suggest.echodocSupport": true,
  "suggest.maxCompleteItemCount": 20,
  "suggest.autoTrigger": "always",
  "coc.preferences.formatOnSaveFiletypes": [
    "javascript",
    "typescript",
    "typescriptreact",
    "json",
    "javascriptreact",
    "css",
    "Markdown",
    "md"
  ],
  "eslint.filetypes": [
    "javascript",
    "json",
    "typescript",
    "typescriptreact",
    "javascriptreact"
  ],
  "diagnostic.errorSign": "•",
  "diagnostic.warningSign": "•",
  "diagnostic.infoSign": "•",
  "diagnostic.checkCurrentLine": true
}

Relevant lines from config:

" Remap for format selected region
xmap <leader>f  <Plug>(coc-format-selected)
nmap <leader>f  <Plug>(coc-format-selected)

augroup mygroup
  autocmd!
  " Setup formatexpr specified filetype(s).
  autocmd FileType typescript,json setl formatexpr=CocAction('formatSelected')
  " Update signature help on jump placeholder
  autocmd User CocJumpPlaceholder call CocActionAsync('showSignatureHelp')
augroup end
" Use `:Format` to format current buffer
command! -nargs=0 Format :call CocAction('format')
" setup prettier
" https://github.com/neoclide/coc-prettier
command! -nargs=0 Prettier :CocCommand prettier.formatFile
nmap <leader>p :CocCommand prettier.formatFile<cr>

coc-format-selected not working

I have the following in my init file vmap <leader>f <Plug>(coc-format-selected) but when I go into visual mode and select some stuff and hit the keymap, it changes my code but not correctly. I turned verbose logging on for eslint and I see the logs hit and it states that it should change it and the changes it requested it correct, but my file just does not update. Am I using this wrong?

The wrong prettier settings are used if the root folder does not contain the package.json

I have a project structured like the following:

|-- .prettierrc.js
|-- client
    |-- package.json
    |-- src
        |-- index.js
        |-- // other js files
|-- server

The client is Javascript and the server is in a different language. I like to be able to edit both, so I open vim at the root of the project. When doing so, my prettier settings are completely ignored. If I open vim inside the client directory, then everything works as expected.

Is there a way to tell coc-prettier to use the proper settings? For example, I have bracketSpacing set to true, but when I run vim inside the root directory, formatting kicks in and removes all of the bracket spacing.

coc-settings.json not respected in absence of local prettier config

If a project does not have a prettier configuration file, the settings in coc-settings.json for prettier are not used. Here is my sample coc-settings.json:

{
  "coc.preferences.formatOnSaveFiletypes": [
      "javascript",
      "typescript"
    ],
  "prettier.semi": false
}

In file types javascript and typescript, semicolons are automatically added when formatted with Prettier (unless I create a prettier config file local to the project).

update to latest release of prettier to fix incorrect code output

I first wanted to file this issue in the prettier repo, but it looks like it was fixed in latest release

code input:

fs.writeFile('./EmojiRegex.txt', emojione.unicodeCharRegex(), function(
  err,
) {
  if (err) {
    return console.log(err);
  }

  console.log('The file was saved!');
});

output, formatted with <leader>f (see vimrc below):

fs.writeFile("./EmojiRegex.txt", emojione.unicodeCharRegex(), function(err) {
  if (err) {
    return console.log(err);
  }

  console.log("The file was saved!");

coc-prettier is using an older release of prettier v1.16.4

my vimrc:

        command! -nargs=0 Prettier :CocCommand prettier.formatFile
        vmap <leader>f <Plug>(coc-format-selected)
        nmap <leader>f :Prettier<CR>

Cannot find module 'core-js/modules/es.array.iterator'

I don't know if it's just me, but after updating to v1.1.14, running :Format gives me this error and the file is not formatted:

## Output channel: prettier

[Error - 5/27/2020, 12:15:04 PM:] Cannot find module 'core-js/modules/es.array.iterator'

I fixed it by installing core-js, but I'm not sure if that's the proper solution (I noticed it was removed in the latest commit, since it's not a prettier-eslint requirement anymore). If it is, I'd be happy to send a PR.

Some files in the same directory tree are auto-formatted, others aren't

In my case lets say I have two tabs open.

One has the file:

FriendServer/modules/FriendModule/src/shared/datastores/couchdb/CouchDBStore.ts

The other has the file:

FriendServer/modules/FriendModule/src/shared/datastores/index.ts

Changes I make to the first file don't get run through prettier, changes I make to the second file do. I don't know why it just won't automatically format some files, seems arbitrary.

`"prettier.requireConfig": true` not working

  1. Added "prettier.requireConfig": true, to ~/.config/nvim/coc-settings.json.
  2. Opened a json file in project that had no .prettierrc, did :w, and it was formatted with prettier.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.