Repository navigation
JavaScript: Configures prettier to use single quotes - #34
aaronmcadam wants to merge 1 commit into
Conversation
|
FYI, you can do this without forking https://github.com/fortes/dotfiles/blob/master/symlinks/config/nvim/init.vim#L297 |
|
Also, since prettier can now use stdin, I would suggest the following: let g:neoformat_javascript_prettier = {
\ 'exe': 'prettier',
\ 'args': ['--stdin', '--single-quote'],
\ 'stdin': 1,
\ } |
|
@sbdchd any reason to prefer using standard in? |
|
with stdin, without stdin, There isn't any usability difference that I know of, but not having to write to a tmp file is a plus. |
|
@sbdchd got it, I'll switch my config. Thanks. |
|
@sbdchd Using your version, I now see |
|
@sbdchd It seems to be enabling |
|
@aaronmcadam Have you updated prettier? Stdin is a relatively new option. Otherwise, can you |
|
Hi @sbdchd Yeah I've updated Here's the output when I turn Neoformat: executable: js-beautify is not an executable
Neoformat: ['import R from ''ramda'';', '', '/**', ' * mediaState is a collection of functions that deal with mediaState', ' * [Media State on Confluence]{@link https://crowdlab.atlassian.net/wiki/display/DATA/Transcode+State+Machine}',
' * Possible States', ' * undefined', ' * no_media', ' * pending', ' * transcoding', ' * uploading', ' * preview', ' * ready', ' * failed', ' */', '', 'const stateContains = R.flip(R.contains);', '', 'const mediaFailed = R.equal
s(''failed'');', '', 'const flashIsNeeded = stateContains(', ' [''failed'', ''pending'', ''transcoding'', ''uploading'', ''preview'']', ');', '', 'const noFlashIsNeeded = R.compose(R.not, flashIsNeeded);', '', 'const message = (mediaStat
e) => (', ' mediaFailed(mediaState) ? ''media.failed'' : ''media.processing''', ');', '', 'const icon = (mediaState) => (mediaFailed(mediaState) ? ''cross'' : ''info'');', '', 'const mediaRequiresPlaceholder = stateContains(', ' [''pend
ing'', ''transcoding'', ''uploading'']', ');', '', 'const mediaIsAvailable = stateContains(', ' [undefined, ''no_media'', ''ready'', ''preview'']', ');', '', 'const mediaState = {', ' mediaFailed,', ' flashIsNeeded,', ' noFlashIsNeede
d,', ' message,', ' icon,', ' mediaRequiresPlaceholder,', ' mediaIsAvailable', '};', '', 'export default mediaState;']
Neoformat: prettier --stdin
Neoformat: ['Usage: prettier [opts] [filename]', '', 'Available options:', ' --write Edit the file in-place (beware!)', ' --print-width <int> Specify the length of line that the printer will wrap on. Defaults to 80.', ' -
-tab-width <int> Specify the number of spaces per indentation-level. Defaults to 2.', ' --flow-parser Use the flow parser instead of babylon', ' --single-quote Use single quotes instead of double', ' --trailing-comma
Print trailing commas wherever possible', ' --bracket-spacing Put spaces between brackets. Defaults to true, set false to turn off']
Neoformat: 1
Neoformat: trying next formatter
Neoformat: executable: prettydiff is not an executable
Neoformat: executable: clang-format is not an executable
Neoformat: executable: esformatter is not an executable
Neoformat: attempted all formatters for current filetype |
|
If you run From your output of |
|
Yeah, that's what it looks like, but running ❯ prettier
Usage: prettier [opts] [filename ...]
Available options:
--write Edit the file in-place (beware!)
--stdin Read input from stdin
--print-width <int> Specify the length of line that the printer will wrap on. Defaults to 80.
--tab-width <int> Specify the number of spaces per indentation-level. Defaults to 2.
--flow-parser Use the flow parser instead of babylon
--single-quote Use single quotes instead of double
--trailing-comma Print trailing commas wherever possible
--bracket-spacing Put spaces between brackets. Defaults to true, set false to turn off |
|
Hmm. Can you try removing all versions of For some reason |
|
@sbdchd I managed to sort it, my global |
I've had to change the formatter for
prettierdirectly to achieve this. There doesn't seem to be a configuration file forprettier, or a way to globally configure it.I think a better idea would be to set a variable like
let g:neoformat_javascript_argsin my neovim configuration, but I'm not sure how to do that.