mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-02-02 22:40:06 +08:00
Fix neoformat (#3677)
This commit is contained in:
parent
1de861e41b
commit
08ad486fae
@ -13,10 +13,12 @@ let s:md_listItemIndent = 1
|
||||
let s:md_enableWcwidth = 0
|
||||
let s:md_listItemChar = '-'
|
||||
let g:vmt_list_indent_text = ' '
|
||||
let s:md_enabled_formater = ['remark']
|
||||
function! SpaceVim#layers#lang#markdown#set_variable(var) abort
|
||||
let s:md_listItemIndent = get(a:var, 'listItemIndent', s:md_listItemIndent)
|
||||
let s:md_enableWcwidth = get(a:var, 'enableWcwidth', s:md_enableWcwidth)
|
||||
let s:md_listItemChar = get(a:var, 'listItemChar', s:md_listItemChar)
|
||||
let s:md_enabled_formater = get(a:var, 'enabled_formater', s:enabled_formater)
|
||||
endfunction
|
||||
|
||||
function! SpaceVim#layers#lang#markdown#plugins() abort
|
||||
@ -64,12 +66,7 @@ function! SpaceVim#layers#lang#markdown#config() abort
|
||||
\},
|
||||
\}
|
||||
let remarkrc = s:generate_remarkrc()
|
||||
if s:SYS.isWindows
|
||||
" @fixme prettier do not support kramdown
|
||||
let g:neoformat_enabled_markdown = ['prettier']
|
||||
else
|
||||
let g:neoformat_enabled_markdown = ['remark']
|
||||
endif
|
||||
let g:neoformat_enabled_markdown = s:md_enabled_formater
|
||||
let g:neoformat_markdown_remark = {
|
||||
\ 'exe': 'remark',
|
||||
\ 'args': ['--no-color', '--silent'] + (empty(remarkrc) ? [] : ['-r', remarkrc]),
|
||||
|
@ -92,7 +92,8 @@ function! s:neoformat(bang, user_input, start_line, end_line) abort
|
||||
endif
|
||||
|
||||
" read from /tmp file if formatter replaces file on format
|
||||
if cmd.replace || len(stdout) == 0
|
||||
" make sure cmd.tmp_file_path is readable
|
||||
if (cmd.replace || len(stdout) == 0) && filereadable(cmd.tmp_file_path)
|
||||
let stdout = readfile(cmd.tmp_file_path)
|
||||
endif
|
||||
|
||||
|
@ -34,8 +34,7 @@ which is written in rust.
|
||||
|
||||
## Formatting
|
||||
|
||||
SpaceVim uses remark to format Markdown file by default, but we suggest using [Prettier](https://github.com/prettier/prettier) on Windows.
|
||||
|
||||
SpaceVim uses remark to format Markdown file by default.
|
||||
You can install remark via [npm](https://www.npmjs.com/get-npm), the commands are shown as below.
|
||||
|
||||
```sh
|
||||
@ -46,6 +45,9 @@ npm -g install remark-frontmatter
|
||||
npm -g install wcwidth
|
||||
```
|
||||
|
||||
To use [Prettier](https://github.com/prettier/prettier),
|
||||
you need to change the layer option: `enabled_formater`.
|
||||
|
||||
You can install [Prettier](https://github.com/prettier/prettier) via [yarn](https://yarnpkg.com/lang/zh-hans/docs/install/#windows-stable) or [npm](https://www.npmjs.com/get-npm), the commands are shown as below:
|
||||
|
||||
1. Via `yarn`
|
||||
@ -78,6 +80,10 @@ Enable/Disable wcwidth for detecting the length of a table cell, default is 0. T
|
||||
|
||||
Bullet marker to use for list items (`'-'`, `'*'`, or `'+'`, default: `'-'`).
|
||||
|
||||
**enabled_formater**
|
||||
|
||||
Specific the enabled formater for markdown file, default is `['remark']`.
|
||||
|
||||
## Tagbar
|
||||
|
||||
To have a table of the headings in the tagbar (toggled by [F2]), make sure php is in your `$PATH` (you can test this in SpaceVim : `:!php --version` should print something about php).
|
||||
|
Loading…
Reference in New Issue
Block a user