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

Add support for buffer-level prettier_exec_cmd, for prettier-stylelint for instance #256

Merged
merged 3 commits into from
Aug 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,20 @@ vim-prettier executable resolution:
3. Look for a global prettier installation
4. Use locally installed vim-prettier prettier executable

### Prettier Stylelint

To use an alternative command, like
[`prettier-stylelint`](https://github.com/hugomrdias/prettier-stylelint), set
this at the buffer level, e.g.:

```vim
au FileType css,scss let b:prettier_exec_cmd = "prettier-stylelint"
```

vim-prettier will look for the executable in the same places it looks for
`prettier`, and will fall back to `prettier` if it can't find
`b:prettier_exec_cmd`

### USAGE

Prettier by default will run on auto save but can also be manually triggered by:
Expand Down
7 changes: 6 additions & 1 deletion autoload/prettier/resolver/executable.vim
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,12 @@ endfunction
function! s:GetExecPath(...) abort
let l:rootDir = a:0 > 0 ? a:1 : -1
let l:dir = l:rootDir != -1 ? l:rootDir . '/.bin/' : ''
return l:dir . 'prettier'
let l:path = l:dir . get(b:, 'prettier_exec_cmd', 'prettier')
if executable(l:path)
return l:path
else
return l:dir . 'prettier'
endif
endfunction

" Searches for the existence of a directory accross
Expand Down