Skip to content

Commit c267aa9

Browse files
committed
tmpfaq
1 parent c437cdc commit c267aa9

File tree

2 files changed

+97
-3
lines changed

2 files changed

+97
-3
lines changed

README-en.md

Lines changed: 52 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,61 @@ free to contribute by modifying the [.vim/install.sh](.vim/install.sh) in this r
4040
To test, run [.vim/package.sh](.vim/package.sh) to generate the installation script `vimrc-install.sh`.
4141
Then run it in Docker or other corresponding environment to test.
4242

43-
# Manual Install (not recommended)
43+
## FAQs
44+
45+
Q: I got error whenever starting Vim:
46+
```
47+
coc.nvim works best on vim >= 8.2.0750 and neovim >= 0.5.0, consider upgrade your vim.
48+
You can add this to your vimrc to avoid this message:
49+
let g:coc_disable_startup_warning = 1
50+
Note that some features may behave incorrectly.
51+
```
52+
53+
Please upgrade to Vim 8.2 or above for best experience.
54+
55+
Q: I got error when editing `.cpp` files in Vim:
56+
```
57+
[coc.nvim] Server languageserver.ccls failed to start: Error: invalid params of initialize: expected array for /workspaceFolders
58+
```
59+
60+
A: This is a bug of ccls. Please do not directly edit `.cpp` files in `/home/YourName` or `/tmp`. Create `.cpp` files in sub-folders of `/home/YourName` instead, for example:
61+
62+
```bash
63+
mkdir ~/MyProject
64+
cd ~/MyProject
65+
vim MyFile.cpp
66+
```
67+
68+
Q: How to set the project root folder?
69+
70+
A: My Vim configuration will regard the folder where `.tasks` or `.git` is found to be the project root.
71+
So if you are already working in a git repo then it's root will be automatically considered to be project root.
72+
Otherwise please manually create a dummy file `.tasks` to help it determine the project root:
73+
74+
```bash
75+
cd ~/MyProject
76+
touch .tasks
77+
```
78+
79+
Q: Why didn't Vim auto-completition recognize my compiler flags in `CMakeLists.txt`?
80+
81+
A: As I said above, it regards the folder where `.tasks` or `.git` is found to be the project root.
82+
Also it only reads compiler flags from the specific path `build/compile_commands.json`.
83+
So make sure **the `build` folder of CMake is located in the same directory as `.tasks` or `.git`**.
84+
And make sure you have **specified the flag `-DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=ON`** to make CMake
85+
generate `compile_commands.json`. (But if you use `<F5>` shortcut of my vimrc, this flag is specified automatically).
86+
87+
```bash
88+
cd ~/MyProject
89+
touch .tasks
90+
cmake -B build -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=ON
91+
```
92+
93+
## Manual Install (not recommended)
4494

4595
See the comments in [.vim/init.vim](.vim/init.vim) for manual installation steps.
4696

47-
# NeoVim tips
97+
## NeoVim tips
4898

4999
For NeoVim users, please create a file `~/.config/nvim/init.vim` containing following contents:
50100

README.md

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,55 @@
4040
要测试的话,先运行 [.vim/package.sh](.vim/package.sh) 来生成一键安装脚本 `vimrc-install.sh`
4141
然后用 Docker 等工具在相应的隔离环境中测试是否能正确安装。
4242

43+
## 常见问题
44+
45+
Q: I got error whenever starting Vim:
46+
```
47+
coc.nvim works best on vim >= 8.2.0750 and neovim >= 0.5.0, consider upgrade your vim.
48+
You can add this to your vimrc to avoid this message:
49+
let g:coc_disable_startup_warning = 1
50+
Note that some features may behave incorrectly.
51+
```
52+
53+
Please upgrade to Vim 8.2 or above for best experience.
54+
55+
Q: I got error when editing `.cpp` files in Vim:
56+
```
57+
[coc.nvim] Server languageserver.ccls failed to start: Error: invalid params of initialize: expected array for /workspaceFolders
58+
```
59+
60+
A: This is a bug of ccls. Please do not directly edit `.cpp` files in `/home/YourName` or `/tmp`. Create `.cpp` files in sub-folders of `/home/YourName` instead, for example:
61+
62+
```bash
63+
mkdir ~/MyProject
64+
cd ~/MyProject
65+
vim MyFile.cpp
66+
```
67+
68+
Q: How to set the project root folder?
69+
70+
A: My Vim configuration will regard the folder where `.tasks` or `.git` is found to be the project root.
71+
So if you are already working in a git repo then it's root will be automatically considered to be project root.
72+
Otherwise please manually create a dummy file `.tasks` to help it determine the project root:
73+
74+
```bash
75+
cd ~/MyProject
76+
touch .tasks
77+
```
78+
79+
Q: Why didn't Vim auto-completition recognize my compiler flags in `CMakeLists.txt`?
80+
81+
A: As I said above, it regards the folder where `.tasks` or `.git` is found to be the project root.
82+
Also it only reads compiler flags from the specific path `build/compile_commands.json`.
83+
So make sure **the `build` folder of CMake is located in the same directory as `.tasks` or `.git`**.
84+
And make sure you have **specified the flag `-DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=ON`** to make CMake
85+
generate `compile_commands.json`. (But if you use `<F5>` shortcut of my vimrc, this flag is specified automatically).
86+
4387
## 手动安装(不推荐)
4488

4589
手动安装方法见 [.vim/init.vim](.vim/init.vim) 中的注释。
4690

47-
# NeoVim 用户
91+
## NeoVim 用户
4892

4993
使用 NeoVim 的用户,请创建一个文件 `~/.config/nvim/init.vim`,内容如下:
5094

0 commit comments

Comments
 (0)