Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: Chinese translation of documents #401

Merged
merged 12 commits into from
May 9, 2023
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
# 入门指南
## Vim 命令

这一页还没写, [您可以帮助我们写](https://github.com/LunarVim/lunarvim.org/issues/352)。
如果你还不了解它们,现在是学习vim动作的好时机,这里有一些资源可以帮助你:

- [ThePrimeagen 的 YouTube 系列 "Vim 作为你的编辑器" ](https://www.youtube.com/playlist?list=PLm323Lc7iSW_wuxqmKx_xxNtJC_hJbQ7R)
- 按下 `:Tutor` 命令后使用Neovim的tutor

## Lua

你需要一些基本的lua知识来配置LunarVim。

- [`:help lua-guide`](https://neovim.io/doc/user/lua-guide.html)

## 接下来

- [了解默认键绑定](./keybinds-overview.md)
- 了解 [最重要的默认插件](./plugins-overview.md)
- 了解如何 [配置 LunarVim](/configuration/README.md)
- 查看 [starter.lvim](https://github.com/LunarVim/starter.lvim) (特定于语言的 lunarvim 配置的集合)
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ sidebar_position: 3
| `<leader>` | [whichkey](https://github.com/folke/which-key.nvim) (键位提示弹窗 (1秒后弹出)) | normal |
| `<leader>e` | [nvimtree](https://github.com/nvim-tree/nvim-tree.lua) (文件浏览边栏) | normal |
| `<leader>f` `<leader>s`(menu) | [telescope](https://github.com/nvim-telescope/telescope.nvim) (查找文件,搜索文本等) | normal |
| `<leader>;` | [alpha](https://github.com/goolord/alpha-nvim) (主页) | normal |
| `<leader>;` | [alpha](https://github.com/goolord/alpha-nvim) (仪表盘) | normal |
| `<C-\>` `<M-1/2/3>` | [toggleterm](https://github.com/akinsho/toggleterm.nvim) (终端) | normal |

## LSP
Expand All @@ -36,6 +36,7 @@ sidebar_position: 3
| `gI` | 跳转到实现 | normal |
| `gs` | 显示签名帮助 | normal |
| `gl` | 显示当前行诊断信息 | normal |
| `glgl` | 将光标移至`gl`诊断窗口内 | normal |

## 编辑

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,19 @@ sidebar_position: 1

# 术语

这一页还没写, [您可以帮助我们写](https://github.com/LunarVim/lunarvim.org/issues/352)。
## Language features

### [LSP (语言服务器协议)](https://microsoft.github.io/language-server-protocol/)

- **LSP** - 在源代码编辑器和LSP服务器之间使用的协议。该协议的目标是实现对编程语言的支持,独立于任何给定的编辑器和IDE。

- **LSP server** - provides programming language-specific features like code completion, syntax
highlighting and marking of warnings and errors, as well as refactoring routines.

### [DAP (调试适配协议)](https://microsoft.github.io/debug-adapter-protocol/)

用于debug支持的协议。

### [Treesitter](https://tree-sitter.github.io/tree-sitter/)

可以为源文件构建语法树,且源文件被编辑时更新语法树。在neovim中它被用于实现语法高亮和缩进。
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,14 @@ sidebar_position: 1

## 更换配色

想快速切换配色方案,可以使用 `<leader>sc` (`:Telescope colorscheme`)

如需实时更换配色,输入以下命令:

```vim
:Telescope colorscheme
```

您也可以使用`<leader>sp` 来预览所有的配色方案。
你也可以使用 `<leader>sp` 循环预览色彩主题。

如需永久改变配色方案,则修改`config.lua`

```lua
lvim.colorscheme = 'desert'
lvim.colorscheme = "desert"
```

## 安装配色方案
Expand All @@ -27,6 +22,44 @@ lvim.colorscheme = 'desert'

[此列表](https://github.com/rockerBOO/awesome-neovim#colorscheme) 有带tree-sitter支持的配色方案。


## 自定义颜色

你可以通过在自动命令覆盖它们来定制高亮组。
找到你想改变的组,然后使用 `leader s H` (`:Telescope highlights`),
`:TSHighlightCapturesUnderCursor` 或者 `:Inspect`

```lua
lvim.autocommands = {
{
{ "ColorScheme" },
{
pattern = "*",
callback = function()
-- change `Normal` to the group you want to change
-- and `#ffffff` to the color you want
-- see `:h nvim_set_hl` for more options
vim.api.nvim_set_hl(0, "Normal", { bg = "#ffffff", underline = false, bold = true })
end,
},
},
}
```

你也可以覆盖内置主题的颜色参数。
例如:to have winseparator colored in orange in tokyonight scheme:

```lua
lvim.colorscheme = "tokyonight"
lvim.builtin.theme.name = "tokyonight"
lvim.builtin.theme.tokyonight.options.on_highlights = function(hl, c)
hl.WinSeparator = {
fg = c.orange,
bold = true,
}
end
```

## 透明窗口

如果您在使用透明的窗口,需要打开这个设置:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,115 +4,119 @@ sidebar_position: 1

# 语言服务器

_This page needs improvement_
LunarVim使用[文件类型插件](/configuration/ftplugin.md)来实现语言服务器的懒加载设置。一个模板生成器被用来创建 `ftplugin` 文件,并将设置调用填充到这些文件中。

## Installing and updating a server
`lvim.lsp.automatic_configuration.skipped_servers` 包含一个默认不会被自动配置的服务器列表,例如,只允许JS-family语言使用 `tsserver`,当一种语言有多个可用的服务器时,那么通常会选择最受欢迎的那个。

### Automatic server installation
:::info

By default, most supported language servers will get automatically installed once you open the supported file-type, e.g, opening a Python file for the first time will install `Pyright` and configure it automatically for you.
如果要更改 `lvim.lsp.automatic_configuration.skipped_servers` 的值,**必须**在之后执行 `:LvimCacheReset` 命令才能生效。

- configuration option
:::

## 安装和更新服务

### 自动安装

默认情况下,一旦你打开支持的文件类型,大多数支持的语言服务器将被自动安装,例如,第一次打开一个Python文件将安装 `pyright` 并自动为你配置。

### 手动安装

```lua
lvim.lsp.automatic_servers_installation = true
lvim.lsp.automatic_servers_installation = false
```

Please refer to [mason](https://github.com/williamboman/mason.nvim) to see the updated full list of currently available servers.
请参考[mason](https://github.com/williamboman/mason.nvim),查看当前可用服务器的最新完整列表。

To install a supported language server:
要安装一个支持的语言服务器:

```md
```vim
:LspInstall `<your_language_server>`
```

You can also toggle `<:Mason>` and interactively choose which servers to install.

## Server override
你也可以打开 `:Mason` ,交互式地选择要安装的服务器(按`g?`键绑定)。

`lvim.lsp.automatic_configuration.skipped_servers` contains a list of servers that will **not** be automatically configured by default, for example only `tsserver` is allowed for JS-family languages, and when a language has more than one server available, then the most popular one is usually chosen.
### 更新服务器

:::tip
打开 `:Mason`,选择一个服务器,用 `u` 来更新它。你可以用 `<S-u>` 来更新所有Mason软件包。

Overriding a server will completely bypass the lsp-installer, so you would have to manage the installation for any of those servers manually.
## 改变默认服务器

:::
要使用与默认服务器不同的服务器,请将默认服务器添加到 `skipped_servers` 列表中,并删除你想使用的那个服务器。

See the current list
:::info

```lua
:lua print(vim.inspect(lvim.lsp.automatic_configuration.skipped_servers))
```
对 `lvim.lsp.automatic_configuration.skipped_servers` 的任何修改都**必须**在按下 `:LvimCacheReset` 之后才会生效。

See the default list in [`lua/lvim/lsp/config.lua`](https://github.com/LunarVim/LunarVim/blob/master/lua/lvim/lsp/config.lua#L1-L40)
:::

:::tip
例子:

Any changes to `lvim.lsp.automatic_configuration.skipped_servers` **must** be followed by `:LvimCacheReset` to take effect.
- 使用j `jedi_language_server` 而不是 `pyright`

:::
```lua
-- add `pyright` to `skipped_servers` list
vim.list_extend(lvim.lsp.automatic_configuration.skipped_servers, { "pyright" })
-- remove `jedi_language_server` from `skipped_servers` list
lvim.lsp.automatic_configuration.skipped_servers = vim.tbl_filter(function(server)
return server ~= "jedi_language_server"
end, lvim.lsp.automatic_configuration.skipped_servers)
```

## Server setup
## 覆盖设置

LunarVim uses [filetype plugins](/configuration/ftplugin.md) to enable lazy-loading the setup of a language server. A template generator is used to create `ftplugin` files and populate them with the setup call.
### 使用 :LspSettings

- configuration option
为你的语言服务器进行设置:

```lua
lvim.lsp.templates_dir = join_paths(get_runtime_dir(), "after", "ftplugin")
```vim
:LspSettings <TAB>
```

A typical setup call with default arguments
例子:

```lua
-- edit this file by running `:lua vim.cmd("edit " .. lvim.lsp.templates_dir .. "/lua.lua")`
require("lvim.lsp.manager").setup("sumneko_lua")
```
1. `:LspSettings sumneko_lua`

2. ```json
{
"Lua.hint.enable": false
}
```

这将在 `/lsp-settings` 中创建一个文件,以实现持久的更改。
请参考 [nlsp-settings](https://github.com/tamago324/nlsp-settings.nvim/blob/main/schemas/README.md) 的文档,
了解支持的语言服务器的完整更新列表。

:::tip

You can quickly find these files by running `<leader>Lf` -> "Find LunarVim Files"
安装 `jsonls` LSP服务器用于自动完成。

:::

### Overriding the default setup options
### 通过覆盖进行设置

Add the server you wish to configure manually to `lvim.lsp.automatic_configuration.skipped_servers`.
将你想手动配置的服务器添加到 `lvim.lsp.automatic_configuration.skipped_servers`

```lua
vim.list_extend(lvim.lsp.automatic_configuration.skipped_servers, { "pyright" })
vim.list_extend(lvim.lsp.automatic_configuration.skipped_servers, { "sumneko_lua" })
```

Now you can set it up manually using the builtin [lsp-manager](https://github.com/LunarVim/LunarVim/blob/rolling/lua/lvim/lsp/manager.lua)
:::info

```lua
--- list of options that should take precedence over any of LunarVim's defaults
--- check the lspconfig documentation for a list of all possible options
local opts = {}
require("lvim.lsp.manager").setup("pyright", opts)
```
对 `lvim.lsp.automatic_configuration.skipped_servers` 的任何修改都**必须**在按下 `:LvimCacheReset` 之后才会生效。

Alternatively, set it up using the `lspconfig` API directly

```lua
--- check the lspconfig documentation for a list of all possible options
local opts = {}
require("lspconfig")["pyright"].setup(opts)
```
:::

## Server settings
现在你可以使用 `$LUNARVIM_CONFIG_DIR/ftplugin/<filetype>.lua` 中的内置的[lsp管理器](https://github.com/LunarVim/LunarVim/blob/master/lua/lvim/lsp/manager.lua)手动设置它。

To set a setting for your language server:
例子:

```vim
:LspSettings <TAB>
:LspSettings <NAME_OF_LANGUAGE_SERVER>
```lua
-- $LUNARVIM_CONFIG_DIR/ftplugin/lua.lua
local opts = {
settings = {
Lua = { hint = { enable = false } },
},
}
require("lvim.lsp.manager").setup("sumneko_lua", opts)
```

This will create a file in `$LUNARVIM_CONFIG_DIR/lsp-settings`, to enable persistent changes. Refer to the documentation of [nlsp-settings](https://github.com/tamago324/nlsp-settings.nvim/blob/main/schemas/README.md) for a full updated list of supported language servers.

:::tip

Make sure to install `jsonls` for autocompletion.

:::
Loading