Skip to content

Prettier Executable resolution doesn't consider nested node_modules #360

@dan-diaz

Description

@dan-diaz

Doesn't work
When opening nvim at my project's top-most level, where there is no direct node_modules, the plugin will not execute on index.js because it cannot find the assocaited prettier installation.

~/project_directory:$ nvim ./
~/project_directory:
  /native
    /node_modules
      /prettier
    package.json
  /web
    /node_modules
      /prettier
    index.js
    package.json

:PrettierCliPath ->> no prettier executable installation found

Works
Opening the project at the subdirectory that directly contains a node_modules folder with the prettier installation, the plugin will execute successfully.

~/project_directory:$ nvim ./web
~/project_directory/web:
  /node_modules
    /prettier
  index.js
  package.json

:PrettierCliPath ->> /home/dan/project_directory/web/node_modules/.bin/prettier

Suggestion
Have vim-prettier resolve the executable by first looking at the directory which contains the file and traversing up through parent directories from there, instead of starting at the root directory.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions