From f286e5a83c343fcd9d2963b8f041181330440f61 Mon Sep 17 00:00:00 2001 From: Wang Shidong Date: Sat, 28 Aug 2021 19:51:05 +0800 Subject: [PATCH] Fix typescript eslint maker (#4441) close #4440 --- autoload/SpaceVim/layers/lang/typescript.vim | 3 +++ autoload/SpaceVim/logger.vim | 2 +- autoload/SpaceVim/plugins/a.vim | 2 +- autoload/SpaceVim/plugins/projectmanager.vim | 2 +- .../autoload/neomake/makers/ft/javascript.vim | 1 - .../2020-04-11-use-vim-as-a-typescript-ide.md | 15 +++++++-------- .../2020-04-12-use-vim-as-a-typescript-ide.md | 2 +- docs/cn/layers/lang/typescript.md | 8 +++++++- docs/layers/lang/typescript.md | 10 +++++++++- 9 files changed, 30 insertions(+), 15 deletions(-) diff --git a/autoload/SpaceVim/layers/lang/typescript.vim b/autoload/SpaceVim/layers/lang/typescript.vim index 15b02c7a6..72a8f6f9d 100644 --- a/autoload/SpaceVim/layers/lang/typescript.vim +++ b/autoload/SpaceVim/layers/lang/typescript.vim @@ -63,6 +63,9 @@ function! SpaceVim#layers#lang#typescript#config() abort \ 'opt': [], \ }) 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? let g:neoformat_typescriptreact_prettier = { \ 'exe': 'prettier', diff --git a/autoload/SpaceVim/logger.vim b/autoload/SpaceVim/logger.vim index 451d419ac..3e6e306ee 100644 --- a/autoload/SpaceVim/logger.vim +++ b/autoload/SpaceVim/logger.vim @@ -6,7 +6,7 @@ " License: GPLv3 "============================================================================= -if $SPACEVIM_LUA +if $SPACEVIM_LUA && has('nvim') function! SpaceVim#logger#info(msg) abort lua require("spacevim.logger").info( \ require("spacevim").eval("a:msg") diff --git a/autoload/SpaceVim/plugins/a.vim b/autoload/SpaceVim/plugins/a.vim index 7affe6081..bd5489394 100644 --- a/autoload/SpaceVim/plugins/a.vim +++ b/autoload/SpaceVim/plugins/a.vim @@ -11,7 +11,7 @@ set cpo&vim scriptencoding utf-8 -if $SPACEVIM_LUA +if $SPACEVIM_LUA && has('nvim') function! SpaceVim#plugins#a#alt(request_parse, ...) abort lua require("spacevim.plugin.a").alt( \ require("spacevim").eval("a:request_parse"), diff --git a/autoload/SpaceVim/plugins/projectmanager.vim b/autoload/SpaceVim/plugins/projectmanager.vim index 8e49b91de..3f6c4c5af 100644 --- a/autoload/SpaceVim/plugins/projectmanager.vim +++ b/autoload/SpaceVim/plugins/projectmanager.vim @@ -8,7 +8,7 @@ -if $SPACEVIM_LUA +if $SPACEVIM_LUA && has('nvim') function! SpaceVim#plugins#projectmanager#complete_project(ArgLead, CmdLine, CursorPos) abort return luaeval('require("spacevim.plugin.projectmanager").complete(' \ .'require("spacevim").eval("a:ArgLead"),' diff --git a/bundle/neomake/autoload/neomake/makers/ft/javascript.vim b/bundle/neomake/autoload/neomake/makers/ft/javascript.vim index 7bb379f2c..3f2cd210b 100644 --- a/bundle/neomake/autoload/neomake/makers/ft/javascript.vim +++ b/bundle/neomake/autoload/neomake/makers/ft/javascript.vim @@ -41,7 +41,6 @@ function! neomake#makers#ft#javascript#eslint() abort \ 'args': ['--format=compact'], \ 'errorformat': '%E%f: line %l\, col %c\, Error - %m,' . \ '%W%f: line %l\, col %c\, Warning - %m,%-G,%-G%*\d problems%#', - \ 'cwd': '%:p:h', \ 'output_stream': 'stdout', \ } diff --git a/docs/_posts/2020-04-11-use-vim-as-a-typescript-ide.md b/docs/_posts/2020-04-11-use-vim-as-a-typescript-ide.md index d8f55a6c4..239500e33 100644 --- a/docs/_posts/2020-04-11-use-vim-as-a-typescript-ide.md +++ b/docs/_posts/2020-04-11-use-vim-as-a-typescript-ide.md @@ -52,23 +52,23 @@ SpaceVim 初次安装时默认并未启用 TypeScript 相关语言模块。首 ### 语法检查 `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` 文件,并加入以下内容: ```json { - "src/*.ts": {"alternate": "test/{}.ts"}, - "test/*.ts": {"alternate": "src/{}.ts"} + "src/*.ts": { "alternate": "test/{}.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 交互式编程还未完全实现,主要是因为 `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)。 diff --git a/docs/_posts/2020-04-12-use-vim-as-a-typescript-ide.md b/docs/_posts/2020-04-12-use-vim-as-a-typescript-ide.md index a3aa155f9..bad90c8c8 100644 --- a/docs/_posts/2020-04-12-use-vim-as-a-typescript-ide.md +++ b/docs/_posts/2020-04-12-use-vim-as-a-typescript-ide.md @@ -60,7 +60,7 @@ It will run [eslint](https://eslint.org/) asynchronously. To install eslint, just run following command in terminal. ``` -npm install eslint --save-dev +npm install -g eslint ``` ### Jump to test file diff --git a/docs/cn/layers/lang/typescript.md b/docs/cn/layers/lang/typescript.md index b0137bde0..9cf244bc4 100644 --- a/docs/cn/layers/lang/typescript.md +++ b/docs/cn/layers/lang/typescript.md @@ -31,10 +31,16 @@ lang: zh 同时,需要通过以下命令安装 TypeScript: -```sh +``` npm install -g typescript ``` +语法检查需要安装`eslint`命令: + +``` +npm install -g eslint +``` + ## 功能特性 - 代码补全 diff --git a/docs/layers/lang/typescript.md b/docs/layers/lang/typescript.md index d18798063..ec3214179 100644 --- a/docs/layers/lang/typescript.md +++ b/docs/layers/lang/typescript.md @@ -28,10 +28,13 @@ To use this configuration layer, update your custom configuration file with: [[layers]] 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 npm install -g neovim ``` + then in SpaceVim run `:UpdateRemotePlugin` 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 ``` +Install `eslint` for syntax checking: + +``` +npm install -g eslint +``` ## Layer options