1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-02-02 23:00:04 +08:00

Fix typescript eslint maker (#4441)

close #4440
This commit is contained in:
Wang Shidong 2021-08-28 19:51:05 +08:00 committed by GitHub
parent ee07874b8b
commit f286e5a83c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 30 additions and 15 deletions

View File

@ -63,6 +63,9 @@ function! SpaceVim#layers#lang#typescript#config() abort
\ 'opt': [], \ 'opt': [],
\ }) \ })
let g:neomake_typescript_enabled_makers = ['eslint'] let g:neomake_typescript_enabled_makers = ['eslint']
if index(g:spacevim_project_rooter_patterns, 'tsconfig.json') == -1
call add(g:spacevim_project_rooter_patterns, 'tsconfig.json')
endif
" does eslint support tsx? " does eslint support tsx?
let g:neoformat_typescriptreact_prettier = { let g:neoformat_typescriptreact_prettier = {
\ 'exe': 'prettier', \ 'exe': 'prettier',

View File

@ -6,7 +6,7 @@
" License: GPLv3 " License: GPLv3
"============================================================================= "=============================================================================
if $SPACEVIM_LUA if $SPACEVIM_LUA && has('nvim')
function! SpaceVim#logger#info(msg) abort function! SpaceVim#logger#info(msg) abort
lua require("spacevim.logger").info( lua require("spacevim.logger").info(
\ require("spacevim").eval("a:msg") \ require("spacevim").eval("a:msg")

View File

@ -11,7 +11,7 @@ set cpo&vim
scriptencoding utf-8 scriptencoding utf-8
if $SPACEVIM_LUA if $SPACEVIM_LUA && has('nvim')
function! SpaceVim#plugins#a#alt(request_parse, ...) abort function! SpaceVim#plugins#a#alt(request_parse, ...) abort
lua require("spacevim.plugin.a").alt( lua require("spacevim.plugin.a").alt(
\ require("spacevim").eval("a:request_parse"), \ require("spacevim").eval("a:request_parse"),

View File

@ -8,7 +8,7 @@
if $SPACEVIM_LUA if $SPACEVIM_LUA && has('nvim')
function! SpaceVim#plugins#projectmanager#complete_project(ArgLead, CmdLine, CursorPos) abort function! SpaceVim#plugins#projectmanager#complete_project(ArgLead, CmdLine, CursorPos) abort
return luaeval('require("spacevim.plugin.projectmanager").complete(' return luaeval('require("spacevim.plugin.projectmanager").complete('
\ .'require("spacevim").eval("a:ArgLead"),' \ .'require("spacevim").eval("a:ArgLead"),'

View File

@ -41,7 +41,6 @@ function! neomake#makers#ft#javascript#eslint() abort
\ 'args': ['--format=compact'], \ 'args': ['--format=compact'],
\ 'errorformat': '%E%f: line %l\, col %c\, Error - %m,' . \ 'errorformat': '%E%f: line %l\, col %c\, Error - %m,' .
\ '%W%f: line %l\, col %c\, Warning - %m,%-G,%-G%*\d problems%#', \ '%W%f: line %l\, col %c\, Warning - %m,%-G,%-G%*\d problems%#',
\ 'cwd': '%:p:h',
\ 'output_stream': 'stdout', \ 'output_stream': 'stdout',
\ } \ }

View File

@ -52,23 +52,23 @@ SpaceVim 初次安装时默认并未启用 TypeScript 相关语言模块。首
### 语法检查 ### 语法检查
`checkers` 模块为 SpaceVim 提供了语法检查的功能,该模块默认已经载入。该模块默认使用 [neomake](https://github.com/neomake/neomake) `checkers` 模块为 SpaceVim 提供了语法检查的功能,该模块默认已经载入。该模块默认使用 [neomake](https://github.com/neomake/neomake)
这一异步语法检查工具。对于 TypeScript 的支持是通过异步调用 [tslint](https://www.npmjs.com/package/tslint) 命令来完成的。 这一异步语法检查工具。对于 TypeScript 的支持是通过异步调用 [eslint](https://eslint.org/) 命令来完成的。
可通过以下命令安装: 可通过以下命令安装:
```sh ```
npm install -g tslint npm install -g eslint
``` ```
### 工程文件跳转 ### 工程文件跳转
SpaceVim 自带工程管理插件可以识别项目根目录自动跳转alternate文件。 SpaceVim 自带工程管理插件,可以识别项目根目录,自动跳转 alternate 文件。
可以在工程根目录添加 `.project_alt.json` 文件,并加入以下内容: 可以在工程根目录添加 `.project_alt.json` 文件,并加入以下内容:
```json ```json
{ {
"src/*.ts": {"alternate": "test/{}.ts"}, "src/*.ts": { "alternate": "test/{}.ts" },
"test/*.ts": {"alternate": "src/{}.ts"} "test/*.ts": { "alternate": "src/{}.ts" }
} }
``` ```
@ -101,5 +101,4 @@ npm install -g typescript-formatter
在编辑 TypeScript 文件时,可通过快捷键 `SPC l s i` 启动 `ts-node -i` 交互窗口,之后使用快捷键将代码发送至解释器。默认快捷键都以 `SPC l s` 为前缀。 在编辑 TypeScript 文件时,可通过快捷键 `SPC l s i` 启动 `ts-node -i` 交互窗口,之后使用快捷键将代码发送至解释器。默认快捷键都以 `SPC l s` 为前缀。
目前 TypeScript 交互式编程还未完全实现,主要是因为 `ts-node -i` 执行是并不刷新buffer可查看[ts-node #1013](https://github.com/TypeStrong/ts-node/issues/1013)。 目前 TypeScript 交互式编程还未完全实现,主要是因为 `ts-node -i` 执行是并不刷新 buffer可查看[ts-node #1013](https://github.com/TypeStrong/ts-node/issues/1013)。

View File

@ -60,7 +60,7 @@ It will run [eslint](https://eslint.org/) asynchronously.
To install eslint, just run following command in terminal. To install eslint, just run following command in terminal.
``` ```
npm install eslint --save-dev npm install -g eslint
``` ```
### Jump to test file ### Jump to test file

View File

@ -31,10 +31,16 @@ lang: zh
同时,需要通过以下命令安装 TypeScript 同时,需要通过以下命令安装 TypeScript
```sh ```
npm install -g typescript npm install -g typescript
``` ```
语法检查需要安装`eslint`命令:
```
npm install -g eslint
```
## 功能特性 ## 功能特性
- 代码补全 - 代码补全

View File

@ -28,10 +28,13 @@ To use this configuration layer, update your custom configuration file with:
[[layers]] [[layers]]
name = "lang#typescript" name = "lang#typescript"
``` ```
and also use npm to install neovim using:
If you are using neovim instead of vim, please use `npm` to install `neovim` lib:
```bash ```bash
npm install -g neovim npm install -g neovim
``` ```
then in SpaceVim run `:UpdateRemotePlugin` then in SpaceVim run `:UpdateRemotePlugin`
To generate doc of typescript file, you need to install [lehre](https://www.npmjs.com/package/lehre) To generate doc of typescript file, you need to install [lehre](https://www.npmjs.com/package/lehre)
@ -40,6 +43,11 @@ To generate doc of typescript file, you need to install [lehre](https://www.npmj
yarn add -D lehre yarn add -D lehre
``` ```
Install `eslint` for syntax checking:
```
npm install -g eslint
```
## Layer options ## Layer options