mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-03-23 17:49:57 +08:00
Update lint (#3363)
This commit is contained in:
parent
7f05c71a0f
commit
c2ce513517
@ -1,60 +1,60 @@
|
|||||||
---
|
---
|
||||||
title: "自定义工程文件跳转"
|
title: "自定义工程文件跳转"
|
||||||
categories: [feature_cn, blog_cn]
|
categories: [feature_cn, blog_cn]
|
||||||
excerpt: "通过配置文件,自定义工程文件跳转路径,包括跳转至测试源文件、文档源文件等。"
|
excerpt: "通过配置文件,自定义工程文件跳转路径,包括跳转至测试源文件、文档源文件等。"
|
||||||
image: https://user-images.githubusercontent.com/13142418/73239989-98c4d800-41d8-11ea-8c5b-383076cfcd6c.png
|
image: https://user-images.githubusercontent.com/13142418/73239989-98c4d800-41d8-11ea-8c5b-383076cfcd6c.png
|
||||||
permalink: /cn/:title/
|
permalink: /cn/:title/
|
||||||
lang: zh
|
lang: zh
|
||||||
type: BlogPosting
|
type: BlogPosting
|
||||||
comments: true
|
comments: true
|
||||||
commentsID: "自定义工程文件跳转"
|
commentsID: "自定义工程文件跳转"
|
||||||
---
|
---
|
||||||
|
|
||||||
# [Blogs](../blog/) >> 自定义工程文件跳转
|
# [Blogs](../blog/) >> 自定义工程文件跳转
|
||||||
|
|
||||||
{{ page.date | date_to_string }}
|
{{ page.date | date_to_string }}
|
||||||
|
|
||||||
|
|
||||||
## 起因和目的
|
## 起因和目的
|
||||||
|
|
||||||
起初,在管理 SpaceVim 这一项目时,每编辑一个模块源文件,总是需要关注以下几件事:
|
起初,在管理 SpaceVim 这一项目时,每编辑一个模块源文件,总是需要关注以下几件事:
|
||||||
|
|
||||||
1. 相关的文档是否存在,是否需要修改,在工程内存在中英文版本的文档,是否内容保持一致。
|
1. 相关的文档是否存在,是否需要修改,在工程内存在中英文版本的文档,是否内容保持一致。
|
||||||
2. 测试文件是否存在,是否需要修改。
|
2. 测试文件是否存在,是否需要修改。
|
||||||
|
|
||||||
出于以上两点的考虑,衍生出如下需求:
|
出于以上两点的考虑,衍生出如下需求:
|
||||||
|
|
||||||
1. 在编辑源文件时,迅速跳转至文档所在的源文件;
|
1. 在编辑源文件时,迅速跳转至文档所在的源文件;
|
||||||
2. 在编辑中文文档时,迅速跳转至英文文档,反之亦然;
|
2. 在编辑中文文档时,迅速跳转至英文文档,反之亦然;
|
||||||
3. 在编辑源文件时,迅速跳转至测试文件,反之亦然;
|
3. 在编辑源文件时,迅速跳转至测试文件,反之亦然;
|
||||||
|
|
||||||
目前,SpaceVim 内置的这一插件基本实现了以上功能,以便于快速在相关文件之间进行跳转。
|
目前,SpaceVim 内置的这一插件基本实现了以上功能,以便于快速在相关文件之间进行跳转。
|
||||||
|
|
||||||
## 基本的使用
|
## 基本的使用
|
||||||
|
|
||||||
SpaceVim 提供了一个内置的工程文件跳转插件,默认的命令为 `:A`,
|
SpaceVim 提供了一个内置的工程文件跳转插件,默认的命令为 `:A`,
|
||||||
该命令可接收参数,指定跳转类别:
|
该命令可接收参数,指定跳转类别:
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
在使用这一特性之前,需要在工程根目录添加配置文件 `.project_alt.json`。例如:
|
在使用这一特性之前,需要在工程根目录添加配置文件 `.project_alt.json`。例如:
|
||||||
|
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"autoload/SpaceVim/layers/lang/*.vim": {"doc": "docs/layers/lang/{}.md"},
|
"autoload/SpaceVim/layers/lang/*.vim": {"doc": "docs/layers/lang/{}.md"},
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
加入以上配置文件后,当编辑 `autoload/SpaceVim/layers/lang/java.vim` 文件时,
|
加入以上配置文件后,当编辑 `autoload/SpaceVim/layers/lang/java.vim` 文件时,
|
||||||
可以通过 `:A doc` 跳转至 `docs/layers/lang/java.md` 文件。
|
可以通过 `:A doc` 跳转至 `docs/layers/lang/java.md` 文件。
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,15 +1,15 @@
|
|||||||
Execute ( SpaceVim plugin: a.vim ):
|
Execute ( SpaceVim plugin: a.vim ):
|
||||||
call SpaceVim#plugins#a#set_config_name('.projections.json')
|
call SpaceVim#plugins#a#set_config_name('.projections.json')
|
||||||
let root = SpaceVim#plugins#a#get_root()
|
let root = SpaceVim#plugins#a#get_root()
|
||||||
AssertEqual SpaceVim#plugins#a#get_alt('docs/index.md', root), 'docs/cn/index.md'
|
AssertEqual SpaceVim#plugins#a#get_alt('docs/index.md', root, 1), 'docs/cn/index.md'
|
||||||
AssertEqual SpaceVim#plugins#a#get_alt('docs/cn/index.md', root), 'docs/index.md'
|
AssertEqual SpaceVim#plugins#a#get_alt('docs/cn/index.md', root, 1), 'docs/index.md'
|
||||||
AssertEqual SpaceVim#plugins#a#get_alt('docs/api/job.md', root), 'docs/cn/api/job.md'
|
AssertEqual SpaceVim#plugins#a#get_alt('docs/api/job.md', root, 1), 'docs/cn/api/job.md'
|
||||||
AssertEqual SpaceVim#plugins#a#get_alt('docs/cn/api/job.md', root), 'docs/api/job.md'
|
AssertEqual SpaceVim#plugins#a#get_alt('docs/cn/api/job.md', root, 1), 'docs/api/job.md'
|
||||||
AssertEqual SpaceVim#plugins#a#get_alt('wiki/en/Project-layout.md', root), 'wiki/cn/Project-layout.md'
|
AssertEqual SpaceVim#plugins#a#get_alt('wiki/en/Project-layout.md', root, 1), 'wiki/cn/Project-layout.md'
|
||||||
AssertEqual SpaceVim#plugins#a#get_alt('wiki/cn/Project-layout.md', root), 'wiki/en/Project-layout.md'
|
AssertEqual SpaceVim#plugins#a#get_alt('wiki/cn/Project-layout.md', root, 1), 'wiki/en/Project-layout.md'
|
||||||
AssertEqual SpaceVim#plugins#a#get_alt('docs/_posts/2018-09-28-use-vim-as-ide.md', root), 'docs/_posts/2018-09-27-use-vim-as-ide.md'
|
AssertEqual SpaceVim#plugins#a#get_alt('docs/_posts/2018-09-28-use-vim-as-ide.md', root, 1), 'docs/_posts/2018-09-27-use-vim-as-ide.md'
|
||||||
AssertEqual SpaceVim#plugins#a#get_alt('docs/_posts/2018-09-27-use-vim-as-ide.md', root), 'docs/_posts/2018-09-28-use-vim-as-ide.md'
|
AssertEqual SpaceVim#plugins#a#get_alt('docs/_posts/2018-09-27-use-vim-as-ide.md', root, 1), 'docs/_posts/2018-09-28-use-vim-as-ide.md'
|
||||||
AssertEqual SpaceVim#plugins#a#get_alt('docs/_posts/2020-01-28-manage-project-alternate-files.md', root), 'docs/_posts/2020-01-27-manage-project-alternate-files.md'
|
AssertEqual SpaceVim#plugins#a#get_alt('docs/_posts/2020-01-28-manage-project-alternate-files.md', root, 1), 'docs/_posts/2020-01-27-manage-project-alternate-files.md'
|
||||||
AssertEqual SpaceVim#plugins#a#get_alt('docs/_posts/2020-01-27-manage-project-alternate-files.md', root), 'docs/_posts/2020-01-28-manage-project-alternate-files.md'
|
AssertEqual SpaceVim#plugins#a#get_alt('docs/_posts/2020-01-27-manage-project-alternate-files.md', root, 1), 'docs/_posts/2020-01-28-manage-project-alternate-files.md'
|
||||||
unlet root
|
unlet root
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user