mirror of
https://github.com/jdhao/nvim-config.git
synced 2025-06-08 14:14:33 +02:00
Compare commits
409 Commits
v0.7.0
...
e23d4bb661
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e23d4bb661 | ||
|
|
510a5501c5 | ||
|
|
e08b17f335 | ||
|
|
adddbc0ba6 | ||
|
|
aadfdae677 | ||
|
|
5826161160 | ||
|
|
ea2b4a728d | ||
|
|
ad4a0e82dc | ||
|
|
9e6be1f001 | ||
|
|
c4160b6f85 | ||
|
|
60852c0473 | ||
|
|
7fa77fbfbf | ||
|
|
f76ef3dbb4 | ||
|
|
d17289cd6b | ||
|
|
bfc531656a | ||
|
|
72e6480933 | ||
|
|
625a4ffa47 | ||
|
|
265f171172 | ||
|
|
b82c1c112f | ||
|
|
0816faee76 | ||
|
|
12147bec86 | ||
|
|
a8a1b92921 | ||
|
|
5f662f143b | ||
|
|
f005a8303d | ||
|
|
8cba1ba234 | ||
|
|
a00e1fd92a | ||
|
|
2383eb7075 | ||
|
|
ab059bbb6d | ||
|
|
93166c65a5 | ||
|
|
4b8c490abd | ||
|
|
2242961925 | ||
|
|
ac421715d3 | ||
|
|
28bda349e8 | ||
|
|
ee4bce4671 | ||
|
|
7f53743255 | ||
|
|
94497c0a73 | ||
|
|
70e9943aac | ||
|
|
9a6584bec3 | ||
|
|
c7fb090e4c | ||
|
|
a02f317a1d | ||
|
|
f95d4c09b4 | ||
|
|
7e706515a8 | ||
|
|
1d66475cae | ||
|
|
5328c477a8 | ||
|
|
917ab82ffb | ||
|
|
54eb3ca811 | ||
|
|
64b41fbd58 | ||
|
|
d941be482b | ||
|
|
ab75189231 | ||
|
|
7645751dc1 | ||
|
|
8880268140 | ||
|
|
d86f599483 | ||
|
|
8dfae271d0 | ||
|
|
1141a18c5f | ||
|
|
fe3d5e5922 | ||
|
|
9769c24633 | ||
|
|
97f72936ac | ||
|
|
94cade03be | ||
|
|
590bd6c7e6 | ||
|
|
4171f190f2 | ||
|
|
5426c88a90 | ||
|
|
d715ce8f31 | ||
|
|
3040fa7969 | ||
|
|
b9cf3cc6ed | ||
|
|
154cde3d71 | ||
|
|
81f64ed32e | ||
|
|
db380ca7a7 | ||
|
|
51f81093da | ||
|
|
a9fc298063 | ||
|
|
9071e045eb | ||
|
|
fa79647a63 | ||
|
|
4b4ff5f549 | ||
|
|
12b0ff02b6 | ||
|
|
e3930e8aa7 | ||
|
|
21522bd194 | ||
|
|
a3c8b3d5b5 | ||
|
|
d150f39afc | ||
|
|
3904cd4ccf | ||
|
|
95d3b2f2d8 | ||
|
|
c3d8dc3e1d | ||
|
|
f9780c2dff | ||
|
|
256c37a946 | ||
|
|
eff98d036d | ||
|
|
6e60475f3f | ||
|
|
d90273df8e | ||
|
|
659f410b9e | ||
|
|
a602d98819 | ||
|
|
9ff76931e3 | ||
|
|
85232b82a8 | ||
|
|
cfc0089bb5 | ||
|
|
f1062a3d8f | ||
|
|
fd6df981cd | ||
|
|
8af8ebd72a | ||
|
|
4c697d89f3 | ||
|
|
e6f95cedb1 | ||
|
|
262ad6aa38 | ||
|
|
b30cc9ed78 | ||
|
|
b3a26e4226 | ||
|
|
794b098090 | ||
|
|
b728b39784 | ||
|
|
acc3ed7829 | ||
|
|
44e9e5a1ce | ||
|
|
5502d29f40 | ||
|
|
fe95658319 | ||
|
|
e165276763 | ||
|
|
933b887281 | ||
|
|
69643e143a | ||
|
|
7f4772fd31 | ||
|
|
bf49e90947 | ||
|
|
784b435f0e | ||
|
|
beec97c086 | ||
|
|
bbb8545403 | ||
|
|
9efadac8fb | ||
|
|
6e137fe9a3 | ||
|
|
719fbfc1ab | ||
|
|
e815de294f | ||
|
|
ca7430056c | ||
|
|
cb8c9208e1 | ||
|
|
ce1e13e2c9 | ||
|
|
2af616bb0d | ||
|
|
3694d3c237 | ||
|
|
69d8543495 | ||
|
|
be3d134c37 | ||
|
|
601396f700 | ||
|
|
e462ebcbcc | ||
|
|
2f8482639d | ||
|
|
050eacaee2 | ||
|
|
01bc4b40d3 | ||
|
|
c06d46e84d | ||
|
|
7cf70f31af | ||
|
|
8416508686 | ||
|
|
df9491b05b | ||
|
|
17d2e3ab3e | ||
|
|
2c9948300d | ||
|
|
dfaa3d97a5 | ||
|
|
8d74fcb75c | ||
|
|
b1f0ef63ef | ||
|
|
54ca6d4191 | ||
|
|
97af59e670 | ||
|
|
4d8ef868ad | ||
|
|
3137850db6 | ||
|
|
eccdc62f38 | ||
|
|
ad483a7dc0 | ||
|
|
6df27d1c22 | ||
|
|
7f6627cfa1 | ||
|
|
7ff11a9760 | ||
|
|
cc4688d089 | ||
|
|
8a1b3193a4 | ||
|
|
e92362041c | ||
|
|
63ff776758 | ||
|
|
41c8c81f21 | ||
|
|
997c6286df | ||
|
|
359621b126 | ||
|
|
4dc2d9575b | ||
|
|
fc1c447319 | ||
|
|
1391ca7ff1 | ||
|
|
6a6f8ff597 | ||
|
|
946e65662b | ||
|
|
4a6379ca5d | ||
|
|
855a88b532 | ||
|
|
892cd49f06 | ||
|
|
e53ee104ec | ||
|
|
671c78df9b | ||
|
|
1608a36dd3 | ||
|
|
450f058da5 | ||
|
|
e2f348cb37 | ||
|
|
fc8175d32d | ||
|
|
4034b6b673 | ||
|
|
67a4b6e6d0 | ||
|
|
bb27d93433 | ||
|
|
9d9c3ef32f | ||
|
|
00e8c77b23 | ||
|
|
7bb3ccc275 | ||
|
|
ee38046ebc | ||
|
|
6c873a32da | ||
|
|
9ca65fd942 | ||
|
|
cc3a7d6ebd | ||
|
|
f3a359a2fa | ||
|
|
9a4d71db88 | ||
|
|
dc597004df | ||
|
|
644993a89e | ||
|
|
164d6129f8 | ||
|
|
cde21f6f67 | ||
|
|
8746c7eb11 | ||
|
|
7c44997289 | ||
|
|
bfdb3f5a26 | ||
|
|
76ced0e265 | ||
|
|
e84d18a204 | ||
|
|
6429e8364c | ||
|
|
f2c6900a8d | ||
|
|
116aaa0675 | ||
|
|
12f3ca9d1f | ||
|
|
7e7944a30c | ||
|
|
53c17aea96 | ||
|
|
43c1615822 | ||
|
|
509a8bce8c | ||
|
|
8b10be60d4 | ||
|
|
074d2bbdfd | ||
|
|
7f9af87185 | ||
|
|
bb0b0c5e25 | ||
|
|
7bb12e4b70 | ||
|
|
41da56b823 | ||
|
|
82f2332281 | ||
|
|
075326ee2e | ||
|
|
baa8f26bc2 | ||
|
|
e9760ae9b8 | ||
|
|
0d50eb723f | ||
|
|
b893bdc099 | ||
|
|
2073f72e67 | ||
|
|
364be4b5dc | ||
|
|
d30d402128 | ||
|
|
fc144e0895 | ||
|
|
18abfa7754 | ||
|
|
6c1dbdf8fc | ||
|
|
202a9a088d | ||
|
|
d939cc75c6 | ||
|
|
26921309ec | ||
|
|
a6f716558b | ||
|
|
3539207913 | ||
|
|
d8b92965e8 | ||
|
|
ebf7170916 | ||
|
|
696466469b | ||
|
|
7a5be43600 | ||
|
|
3b39067097 | ||
|
|
e6b3be0777 | ||
|
|
acb423984a | ||
|
|
d40d87cb61 | ||
|
|
81663c8f3c | ||
|
|
2c7e4aa87a | ||
|
|
07dd60206b | ||
|
|
c3d4eb371b | ||
|
|
597a2aba80 | ||
|
|
f1f6d0b351 | ||
|
|
e1930ba153 | ||
|
|
a8db734e75 | ||
|
|
4026baef19 | ||
|
|
f63152f79b | ||
|
|
5229c460ea | ||
|
|
f308ccad7b | ||
|
|
09dd81bf67 | ||
|
|
5ecb74ad85 | ||
|
|
773003b71b | ||
|
|
f5097b44b9 | ||
|
|
238886c136 | ||
|
|
2fccb59293 | ||
|
|
830297a973 | ||
|
|
1f3fcc604a | ||
|
|
7f5bf5a1b2 | ||
|
|
81bc5e46f1 | ||
|
|
b4c3b7eba0 | ||
|
|
4203410878 | ||
|
|
9f58c3b7a5 | ||
|
|
45d0d68b9e | ||
|
|
74a9767018 | ||
|
|
ab25bfc9c4 | ||
|
|
ebbdb27d01 | ||
|
|
1b1f0199da | ||
|
|
40fa9aab1c | ||
|
|
6e8e61e53a | ||
|
|
89effe8b17 | ||
|
|
aaeb6a813a | ||
|
|
9ba728e201 | ||
|
|
e5f1b4d224 | ||
|
|
eaddee0c5c | ||
|
|
0582f26abe | ||
|
|
e209ef686a | ||
|
|
8b3610ed3d | ||
|
|
bde6083f22 | ||
|
|
c1f139108a | ||
|
|
3bb8b224e7 | ||
|
|
b69320b4e2 | ||
|
|
5c63ade4a0 | ||
|
|
b504c932e6 | ||
|
|
a39befff93 | ||
|
|
309c8ad636 | ||
|
|
954a4a1cad | ||
|
|
67a322c26c | ||
|
|
91c9dbe40d | ||
|
|
6a5f1d24a7 | ||
|
|
4dcafbe2bc | ||
|
|
14860072d0 | ||
|
|
5a69d43cab | ||
|
|
11e6797cb5 | ||
|
|
858848128f | ||
|
|
d436227f65 | ||
|
|
acb8b7fcf8 | ||
|
|
46cbdc2d7f | ||
|
|
c71ad44cd3 | ||
|
|
db378b858b | ||
|
|
ee45f1f5a1 | ||
|
|
43660dd540 | ||
|
|
17acda10a0 | ||
|
|
eb87c5b0c3 | ||
|
|
b35956e6cd | ||
|
|
82f4c0e399 | ||
|
|
16be5e0499 | ||
|
|
a39b53b7c1 | ||
|
|
b9616aeab0 | ||
|
|
208b190a65 | ||
|
|
602254a881 | ||
|
|
7022eefe22 | ||
|
|
dee7768162 | ||
|
|
22b33871ef | ||
|
|
aab74751f4 | ||
|
|
5dbe643ea2 | ||
|
|
b41998828d | ||
|
|
3670a19e51 | ||
|
|
545c6f4b92 | ||
|
|
86e3b29730 | ||
|
|
bc9b0a8cf8 | ||
|
|
fb9a0bb2dd | ||
|
|
59525c5577 | ||
|
|
6539e72a5d | ||
|
|
b279c0cd95 | ||
|
|
96129335ad | ||
|
|
b6fa0b7aa5 | ||
|
|
dff469ddc4 | ||
|
|
6d5cda0f97 | ||
|
|
4d35362e83 | ||
|
|
e57e747b26 | ||
|
|
c3f8d75ece | ||
|
|
78baf8d015 | ||
|
|
9d8a58be17 | ||
|
|
2372d9159f | ||
|
|
e9a3d16260 | ||
|
|
fdf8236fc2 | ||
|
|
085c8017d8 | ||
|
|
efa7b215e7 | ||
|
|
e68c687f23 | ||
|
|
497f93d6c7 | ||
|
|
cfe2e0611d | ||
|
|
9de08d0afe | ||
|
|
d5b7584e68 | ||
|
|
64a7a23309 | ||
|
|
c1efc0bad6 | ||
|
|
b3b69f21f4 | ||
|
|
f491e26676 | ||
|
|
e7e4892c22 | ||
|
|
a52a362b02 | ||
|
|
2880d7bce3 | ||
|
|
7e6dd23d37 | ||
|
|
fcbd7d3a0d | ||
|
|
97f302084f | ||
|
|
9d29544d72 | ||
|
|
cad9f5a214 | ||
|
|
ecde08941b | ||
|
|
ab88c112ff | ||
|
|
4c96243a4c | ||
|
|
fdc158272b | ||
|
|
b331cddc73 | ||
|
|
b11c57e36f | ||
|
|
84d73660fa | ||
|
|
a9cc10b2ef | ||
|
|
cad6112cc2 | ||
|
|
4d7fd6580a | ||
|
|
f492a94db6 | ||
|
|
0c92d9a018 | ||
|
|
369687b047 | ||
|
|
54908dfe9f | ||
|
|
2e5f5c5991 | ||
|
|
8291b15599 | ||
|
|
3de31f7d0a | ||
|
|
6b59c268f9 | ||
|
|
dd550dc3d0 | ||
|
|
3aae07df56 | ||
|
|
ed5ddf60cc | ||
|
|
bcdc8d3f66 | ||
|
|
5498a05bf7 | ||
|
|
644f8b6e2d | ||
|
|
3af7dd51b8 | ||
|
|
e0fc068f2e | ||
|
|
58ed71f870 | ||
|
|
aae9a7b7a7 | ||
|
|
33270f3257 | ||
|
|
99d5a0343b | ||
|
|
3678da1b3c | ||
|
|
a8fdbf3573 | ||
|
|
351ba5fc63 | ||
|
|
6dfaf2c521 | ||
|
|
ae759477c7 | ||
|
|
921fd17221 | ||
|
|
81696c9e13 | ||
|
|
32b1d3ac16 | ||
|
|
e3b15da059 | ||
|
|
934ef7fb13 | ||
|
|
3ee785506c | ||
|
|
428f612bb3 | ||
|
|
95b7ee5bc8 | ||
|
|
4899a82b35 | ||
|
|
424981683e | ||
|
|
c3253a5731 | ||
|
|
a9be0d0b20 | ||
|
|
13111596b8 | ||
|
|
6cea10fcc5 | ||
|
|
58102f182a | ||
|
|
9e284f58cb | ||
|
|
a5dc045acc | ||
|
|
dd3e9dd2f4 | ||
|
|
6784a87e26 | ||
|
|
99637c86f9 | ||
|
|
3817525441 | ||
|
|
4b4331d394 | ||
|
|
aaafaf58d6 | ||
|
|
1b9bd9ceef | ||
|
|
e043f07b71 | ||
|
|
b20b21b5dd | ||
|
|
c3ced68bea | ||
|
|
905efeb53f | ||
|
|
a3795cd043 |
2
.github/ISSUE_TEMPLATE/bug_report.md
vendored
2
.github/ISSUE_TEMPLATE/bug_report.md
vendored
@@ -8,7 +8,7 @@ assignees: ''
|
||||
|
||||
<!-- Before reporting: make sure that you have read the doc (https://github.com/jdhao/nvim-config/tree/master/docs) and searched existing issues. -->
|
||||
|
||||
- `nvim --version`:
|
||||
- `nvim --version`: <!--should be latest stable version: https://github.com/neovim/neovim/releases/tag/stable -->
|
||||
- terminal emulator and version:
|
||||
- Operating system/version:
|
||||
- Have you read and followed all steps in the [doc](https://github.com/jdhao/nvim-config/tree/master/docs):
|
||||
|
||||
2
.gitignore
vendored
2
.gitignore
vendored
@@ -2,6 +2,6 @@ tags
|
||||
en.utf-8.add.spl
|
||||
*.exe
|
||||
.netrwhist
|
||||
packer_compiled.lua
|
||||
*.log
|
||||
.DS_Store
|
||||
lazy-lock.json
|
||||
|
||||
6
.stylua.toml
Normal file
6
.stylua.toml
Normal file
@@ -0,0 +1,6 @@
|
||||
# config for stylua, ref: https://github.com/JohnnyMorganz/StyLua
|
||||
line_endings = "Unix"
|
||||
indent_type = "Spaces"
|
||||
indent_width = 2
|
||||
quote_style = "AutoPreferDouble"
|
||||
call_parentheses= "NoSingleTable"
|
||||
2
LICENSE
2
LICENSE
@@ -1,6 +1,6 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2018-2022 jdhao
|
||||
Copyright (c) 2018-2023 jdhao
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
102
README.md
102
README.md
@@ -9,24 +9,24 @@
|
||||
<a>
|
||||
<img alt="Windows" src="https://img.shields.io/badge/Windows-%23.svg?style=flat-square&logo=windows&color=0078D6&logoColor=white" />
|
||||
</a>
|
||||
<a href="https://github.com/jdhao/nvim-config/commits">
|
||||
<img src="https://badgen.net/github/commits/jdhao/nvim-config" alt="Commit number" />
|
||||
</a>
|
||||
<a href="https://github.com/jdhao/nvim-config/network">
|
||||
<img alt="Forks" src="https://badgen.net/github/forks/jdhao/nvim-config">
|
||||
</a>
|
||||
<a href="https://github.com/jdhao/nvim-config/stargazers">
|
||||
<img alt="Stars" src="https://badgen.net/github/stars/jdhao/nvim-config">
|
||||
<a href="https://github.com/neovim/neovim/releases/tag/stable">
|
||||
<img src="https://img.shields.io/badge/Neovim-0.11.0-blueviolet.svg?style=flat-square&logo=Neovim&logoColor=green" alt="Neovim minimum version"/>
|
||||
</a>
|
||||
<a href="https://github.com/jdhao/nvim-config/releases/latest">
|
||||
<img alt="Latest release" src="https://img.shields.io/github/v/release/jdhao/nvim-config" />
|
||||
</a>
|
||||
<a href="https://github.com/neovim/neovim/releases/tag/stable">
|
||||
<img src="https://img.shields.io/badge/Neovim-0.7.0-blueviolet.svg?style=flat-square&logo=Neovim&logoColor=green" alt="Neovim minimum version"/>
|
||||
</a>
|
||||
<a href="https://github.com/jdhao/nvim-config/search?l=vim-script">
|
||||
<img src="https://img.shields.io/github/languages/top/jdhao/nvim-config" alt="Top languages"/>
|
||||
</a>
|
||||
<a href="https://github.com/jdhao/nvim-config/graphs/commit-activity">
|
||||
<img src="https://img.shields.io/github/commit-activity/m/jdhao/nvim-config?style=flat-square" />
|
||||
</a>
|
||||
<a href="https://github.com/jdhao/nvim-config/graphs/contributors">
|
||||
<img src="https://img.shields.io/github/contributors/jdhao/nvim-config?style=flat-square" />
|
||||
</a>
|
||||
<a>
|
||||
<img src="https://img.shields.io/github/repo-size/jdhao/nvim-config?style=flat-square" />
|
||||
</a>
|
||||
<a href="https://github.com/jdhao/nvim-config/blob/master/LICENSE">
|
||||
<img src="https://img.shields.io/github/license/jdhao/nvim-config?style=flat-square&logo=GNU&label=License" alt="License"/>
|
||||
</a>
|
||||
@@ -36,67 +36,67 @@
|
||||
# Introduction
|
||||
|
||||
This repo hosts my Nvim configuration for Linux, macOS, and Windows.
|
||||
`init.vim` is the config entry point for terminal Nvim,
|
||||
`init.lua` is the config entry point for terminal Nvim,
|
||||
and `ginit.vim` is the additional config file for [GUI client of Nvim](https://github.com/neovim/neovim/wiki/Related-projects#gui).
|
||||
|
||||
My configurations are heavily documented to make it as clear as possible.
|
||||
While you can download the whole repository and use it, it is not recommended though.
|
||||
While you can clone the whole repository and use it, it is not recommended though.
|
||||
Good configurations are personal. Everyone should have his or her unique config file.
|
||||
You are encouraged to copy from this repo the part you feel useful and add it to your own Nvim config.
|
||||
You are encouraged to copy from this repo the part you want and add it to your own config.
|
||||
|
||||
To reduce the possibility of breakage, **this config is only maintained for [the latest nvim stable release](https://github.com/neovim/neovim/releases/tag/stable).
|
||||
No effort is spent on maintaining backward compatibility.**
|
||||
|
||||
# Install and setup
|
||||
|
||||
See [doc here](docs/README.md) on how to install Nvim's dependencies, Nvim itself,
|
||||
and how to set up on different platforms (Linux, macOS, and Windows).
|
||||
|
||||
**This config is tested against [Nvim v0.7.0 release](https://github.com/neovim/neovim/releases/tag/stable).
|
||||
No backward compatibility is guaranteed.**
|
||||
|
||||
# Features #
|
||||
|
||||
+ Plugin management via [Packer.nvim](https://github.com/wbthomason/packer.nvim).
|
||||
+ Code auto-completion via [nvim-cmp](https://github.com/hrsh7th/nvim-cmp) and [nvim-lspconfig](https://github.com/neovim/nvim-lspconfig).
|
||||
+ Plugin management via [Lazy.nvim](https://github.com/folke/lazy.nvim).
|
||||
+ Code, snippet, word auto-completion via [nvim-cmp](https://github.com/hrsh7th/nvim-cmp).
|
||||
+ Language server protocol (LSP) support via [nvim-lspconfig](https://github.com/neovim/nvim-lspconfig).
|
||||
+ Git integration via [vim-fugitive](https://github.com/tpope/vim-fugitive).
|
||||
+ Better escaping from insert mode via [better-escape.vim](https://github.com/jdhao/better-escape.vim).
|
||||
+ Ultra-fast project-wide fuzzy searching via [LeaderF](https://github.com/Yggdroot/LeaderF).
|
||||
+ Better escaping from insert mode via [better-escape.vim](https://github.com/nvim-zh/better-escape.vim).
|
||||
+ Ultra-fast project-wide fuzzy searching via [fzf-lua](https://github.com/ibhagwan/fzf-lua).
|
||||
+ Faster code commenting via [vim-commentary](https://github.com/tpope/vim-commentary).
|
||||
+ Faster matching pair insertion and jump via [delimitMate](https://github.com/Raimondi/delimitMate).
|
||||
+ Faster matching pair insertion and jump via [nvim-autopairs](https://github.com/windwp/nvim-autopairs).
|
||||
+ Smarter and faster matching pair management (add, replace or delete) via [vim-sandwich](https://github.com/machakann/vim-sandwich).
|
||||
+ Fast buffer jump via [hop.nvim](https://github.com/phaazon/hop.nvim).
|
||||
+ Ultra fast snippet insertion via [Ultisnips](https://github.com/SirVer/ultisnips).
|
||||
+ Beautiful status line via [lualine.nvim](https://github.com/nvim-lualine/lualine.nvim).
|
||||
+ File tree explorer via [nvim-tree.lua](https://github.com/kyazdani42/nvim-tree.lua).
|
||||
+ Powerful snippet insertion via [Ultisnips](https://github.com/SirVer/ultisnips).
|
||||
+ Beautiful statusline via [lualine.nvim](https://github.com/nvim-lualine/lualine.nvim).
|
||||
+ File tree explorer via [nvim-tree.lua](https://github.com/nvim-tree/nvim-tree.lua).
|
||||
+ Better quickfix list with [nvim-bqf](https://github.com/kevinhwang91/nvim-bqf).
|
||||
+ Show search index and count with [nvim-hlslens](https://github.com/kevinhwang91/nvim-hlslens).
|
||||
+ Command line auto-completion via [wilder.nvim](https://github.com/gelguy/wilder.nvim).
|
||||
+ Keymap display via [which-key.nvim](https://github.com/folke/which-key.nvim).
|
||||
+ User-defined mapping hint via [which-key.nvim](https://github.com/folke/which-key.nvim).
|
||||
+ Asynchronous code execution via [asyncrun.vim](https://github.com/skywind3000/asyncrun.vim).
|
||||
+ Code highlighting via [nvim-treesitter](https://github.com/nvim-treesitter/nvim-treesitter).
|
||||
+ Code editing using true nvim inside browser via [firenvim](https://github.com/glacambre/firenvim).
|
||||
+ Color theme via [vim-gruvbox8](https://github.com/lifepillar/vim-gruvbox8) and other beautiful themes.
|
||||
+ Markdown writing and previewing via [vim-markdown](https://github.com/plasticboy/vim-markdown) and [markdown-preview.nvim](https://github.com/iamcco/markdown-preview.nvim).
|
||||
+ Beautiful colorscheme via [sainnhe/gruvbox-material](https://github.com/sainnhe/gruvbox-material) and other colorschemes.
|
||||
+ Markdown writing and previewing via [vim-markdown](https://github.com/preservim/vim-markdown) and [markdown-preview.nvim](https://github.com/iamcco/markdown-preview.nvim).
|
||||
+ LaTeX editing and previewing via [vimtex](https://github.com/lervag/vimtex)
|
||||
+ Animated GUI style notification via [nvim-notify](https://github.com/rcarriga/nvim-notify).
|
||||
+ Smooth scroll experience via [neoscroll](https://github.com/karb94/neoscroll.nvim).
|
||||
+ Tags navigation via [vista](https://github.com/liuchengxu/vista.vim).
|
||||
+ Code formatting via [Neoformat](https://github.com/sbdchd/neoformat).
|
||||
+ Undo management via [vim-mundo](https://github.com/simnalamburt/vim-mundo)
|
||||
+ LaTeX editing via [vimtex](https://github.com/lervag/vimtex) <sup id="a1">[1](#f1)</sup>.
|
||||
+ Code folding with [nvim-ufo](https://github.com/kevinhwang91/nvim-ufo) and [statuscol.nvim](https://github.com/luukvbaal/statuscol.nvim)
|
||||
+ ......
|
||||
|
||||
# UI Demo
|
||||
|
||||
For more UI demos, see [here](https://github.com/jdhao/nvim-config/issues/15).
|
||||
For more UI demos, check [here](https://github.com/jdhao/nvim-config/issues/15).
|
||||
|
||||
## Start screen with alpha-nvim
|
||||
## Start screen with dashboard-nvim
|
||||
|
||||
<p align="center">
|
||||
<img src="https://user-images.githubusercontent.com/16662357/139459989-0537ded4-c119-4749-99bf-b551ca1ba118.jpg" width="800">
|
||||
<img src="https://user-images.githubusercontent.com/16662357/183256752-fb23b215-a6b8-4646-beed-9999f52d53f1.png" width="800">
|
||||
</p>
|
||||
|
||||
## fuzzy finding using LeaderF
|
||||
## File fuzzy finding using fzf-lua
|
||||
|
||||
<p align="center">
|
||||
<img src="https://user-images.githubusercontent.com/16662357/139462025-7bce98c5-d2d5-413f-9659-20545865cdca.gif" width="800">
|
||||
<img src="https://github.com/user-attachments/assets/3199e35d-121a-487b-bfd1-58eb69b0b48a" width="800">
|
||||
</p>
|
||||
|
||||
## Code autocompletion with nvim-cmp
|
||||
@@ -137,12 +137,18 @@ Go to a string starting with `se`
|
||||
<img src="https://user-images.githubusercontent.com/16662357/128589873-aadb8264-1098-4834-9876-fa66a309be05.gif" width="800">
|
||||
</p>
|
||||
|
||||
## code folding with nvim-ufo and statuscol.nvim
|
||||
|
||||
<p align="center">
|
||||
<img src="https://github.com/user-attachments/assets/a01a56b2-7c91-43de-b305-f2fbaa81dcec" width="800">
|
||||
</p>
|
||||
|
||||
# Shortcuts
|
||||
|
||||
Some of the shortcuts I use frequently is listed here. In the following shortcuts, `<leader>` represents ASCII character `,`.
|
||||
Some of the shortcuts I use frequently are listed here. In the following shortcuts, `<leader>` represents ASCII character `,`.
|
||||
|
||||
| Shortcut | Mode | platform | Description |
|
||||
|-------------------|---------------|-----------------|------------------------------------------------------------------|
|
||||
|-------------------|---------------|-----------------|--------------------------------------------------------------------------|
|
||||
| `<leader>ff` | Normal | Linux/macOS/Win | Fuzzy file searching in a floating window |
|
||||
| `<leader>fh` | Normal | Linux/macOS/Win | Fuzzy help file grepping in a floating window |
|
||||
| `<leader>fg` | Normal | Linux/macOS/Win | Fuzzy project-wide grepping in a floating window |
|
||||
@@ -162,19 +168,25 @@ Some of the shortcuts I use frequently is listed here. In the following shortcut
|
||||
| `<space>t` | Normal | Linux/macOS/Win | Toggle tag window (show project tags in the right window) |
|
||||
| `<leader>gs` | Normal | Linux/macOS/Win | Show Git status result |
|
||||
| `<leader>gw` | Normal | Linux/macOS/Win | Run Git add for current file |
|
||||
| `<leader>gd` | Normal | Linux/macOS/Win | Run git diff for current file |
|
||||
| `<leader>gc` | Normal | Linux/macOS/Win | Run git commit |
|
||||
| `<leader>gpl` | Normal | Linux/macOS/Win | Run git pull |
|
||||
| `<leader>gpu` | Normal | Linux/macOS/Win | Run git push |
|
||||
| `<F9>` | Normal | Linux/macOS/Win | Run current source file (for Python, C++) |
|
||||
| `<leader>gbd` | Normal | Linux/macOS/Win | Delete a branch |
|
||||
| `<leader>gbn` | Normal | Linux/macOS/Win | Create a new branch |
|
||||
| `<leader>gl` | Normal/Visual | Linux/macOS/Win | Get perm link for current/visually-select lines |
|
||||
| `<leader>gbr` | Normal | macOS | Browse current git repo in browser |
|
||||
| `<leader>gb` | Visual | macOS | Blame current line |
|
||||
| `<F9>` | Normal | Linux/macOS/Win | Compile&run current source file (for C++, LaTeX, Lua, Python) |
|
||||
| `<F11>` | Normal | Linux/macOS/Win | Toggle spell checking |
|
||||
| `<F12>` | Normal | Linux/macOS/Win | Toggle paste mode |
|
||||
| `\x` | Normal | Linux/macOS/Win | Close location or quickfix window |
|
||||
| `\d` | Normal | Linux/macOS/Win | Close current buffer and go to previous buffer |
|
||||
| `{count}gb` | Normal | Linux/macOS/Win | Go to buffer {count} or next buffer in the buffer list. |
|
||||
| `{count}gb` | Normal | Linux/macOS/Win | Go to buffer `{count}` or next buffer in the buffer list. |
|
||||
| `{operator}iB` | Normal | Linux/macOS/Win | Operate in the whole buffer, `{operator}` can be `v`, `y`, `c`, `d` etc. |
|
||||
| `Alt-k` | Normal | Linux/macOS/Win | Move current line or selected lines up |
|
||||
| `Alt-j` | Normal | Linux/macOS/Win | Move current line or selected lines down |
|
||||
| `Alt-m` | Normal | macOS/Win | Markdown previewing in system browser |
|
||||
| `Alt-Shift-m` | Normal | macOS/Win | Stopping Markdown previewing in system browser |
|
||||
| `ob` | Normal/Visual | macOS/Win | Open link under cursor or search visual selection |
|
||||
| `ctrl-u` | Insert | Linux/macOS/Win | Turn word under cursor to upper case |
|
||||
| `ctrl-t` | Insert | Linux/macOS/Win | Turn word under cursor to title case |
|
||||
| `jk` | Insert | Linux/macOS/Win | Return to Normal mode without lagging |
|
||||
@@ -184,10 +196,12 @@ Some of the shortcuts I use frequently is listed here. In the following shortcut
|
||||
In addition to commands provided by various plugins, I have also created some custom commands for personal use.
|
||||
|
||||
| command | description | example |
|
||||
|------------|-------------------------------------------------------------------------|--------------------------------|
|
||||
|--------------|-------------------------------------------------------------------------|--------------------------------|
|
||||
| `Redir` | capture command output to a tabpage for easier inspection. | `Redir hi` |
|
||||
| `Edit` | edit multiple files at the same time, supports globing | `Edit *.vim` |
|
||||
| `Datetime` | print current date and time or convert Unix time stamp to date and time | `Datetime 12345` or `Datetime` |
|
||||
| `JSONFormat` | format a JSON file | `JSONFormat` |
|
||||
| `CopyPath` | copy current file path to clipboard | `CopyPath relative` |
|
||||
|
||||
# Contributing
|
||||
|
||||
@@ -208,5 +222,3 @@ You may also be interested in my posts on configuring Nvim:
|
||||
+ [Config nvim on Linux for Python development](https://jdhao.github.io/2018/12/24/centos_nvim_install_use_guide_en/)
|
||||
+ [Nvim config on Windows 10](https://jdhao.github.io/2018/11/15/neovim_configuration_windows/)
|
||||
+ [Nvim-qt config on Windows 10](https://jdhao.github.io/2019/01/17/nvim_qt_settings_on_windows/)
|
||||
|
||||
<b id="f1">1:</b> Not enabled for Linux, you need to tweak [`lua/plugins.lua`](lua/plugins.lua) and change the condition for installing vimtex.[↩](#a1)
|
||||
|
||||
@@ -1,10 +1,5 @@
|
||||
set commentstring=//\ %s
|
||||
|
||||
set tabstop=2 " number of visual spaces per TAB
|
||||
set softtabstop=2 " number of spaces in tab when editing
|
||||
set shiftwidth=2 " number of spaces to use for autoindent
|
||||
set expandtab " expand tab to spaces so that tabs are spaces
|
||||
|
||||
" Disable inserting comment leader after hitting o or O or <Enter>
|
||||
set formatoptions-=o
|
||||
set formatoptions-=r
|
||||
@@ -39,6 +34,3 @@ function s:create_term_buf(_type, size) abort
|
||||
endif
|
||||
execute 'resize ' . a:size
|
||||
endfunction
|
||||
|
||||
" For delimitMate
|
||||
let b:delimitMate_matchpairs = "(:),[:],{:}"
|
||||
|
||||
1
after/ftplugin/gitconfig.vim
Normal file
1
after/ftplugin/gitconfig.vim
Normal file
@@ -0,0 +1 @@
|
||||
set commentstring=#\ %s
|
||||
3
after/ftplugin/javascript.vim
Normal file
3
after/ftplugin/javascript.vim
Normal file
@@ -0,0 +1,3 @@
|
||||
" Disable inserting comment leader after hitting o or O or <Enter>
|
||||
set formatoptions-=o
|
||||
set formatoptions-=r
|
||||
@@ -2,7 +2,6 @@
|
||||
set formatoptions-=o
|
||||
set formatoptions-=r
|
||||
|
||||
set tabstop=2 " number of visual spaces per TAB
|
||||
set softtabstop=2 " number of spaces in tab when editing
|
||||
set shiftwidth=2 " number of spaces to use for autoindent
|
||||
set expandtab " expand tab to spaces so that tabs are spaces
|
||||
nnoremap <buffer><silent> <F9> :luafile %<CR>
|
||||
|
||||
nnoremap <buffer><silent> <space>f <cmd>silent !stylua %<CR>
|
||||
|
||||
@@ -8,5 +8,9 @@ set sidescroll=5
|
||||
set sidescrolloff=2
|
||||
set colorcolumn=100
|
||||
|
||||
" For delimitMate
|
||||
let b:delimitMate_matchpairs = "(:),[:],{:}"
|
||||
set tabstop=4 " number of visual spaces per TAB
|
||||
set softtabstop=4 " number of spaces in tab when editing
|
||||
set shiftwidth=4 " number of spaces to use for autoindent
|
||||
set expandtab " expand tab to spaces so that tabs are spaces
|
||||
|
||||
nnoremap <buffer><silent> <space>f <cmd>silent !black %<CR>
|
||||
|
||||
1
after/ftplugin/sql.vim
Normal file
1
after/ftplugin/sql.vim
Normal file
@@ -0,0 +1 @@
|
||||
set commentstring=--\ %s
|
||||
@@ -1,4 +0,0 @@
|
||||
set tabstop=2 " number of visual spaces per TAB
|
||||
set softtabstop=2 " number of spaces in tab when editing
|
||||
set shiftwidth=2 " number of spaces to use for autoindent
|
||||
set expandtab " expand tab to spaces so that tabs are spaces
|
||||
|
||||
@@ -12,7 +12,4 @@ set foldmethod=expr foldexpr=utils#VimFolds(v:lnum) foldtext=utils#MyFoldText()
|
||||
" see `:h K` and https://stackoverflow.com/q/15867323/6064933
|
||||
set keywordprg=:help
|
||||
|
||||
set tabstop=2 " number of visual spaces per TAB
|
||||
set softtabstop=2 " number of spaces in tab when editing
|
||||
set shiftwidth=2 " number of spaces to use for autoindent
|
||||
set expandtab " expand tab to spaces so that tabs are spaces
|
||||
nnoremap <buffer><silent> <F9> :source %<CR>
|
||||
|
||||
@@ -1,8 +1,3 @@
|
||||
set tabstop=2 " number of visual spaces per TAB
|
||||
set softtabstop=2 " number of spaces in tab when editing
|
||||
set shiftwidth=2 " number of spaces to use for autoindent
|
||||
set expandtab " expand tab to spaces so that tabs are spaces
|
||||
|
||||
" Turn off syntax highlighting for large YAML files.
|
||||
if line('$') > 500
|
||||
setlocal syntax=OFF
|
||||
|
||||
@@ -15,7 +15,7 @@ function! buf_utils#GoToBuffer(count, direction) abort
|
||||
" we are essentially mixing Lua and vim script. We need to make sure that
|
||||
" args inside vim.notify() are valid vim values. The conversion from vim
|
||||
" value to lua value will be done by Nvim. See also https://github.com/neovim/neovim/pull/11338.
|
||||
call v:lua.vim.notify('Invalid bufnr: ' . a:count, 'error', {'title': 'nvim-config'})
|
||||
call v:lua.vim.notify('Invalid bufnr: ' . a:count, 4, {'title': 'nvim-config'})
|
||||
return
|
||||
endif
|
||||
|
||||
|
||||
@@ -10,38 +10,6 @@ function! s:Single_quote(str) abort
|
||||
return "'" . substitute(copy(a:str), "'", "''", 'g') . "'"
|
||||
endfunction
|
||||
|
||||
" Check the syntax group in the current cursor position, see
|
||||
" https://stackoverflow.com/q/9464844/6064933 and
|
||||
" https://jordanelver.co.uk/blog/2015/05/27/working-with-vim-colorschemes/
|
||||
function! utils#SynGroup() abort
|
||||
if !exists('*synstack')
|
||||
return
|
||||
endif
|
||||
echo map(synstack(line('.'), col('.')), 'synIDattr(v:val, "name")')
|
||||
endfunction
|
||||
|
||||
" Check if a colorscheme exists in runtimepath.
|
||||
" The following two functions are inspired by https://stackoverflow.com/a/5703164/6064933.
|
||||
function! utils#HasColorscheme(name) abort
|
||||
let l:pat = printf('colors/%s.vim', a:name)
|
||||
return !empty(globpath(&runtimepath, l:pat))
|
||||
endfunction
|
||||
|
||||
" Generate random integers in the range [Low, High] in pure vim script,
|
||||
" adapted from https://stackoverflow.com/a/12739441/6064933
|
||||
function! utils#RandInt(Low, High) abort
|
||||
" Use lua to generate random int. It is faster. Ref: https://stackoverflow.com/a/20157671/6064933
|
||||
call v:lua.math.randomseed(localtime())
|
||||
return v:lua.math.random(a:Low, a:High)
|
||||
endfunction
|
||||
|
||||
" Selection a random element from a sequence/list
|
||||
function! utils#RandElement(seq) abort
|
||||
let l:idx = utils#RandInt(0, len(a:seq)-1)
|
||||
|
||||
return a:seq[l:idx]
|
||||
endfunction
|
||||
|
||||
" Custom fold expr, adapted from https://vi.stackexchange.com/a/9094/15292
|
||||
function! utils#VimFolds(lnum) abort
|
||||
" get content of current line and the line below
|
||||
@@ -131,9 +99,11 @@ function! utils#Get_titlestr() abort
|
||||
if g:is_linux
|
||||
let l:title_str = hostname() . ' '
|
||||
endif
|
||||
let l:title_str = l:title_str . expand('%:p:~') . ' '
|
||||
if &buflisted
|
||||
let l:title_str = l:title_str . strftime('%Y-%m-%d %H:%M',getftime(expand('%')))
|
||||
|
||||
let l:buf_path = expand('%:p:~')
|
||||
let l:title_str = l:title_str . l:buf_path . ' '
|
||||
if &buflisted && l:buf_path != ""
|
||||
let l:title_str = l:title_str . strftime('%Y-%m-%d %H:%M:%S%z', getftime(expand('%')))
|
||||
endif
|
||||
|
||||
return l:title_str
|
||||
@@ -141,34 +111,22 @@ endfunction
|
||||
|
||||
" Output current time or unix timestamp in human-readable format.
|
||||
function! utils#iso_time(timestamp) abort
|
||||
if a:timestamp
|
||||
return strftime('%Y-%m-%d %H:%M:%S%z', a:timestamp)
|
||||
endif
|
||||
|
||||
" Get current datetime
|
||||
if !a:timestamp
|
||||
return strftime('%Y-%m-%d %H:%M:%S%z')
|
||||
endfunction
|
||||
|
||||
" Check if we are inside a Git repo.
|
||||
function! utils#Inside_git_repo() abort
|
||||
let res = system('git rev-parse --is-inside-work-tree')
|
||||
if match(res, 'true') == -1
|
||||
return v:false
|
||||
else
|
||||
" Manually trigger a specical user autocmd InGitRepo (to use it for
|
||||
" lazyloading of fugitive by packer.nvim).
|
||||
" See also https://github.com/wbthomason/packer.nvim/discussions/534.
|
||||
doautocmd User InGitRepo
|
||||
return v:true
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! utils#GetGitBranch()
|
||||
let l:res = systemlist('git rev-parse --abbrev-ref HEAD')[0]
|
||||
if match(l:res, 'fatal') != -1
|
||||
return ''
|
||||
" this timestamp in expressed in milliseconds
|
||||
if len(a:timestamp) == 13
|
||||
let l:timestamp = a:timestamp[:-4]
|
||||
" this timestamp in expressed in microseconds
|
||||
elseif len(a:timestamp) == 16
|
||||
let l:timestamp = a:timestamp[:-7]
|
||||
else
|
||||
return l:res
|
||||
let l:timestamp = a:timestamp
|
||||
endif
|
||||
return strftime('%Y-%m-%d %H:%M:%S%z', l:timestamp)
|
||||
|
||||
endfunction
|
||||
|
||||
" Redirect command output to a register for later processing.
|
||||
@@ -196,14 +154,3 @@ function! utils#MultiEdit(patterns) abort
|
||||
endfor
|
||||
endfor
|
||||
endfunction
|
||||
|
||||
function! utils#add_pack(name) abort
|
||||
let l:status = v:true
|
||||
try
|
||||
execute printf("packadd! %s", a:name)
|
||||
catch /^Vim\%((\a\+)\)\=:E919/
|
||||
let l:status = v:false
|
||||
endtry
|
||||
|
||||
return l:status
|
||||
endfunction
|
||||
|
||||
@@ -1,137 +0,0 @@
|
||||
" Do not use smart case in command line mode, extracted from https://vi.stackexchange.com/a/16511/15292.
|
||||
augroup dynamic_smartcase
|
||||
autocmd!
|
||||
autocmd CmdLineEnter : set nosmartcase
|
||||
autocmd CmdLineLeave : set smartcase
|
||||
augroup END
|
||||
|
||||
augroup term_settings
|
||||
autocmd!
|
||||
" Do not use number and relative number for terminal inside nvim
|
||||
autocmd TermOpen * setlocal norelativenumber nonumber
|
||||
" Go to insert mode by default to start typing command
|
||||
autocmd TermOpen * startinsert
|
||||
augroup END
|
||||
|
||||
" More accurate syntax highlighting? (see `:h syn-sync`)
|
||||
augroup accurate_syn_highlight
|
||||
autocmd!
|
||||
autocmd BufEnter * :syntax sync fromstart
|
||||
augroup END
|
||||
|
||||
" Return to last cursor position when opening a file
|
||||
augroup resume_cursor_position
|
||||
autocmd!
|
||||
autocmd BufReadPost * call s:resume_cursor_position()
|
||||
augroup END
|
||||
|
||||
" Only resume last cursor position when there is no go-to-line command (something like '+23').
|
||||
function s:resume_cursor_position() abort
|
||||
if line("'\"") > 1 && line("'\"") <= line("$") && &ft !~# 'commit'
|
||||
let l:args = v:argv " command line arguments
|
||||
for l:cur_arg in l:args
|
||||
" Check if a go-to-line command is given.
|
||||
let idx = match(l:cur_arg, '\v^\+(\d){1,}$')
|
||||
if idx != -1
|
||||
return
|
||||
endif
|
||||
endfor
|
||||
|
||||
execute "normal! g`\"zvzz"
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" Display a message when the current file is not in utf-8 format.
|
||||
" Note that we need to use `unsilent` command here because of this issue:
|
||||
" https://github.com/vim/vim/issues/4379
|
||||
augroup non_utf8_file_warn
|
||||
autocmd!
|
||||
" we can not use `lua vim.notify()`: it will error out E5107 parsing lua.
|
||||
autocmd BufRead * if &fileencoding != 'utf-8' | call v:lua.vim.notify('File not in UTF-8 format!', 'warn', {'title': 'nvim-config'}) | endif
|
||||
augroup END
|
||||
|
||||
" Automatically reload the file if it is changed outside of Nvim, see
|
||||
" https://unix.stackexchange.com/a/383044/221410. It seems that `checktime`
|
||||
" command does not work in command line. We need to check if we are in command
|
||||
" line before executing this command. See also
|
||||
" https://vi.stackexchange.com/a/20397/15292.
|
||||
augroup auto_read
|
||||
autocmd!
|
||||
autocmd FileChangedShellPost * call v:lua.vim.notify("File changed on disk. Buffer reloaded!", 'warn', {'title': 'nvim-config'})
|
||||
autocmd FocusGained,CursorHold * if getcmdwintype() == '' | checktime | endif
|
||||
augroup END
|
||||
|
||||
augroup numbertoggle
|
||||
autocmd!
|
||||
autocmd BufEnter,FocusGained,InsertLeave,WinEnter * if &nu | set rnu | endif
|
||||
autocmd BufLeave,FocusLost,InsertEnter,WinLeave * if &nu | set nornu | endif
|
||||
augroup END
|
||||
|
||||
" Define or override some highlight groups
|
||||
augroup custom_highlight
|
||||
autocmd!
|
||||
autocmd ColorScheme * call s:custom_highlight()
|
||||
augroup END
|
||||
|
||||
function! s:custom_highlight() abort
|
||||
" For yank highlight
|
||||
highlight YankColor ctermfg=59 ctermbg=41 guifg=#34495E guibg=#2ECC71
|
||||
|
||||
" For cursor colors
|
||||
highlight Cursor cterm=bold gui=bold guibg=#00c918 guifg=black
|
||||
highlight Cursor2 guifg=red guibg=red
|
||||
|
||||
" For floating windows border highlight
|
||||
highlight FloatBorder guifg=LightGreen guibg=NONE
|
||||
|
||||
" highlight for matching parentheses
|
||||
highlight MatchParen cterm=bold,underline gui=bold,underline
|
||||
endfunction
|
||||
|
||||
" highlight yanked region, see `:h lua-highlight`
|
||||
augroup highlight_yank
|
||||
autocmd!
|
||||
au TextYankPost * silent! lua vim.highlight.on_yank{higroup="YankColor", timeout=300, on_visual=false}
|
||||
augroup END
|
||||
|
||||
augroup auto_close_win
|
||||
autocmd!
|
||||
autocmd BufEnter * call s:quit_current_win()
|
||||
augroup END
|
||||
|
||||
" Quit Nvim if we have only one window, and its filetype match our pattern.
|
||||
function! s:quit_current_win() abort
|
||||
let l:quit_filetypes = ['qf', 'vista', 'NvimTree']
|
||||
|
||||
let l:should_quit = v:true
|
||||
|
||||
let l:tabwins = nvim_tabpage_list_wins(0)
|
||||
for w in l:tabwins
|
||||
let l:buf = nvim_win_get_buf(w)
|
||||
let l:bf = getbufvar(l:buf, '&filetype')
|
||||
|
||||
if index(l:quit_filetypes, l:bf) == -1
|
||||
let l:should_quit = v:false
|
||||
endif
|
||||
endfor
|
||||
|
||||
if l:should_quit
|
||||
qall
|
||||
endif
|
||||
endfunction
|
||||
|
||||
augroup git_repo_check
|
||||
autocmd!
|
||||
autocmd VimEnter,DirChanged * call utils#Inside_git_repo()
|
||||
augroup END
|
||||
|
||||
" Auto-generate packer_compiled.lua file
|
||||
augroup packer_auto_compile
|
||||
autocmd!
|
||||
autocmd BufWritePost */nvim/lua/plugins.lua source <afile> | PackerCompile
|
||||
augroup END
|
||||
|
||||
augroup auto_create_dir
|
||||
autocmd!
|
||||
autocmd BufWritePre * lua require('utils').may_create_dir()
|
||||
augroup END
|
||||
@@ -1,72 +0,0 @@
|
||||
"{ Global Variable
|
||||
"{{ Custom variables
|
||||
let g:is_win = (has('win32') || has('win64')) ? v:true : v:false
|
||||
let g:is_linux = (has('unix') && !has('macunix')) ? v:true : v:false
|
||||
let g:is_mac = has('macunix') ? v:true : v:false
|
||||
let g:logging_level = 'info'
|
||||
"}}
|
||||
|
||||
"{{ Builtin variables
|
||||
" Disable perl provider
|
||||
let g:loaded_perl_provider = 0
|
||||
|
||||
" Disable ruby provider
|
||||
let g:loaded_ruby_provider = 0
|
||||
|
||||
" Disable node provider
|
||||
let g:loaded_node_provider = 0
|
||||
|
||||
let g:did_install_default_menus = 1 " do not load menu
|
||||
|
||||
" Path to Python 3 interpreter (must be an absolute path), make startup
|
||||
" faster. See https://neovim.io/doc/user/provider.html.
|
||||
if executable('python')
|
||||
if g:is_win
|
||||
let g:python3_host_prog=substitute(exepath('python'), '.exe$', '', 'g')
|
||||
elseif g:is_linux || g:is_mac
|
||||
let g:python3_host_prog=exepath('python')
|
||||
endif
|
||||
else
|
||||
echoerr 'Python 3 executable not found! You must install Python 3 and set its PATH correctly!'
|
||||
endif
|
||||
|
||||
" Custom mapping <leader> (see `:h mapleader` for more info)
|
||||
let g:mapleader = ','
|
||||
|
||||
" Enable highlighting for lua HERE doc inside vim script
|
||||
let g:vimsyn_embed = 'l'
|
||||
|
||||
" Use English as main language
|
||||
language en_US.utf-8
|
||||
|
||||
" use filetype.lua instead of filetype.vim
|
||||
let g:do_filetype_lua = 1
|
||||
let g:did_load_filetypes = 0
|
||||
"}}
|
||||
|
||||
"{{ Disable loading certain plugins
|
||||
" Whether to load netrw by default, see
|
||||
" https://github.com/bling/dotvim/issues/4
|
||||
let g:loaded_netrw = 1
|
||||
let g:loaded_netrwPlugin = 1
|
||||
let g:netrw_liststyle = 3
|
||||
if g:is_win
|
||||
let g:netrw_http_cmd = 'curl --ssl-no-revoke -Lo'
|
||||
endif
|
||||
|
||||
" Do not load tohtml.vim
|
||||
let g:loaded_2html_plugin = 1
|
||||
|
||||
" Do not load zipPlugin.vim, gzip.vim and tarPlugin.vim (all these plugins are
|
||||
" related to checking files inside compressed files)
|
||||
let g:loaded_zipPlugin = 1
|
||||
let loaded_gzip = 1
|
||||
let g:loaded_tarPlugin = 1
|
||||
|
||||
let g:loaded_tutor_mode_plugin = 1 " do not load the tutor plugin
|
||||
|
||||
" Do not use builtin matchit.vim and matchparen.vim since we use vim-matchup
|
||||
let g:loaded_matchit = 1
|
||||
let g:loaded_matchparen = 1
|
||||
"}}
|
||||
"}
|
||||
@@ -1,192 +0,0 @@
|
||||
" Save key strokes (now we do not need to press shift to enter command mode).
|
||||
" Vim-sneak has also mapped `;`, so using the below mapping will break the map
|
||||
" used by vim-sneak
|
||||
nnoremap ; :
|
||||
xnoremap ; :
|
||||
|
||||
" Quicker way to open command window
|
||||
nnoremap q; q:
|
||||
|
||||
" Turn the word under cursor to upper case
|
||||
inoremap <c-u> <Esc>viwUea
|
||||
|
||||
" Turn the current word into title case
|
||||
inoremap <c-t> <Esc>b~lea
|
||||
|
||||
" Paste non-linewise text above or below current cursor,
|
||||
" see https://stackoverflow.com/a/1346777/6064933
|
||||
nnoremap <leader>p m`o<ESC>p``
|
||||
nnoremap <leader>P m`O<ESC>p``
|
||||
|
||||
" Shortcut for faster save and quit
|
||||
nnoremap <silent> <leader>w :<C-U>update<CR>
|
||||
" Saves the file if modified and quit
|
||||
nnoremap <silent> <leader>q :<C-U>x<CR>
|
||||
" Quit all opened buffers
|
||||
nnoremap <silent> <leader>Q :<C-U>qa!<CR>
|
||||
|
||||
" Navigation in the location and quickfix list
|
||||
nnoremap <silent> [l :<C-U>lprevious<CR>zv
|
||||
nnoremap <silent> ]l :<C-U>lnext<CR>zv
|
||||
nnoremap <silent> [L :<C-U>lfirst<CR>zv
|
||||
nnoremap <silent> ]L :<C-U>llast<CR>zv
|
||||
nnoremap <silent> [q :<C-U>cprevious<CR>zv
|
||||
nnoremap <silent> ]q :<C-U>cnext<CR>zv
|
||||
nnoremap <silent> [Q :<C-U>cfirst<CR>zv
|
||||
nnoremap <silent> ]Q :<C-U>clast<CR>zv
|
||||
|
||||
" Close location list or quickfix list if they are present,
|
||||
" see https://superuser.com/q/355325/736190
|
||||
nnoremap<silent> \x :<C-U>windo lclose <bar> cclose<CR>
|
||||
|
||||
" Close a buffer and switching to another buffer, do not close the
|
||||
" window, see https://stackoverflow.com/q/4465095/6064933
|
||||
nnoremap <silent> \d :<C-U>bprevious <bar> bdelete #<CR>
|
||||
|
||||
" Insert a blank line below or above current line (do not move the cursor),
|
||||
" see https://stackoverflow.com/a/16136133/6064933
|
||||
nnoremap <expr> <Space>o printf('m`%so<ESC>``', v:count1)
|
||||
nnoremap <expr> <Space>O printf('m`%sO<ESC>``', v:count1)
|
||||
|
||||
" Insert a space after current character
|
||||
nnoremap <Space><Space> a<Space><ESC>h
|
||||
|
||||
" Move the cursor based on physical lines, not the actual lines.
|
||||
nnoremap <expr> j (v:count == 0 ? 'gj' : 'j')
|
||||
nnoremap <expr> k (v:count == 0 ? 'gk' : 'k')
|
||||
nnoremap ^ g^
|
||||
nnoremap 0 g0
|
||||
|
||||
" Do not include white space characters when using $ in visual mode,
|
||||
" see https://vi.stackexchange.com/q/12607/15292
|
||||
xnoremap $ g_
|
||||
|
||||
" Jump to matching pairs easily in normal mode
|
||||
nnoremap <Tab> %
|
||||
|
||||
" Go to start or end of line easier
|
||||
nnoremap H ^
|
||||
xnoremap H ^
|
||||
nnoremap L g_
|
||||
xnoremap L g_
|
||||
|
||||
" Continuous visual shifting (does not exit Visual mode), `gv` means
|
||||
" to reselect previous visual area, see https://superuser.com/q/310417/736190
|
||||
xnoremap < <gv
|
||||
xnoremap > >gv
|
||||
|
||||
" When completion menu is shown, use <cr> to select an item and do not add an
|
||||
" annoying newline. Otherwise, <enter> is what it is. For more info , see
|
||||
" https://superuser.com/a/941082/736190 and
|
||||
" https://unix.stackexchange.com/q/162528/221410
|
||||
" inoremap <expr> <cr> ((pumvisible())?("\<C-Y>"):("\<cr>"))
|
||||
" Use <esc> to close auto-completion menu
|
||||
" inoremap <expr> <esc> ((pumvisible())?("\<C-e>"):("\<esc>"))
|
||||
|
||||
" Tab-complete, see https://vi.stackexchange.com/q/19675/15292.
|
||||
inoremap <expr> <tab> pumvisible() ? "\<c-n>" : "\<tab>"
|
||||
inoremap <expr> <s-tab> pumvisible() ? "\<c-p>" : "\<s-tab>"
|
||||
|
||||
" Edit and reload init.vim quickly
|
||||
nnoremap <silent> <leader>ev :<C-U>tabnew $MYVIMRC <bar> tcd %:h<cr>
|
||||
nnoremap <silent> <leader>sv :<C-U>silent update $MYVIMRC <bar> source $MYVIMRC <bar>
|
||||
\ call v:lua.vim.notify("Nvim config successfully reloaded!", 'info', {'title': 'nvim-config'})<cr>
|
||||
|
||||
" Reselect the text that has just been pasted, see also https://stackoverflow.com/a/4317090/6064933.
|
||||
nnoremap <expr> <leader>v printf('`[%s`]', getregtype()[0])
|
||||
|
||||
" Search in selected region
|
||||
xnoremap / :<C-U>call feedkeys('/\%>'.(line("'<")-1).'l\%<'.(line("'>")+1)."l")<CR>
|
||||
|
||||
" Find and replace (like Sublime Text 3)
|
||||
nnoremap <C-H> :%s/
|
||||
xnoremap <C-H> :s/
|
||||
|
||||
" Change current working directory locally and print cwd after that,
|
||||
" see https://vim.fandom.com/wiki/Set_working_directory_to_the_current_file
|
||||
nnoremap <silent> <leader>cd :<C-U>lcd %:p:h<CR>:pwd<CR>
|
||||
|
||||
" Use Esc to quit builtin terminal
|
||||
tnoremap <ESC> <C-\><C-n>
|
||||
|
||||
" Toggle spell checking (autosave does not play well with z=, so we disable it
|
||||
" when we are doing spell checking)
|
||||
nnoremap <silent> <F11> :<C-U>set spell!<cr>
|
||||
inoremap <silent> <F11> <C-O>:<C-U>set spell!<cr>
|
||||
|
||||
" Change text without putting it into the vim register,
|
||||
" see https://stackoverflow.com/q/54255/6064933
|
||||
nnoremap c "_c
|
||||
nnoremap C "_C
|
||||
nnoremap cc "_cc
|
||||
xnoremap c "_c
|
||||
|
||||
" Remove trailing whitespace characters
|
||||
nnoremap <silent> <leader><Space> :<C-U>StripTrailingWhitespace<CR>
|
||||
|
||||
" check the syntax group of current cursor position
|
||||
nnoremap <silent> <leader>st :<C-U>call utils#SynGroup()<CR>
|
||||
|
||||
" Clear highlighting
|
||||
if maparg('<C-L>', 'n') ==# ''
|
||||
nnoremap <silent> <C-L> :<C-U>nohlsearch<C-R>=has('diff')?'<Bar>diffupdate':''<CR><CR><C-L>
|
||||
endif
|
||||
|
||||
" Copy entire buffer.
|
||||
nnoremap <silent> <leader>y :<C-U>%y<CR>
|
||||
|
||||
" Toggle cursor column
|
||||
nnoremap <silent> <leader>cl :<C-U>call utils#ToggleCursorCol()<CR>
|
||||
|
||||
" Move current line up and down
|
||||
nnoremap <silent> <A-k> <Cmd>call utils#SwitchLine(line('.'), 'up')<CR>
|
||||
nnoremap <silent> <A-j> <Cmd>call utils#SwitchLine(line('.'), 'down')<CR>
|
||||
|
||||
" Move current visual-line selection up and down
|
||||
xnoremap <silent> <A-k> :<C-U>call utils#MoveSelection('up')<CR>
|
||||
xnoremap <silent> <A-j> :<C-U>call utils#MoveSelection('down')<CR>
|
||||
|
||||
" Replace visual selection with text in register, but not contaminate the
|
||||
" register, see also https://stackoverflow.com/q/10723700/6064933.
|
||||
xnoremap p "_c<ESC>p
|
||||
|
||||
nnoremap <silent> gb :<C-U>call buf_utils#GoToBuffer(v:count, 'forward')<CR>
|
||||
nnoremap <silent> gB :<C-U>call buf_utils#GoToBuffer(v:count, 'backward')<CR>
|
||||
|
||||
nnoremap <Left> <C-W>h
|
||||
nnoremap <Right> <C-W>l
|
||||
nnoremap <Up> <C-W>k
|
||||
nnoremap <Down> <C-W>j
|
||||
|
||||
" Text objects for URL
|
||||
xnoremap <silent> iu :<C-U>call text_obj#URL()<CR>
|
||||
onoremap <silent> iu :<C-U>call text_obj#URL()<CR>
|
||||
|
||||
" Text objects for entire buffer
|
||||
xnoremap <silent> iB :<C-U>call text_obj#Buffer()<CR>
|
||||
onoremap <silent> iB :<C-U>call text_obj#Buffer()<CR>
|
||||
|
||||
" Do not move my cursor when joining lines.
|
||||
nnoremap J mzJ`z
|
||||
|
||||
" Break inserted text into smaller undo units.
|
||||
for ch in [',', '.', '!', '?', ';', ':']
|
||||
execute printf('inoremap %s %s<C-g>u', ch, ch)
|
||||
endfor
|
||||
|
||||
" insert semicolon in the end
|
||||
inoremap <A-;> <ESC>miA;<ESC>`ii
|
||||
|
||||
" Keep cursor position after yanking
|
||||
nnoremap y myy
|
||||
xnoremap y myy
|
||||
|
||||
augroup restore_after_yank
|
||||
autocmd!
|
||||
autocmd TextYankPost * call s:restore_cursor()
|
||||
augroup END
|
||||
|
||||
function! s:restore_cursor() abort
|
||||
silent! normal `y
|
||||
silent! delmarks y
|
||||
endfunction
|
||||
@@ -1,91 +0,0 @@
|
||||
let s:theme_setup_dict = {}
|
||||
|
||||
function! s:theme_setup_dict.gruvbox8() dict abort
|
||||
" Italic options should be put before colorscheme setting,
|
||||
" see https://github.com/morhetz/gruvbox/wiki/Terminal-specific#1-italics-is-disabled
|
||||
let g:gruvbox_italics=1
|
||||
let g:gruvbox_italicize_strings=1
|
||||
let g:gruvbox_filetype_hi_groups = 1
|
||||
let g:gruvbox_plugin_hi_groups = 1
|
||||
colorscheme gruvbox8_hard
|
||||
endfunction
|
||||
|
||||
function! s:theme_setup_dict.onedark() dict abort
|
||||
colorscheme onedark
|
||||
endfunction
|
||||
|
||||
function! s:theme_setup_dict.edge() dict abort
|
||||
let g:edge_enable_italic = 1
|
||||
let g:edge_better_performance = 1
|
||||
colorscheme edge
|
||||
endfunction
|
||||
|
||||
function! s:theme_setup_dict.sonokai() dict abort
|
||||
let g:sonokai_enable_italic = 1
|
||||
let g:sonokai_better_performance = 1
|
||||
colorscheme sonokai
|
||||
endfunction
|
||||
|
||||
function! s:theme_setup_dict.gruvbox_material() dict abort
|
||||
let g:gruvbox_material_enable_italic = 1
|
||||
let g:gruvbox_material_better_performance = 1
|
||||
colorscheme gruvbox-material
|
||||
endfunction
|
||||
|
||||
function! s:theme_setup_dict.nord() dict abort
|
||||
colorscheme nord
|
||||
endfunction
|
||||
|
||||
function! s:theme_setup_dict.doom_one() dict abort
|
||||
colorscheme doom-one
|
||||
endfunction
|
||||
|
||||
function! s:theme_setup_dict.everforest() dict abort
|
||||
let g:everforest_enable_italic = 1
|
||||
let g:everforest_better_performance = 1
|
||||
colorscheme everforest
|
||||
endfunction
|
||||
|
||||
function! s:theme_setup_dict.nightfox() dict abort
|
||||
colorscheme nordfox
|
||||
endfunction
|
||||
|
||||
function! s:theme_setup_dict.kanagawa() dict abort
|
||||
colorscheme kanagawa
|
||||
endfunction
|
||||
|
||||
" Theme to directory name mapping, because theme repo name is not necessarily
|
||||
" the same as the theme name itself.
|
||||
let s:theme2dir = {
|
||||
\ 'gruvbox8' : 'vim-gruvbox8',
|
||||
\ 'onedark': 'onedark.nvim',
|
||||
\ 'edge' : 'edge',
|
||||
\ 'sonokai': 'sonokai',
|
||||
\ 'gruvbox_material': 'gruvbox-material',
|
||||
\ 'nord': 'nord.nvim',
|
||||
\ 'doom_one': 'doom-one.nvim',
|
||||
\ 'everforest' :'everforest',
|
||||
\ 'nightfox': 'nightfox.nvim',
|
||||
\ 'kanagawa': 'kanagawa.nvim',
|
||||
\ }
|
||||
|
||||
let s:theme = utils#RandElement(keys(s:theme2dir))
|
||||
let s:colorscheme_func = printf('s:theme_setup_dict.%s()', s:theme)
|
||||
|
||||
if !has_key(s:theme_setup_dict, s:theme)
|
||||
let s:msg = "Invalid colorscheme function: " . s:colorscheme_func
|
||||
call v:lua.vim.notify(s:msg, 'error', {'title': 'nvim-config'})
|
||||
finish
|
||||
endif
|
||||
|
||||
let s:status = utils#add_pack(s:theme2dir[s:theme])
|
||||
if !s:status
|
||||
echomsg printf("Theme %s not installed. Run PackerSync to install.", s:theme)
|
||||
finish
|
||||
endif
|
||||
|
||||
execute 'call ' . s:colorscheme_func
|
||||
if g:logging_level == 'info'
|
||||
let s:msg1 = "Colorscheme: " . s:theme
|
||||
call v:lua.vim.notify(s:msg1, 'info', {'title': 'nvim-config'})
|
||||
endif
|
||||
154
docs/README.md
154
docs/README.md
@@ -2,9 +2,48 @@ This doc summarizes how to install and use this configuration in detail.
|
||||
|
||||
# Pre-requisite
|
||||
|
||||
## Terminal emulators
|
||||
|
||||
Which [terminal emulator](https://en.wikipedia.org/wiki/Terminal_emulator) we choose to use greatly affects the appearance and features of Nvim.
|
||||
Since Nvim supports true colors, terminals that support true colors are preferred.
|
||||
For a list of terminals that support true colors, see [here](https://github.com/termstandard/colors).
|
||||
|
||||
For macOS, we can use [kitty](https://sw.kovidgoyal.net/kitty/), [iterm2](https://www.iterm2.com/), [wezterm](https://wezfurlong.org/wezterm/) or [Alacritty](https://github.com/jwilm/alacritty).
|
||||
|
||||
If you ssh to Linux server on Windows, I recommend [wsltty](https://github.com/mintty/wsltty) and [Cygwin](https://www.cygwin.com/),
|
||||
both of them use [mintty](https://github.com/mintty/mintty) as the terminal emulator.
|
||||
For the latest version of Windows 10, you can also try [Windows Terminal](https://github.com/microsoft/terminal).
|
||||
|
||||
## Patched Fonts
|
||||
|
||||
Since statusline or file explorer plugins often use Unicode symbols not available in normal font,
|
||||
we need to install a patched font from the [nerd-fonts](https://github.com/ryanoasis/nerd-fonts) project.
|
||||
|
||||
# Automatic installation
|
||||
|
||||
## Automatic Installation for Linux
|
||||
|
||||
To set up a workable Nvim environment on Linux,
|
||||
I use [a bash script](nvim_setup_linux.sh) to automatically install necessary dependencies, Nvim itself and configs.
|
||||
|
||||
Note that the variable `PYTHON_INSTALLED`, `SYSTEM_PYTHON` and `ADD_TO_SYSTEM_PATH` in the script
|
||||
should be set properly based on your environment.
|
||||
|
||||
## Automatic installation for Windows
|
||||
|
||||
Run the script [nvim_setup_windows.ps1](nvim_setup_windows.ps1) in PowerShell **with Administrator rights**:
|
||||
|
||||
```
|
||||
.\docs\nvim_setup_windows.ps1
|
||||
```
|
||||
|
||||
# Manual install
|
||||
|
||||
There are a few dependencies if we want to use Nvim for efficient editing and development work.
|
||||
|
||||
## Python
|
||||
## Dependencies
|
||||
|
||||
### Python
|
||||
|
||||
A lot of Nvim plugins are mainly written in Python, so we must install Python 3.
|
||||
The easiest way to install is via [Anaconda](https://docs.anaconda.com/anaconda/install/index.html) or [Miniconda](https://docs.conda.io/en/latest/miniconda.html).
|
||||
@@ -12,7 +51,7 @@ The easiest way to install is via [Anaconda](https://docs.anaconda.com/anaconda/
|
||||
After installation, make sure that you can run `python --version`,
|
||||
and that the output should be Python 3.x.
|
||||
|
||||
## Pynvim
|
||||
### Pynvim
|
||||
|
||||
Nvim relies on [pynvim](https://github.com/neovim/pynvim) to communicate with plugins that utilize its Python binding.
|
||||
Pynvim is required by plugins such as [wilder.nvim](https://github.com/gelguy/wilder.nvim).
|
||||
@@ -21,19 +60,19 @@ Pynvim is required by plugins such as [wilder.nvim](https://github.com/gelguy/wi
|
||||
pip install -U pynvim
|
||||
```
|
||||
|
||||
## python-lsp-server
|
||||
### python-lsp-server
|
||||
|
||||
[python-lsp-server (pylsp)](https://github.com/python-lsp/python-lsp-server) is a Python [Language Server](https://microsoft.github.io/language-server-protocol/) for completion, linting, go to definition, etc.
|
||||
|
||||
```
|
||||
pip install 'python-lsp-server[all]' pylsp-mypy pyls-isort
|
||||
pip install 'python-lsp-server[all]' pylsp-mypy python-lsp-isort python-lsp-black
|
||||
```
|
||||
|
||||
Note the executable for pylsp is also named `pylsp`. You need to set its PATH correctly.
|
||||
If you use pip from Anaconda, the executable path may be something like `$CONDA_ROOT/bin/pylsp`.
|
||||
For native python, the path for pylsp may be like `$HOME/.local/bin/pylsp`
|
||||
|
||||
## Node
|
||||
### Node
|
||||
|
||||
We need to install node.js from [here](https://nodejs.org/en/download/).
|
||||
For Linux, you can use the following script:
|
||||
@@ -60,7 +99,7 @@ source ~/.bash_profile
|
||||
# source ~/.zshrc
|
||||
```
|
||||
|
||||
## vim-language-server
|
||||
### vim-language-server
|
||||
|
||||
[vim-language-server](https://github.com/iamcco/vim-language-server) provides completion for vim script. We can install vim-language-server globally:
|
||||
|
||||
@@ -70,25 +109,25 @@ npm install -g vim-language-server
|
||||
|
||||
vim-language-server is installed in the same directory as the node executable.
|
||||
|
||||
## Git
|
||||
### Git
|
||||
|
||||
Git is required by plugin manager [packer.nvim](https://github.com/wbthomason/packer.nvim) and other git-related plugins.
|
||||
Git is required by plugin manager [lazy.nvim](https://github.com/folke/lazy.nvim) and other git-related plugins.
|
||||
|
||||
For Linux and macOS, Git is usually pre-installed.
|
||||
The version of Git on the Linux system may be too old so that plugins may break.
|
||||
Check [here](https://jdhao.github.io/2021/03/27/upgrade_git_on_linux/) on how to install and set up the latest version of Git.
|
||||
For Windows, install [Git for Windows](https://git-scm.com/download/win) and make sure you can run `git` from command line.
|
||||
|
||||
## ctags
|
||||
### universal-ctags
|
||||
|
||||
In order to use tags related plugins such as [vista.vim](https://github.com/liuchengxu/vista.vim), we need to install a ctags distribution.
|
||||
Universal-ctags is preferred.
|
||||
|
||||
To install it on Linux, we need to build it from source. See [here](https://askubuntu.com/a/836521/768311) for the details.
|
||||
To install ctags on macOS, use [Homebrew](https://github.com/universal-ctags/homebrew-universal-ctags):
|
||||
To install ctags on macOS, use [Homebrew](https://formulae.brew.sh/formula/universal-ctags):
|
||||
|
||||
```bash
|
||||
brew install ctags
|
||||
brew install universal-ctags
|
||||
```
|
||||
|
||||
To install it Windows, use [chocolatey](https://chocolatey.org/) or [scoop](https://scoop.sh/)
|
||||
@@ -102,7 +141,7 @@ choco install universal-ctags
|
||||
|
||||
Set its PATH properly and make sure you can run `ctags` from command line.
|
||||
|
||||
## Ripgrep
|
||||
### Ripgrep
|
||||
|
||||
[Ripgrep](https://github.com/BurntSushi/ripgrep), aka, `rg`, is a fast grepping tool available for both Linux, Windows and macOS.
|
||||
It is used by several searching plugins.
|
||||
@@ -112,7 +151,7 @@ For Linux, we can download the [binary release](https://github.com/BurntSushi/ri
|
||||
|
||||
Set its PATH properly and make sure you can run `rg` from command line.
|
||||
|
||||
## Linters
|
||||
### Linters
|
||||
|
||||
A linter is a tool to check the source code for possible style and syntax issues.
|
||||
Based on the programming languages we use, we may need to install various linters.
|
||||
@@ -122,78 +161,21 @@ Based on the programming languages we use, we may need to install various linter
|
||||
|
||||
Set their PATH properly and make sure you can run `pylint`, `flake8` and `vint` from command line.
|
||||
|
||||
## Terminal emulators
|
||||
|
||||
Which [terminal emulator](https://en.wikipedia.org/wiki/Terminal_emulator) we choose to use greatly affects the appearance and features of Nvim.
|
||||
Since Nvim supports true colors, terminals that support true colors are preferred.
|
||||
For a list of terminals that support true colors, see [here](https://github.com/termstandard/colors).
|
||||
|
||||
For macOS, we can use [kitty](https://sw.kovidgoyal.net/kitty/), [iterm2](https://www.iterm2.com/), [wezterm](https://wezfurlong.org/wezterm/) or [Alacritty](https://github.com/jwilm/alacritty).
|
||||
|
||||
If you ssh to Linux server on Windows, I recommend [wsltty](https://github.com/mintty/wsltty) and [Cygwin](https://www.cygwin.com/),
|
||||
both of them use [mintty](https://github.com/mintty/mintty) as the terminal emulator.
|
||||
For the latest version of Windows 10, you can also try [Windows Terminal](https://github.com/microsoft/terminal).
|
||||
|
||||
## Patched Fonts
|
||||
|
||||
Since statusline or file explorer plugins often use Unicode symbols not available in normal font,
|
||||
we need to install a patched font from the [nerd-fonts](https://github.com/ryanoasis/nerd-fonts) project.
|
||||
|
||||
# Install Nvim
|
||||
## Install Nvim
|
||||
|
||||
There are various ways to install Nvim depending on your system.
|
||||
Current configuration is tested against nvim v0.7.0.
|
||||
This config is only maintained for [the latest nvim stable release](https://github.com/neovim/neovim/releases/tag/stable).
|
||||
|
||||
## Linux
|
||||
Please check the official doc on how to install Neovim on different systems: https://github.com/neovim/neovim/blob/master/INSTALL.md
|
||||
|
||||
We can directly download the binary release from [here](https://github.com/neovim/neovim/releases/download/stable/nvim-linux64.tar.gz).
|
||||
You can also use the system package manager to install nvim,
|
||||
but that is not reliable since latest version may not be available.
|
||||
After installing Nvim, we need to set the PATH to nvim correctly.
|
||||
**Make sure that you can run `nvim` from the command line after all these setups**.
|
||||
|
||||
## Windows
|
||||
## Setting up Nvim
|
||||
|
||||
You may download from [nvim release](https://github.com/neovim/neovim/releases/download/stable/nvim-win64.zip) from GitHub and manually extract it.
|
||||
After installing nvim and all the dependencies, we will install plugin managers and set up this config.
|
||||
|
||||
Another way to install Nvim on Windows is via chocolatey or scoop:
|
||||
|
||||
```
|
||||
choco install neovim
|
||||
|
||||
# via scoop
|
||||
# scoop bucket add versions
|
||||
# scoop install neovim
|
||||
```
|
||||
|
||||
## macOS
|
||||
|
||||
It is recommended to install neovim via [Homebrew](https://brew.sh/) on macOS. Simply run the following command:
|
||||
|
||||
```bash
|
||||
brew install neovim
|
||||
```
|
||||
|
||||
After installing Nvim, we need to set the path to nvim correctly.
|
||||
Make sure that you can run `nvim` from the command line after all these setups.
|
||||
|
||||
# Setting up Nvim
|
||||
|
||||
## Install plugin manager packer.nvim
|
||||
|
||||
I use packer.nvim to manage my plugins. We need to install packer.nvim on our system first.
|
||||
|
||||
For Windows, if curl is installed, run the following command (on PowerShell):
|
||||
|
||||
```
|
||||
git clone --depth=1 https://github.com/wbthomason/packer.nvim "$env:LOCALAPPDATA\nvim-data\site\pack\packer\opt\packer.nvim"
|
||||
```
|
||||
|
||||
For macOS and Linux, run the following command:
|
||||
|
||||
```bash
|
||||
git clone --depth=1 https://github.com/wbthomason/packer.nvim ~/.local/share/nvim/site/pack/packer/opt/packer.nvim
|
||||
```
|
||||
|
||||
## How to install this configuration
|
||||
### How to install this configuration
|
||||
|
||||
On Linux and macOS, the directory is `~/.config/nvim`.
|
||||
On Windows, the config directory is `$HOME/AppData/Local/nvim`[^1].
|
||||
@@ -204,21 +186,7 @@ then go to this directory, and run the following command:
|
||||
git clone --depth=1 https://github.com/jdhao/nvim-config.git .
|
||||
```
|
||||
|
||||
After that, when we first open nvim, run command `:PackerSync` to install all the plugins.
|
||||
After that, when we first open nvim, all the plugins will be installed automatically.
|
||||
Since I use quite a lot of plugins (more than 60), it may take some time to install all of them.
|
||||
|
||||
# Automatic installation
|
||||
|
||||
## Automatic Installation for Linux #
|
||||
|
||||
To set up a workable Nvim environment on Linux,
|
||||
I use [a bash script](nvim_setup_linux.sh) to automatically install necessary dependencies, Nvim itself and configs.
|
||||
|
||||
Note that the variable `PYTHON_INSTALLED`, `SYSTEM_PYTHON` and `ADD_TO_SYSTEM_PATH` in the script
|
||||
should be set properly based on your environment.
|
||||
|
||||
## Automatic installation for Windows
|
||||
|
||||
Run script [nvim_setup_windows.ps1](nvim_setup_windows.ps1) under PowerShell.
|
||||
|
||||
[^1]: Use `echo %userprofile%` to see where your `$HOME` is.
|
||||
|
||||
@@ -9,8 +9,9 @@ if [[ ! -d "$HOME/tools/" ]]; then
|
||||
fi
|
||||
|
||||
# Delete existing nvim installation.
|
||||
if [[ -d "$HOME/tools/nvim-osx64" ]]; then
|
||||
rm -rf "$HOME/tools/nvim-osx64"
|
||||
# For newer release, the directory name is nvim-macos
|
||||
if [[ -d "$HOME/tools/nvim-macos" ]]; then
|
||||
rm -rf "$HOME/tools/nvim-macos"
|
||||
fi
|
||||
|
||||
# Extract the tar ball
|
||||
|
||||
@@ -68,7 +68,7 @@ fi
|
||||
|
||||
# Install some Python packages used by Nvim plugins.
|
||||
echo "Installing Python packages"
|
||||
declare -a py_packages=("pynvim" 'python-lsp-server[all]' "black" "vim-vint" "pyls-isort" "pylsp-mypy")
|
||||
declare -a PY_PACKAGES=("pynvim" 'python-lsp-server[all]' "vim-vint" "python-lsp-isort" "pylsp-mypy" "python-lsp-black")
|
||||
|
||||
if [[ "$SYSTEM_PYTHON" = true ]]; then
|
||||
echo "Using system Python to install $(PY_PACKAGES)"
|
||||
@@ -76,12 +76,12 @@ if [[ "$SYSTEM_PYTHON" = true ]]; then
|
||||
# If we use system Python, we need to install these Python packages under
|
||||
# user HOME, since we do not have permissions to install them under system
|
||||
# directories.
|
||||
for p in "${py_packages[@]}"; do
|
||||
for p in "${PY_PACKAGES[@]}"; do
|
||||
pip install --user "$p"
|
||||
done
|
||||
else
|
||||
echo "Using custom Python to install $(PY_PACKAGES)"
|
||||
for p in "${py_packages[@]}"; do
|
||||
for p in "${PY_PACKAGES[@]}"; do
|
||||
"$CONDA_DIR/bin/pip" install "$p"
|
||||
done
|
||||
fi
|
||||
@@ -112,6 +112,7 @@ if [[ -z "$(command -v node)" ]]; then
|
||||
fi
|
||||
else
|
||||
echo "Node.js is already installed. Skip installing it."
|
||||
NODE_DIR="$(realpath $(dirname $(which node))/..)"
|
||||
fi
|
||||
|
||||
# Install vim-language-server
|
||||
@@ -120,6 +121,35 @@ fi
|
||||
# Install bash-language-server
|
||||
"$NODE_DIR/bin/npm" install -g bash-language-server
|
||||
|
||||
#######################################################################
|
||||
# lua-language-server #
|
||||
#######################################################################
|
||||
LUA_LS_DIR=$HOME/tools/lua-language-server
|
||||
LUA_LS_SRC=$HOME/packages/lua-language-server.tar.gz
|
||||
LUA_LS_LINK="https://github.com/LuaLS/lua-language-server/releases/download/3.6.11/lua-language-server-3.6.11-linux-x64.tar.gz"
|
||||
|
||||
if [[ -z "$(command -v lua-language-server)" ]] && [[ ! -f "$LUA_LS_DIR/bin/lua-language-server" ]]; then
|
||||
echo 'Install lua-language-server'
|
||||
if [[ ! -f $LUA_LS_SRC ]]; then
|
||||
echo "Downloading lua-language-server and renaming"
|
||||
wget $LUA_LS_LINK -O "$LUA_LS_SRC"
|
||||
fi
|
||||
|
||||
if [[ ! -d "$LUA_LS_DIR" ]]; then
|
||||
echo "Creating lua-language-server directory under tools directory"
|
||||
mkdir -p "$LUA_LS_DIR"
|
||||
echo "Extracting to directory $LUA_LS_DIR"
|
||||
|
||||
tar zxvf "$LUA_LS_SRC" -C "$LUA_LS_DIR"
|
||||
fi
|
||||
|
||||
if [[ "$ADD_TO_SYSTEM_PATH" = true ]] && [[ "$USE_BASH_SHELL" = true ]]; then
|
||||
echo "export PATH=\"$LUA_LS_DIR/bin:\$PATH\"" >> "$HOME/.bash_profile"
|
||||
fi
|
||||
else
|
||||
echo "lua-language-server is already installed. Skip installing it."
|
||||
fi
|
||||
|
||||
#######################################################################
|
||||
# Ripgrep part #
|
||||
#######################################################################
|
||||
@@ -145,8 +175,8 @@ if [[ -z "$(command -v rg)" ]] && [[ ! -f "$RIPGREP_DIR/rg" ]]; then
|
||||
fi
|
||||
|
||||
# set up manpath and zsh completion for ripgrep
|
||||
mkdir -p $HOME/tools/ripgrep/doc/man/man1
|
||||
mv $HOME/tools/ripgrep/doc/rg.1 $HOME/tools/ripgrep/doc/man/man1
|
||||
mkdir -p "$HOME/tools/ripgrep/doc/man/man1"
|
||||
mv "$HOME/tools/ripgrep/doc/rg.1" "$HOME/tools/ripgrep/doc/man/man1"
|
||||
|
||||
if [[ "$USE_BASH_SHELL" = true ]]; then
|
||||
echo 'export MANPATH=$HOME/tools/ripgrep/doc/man:$MANPATH' >> "$HOME/.bash_profile"
|
||||
@@ -216,16 +246,13 @@ fi
|
||||
|
||||
echo "Setting up config and installing plugins"
|
||||
if [[ -d "$NVIM_CONFIG_DIR" ]]; then
|
||||
rm -rf "$NVIM_CONFIG_DIR.backup"
|
||||
mv "$NVIM_CONFIG_DIR" "$NVIM_CONFIG_DIR.backup"
|
||||
fi
|
||||
|
||||
git clone --depth=1 https://github.com/jdhao/nvim-config.git "$NVIM_CONFIG_DIR"
|
||||
|
||||
echo "Installing packer.nvim"
|
||||
git clone --depth=1 https://github.com/wbthomason/packer.nvim \
|
||||
~/.local/share/nvim/site/pack/packer/opt/packer.nvim
|
||||
|
||||
echo "Installing nvim plugins, please wait"
|
||||
"$NVIM_DIR/bin/nvim" -c "autocmd User PackerComplete quitall" -c "PackerSync"
|
||||
"$NVIM_DIR/bin/nvim" -c "autocmd User LazyInstall quitall" -c "lua require('lazy').install()"
|
||||
|
||||
echo "Finished installing Nvim and its dependencies!"
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
# Install scoop
|
||||
# Set policy to avoid errors
|
||||
Set-ExecutionPolicy RemoteSigned -scope CurrentUser
|
||||
iwr -useb get.scoop.sh | iex
|
||||
|
||||
# Install scoop
|
||||
Invoke-WebRequest -UseBasicParsing get.scoop.sh | Invoke-Expression
|
||||
|
||||
# Install node
|
||||
scoop install nodejs
|
||||
@@ -18,14 +20,35 @@ npm install -g vim-language-server
|
||||
# Install bash-language-server
|
||||
npm install -g bash-language-server
|
||||
|
||||
# Install miniconda3
|
||||
# Install miniconda3 (for Python)
|
||||
scoop install miniconda3
|
||||
|
||||
# Install pynvim
|
||||
pip install -U pynvim
|
||||
|
||||
# Install python-language-server
|
||||
pip install 'python-lsp-server[all]' pylsp-mypy pyls-isort
|
||||
pip install 'python-lsp-server[all]' pylsp-mypy python-lsp-isort
|
||||
|
||||
# Install visual c++ redistribution
|
||||
scoop install vcredist2022
|
||||
|
||||
# Install 7zip
|
||||
scoop install 7zip
|
||||
|
||||
# Install lua-language-server
|
||||
$lua_ls_link = "https://github.com/LuaLS/lua-language-server/releases/download/3.6.11/lua-language-server-3.6.11-win32-x64.zip"
|
||||
$lua_ls_install_dir = "D:\portable_tools"
|
||||
$lua_ls_src_path = "$lua_ls_install_dir\lua-language-server.zip"
|
||||
$lua_ls_dir = "$lua_ls_install_dir\lua-language-server"
|
||||
|
||||
# Download file, ref: https://stackoverflow.com/a/51225744/6064933
|
||||
Invoke-WebRequest $lua_ls_link -OutFile "$lua_ls_src_path"
|
||||
|
||||
# Extract the zip file using 7zip, ref: https://stackoverflow.com/a/41933215/6064933
|
||||
7z x "$lua_ls_src_path" -o"$lua_ls_dir"
|
||||
|
||||
# Setup PATH env variable, ref: https://stackoverflow.com/q/714877/6064933
|
||||
[Environment]::SetEnvironmentVariable("Path", $env:Path + ";$lua_ls_dir\bin", "Machine")
|
||||
|
||||
# Install neovim nightly
|
||||
scoop bucket add versions
|
||||
|
||||
13
ginit.vim
13
ginit.vim
@@ -59,3 +59,16 @@ if exists('g:fvim_loaded')
|
||||
|
||||
FVimUIPopupMenu v:false
|
||||
endif
|
||||
|
||||
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
" config for neovide "
|
||||
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
if exists("g:neovide")
|
||||
set guifont=Hack\ NF:h10
|
||||
let g:neovide_transparency = 1.0
|
||||
let g:neovide_cursor_animation_length = 0.1
|
||||
let g:neovide_cursor_trail_size=0.3
|
||||
let g:neovide_cursor_vfx_mode = ""
|
||||
let g:neovide_cursor_vfx_particle_density=10.0
|
||||
let g:neovide_cursor_vfx_opacity=150.0
|
||||
endif
|
||||
|
||||
40
init.lua
Normal file
40
init.lua
Normal file
@@ -0,0 +1,40 @@
|
||||
-- This is my personal Nvim configuration supporting Mac, Linux and Windows, with various plugins configured.
|
||||
-- This configuration evolves as I learn more about Nvim and become more proficient in using Nvim.
|
||||
-- Since it is very long (more than 1000 lines!), you should read it carefully and take only the settings that suit you.
|
||||
-- I would not recommend cloning this repo and replace your own config. Good configurations are personal,
|
||||
-- built over time with a lot of polish.
|
||||
--
|
||||
-- Author: Jiedong Hao
|
||||
-- Email: jdhao@hotmail.com
|
||||
-- Blog: https://jdhao.github.io/
|
||||
-- GitHub: https://github.com/jdhao
|
||||
-- StackOverflow: https://stackoverflow.com/users/6064933/jdhao
|
||||
vim.loader.enable()
|
||||
|
||||
local utils = require("utils")
|
||||
|
||||
local expected_version = "0.11.0"
|
||||
utils.is_compatible_version(expected_version)
|
||||
|
||||
local config_dir = vim.fn.stdpath("config")
|
||||
---@cast config_dir string
|
||||
|
||||
-- some global settings
|
||||
require("globals")
|
||||
-- setting options in nvim
|
||||
vim.cmd("source " .. vim.fs.joinpath(config_dir, "viml_conf/options.vim"))
|
||||
-- various autocommands
|
||||
require("custom-autocmd")
|
||||
-- all the user-defined mappings
|
||||
require("mappings")
|
||||
-- all the plugins installed and their configurations
|
||||
vim.cmd("source " .. vim.fs.joinpath(config_dir, "viml_conf/plugins.vim"))
|
||||
|
||||
-- diagnostic related config
|
||||
require("diagnostic-conf")
|
||||
|
||||
-- colorscheme settings
|
||||
local color_scheme = require("colorschemes")
|
||||
|
||||
-- Load a random colorscheme
|
||||
color_scheme.rand_colorscheme()
|
||||
22
init.vim
22
init.vim
@@ -1,22 +0,0 @@
|
||||
" This is my personal Nvim configuration supporting Mac, Linux and Windows, with various plugins configured.
|
||||
" This configuration evolves as I learn more about Nvim and become more proficient in using Nvim.
|
||||
" Since it is very long (more than 1000 lines!), you should read it carefully and take only the settings that suit you.
|
||||
" I would not recommend cloning this repo and replace your own config. Good configurations are personal,
|
||||
" built over time with a lot of polish.
|
||||
"
|
||||
" Author: Jie-dong Hao
|
||||
" Email: jdhao@hotmail.com
|
||||
" Blog: https://jdhao.github.io/
|
||||
|
||||
let s:core_conf_files = [
|
||||
\ 'globals.vim',
|
||||
\ 'options.vim',
|
||||
\ 'autocommands.vim',
|
||||
\ 'mappings.vim',
|
||||
\ 'plugins.vim',
|
||||
\ 'themes.vim'
|
||||
\ ]
|
||||
|
||||
for s:fname in s:core_conf_files
|
||||
execute printf('source %s/core/%s', stdpath('config'), s:fname)
|
||||
endfor
|
||||
74
lua/colorschemes.lua
Normal file
74
lua/colorschemes.lua
Normal file
@@ -0,0 +1,74 @@
|
||||
--- This module will load a random colorscheme on nvim startup process.
|
||||
local utils = require("utils")
|
||||
|
||||
local M = {}
|
||||
|
||||
-- Colorscheme to its directory name mapping, because colorscheme repo name is not necessarily
|
||||
-- the same as the colorscheme name itself.
|
||||
M.colorscheme_conf = {
|
||||
onedark = function()
|
||||
-- Lua
|
||||
require("onedark").setup {
|
||||
style = "darker",
|
||||
}
|
||||
require("onedark").load()
|
||||
end,
|
||||
edge = function()
|
||||
vim.g.edge_style = "default"
|
||||
vim.g.edge_enable_italic = 1
|
||||
vim.g.edge_better_performance = 1
|
||||
|
||||
vim.cmd([[colorscheme edge]])
|
||||
end,
|
||||
sonokai = function()
|
||||
vim.g.sonokai_enable_italic = 1
|
||||
vim.g.sonokai_better_performance = 1
|
||||
|
||||
vim.cmd([[colorscheme sonokai]])
|
||||
end,
|
||||
gruvbox_material = function()
|
||||
-- foreground option can be material, mix, or original
|
||||
vim.g.gruvbox_material_foreground = "original"
|
||||
--background option can be hard, medium, soft
|
||||
vim.g.gruvbox_material_background = "hard"
|
||||
vim.g.gruvbox_material_enable_italic = 1
|
||||
vim.g.gruvbox_material_better_performance = 1
|
||||
|
||||
vim.cmd([[colorscheme gruvbox-material]])
|
||||
end,
|
||||
everforest = function()
|
||||
vim.g.everforest_background = "hard"
|
||||
vim.g.everforest_enable_italic = 1
|
||||
vim.g.everforest_better_performance = 1
|
||||
|
||||
vim.cmd([[colorscheme everforest]])
|
||||
end,
|
||||
nightfox = function()
|
||||
vim.cmd([[colorscheme carbonfox]])
|
||||
end,
|
||||
onedarkpro = function()
|
||||
-- set colorscheme after options
|
||||
-- onedark_vivid does not enough contrast
|
||||
vim.cmd("colorscheme onedark_dark")
|
||||
end,
|
||||
material = function()
|
||||
vim.g.material_style = "darker"
|
||||
vim.cmd("colorscheme material")
|
||||
end,
|
||||
arctic = function()
|
||||
vim.cmd("colorscheme arctic")
|
||||
end,
|
||||
kanagawa = function()
|
||||
vim.cmd("colorscheme kanagawa-wave")
|
||||
end,
|
||||
}
|
||||
|
||||
--- Use a random colorscheme from the pre-defined list of colorschemes.
|
||||
M.rand_colorscheme = function()
|
||||
local colorscheme = utils.rand_element(vim.tbl_keys(M.colorscheme_conf))
|
||||
|
||||
-- Load the colorscheme and its settings
|
||||
M.colorscheme_conf[colorscheme]()
|
||||
end
|
||||
|
||||
return M
|
||||
@@ -1,32 +0,0 @@
|
||||
local alpha = require("alpha")
|
||||
local dashboard = require("alpha.themes.dashboard")
|
||||
|
||||
-- Set header
|
||||
dashboard.section.header.val = {
|
||||
" ",
|
||||
" ███╗ ██╗███████╗ ██████╗ ██╗ ██╗██╗███╗ ███╗ ",
|
||||
" ████╗ ██║██╔════╝██╔═══██╗██║ ██║██║████╗ ████║ ",
|
||||
" ██╔██╗ ██║█████╗ ██║ ██║██║ ██║██║██╔████╔██║ ",
|
||||
" ██║╚██╗██║██╔══╝ ██║ ██║╚██╗ ██╔╝██║██║╚██╔╝██║ ",
|
||||
" ██║ ╚████║███████╗╚██████╔╝ ╚████╔╝ ██║██║ ╚═╝ ██║ ",
|
||||
" ╚═╝ ╚═══╝╚══════╝ ╚═════╝ ╚═══╝ ╚═╝╚═╝ ╚═╝ ",
|
||||
" ",
|
||||
}
|
||||
|
||||
-- Set menu
|
||||
dashboard.section.buttons.val = {
|
||||
dashboard.button( "Leader f f", " > Find file", ":Leaderf file --popup<CR>"),
|
||||
dashboard.button( "Leader f r", " > Recent files" , ":Leaderf mru --popup<CR>"),
|
||||
dashboard.button( "Leader f g", " > Project grep" , ":Leaderf rg --popup<CR>"),
|
||||
dashboard.button( "u", " > Update plugins" , ":PackerSync<CR>"),
|
||||
dashboard.button( "e", " > New file" , ":enew <CR>"),
|
||||
dashboard.button( "q", " > Quit NVIM", ":qa<CR>"),
|
||||
}
|
||||
|
||||
local fortune = require("alpha.fortune")
|
||||
dashboard.section.footer.val = fortune()
|
||||
|
||||
alpha.setup(dashboard.opts)
|
||||
|
||||
-- Send config to alpha
|
||||
alpha.setup(dashboard.opts)
|
||||
@@ -1,15 +0,0 @@
|
||||
require("autosave").setup({
|
||||
enabled = true,
|
||||
execution_message = "Autosaved at " .. vim.fn.strftime("%H:%M:%S"),
|
||||
events = { "InsertLeave", "TextChanged" },
|
||||
conditions = {
|
||||
exists = true,
|
||||
filename_is_not = {"plugins.lua"},
|
||||
filetype_is_not = {},
|
||||
modifiable = true,
|
||||
},
|
||||
write_all_buffers = false,
|
||||
on_off_commands = true,
|
||||
clean_command_line_interval = 1000,
|
||||
debounce_delay = 135,
|
||||
})
|
||||
@@ -1,6 +1,6 @@
|
||||
require("bqf").setup({
|
||||
require("bqf").setup {
|
||||
auto_resize_height = false,
|
||||
preview = {
|
||||
auto_preview = false,
|
||||
}
|
||||
})
|
||||
},
|
||||
}
|
||||
|
||||
@@ -1,12 +1,15 @@
|
||||
require("bufferline").setup({
|
||||
require("bufferline").setup {
|
||||
options = {
|
||||
numbers = "buffer_id",
|
||||
numbers = "none",
|
||||
close_command = "bdelete! %d",
|
||||
right_mouse_command = nil,
|
||||
left_mouse_command = "buffer %d",
|
||||
middle_mouse_command = nil,
|
||||
indicator_icon = "▎",
|
||||
buffer_close_icon = "",
|
||||
indicator = {
|
||||
icon = "▎", -- this should be omitted if indicator style is not 'icon'
|
||||
style = "icon",
|
||||
},
|
||||
buffer_close_icon = "",
|
||||
modified_icon = "●",
|
||||
close_icon = "",
|
||||
left_trunc_marker = "",
|
||||
@@ -40,4 +43,8 @@ require("bufferline").setup({
|
||||
always_show_bufferline = true,
|
||||
sort_by = "id",
|
||||
},
|
||||
}
|
||||
|
||||
vim.keymap.set("n", "<space>bp", "<cmd>BufferLinePick<CR>", {
|
||||
desc = "pick a buffer",
|
||||
})
|
||||
|
||||
75
lua/config/dashboard-nvim.lua
Normal file
75
lua/config/dashboard-nvim.lua
Normal file
@@ -0,0 +1,75 @@
|
||||
local api = vim.api
|
||||
local keymap = vim.keymap
|
||||
local dashboard = require("dashboard")
|
||||
|
||||
local conf = {}
|
||||
conf.header = {
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ███╗ ██╗ ███████╗ ██████╗ ██╗ ██╗ ██╗ ███╗ ███╗",
|
||||
" ████╗ ██║ ██╔════╝██╔═══██╗ ██║ ██║ ██║ ████╗ ████║",
|
||||
" ██╔██╗ ██║ █████╗ ██║ ██║ ██║ ██║ ██║ ██╔████╔██║",
|
||||
" ██║╚██╗██║ ██╔══╝ ██║ ██║ ╚██╗ ██╔╝ ██║ ██║╚██╔╝██║",
|
||||
" ██║ ╚████║ ███████╗╚██████╔╝ ╚████╔╝ ██║ ██║ ╚═╝ ██║",
|
||||
" ╚═╝ ╚═══╝ ╚══════╝ ╚═════╝ ╚═══╝ ╚═╝ ╚═╝ ╚═╝",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
}
|
||||
|
||||
conf.center = {
|
||||
{
|
||||
icon = " ",
|
||||
desc = "Find File ",
|
||||
action = "FzfLua files",
|
||||
key = "<Leader> f f",
|
||||
},
|
||||
{
|
||||
icon = " ",
|
||||
desc = "Recently opened files ",
|
||||
action = "FzfLua oldfiles",
|
||||
key = "<Leader> f r",
|
||||
},
|
||||
{
|
||||
icon = " ",
|
||||
desc = "Project grep ",
|
||||
action = "FzfLua live_grep",
|
||||
key = "<Leader> f g",
|
||||
},
|
||||
{
|
||||
icon = " ",
|
||||
desc = "Open Nvim config ",
|
||||
action = "tabnew $MYVIMRC | tcd %:p:h",
|
||||
key = "<Leader> e v",
|
||||
},
|
||||
{
|
||||
icon = " ",
|
||||
desc = "New file ",
|
||||
action = "enew",
|
||||
key = "e",
|
||||
},
|
||||
{
|
||||
icon = " ",
|
||||
desc = "Quit Nvim ",
|
||||
-- desc = "Quit Nvim ",
|
||||
action = "qa",
|
||||
key = "q",
|
||||
},
|
||||
}
|
||||
|
||||
dashboard.setup {
|
||||
theme = "doom",
|
||||
shortcut_type = "number",
|
||||
config = conf,
|
||||
}
|
||||
|
||||
api.nvim_create_autocmd("FileType", {
|
||||
pattern = "dashboard",
|
||||
group = api.nvim_create_augroup("dashboard_enter", { clear = true }),
|
||||
callback = function()
|
||||
keymap.set("n", "q", ":qa<CR>", { buffer = true, silent = true })
|
||||
keymap.set("n", "e", ":enew<CR>", { buffer = true, silent = true })
|
||||
end,
|
||||
})
|
||||
1
lua/config/fidget-nvim.lua
Normal file
1
lua/config/fidget-nvim.lua
Normal file
@@ -0,0 +1 @@
|
||||
require("fidget").setup {}
|
||||
27
lua/config/fugitive.lua
Normal file
27
lua/config/fugitive.lua
Normal file
@@ -0,0 +1,27 @@
|
||||
local keymap = vim.keymap
|
||||
|
||||
keymap.set("n", "<leader>gs", "<cmd>Git<cr>", { desc = "Git: show status" })
|
||||
keymap.set("n", "<leader>gw", "<cmd>Gwrite<cr>", { desc = "Git: add file" })
|
||||
keymap.set("n", "<leader>gc", "<cmd>Git commit<cr>", { desc = "Git: commit changes" })
|
||||
keymap.set("n", "<leader>gpl", "<cmd>Git pull<cr>", { desc = "Git: pull changes" })
|
||||
keymap.set("n", "<leader>gpu", "<cmd>15 split|term git push<cr>", { desc = "Git: push changes" })
|
||||
keymap.set("v", "<leader>gb", ":Git blame<cr>", { desc = "Git: blame selected line" })
|
||||
|
||||
-- convert git to Git in command line mode
|
||||
vim.fn["utils#Cabbrev"]("git", "Git")
|
||||
|
||||
keymap.set("n", "<leader>gbn", function()
|
||||
vim.ui.input({ prompt = "Enter a new branch name" }, function(user_input)
|
||||
if user_input == nil or user_input == "" then
|
||||
return
|
||||
end
|
||||
|
||||
local cmd_str = string.format("G checkout -b %s", user_input)
|
||||
vim.cmd(cmd_str)
|
||||
end)
|
||||
end, {
|
||||
desc = "Git: create new branch",
|
||||
})
|
||||
|
||||
keymap.set("n", "<leader>gf", ":Git fetch ", { desc = "Git: prune branches" })
|
||||
keymap.set("n", "<leader>gbd", ":Git branch -D ", { desc = "Git: delete branch" })
|
||||
18
lua/config/fzf-lua.lua
Normal file
18
lua/config/fzf-lua.lua
Normal file
@@ -0,0 +1,18 @@
|
||||
require("fzf-lua").setup {
|
||||
defaults = {
|
||||
file_icons = "mini",
|
||||
},
|
||||
winopts = {
|
||||
row = 0.5,
|
||||
height = 0.7,
|
||||
},
|
||||
files = {
|
||||
previewer = false,
|
||||
},
|
||||
}
|
||||
|
||||
vim.keymap.set("n", "<leader>ff", "<cmd>FzfLua files<cr>", { desc = "Fuzzy find files" })
|
||||
vim.keymap.set("n", "<leader>fg", "<cmd>FzfLua live_grep<cr>", { desc = "Fuzzy grep files" })
|
||||
vim.keymap.set("n", "<leader>fh", "<cmd>FzfLua helptags<cr>", { desc = "Fuzzy grep tags in help files" })
|
||||
vim.keymap.set("n", "<leader>ft", "<cmd>FzfLua btags<cr>", { desc = "Fuzzy search buffer tags" })
|
||||
vim.keymap.set("n", "<leader>fb", "<cmd>FzfLua buffers<cr>", { desc = "Fuzzy search opened buffers" })
|
||||
12
lua/config/git-conflict.lua
Normal file
12
lua/config/git-conflict.lua
Normal file
@@ -0,0 +1,12 @@
|
||||
require("git-conflict").setup {}
|
||||
|
||||
vim.api.nvim_create_autocmd("User", {
|
||||
pattern = "GitConflictResolved",
|
||||
callback = function()
|
||||
-- clear qf list
|
||||
vim.fn.setqflist({}, "r")
|
||||
|
||||
-- reopen it?
|
||||
vim.cmd([[GitConflictListQf]])
|
||||
end,
|
||||
})
|
||||
47
lua/config/git-linker.lua
Normal file
47
lua/config/git-linker.lua
Normal file
@@ -0,0 +1,47 @@
|
||||
local keymap = vim.keymap
|
||||
local gitlinker = require("gitlinker")
|
||||
|
||||
gitlinker.setup {
|
||||
callbacks = {
|
||||
["dev.azure.com"] = function(url_data)
|
||||
vim.print(url_data)
|
||||
local url = require("gitlinker.hosts").get_base_https_url(url_data)
|
||||
|
||||
if url_data.lstart then
|
||||
if url_data.lend == nil then
|
||||
url_data.lend = url_data.lstart
|
||||
end
|
||||
url = url
|
||||
.. "?path=/"
|
||||
.. url_data.file
|
||||
.. "&version=GC"
|
||||
.. url_data.rev
|
||||
.. "&line="
|
||||
.. url_data.lstart
|
||||
.. "&lineEnd="
|
||||
.. url_data.lend
|
||||
.. "&lineStartColumn=1"
|
||||
.. "&lineEndColumn=120"
|
||||
end
|
||||
return url
|
||||
end,
|
||||
},
|
||||
mappings = nil,
|
||||
}
|
||||
|
||||
keymap.set({ "n", "v" }, "<leader>gl", function()
|
||||
local mode = string.lower(vim.fn.mode())
|
||||
gitlinker.get_buf_range_url(mode)
|
||||
end, {
|
||||
silent = true,
|
||||
desc = "Git: get permlink",
|
||||
})
|
||||
|
||||
keymap.set("n", "<leader>gbr", function()
|
||||
gitlinker.get_repo_url {
|
||||
action_callback = gitlinker.actions.open_in_browser,
|
||||
}
|
||||
end, {
|
||||
silent = true,
|
||||
desc = "Git: browse repo in browser",
|
||||
})
|
||||
57
lua/config/gitsigns.lua
Normal file
57
lua/config/gitsigns.lua
Normal file
@@ -0,0 +1,57 @@
|
||||
local gs = require("gitsigns")
|
||||
|
||||
gs.setup {
|
||||
signs = {
|
||||
add = { text = "+" },
|
||||
change = { text = "~" },
|
||||
delete = { text = "_" },
|
||||
topdelete = { text = "‾" },
|
||||
changedelete = { text = "│" },
|
||||
},
|
||||
word_diff = false,
|
||||
on_attach = function(bufnr)
|
||||
local function map(mode, l, r, opts)
|
||||
opts = opts or {}
|
||||
opts.buffer = bufnr
|
||||
vim.keymap.set(mode, l, r, opts)
|
||||
end
|
||||
|
||||
-- Navigation
|
||||
map("n", "]c", function()
|
||||
if vim.wo.diff then
|
||||
return "]c"
|
||||
end
|
||||
vim.schedule(function()
|
||||
gs.next_hunk()
|
||||
end)
|
||||
return "<Ignore>"
|
||||
end, { expr = true, desc = "next hunk" })
|
||||
|
||||
map("n", "[c", function()
|
||||
if vim.wo.diff then
|
||||
return "[c"
|
||||
end
|
||||
vim.schedule(function()
|
||||
gs.prev_hunk()
|
||||
end)
|
||||
return "<Ignore>"
|
||||
end, { expr = true, desc = "previous hunk" })
|
||||
|
||||
-- Actions
|
||||
map("n", "<leader>hp", gs.preview_hunk, { desc = "preview hunk" })
|
||||
map("n", "<leader>hb", function()
|
||||
gs.blame_line { full = true }
|
||||
end, { desc = "blame hunk" })
|
||||
end,
|
||||
}
|
||||
|
||||
vim.api.nvim_create_autocmd("ColorScheme", {
|
||||
pattern = "*",
|
||||
callback = function()
|
||||
vim.cmd([[
|
||||
hi GitSignsChangeInline gui=reverse
|
||||
hi GitSignsAddInline gui=reverse
|
||||
hi GitSignsDeleteInline gui=reverse
|
||||
]])
|
||||
end,
|
||||
})
|
||||
12
lua/config/glance.lua
Normal file
12
lua/config/glance.lua
Normal file
@@ -0,0 +1,12 @@
|
||||
local glance = require("glance")
|
||||
|
||||
glance.setup {
|
||||
height = 25,
|
||||
border = {
|
||||
enable = true,
|
||||
},
|
||||
}
|
||||
|
||||
vim.keymap.set("n", "<space>gd", "<cmd>Glance definitions<cr>")
|
||||
vim.keymap.set("n", "<space>gr", "<cmd>Glance references<cr>")
|
||||
vim.keymap.set("n", "<space>gi", "<cmd>Glance implementations<cr>")
|
||||
@@ -1,21 +1,82 @@
|
||||
require('hlslens').setup({
|
||||
local api = vim.api
|
||||
local keymap = vim.keymap
|
||||
|
||||
local hlslens = require("hlslens")
|
||||
|
||||
hlslens.setup {
|
||||
calm_down = true,
|
||||
nearest_only = true,
|
||||
}
|
||||
|
||||
local activate_hlslens = function(direction)
|
||||
local cmd = string.format("normal! %s%szzzv", vim.v.count1, direction)
|
||||
local status, msg = pcall(vim.cmd, cmd)
|
||||
|
||||
-- Deal with the case that there is no such pattern in current buffer.
|
||||
if not status then
|
||||
local start_idx, _ = string.find(msg, "E486", 1, true)
|
||||
local msg_part = string.sub(msg, start_idx)
|
||||
api.nvim_echo({ { msg_part } }, true, { err = true })
|
||||
return
|
||||
end
|
||||
|
||||
hlslens.start()
|
||||
end
|
||||
|
||||
keymap.set("n", "n", "", {
|
||||
callback = function()
|
||||
activate_hlslens("n")
|
||||
end,
|
||||
})
|
||||
|
||||
vim.api.nvim_set_keymap(
|
||||
"n",
|
||||
"n",
|
||||
"<Cmd>execute('normal! ' . v:count1 . 'nzzzv')<CR><Cmd>lua require('hlslens').start()<CR>",
|
||||
{ noremap = true, silent = true }
|
||||
)
|
||||
keymap.set("n", "N", "", {
|
||||
callback = function()
|
||||
activate_hlslens("N")
|
||||
end,
|
||||
})
|
||||
|
||||
vim.api.nvim_set_keymap(
|
||||
"n",
|
||||
"N",
|
||||
"<Cmd>execute('normal! ' . v:count1 . 'Nzzzv')<CR><Cmd>lua require('hlslens').start()<CR>",
|
||||
{ noremap = true, silent = true }
|
||||
)
|
||||
local check_cursor_word = function()
|
||||
local cursor_word = vim.fn.expand("<cword>")
|
||||
local result = cursor_word == ""
|
||||
if result then
|
||||
local msg = "E348: No string under cursor"
|
||||
api.nvim_echo({ { msg } }, true, { err = true })
|
||||
end
|
||||
|
||||
vim.api.nvim_set_keymap("n", "*", "<Plug>(asterisk-z*)<Cmd>lua require('hlslens').start()<CR>", { silent = true })
|
||||
vim.api.nvim_set_keymap("n", "#", "<Plug>(asterisk-z#)<Cmd>lua require('hlslens').start()<CR>", { silent = true })
|
||||
return result, cursor_word
|
||||
end
|
||||
|
||||
keymap.set("n", "*", "", {
|
||||
callback = function()
|
||||
local cursor_word_empty, cursor_word = check_cursor_word()
|
||||
if cursor_word_empty then
|
||||
return
|
||||
end
|
||||
|
||||
local cmd = string.format([[normal! /\v<%s>]], cursor_word)
|
||||
|
||||
-- In order to say that we are pressing Enter key, instead of typing literally the character,
|
||||
-- we need to replace special notation with their internal representation.
|
||||
local escaped_enter = vim.api.nvim_replace_termcodes("<CR>", true, false, true)
|
||||
|
||||
-- character `N` is used to keep the cursor when pressing `*`
|
||||
local full_cmd = cmd .. escaped_enter .. "N"
|
||||
vim.fn.execute(full_cmd)
|
||||
hlslens.start()
|
||||
end,
|
||||
})
|
||||
keymap.set("n", "#", "", {
|
||||
callback = function()
|
||||
local cursor_word_empty, cursor_word = check_cursor_word()
|
||||
if cursor_word_empty then
|
||||
return
|
||||
end
|
||||
|
||||
local cmd = string.format([[normal! ?\v<%s>]], cursor_word)
|
||||
local escaped_enter = vim.api.nvim_replace_termcodes("<CR>", true, false, true)
|
||||
|
||||
local full_cmd = cmd .. escaped_enter .. "N"
|
||||
vim.fn.execute(full_cmd)
|
||||
hlslens.start()
|
||||
end,
|
||||
})
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
require("indent_blankline").setup({
|
||||
-- U+2502 may also be a good choice, it will be on the middle of cursor.
|
||||
-- U+250A is also a good choice
|
||||
char = "▏",
|
||||
show_end_of_line = false,
|
||||
disable_with_nolist = true,
|
||||
buftype_exclude = { "terminal" },
|
||||
filetype_exclude = { "help", "git", "markdown", "snippets", "text", "gitconfig", "alpha" },
|
||||
})
|
||||
|
||||
vim.cmd([[
|
||||
function! Should_activate_indentblankline() abort
|
||||
if index(g:indent_blankline_filetype_exclude, &filetype) == -1
|
||||
IndentBlanklineEnable
|
||||
endif
|
||||
endfunction
|
||||
|
||||
augroup indent_blankline
|
||||
autocmd!
|
||||
autocmd InsertEnter * IndentBlanklineDisable
|
||||
autocmd InsertLeave * call Should_activate_indentblankline()
|
||||
augroup END
|
||||
]])
|
||||
@@ -1,7 +1,7 @@
|
||||
local iron = require("iron")
|
||||
iron.core.set_config({
|
||||
iron.core.set_config {
|
||||
preferred = {
|
||||
python = "ipython",
|
||||
},
|
||||
repl_open_cmd = "vertical 120 split",
|
||||
})
|
||||
}
|
||||
|
||||
20
lua/config/lightbulb.lua
Normal file
20
lua/config/lightbulb.lua
Normal file
@@ -0,0 +1,20 @@
|
||||
---@diagnostic disable: missing-fields
|
||||
require("nvim-lightbulb").setup {
|
||||
autocmd = {
|
||||
enabled = true,
|
||||
updatetime = -1,
|
||||
},
|
||||
---@diagnostic disable-next-line: unused-local
|
||||
filter = function(client_name, result)
|
||||
-- Ruff always sends these two actions even if there are no action to take,
|
||||
-- so it is better to just ignore this to avoid noise. See also discussion below:
|
||||
-- https://github.com/astral-sh/ruff-lsp/issues/91
|
||||
local ignored_kinds = { "source.fixAll.ruff", "source.organizeImports.ruff" }
|
||||
|
||||
if vim.tbl_contains(ignored_kinds, result.kind) then
|
||||
return false
|
||||
end
|
||||
|
||||
return true
|
||||
end,
|
||||
}
|
||||
4
lua/config/live-command.lua
Normal file
4
lua/config/live-command.lua
Normal file
@@ -0,0 +1,4 @@
|
||||
require("live-command").setup {
|
||||
enable_highlighting = true,
|
||||
inline_highlighting = true,
|
||||
}
|
||||
@@ -1,204 +1,215 @@
|
||||
local api = vim.api
|
||||
local keymap = vim.keymap
|
||||
local lsp = vim.lsp
|
||||
local lspconfig = require("lspconfig")
|
||||
|
||||
local utils = require("utils")
|
||||
|
||||
local M = {}
|
||||
vim.api.nvim_create_autocmd("LspAttach", {
|
||||
group = vim.api.nvim_create_augroup("buf_behavior_conf", { clear = true }),
|
||||
callback = function(event_context)
|
||||
local client = vim.lsp.get_client_by_id(event_context.data.client_id)
|
||||
-- vim.print(client.name, client.server_capabilities)
|
||||
|
||||
function M.show_line_diagnostics()
|
||||
local opts = {
|
||||
focusable = false,
|
||||
close_events = { "BufLeave", "CursorMoved", "InsertEnter", "FocusLost" },
|
||||
border = 'rounded',
|
||||
source = 'always', -- show source in diagnostic popup window
|
||||
prefix = ' '
|
||||
}
|
||||
vim.diagnostic.open_float(nil, opts)
|
||||
end
|
||||
if not client then
|
||||
return
|
||||
end
|
||||
|
||||
local bufnr = event_context.buf
|
||||
|
||||
local custom_attach = function(client, bufnr)
|
||||
-- Mappings.
|
||||
local opts = { silent = true, buffer = bufnr }
|
||||
vim.keymap.set("n", "gd", vim.lsp.buf.definition, opts)
|
||||
vim.keymap.set("n", "<C-]>", vim.lsp.buf.definition, opts)
|
||||
vim.keymap.set("n", "K", vim.lsp.buf.hover, opts)
|
||||
vim.keymap.set("n", "<C-k>", vim.lsp.buf.signature_help, opts)
|
||||
vim.keymap.set("n", "<space>wa", vim.lsp.buf.add_workspace_folder, opts)
|
||||
vim.keymap.set("n", "<space>wr", vim.lsp.buf.remove_workspace_folder, opts)
|
||||
vim.keymap.set("n", "<space>wl", function() print(vim.inspect(vim.lsp.buf.list_workspace_folders())) end, opts)
|
||||
vim.keymap.set("n", "<space>rn", vim.lsp.buf.rename, opts)
|
||||
vim.keymap.set("n", "gr", vim.lsp.buf.references, opts)
|
||||
vim.keymap.set("n", "[d", vim.diagnostic.goto_prev, opts)
|
||||
vim.keymap.set("n", "]d", vim.diagnostic.goto_next, opts)
|
||||
vim.keymap.set("n", "<space>q", function() vim.diagnostic.setqflist({open = true}) end, opts)
|
||||
vim.keymap.set("n", "<space>ca", vim.lsp.buf.code_action, opts)
|
||||
local map = function(mode, l, r, opts)
|
||||
opts = opts or {}
|
||||
opts.silent = true
|
||||
opts.buffer = bufnr
|
||||
keymap.set(mode, l, r, opts)
|
||||
end
|
||||
|
||||
vim.cmd([[
|
||||
autocmd CursorHold <buffer> lua require('config.lsp').show_line_diagnostics()
|
||||
]])
|
||||
map("n", "gd", vim.lsp.buf.definition, { desc = "go to definition" })
|
||||
map("n", "<C-]>", vim.lsp.buf.definition)
|
||||
map("n", "K", function()
|
||||
vim.lsp.buf.hover { border = "single", max_height = 25, max_width = 120 }
|
||||
end)
|
||||
map("n", "<C-k>", vim.lsp.buf.signature_help)
|
||||
map("n", "<space>rn", vim.lsp.buf.rename, { desc = "varialbe rename" })
|
||||
map("n", "<space>ca", vim.lsp.buf.code_action, { desc = "LSP code action" })
|
||||
map("n", "<space>wa", vim.lsp.buf.add_workspace_folder, { desc = "add workspace folder" })
|
||||
map("n", "<space>wr", vim.lsp.buf.remove_workspace_folder, { desc = "remove workspace folder" })
|
||||
map("n", "<space>wl", function()
|
||||
vim.print(vim.lsp.buf.list_workspace_folders())
|
||||
end, { desc = "list workspace folder" })
|
||||
|
||||
-- Set some key bindings conditional on server capabilities
|
||||
if client.resolved_capabilities.document_formatting then
|
||||
vim.keymap.set("n", "<space>f", vim.lsp.buf.formatting_sync, opts)
|
||||
if client.server_capabilities.documentFormattingProvider and client.name ~= "lua_ls" then
|
||||
map({ "n", "x" }, "<space>f", vim.lsp.buf.format, { desc = "format code" })
|
||||
end
|
||||
if client.resolved_capabilities.document_range_formatting then
|
||||
vim.keymap.set("x", "<space>f", vim.lsp.buf.range_formatting, opts)
|
||||
|
||||
-- Disable ruff hover feature in favor of Pyright
|
||||
if client.name == "ruff" then
|
||||
client.server_capabilities.hoverProvider = false
|
||||
end
|
||||
|
||||
-- Uncomment code below to enable inlay hint from language server, some LSP server supports inlay hint,
|
||||
-- but disable this feature by default, so you may need to enable inlay hint in the LSP server config.
|
||||
-- vim.lsp.inlay_hint.enable(true, {buffer=bufnr})
|
||||
|
||||
-- The blow command will highlight the current variable and its usages in the buffer.
|
||||
if client.resolved_capabilities.document_highlight then
|
||||
vim.cmd([[
|
||||
hi! link LspReferenceRead Visual
|
||||
hi! link LspReferenceText Visual
|
||||
hi! link LspReferenceWrite Visual
|
||||
augroup lsp_document_highlight
|
||||
autocmd! * <buffer>
|
||||
autocmd CursorHold <buffer> lua vim.lsp.buf.document_highlight()
|
||||
autocmd CursorMoved <buffer> lua vim.lsp.buf.clear_references()
|
||||
augroup END
|
||||
]])
|
||||
end
|
||||
|
||||
if vim.g.logging_level == 'debug' then
|
||||
local msg = string.format("Language server %s started!", client.name)
|
||||
vim.notify(msg, 'info', {title = 'Nvim-config'})
|
||||
end
|
||||
end
|
||||
|
||||
local capabilities = lsp.protocol.make_client_capabilities()
|
||||
capabilities = require('cmp_nvim_lsp').update_capabilities(capabilities)
|
||||
capabilities.textDocument.completion.completionItem.snippetSupport = true
|
||||
|
||||
local lspconfig = require("lspconfig")
|
||||
|
||||
if utils.executable('pylsp') then
|
||||
lspconfig.pylsp.setup({
|
||||
on_attach = custom_attach,
|
||||
settings = {
|
||||
pylsp = {
|
||||
plugins = {
|
||||
pylint = { enabled = true, executable = "pylint" },
|
||||
pyflakes = { enabled = false },
|
||||
pycodestyle = { enabled = false },
|
||||
jedi_completion = { fuzzy = true },
|
||||
pyls_isort = { enabled = true },
|
||||
pylsp_mypy = { enabled = true },
|
||||
},
|
||||
},
|
||||
},
|
||||
flags = {
|
||||
debounce_text_changes = 200,
|
||||
},
|
||||
capabilities = capabilities,
|
||||
if client.server_capabilities.documentHighlightProvider then
|
||||
local gid = api.nvim_create_augroup("lsp_document_highlight", { clear = true })
|
||||
api.nvim_create_autocmd("CursorHold", {
|
||||
group = gid,
|
||||
buffer = bufnr,
|
||||
callback = function()
|
||||
lsp.buf.document_highlight()
|
||||
end,
|
||||
})
|
||||
|
||||
api.nvim_create_autocmd("CursorMoved", {
|
||||
group = gid,
|
||||
buffer = bufnr,
|
||||
callback = function()
|
||||
lsp.buf.clear_references()
|
||||
end,
|
||||
})
|
||||
end
|
||||
end,
|
||||
nested = true,
|
||||
desc = "Configure buffer keymap and behavior based on LSP",
|
||||
})
|
||||
|
||||
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
||||
|
||||
-- required by nvim-ufo
|
||||
capabilities.textDocument.foldingRange = {
|
||||
dynamicRegistration = false,
|
||||
lineFoldingOnly = true,
|
||||
}
|
||||
|
||||
-- For what diagnostic is enabled in which type checking mode, check doc:
|
||||
-- https://github.com/microsoft/pyright/blob/main/docs/configuration.md#diagnostic-settings-defaults
|
||||
-- Currently, the pyright also has some issues displaying hover documentation:
|
||||
-- https://www.reddit.com/r/neovim/comments/1gdv1rc/what_is_causeing_the_lsp_hover_docs_to_looks_like/
|
||||
|
||||
if utils.executable("pyright") then
|
||||
local new_capability = {
|
||||
-- this will remove some of the diagnostics that duplicates those from ruff, idea taken and adapted from
|
||||
-- here: https://github.com/astral-sh/ruff-lsp/issues/384#issuecomment-1989619482
|
||||
textDocument = {
|
||||
publishDiagnostics = {
|
||||
tagSupport = {
|
||||
valueSet = { 2 },
|
||||
},
|
||||
},
|
||||
hover = {
|
||||
contentFormat = { "plaintext" },
|
||||
dynamicRegistration = true,
|
||||
},
|
||||
},
|
||||
}
|
||||
local merged_capability = vim.tbl_deep_extend("force", capabilities, new_capability)
|
||||
|
||||
lspconfig.pyright.setup {
|
||||
cmd = { "delance-langserver", "--stdio" },
|
||||
capabilities = merged_capability,
|
||||
settings = {
|
||||
pyright = {
|
||||
-- disable import sorting and use Ruff for this
|
||||
disableOrganizeImports = true,
|
||||
disableTaggedHints = false,
|
||||
},
|
||||
python = {
|
||||
analysis = {
|
||||
autoSearchPaths = true,
|
||||
diagnosticMode = "workspace",
|
||||
typeCheckingMode = "standard",
|
||||
useLibraryCodeForTypes = true,
|
||||
-- we can this setting below to redefine some diagnostics
|
||||
diagnosticSeverityOverrides = {
|
||||
deprecateTypingAliases = false,
|
||||
},
|
||||
-- inlay hint settings are provided by pylance?
|
||||
inlayHints = {
|
||||
callArgumentNames = "partial",
|
||||
functionReturnTypes = true,
|
||||
pytestParameters = true,
|
||||
variableTypes = true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
else
|
||||
vim.notify("pylsp not found!", 'warn', {title = 'Nvim-config'})
|
||||
vim.notify("pyright not found!", vim.log.levels.WARN, { title = "Nvim-config" })
|
||||
end
|
||||
|
||||
-- if utils.executable('pyright') then
|
||||
-- lspconfig.pyright.setup{
|
||||
-- on_attach = custom_attach,
|
||||
-- capabilities = capabilities
|
||||
-- }
|
||||
-- else
|
||||
-- vim.notify("pyright not found!", 'warn', {title = 'Nvim-config'})
|
||||
-- end
|
||||
if utils.executable("ruff") then
|
||||
require("lspconfig").ruff.setup {
|
||||
capabilities = capabilities,
|
||||
init_options = {
|
||||
-- the settings can be found here: https://docs.astral.sh/ruff/editors/settings/
|
||||
settings = {
|
||||
organizeImports = true,
|
||||
},
|
||||
},
|
||||
}
|
||||
end
|
||||
|
||||
if utils.executable('clangd') then
|
||||
lspconfig.clangd.setup({
|
||||
on_attach = custom_attach,
|
||||
if utils.executable("ltex-ls") then
|
||||
lspconfig.ltex.setup {
|
||||
cmd = { "ltex-ls" },
|
||||
filetypes = { "text", "plaintex", "tex", "markdown" },
|
||||
settings = {
|
||||
ltex = {
|
||||
language = "en",
|
||||
},
|
||||
},
|
||||
flags = { debounce_text_changes = 300 },
|
||||
}
|
||||
end
|
||||
|
||||
if utils.executable("clangd") then
|
||||
lspconfig.clangd.setup {
|
||||
capabilities = capabilities,
|
||||
filetypes = { "c", "cpp", "cc" },
|
||||
flags = {
|
||||
debounce_text_changes = 500,
|
||||
},
|
||||
})
|
||||
else
|
||||
vim.notify("clangd not found!", 'warn', {title = 'Nvim-config'})
|
||||
}
|
||||
end
|
||||
|
||||
-- set up vim-language-server
|
||||
if utils.executable('vim-language-server') then
|
||||
lspconfig.vimls.setup({
|
||||
on_attach = custom_attach,
|
||||
if utils.executable("vim-language-server") then
|
||||
lspconfig.vimls.setup {
|
||||
flags = {
|
||||
debounce_text_changes = 500,
|
||||
},
|
||||
capabilities = capabilities,
|
||||
})
|
||||
}
|
||||
else
|
||||
vim.notify("vim-language-server not found!", 'warn', {title = 'Nvim-config'})
|
||||
vim.notify("vim-language-server not found!", vim.log.levels.WARN, { title = "Nvim-config" })
|
||||
end
|
||||
|
||||
-- set up bash-language-server
|
||||
if utils.executable('bash-language-server') then
|
||||
lspconfig.bashls.setup({
|
||||
on_attach = custom_attach,
|
||||
if utils.executable("bash-language-server") then
|
||||
lspconfig.bashls.setup {
|
||||
capabilities = capabilities,
|
||||
})
|
||||
}
|
||||
end
|
||||
|
||||
local sumneko_binary_path = vim.fn.exepath("lua-language-server")
|
||||
if vim.g.is_mac or vim.g.is_linux and sumneko_binary_path ~= "" then
|
||||
local sumneko_root_path = vim.fn.fnamemodify(sumneko_binary_path, ":h:h:h")
|
||||
|
||||
local runtime_path = vim.split(package.path, ";")
|
||||
table.insert(runtime_path, "lua/?.lua")
|
||||
table.insert(runtime_path, "lua/?/init.lua")
|
||||
|
||||
lspconfig.sumneko_lua.setup({
|
||||
on_attach = custom_attach,
|
||||
cmd = { sumneko_binary_path, "-E", sumneko_root_path .. "/main.lua" },
|
||||
-- settings for lua-language-server can be found on https://luals.github.io/wiki/settings/
|
||||
if utils.executable("lua-language-server") then
|
||||
lspconfig.lua_ls.setup {
|
||||
settings = {
|
||||
Lua = {
|
||||
runtime = {
|
||||
-- Tell the language server which version of Lua you're using (most likely LuaJIT in the case of Neovim)
|
||||
version = "LuaJIT",
|
||||
-- Setup your lua path
|
||||
path = runtime_path,
|
||||
},
|
||||
diagnostics = {
|
||||
-- Get the language server to recognize the `vim` global
|
||||
globals = { "vim" },
|
||||
},
|
||||
workspace = {
|
||||
-- Make the server aware of Neovim runtime files
|
||||
library = api.nvim_get_runtime_file("", true),
|
||||
},
|
||||
-- Do not send telemetry data containing a randomized but unique identifier
|
||||
telemetry = {
|
||||
enable = false,
|
||||
hint = {
|
||||
enable = true,
|
||||
},
|
||||
},
|
||||
},
|
||||
capabilities = capabilities,
|
||||
})
|
||||
}
|
||||
end
|
||||
|
||||
-- Change diagnostic signs.
|
||||
vim.fn.sign_define("DiagnosticSignError", { text = "✗", texthl = "DiagnosticSignError" })
|
||||
vim.fn.sign_define("DiagnosticSignWarn", { text = "!", texthl = "DiagnosticSignWarn" })
|
||||
vim.fn.sign_define("DiagnosticSignInformation", { text = "", texthl = "DiagnosticSignInfo" })
|
||||
vim.fn.sign_define("DiagnosticSignHint", { text = "", texthl = "DiagnosticSignHint" })
|
||||
|
||||
-- global config for diagnostic
|
||||
vim.diagnostic.config({
|
||||
underline = false,
|
||||
virtual_text = false,
|
||||
signs = true,
|
||||
severity_sort = true,
|
||||
})
|
||||
|
||||
-- lsp.handlers["textDocument/publishDiagnostics"] = lsp.with(lsp.diagnostic.on_publish_diagnostics, {
|
||||
-- underline = false,
|
||||
-- virtual_text = false,
|
||||
-- signs = true,
|
||||
-- update_in_insert = false,
|
||||
-- })
|
||||
|
||||
-- Change border of documentation hover window, See https://github.com/neovim/neovim/pull/13998.
|
||||
lsp.handlers["textDocument/hover"] = lsp.with(vim.lsp.handlers.hover, {
|
||||
border = "rounded",
|
||||
})
|
||||
|
||||
return M
|
||||
|
||||
310
lua/config/lualine.lua
Normal file
310
lua/config/lualine.lua
Normal file
@@ -0,0 +1,310 @@
|
||||
local fn = vim.fn
|
||||
|
||||
local git_status_cache = {}
|
||||
|
||||
local on_exit_fetch = function(result)
|
||||
if result.code == 0 then
|
||||
git_status_cache.fetch_success = true
|
||||
end
|
||||
end
|
||||
|
||||
local function handle_numeric_result(cache_key)
|
||||
return function(result)
|
||||
if result.code == 0 then
|
||||
git_status_cache[cache_key] = tonumber(result.stdout:match("(%d+)")) or 0
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local async_cmd = function(cmd_str, on_exit)
|
||||
local cmd = vim.tbl_filter(function(element)
|
||||
return element ~= ""
|
||||
end, vim.split(cmd_str, " "))
|
||||
|
||||
vim.system(cmd, { text = true }, on_exit)
|
||||
end
|
||||
|
||||
local async_git_status_update = function()
|
||||
-- Fetch the latest changes from the remote repository (replace 'origin' if needed)
|
||||
async_cmd("git fetch origin", on_exit_fetch)
|
||||
if not git_status_cache.fetch_success then
|
||||
return
|
||||
end
|
||||
|
||||
-- Get the number of commits behind
|
||||
-- the @{upstream} notation is inspired by post: https://www.reddit.com/r/neovim/comments/t48x5i/git_branch_aheadbehind_info_status_line_component/
|
||||
-- note that here we should use double dots instead of triple dots
|
||||
local behind_cmd_str = "git rev-list --count HEAD..@{upstream}"
|
||||
async_cmd(behind_cmd_str, handle_numeric_result("behind_count"))
|
||||
|
||||
-- Get the number of commits ahead
|
||||
local ahead_cmd_str = "git rev-list --count @{upstream}..HEAD"
|
||||
async_cmd(ahead_cmd_str, handle_numeric_result("ahead_count"))
|
||||
end
|
||||
|
||||
local function get_git_ahead_behind_info()
|
||||
async_git_status_update()
|
||||
|
||||
local status = git_status_cache
|
||||
if not status then
|
||||
return ""
|
||||
end
|
||||
|
||||
local msg = ""
|
||||
|
||||
if type(status.ahead_count) == "number" and status.ahead_count > 0 then
|
||||
local ahead_str = string.format("↑[%d] ", status.ahead_count)
|
||||
msg = msg .. ahead_str
|
||||
end
|
||||
|
||||
if type(status.behind_count) == "number" and status.behind_count > 0 then
|
||||
local behind_str = string.format("↓[%d] ", status.behind_count)
|
||||
msg = msg .. behind_str
|
||||
end
|
||||
|
||||
return msg
|
||||
end
|
||||
|
||||
local function spell()
|
||||
if vim.o.spell then
|
||||
return string.format("[SPELL]")
|
||||
end
|
||||
|
||||
return ""
|
||||
end
|
||||
|
||||
--- show indicator for Chinese IME
|
||||
local function ime_state()
|
||||
if vim.g.is_mac then
|
||||
-- ref: https://github.com/vim-airline/vim-airline/blob/master/autoload/airline/extensions/xkblayout.vim#L11
|
||||
local layout = fn.libcall(vim.g.XkbSwitchLib, "Xkb_Switch_getXkbLayout", "")
|
||||
|
||||
-- We can use `xkbswitch -g` on the command line to get current mode.
|
||||
-- mode for macOS builtin pinyin IME: com.apple.inputmethod.SCIM.ITABC
|
||||
-- mode for Rime: im.rime.inputmethod.Squirrel.Rime
|
||||
local res = fn.match(layout, [[\v(Squirrel\.Rime|SCIM.ITABC)]])
|
||||
if res ~= -1 then
|
||||
return "[CN]"
|
||||
end
|
||||
end
|
||||
|
||||
return ""
|
||||
end
|
||||
|
||||
local function trailing_space()
|
||||
if not vim.o.modifiable then
|
||||
return ""
|
||||
end
|
||||
|
||||
local line_num = nil
|
||||
|
||||
for i = 1, fn.line("$") do
|
||||
local linetext = fn.getline(i)
|
||||
-- To prevent invalid escape error, we wrap the regex string with `[[]]`.
|
||||
local idx = fn.match(linetext, [[\v\s+$]])
|
||||
|
||||
if idx ~= -1 then
|
||||
line_num = i
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
local msg = ""
|
||||
if line_num ~= nil then
|
||||
msg = string.format("[%d]trailing", line_num)
|
||||
end
|
||||
|
||||
return msg
|
||||
end
|
||||
|
||||
local function mixed_indent()
|
||||
if not vim.o.modifiable then
|
||||
return ""
|
||||
end
|
||||
|
||||
local space_pat = [[\v^ +]]
|
||||
local tab_pat = [[\v^\t+]]
|
||||
local space_indent = fn.search(space_pat, "nwc")
|
||||
local tab_indent = fn.search(tab_pat, "nwc")
|
||||
local mixed = (space_indent > 0 and tab_indent > 0)
|
||||
local mixed_same_line
|
||||
if not mixed then
|
||||
mixed_same_line = fn.search([[\v^(\t+ | +\t)]], "nwc")
|
||||
mixed = mixed_same_line > 0
|
||||
end
|
||||
if not mixed then
|
||||
return ""
|
||||
end
|
||||
if mixed_same_line ~= nil and mixed_same_line > 0 then
|
||||
return "MI:" .. mixed_same_line
|
||||
end
|
||||
local space_indent_cnt = fn.searchcount({ pattern = space_pat, max_count = 1e3 }).total
|
||||
local tab_indent_cnt = fn.searchcount({ pattern = tab_pat, max_count = 1e3 }).total
|
||||
if space_indent_cnt > tab_indent_cnt then
|
||||
return "MI:" .. tab_indent
|
||||
else
|
||||
return "MI:" .. space_indent
|
||||
end
|
||||
end
|
||||
|
||||
local diff = function()
|
||||
local git_status = vim.b.gitsigns_status_dict
|
||||
if git_status == nil then
|
||||
return
|
||||
end
|
||||
|
||||
local modify_num = git_status.changed
|
||||
local remove_num = git_status.removed
|
||||
local add_num = git_status.added
|
||||
|
||||
local info = { added = add_num, modified = modify_num, removed = remove_num }
|
||||
-- vim.print(info)
|
||||
return info
|
||||
end
|
||||
|
||||
local virtual_env = function()
|
||||
-- only show virtual env for Python
|
||||
if vim.bo.filetype ~= "python" then
|
||||
return ""
|
||||
end
|
||||
|
||||
local conda_env = os.getenv("CONDA_DEFAULT_ENV")
|
||||
local venv_path = os.getenv("VIRTUAL_ENV")
|
||||
|
||||
if venv_path == nil then
|
||||
if conda_env == nil then
|
||||
return ""
|
||||
else
|
||||
return string.format(" %s (conda)", conda_env)
|
||||
end
|
||||
else
|
||||
local venv_name = vim.fn.fnamemodify(venv_path, ":t")
|
||||
return string.format(" %s (venv)", venv_name)
|
||||
end
|
||||
end
|
||||
|
||||
local get_active_lsp = function()
|
||||
local msg = "🚫"
|
||||
local buf_ft = vim.api.nvim_get_option_value("filetype", {})
|
||||
local clients = vim.lsp.get_clients { bufnr = 0 }
|
||||
if next(clients) == nil then
|
||||
return msg
|
||||
end
|
||||
|
||||
for _, client in ipairs(clients) do
|
||||
---@diagnostic disable-next-line: undefined-field
|
||||
local filetypes = client.config.filetypes
|
||||
if filetypes and vim.fn.index(filetypes, buf_ft) ~= -1 then
|
||||
return client.name
|
||||
end
|
||||
end
|
||||
return msg
|
||||
end
|
||||
|
||||
require("lualine").setup {
|
||||
options = {
|
||||
icons_enabled = true,
|
||||
theme = "auto",
|
||||
component_separators = { left = "⏐", right = "⏐" },
|
||||
section_separators = "",
|
||||
disabled_filetypes = {},
|
||||
always_divide_middle = true,
|
||||
refresh = {
|
||||
statusline = 500,
|
||||
},
|
||||
},
|
||||
sections = {
|
||||
lualine_a = {
|
||||
{
|
||||
"filename",
|
||||
symbols = {
|
||||
readonly = "[🔒]",
|
||||
},
|
||||
},
|
||||
},
|
||||
lualine_b = {
|
||||
{
|
||||
"branch",
|
||||
fmt = function(name, _)
|
||||
-- truncate branch name in case the name is too long
|
||||
return string.sub(name, 1, 20)
|
||||
end,
|
||||
color = { gui = "italic,bold" },
|
||||
},
|
||||
{
|
||||
get_git_ahead_behind_info,
|
||||
color = { fg = "#E0C479" },
|
||||
},
|
||||
{
|
||||
"diff",
|
||||
source = diff,
|
||||
},
|
||||
{
|
||||
virtual_env,
|
||||
color = { fg = "black", bg = "#F1CA81" },
|
||||
},
|
||||
},
|
||||
lualine_c = {
|
||||
{
|
||||
"%S",
|
||||
color = { gui = "bold", fg = "cyan" },
|
||||
},
|
||||
{
|
||||
spell,
|
||||
color = { fg = "black", bg = "#a7c080" },
|
||||
},
|
||||
},
|
||||
lualine_x = {
|
||||
{
|
||||
get_active_lsp,
|
||||
icon = "📡",
|
||||
},
|
||||
{
|
||||
"diagnostics",
|
||||
sources = { "nvim_diagnostic" },
|
||||
symbols = { error = "🆇 ", warn = "⚠️ ", info = "ℹ️ ", hint = " " },
|
||||
},
|
||||
{
|
||||
trailing_space,
|
||||
color = "WarningMsg",
|
||||
},
|
||||
{
|
||||
mixed_indent,
|
||||
color = "WarningMsg",
|
||||
},
|
||||
},
|
||||
lualine_y = {
|
||||
{
|
||||
"encoding",
|
||||
fmt = string.upper,
|
||||
},
|
||||
{
|
||||
"fileformat",
|
||||
symbols = {
|
||||
unix = "unix",
|
||||
dos = "win",
|
||||
mac = "mac",
|
||||
},
|
||||
},
|
||||
"filetype",
|
||||
{
|
||||
ime_state,
|
||||
color = { fg = "black", bg = "#f46868" },
|
||||
},
|
||||
},
|
||||
lualine_z = {
|
||||
"location",
|
||||
"progress",
|
||||
},
|
||||
},
|
||||
inactive_sections = {
|
||||
lualine_a = {},
|
||||
lualine_b = {},
|
||||
lualine_c = { "filename" },
|
||||
lualine_x = { "location" },
|
||||
lualine_y = {},
|
||||
lualine_z = {},
|
||||
},
|
||||
tabline = {},
|
||||
extensions = { "quickfix", "fugitive", "nvim-tree" },
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
require("neoscroll").setup({
|
||||
easing_function = "quadratic",
|
||||
})
|
||||
|
||||
local t = {}
|
||||
-- Syntax: t[keys] = {function, {function arguments}}
|
||||
-- Use the "sine" easing function
|
||||
t["<C-u>"] = { "scroll", { "-vim.wo.scroll", "true", "20", [['cubic']] } }
|
||||
t["<C-d>"] = { "scroll", { "vim.wo.scroll", "true", "20", [['cubic']] } }
|
||||
-- Use the "circular" easing function
|
||||
t["<C-b>"] = { "scroll", { "-vim.api.nvim_win_get_height(0)", "true", "50", [['cubic']] } }
|
||||
t["<C-f>"] = { "scroll", { "vim.api.nvim_win_get_height(0)", "true", "50", [['cubic']] } }
|
||||
-- Pass "nil" to disable the easing animation (constant scrolling speed)
|
||||
t["<C-y>"] = { "scroll", { "-0.10", "false", "100", nil } }
|
||||
t["<C-e>"] = { "scroll", { "0.10", "false", "100", nil } }
|
||||
-- When no easing function is provided the default easing function (in this case "quadratic") will be used
|
||||
t["zt"] = { "zt", { "10" } }
|
||||
t["zz"] = { "zz", { "10" } }
|
||||
t["zb"] = { "zb", { "10" } }
|
||||
|
||||
require("neoscroll.config").set_mappings(t)
|
||||
@@ -1,69 +1,78 @@
|
||||
-- Setup nvim-cmp.
|
||||
local cmp = require'cmp'
|
||||
local lspkind = require'lspkind'
|
||||
local cmp = require("cmp")
|
||||
|
||||
cmp.setup({
|
||||
-- The extentions needed by nvim-cmp should be loaded beforehand
|
||||
require("cmp_nvim_lsp")
|
||||
require("cmp_path")
|
||||
require("cmp_buffer")
|
||||
require("cmp_omni")
|
||||
require("cmp_nvim_ultisnips")
|
||||
|
||||
local MiniIcons = require("mini.icons")
|
||||
|
||||
cmp.setup {
|
||||
snippet = {
|
||||
expand = function(args)
|
||||
-- For `ultisnips` user.
|
||||
vim.fn["UltiSnips#Anon"](args.body)
|
||||
end,
|
||||
},
|
||||
mapping = cmp.mapping.preset.insert({
|
||||
['<Tab>'] = function(fallback)
|
||||
mapping = cmp.mapping.preset.insert {
|
||||
["<Tab>"] = function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_next_item()
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end,
|
||||
['<S-Tab>'] = function(fallback)
|
||||
["<S-Tab>"] = function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_prev_item()
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end,
|
||||
['<CR>'] = cmp.mapping.confirm({ select = true }),
|
||||
['<C-e>'] = cmp.mapping.abort(),
|
||||
['<Esc>'] = cmp.mapping.close(),
|
||||
['<C-d>'] = cmp.mapping.scroll_docs(-4),
|
||||
['<C-f>'] = cmp.mapping.scroll_docs(4),
|
||||
}),
|
||||
["<CR>"] = cmp.mapping.confirm { select = true },
|
||||
["<C-e>"] = cmp.mapping.abort(),
|
||||
["<Esc>"] = cmp.mapping.close(),
|
||||
["<C-d>"] = cmp.mapping.scroll_docs(-4),
|
||||
["<C-f>"] = cmp.mapping.scroll_docs(4),
|
||||
},
|
||||
sources = {
|
||||
{ name = 'nvim_lsp' }, -- For nvim-lsp
|
||||
{ name = 'ultisnips' }, -- For ultisnips user.
|
||||
{ name = 'nvim_lua' }, -- for nvim lua function
|
||||
{ name = 'path' }, -- for path completion
|
||||
{ name = 'buffer', keyword_length = 4 }, -- for buffer word completion
|
||||
{ name = 'omni' },
|
||||
{ name = 'emoji', insert = true, } -- emoji completion
|
||||
{ name = "nvim_lsp" }, -- For nvim-lsp
|
||||
{ name = "ultisnips" }, -- For ultisnips user.
|
||||
{ name = "path" }, -- for path completion
|
||||
{ name = "buffer", keyword_length = 2 }, -- for buffer word completion
|
||||
},
|
||||
completion = {
|
||||
keyword_length = 1,
|
||||
completeopt = "menu,noselect"
|
||||
completeopt = "menu,noselect",
|
||||
},
|
||||
view = {
|
||||
entries = 'custom',
|
||||
entries = "custom",
|
||||
},
|
||||
-- solution taken from https://github.com/echasnovski/mini.nvim/issues/1007#issuecomment-2258929830
|
||||
formatting = {
|
||||
format = lspkind.cmp_format({
|
||||
mode = "symbol_text",
|
||||
menu = ({
|
||||
nvim_lsp = "[LSP]",
|
||||
ultisnips = "[US]",
|
||||
nvim_lua = "[Lua]",
|
||||
path = "[Path]",
|
||||
buffer = "[Buffer]",
|
||||
emoji = "[Emoji]",
|
||||
omni = "[Omni]",
|
||||
}),
|
||||
}),
|
||||
format = function(_, vim_item)
|
||||
local icon, hl = MiniIcons.get("lsp", vim_item.kind)
|
||||
vim_item.kind = icon .. " " .. vim_item.kind
|
||||
vim_item.kind_hl_group = hl
|
||||
return vim_item
|
||||
end,
|
||||
},
|
||||
}
|
||||
|
||||
cmp.setup.filetype("tex", {
|
||||
sources = {
|
||||
{ name = "omni" },
|
||||
{ name = "ultisnips" }, -- For ultisnips user.
|
||||
{ name = "buffer", keyword_length = 2 }, -- for buffer word completion
|
||||
{ name = "path" }, -- for path completion
|
||||
},
|
||||
})
|
||||
|
||||
-- see https://github.com/hrsh7th/nvim-cmp/wiki/Menu-Appearance#how-to-add-visual-studio-code-dark-theme-colors-to-the-menu
|
||||
vim.cmd[[
|
||||
vim.cmd([[
|
||||
highlight! link CmpItemMenu Comment
|
||||
" gray
|
||||
highlight! CmpItemAbbrDeprecated guibg=NONE gui=strikethrough guifg=#808080
|
||||
@@ -81,4 +90,4 @@ vim.cmd[[
|
||||
highlight! CmpItemKindKeyword guibg=NONE guifg=#D4D4D4
|
||||
highlight! CmpItemKindProperty guibg=NONE guifg=#D4D4D4
|
||||
highlight! CmpItemKindUnit guibg=NONE guifg=#D4D4D4
|
||||
]]
|
||||
]])
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
local nvim_notify = require("notify")
|
||||
nvim_notify.setup({
|
||||
nvim_notify.setup {
|
||||
-- Animation style
|
||||
stages = "fade_in_slide_out",
|
||||
-- Default timeout for notifications
|
||||
timeout = 1500,
|
||||
background_colour = "#2E3440",
|
||||
})
|
||||
}
|
||||
|
||||
vim.notify = nvim_notify
|
||||
|
||||
23
lua/config/nvim-statuscol.lua
Normal file
23
lua/config/nvim-statuscol.lua
Normal file
@@ -0,0 +1,23 @@
|
||||
local builtin = require("statuscol.builtin")
|
||||
local ffi = require("statuscol.ffidef")
|
||||
local C = ffi.C
|
||||
|
||||
-- only show fold level up to this level
|
||||
local fold_level_limit = 3
|
||||
local function foldfunc(args)
|
||||
local foldinfo = C.fold_info(args.wp, args.lnum)
|
||||
if foldinfo.level > fold_level_limit then
|
||||
return " "
|
||||
end
|
||||
|
||||
return builtin.foldfunc(args)
|
||||
end
|
||||
|
||||
require("statuscol").setup {
|
||||
relculright = false,
|
||||
segments = {
|
||||
{ text = { "%s" }, click = "v:lua.ScSa" },
|
||||
{ text = { builtin.lnumfunc, " " }, click = "v:lua.ScLa" },
|
||||
{ text = { foldfunc, " " }, condition = { true, builtin.not_empty }, click = "v:lua.ScFa" },
|
||||
},
|
||||
}
|
||||
@@ -1,62 +1,108 @@
|
||||
local keymap = vim.keymap
|
||||
local nvim_tree = require("nvim-tree")
|
||||
|
||||
nvim_tree.setup({
|
||||
disable_netrw = true,
|
||||
nvim_tree.setup {
|
||||
auto_reload_on_write = true,
|
||||
disable_netrw = false,
|
||||
hijack_netrw = true,
|
||||
open_on_setup = false,
|
||||
ignore_ft_on_setup = {},
|
||||
open_on_tab = false,
|
||||
hijack_cursor = false,
|
||||
hijack_unnamed_buffer_when_opening = false,
|
||||
open_on_tab = false,
|
||||
sort_by = "name",
|
||||
update_cwd = false,
|
||||
update_to_buf_dir = {
|
||||
enable = true,
|
||||
auto_open = true,
|
||||
view = {
|
||||
width = 30,
|
||||
side = "left",
|
||||
preserve_window_proportions = false,
|
||||
number = false,
|
||||
relativenumber = false,
|
||||
signcolumn = "yes",
|
||||
},
|
||||
diagnostics = {
|
||||
renderer = {
|
||||
indent_markers = {
|
||||
enable = false,
|
||||
icons = {
|
||||
hint = "",
|
||||
info = "",
|
||||
warning = "",
|
||||
error = "",
|
||||
corner = "└ ",
|
||||
edge = "│ ",
|
||||
none = " ",
|
||||
},
|
||||
},
|
||||
icons = {
|
||||
webdev_colors = true,
|
||||
},
|
||||
},
|
||||
hijack_directories = {
|
||||
enable = true,
|
||||
auto_open = true,
|
||||
},
|
||||
update_focused_file = {
|
||||
enable = false,
|
||||
update_cwd = false,
|
||||
ignore_list = {},
|
||||
},
|
||||
system_open = {
|
||||
cmd = nil,
|
||||
cmd = "",
|
||||
args = {},
|
||||
},
|
||||
diagnostics = {
|
||||
enable = false,
|
||||
show_on_dirs = false,
|
||||
icons = {
|
||||
hint = "",
|
||||
info = "",
|
||||
warning = "",
|
||||
error = "",
|
||||
},
|
||||
},
|
||||
filters = {
|
||||
dotfiles = false,
|
||||
custom = {},
|
||||
exclude = {},
|
||||
},
|
||||
git = {
|
||||
enable = true,
|
||||
ignore = true,
|
||||
timeout = 500,
|
||||
timeout = 400,
|
||||
},
|
||||
actions = {
|
||||
use_system_clipboard = true,
|
||||
change_dir = {
|
||||
enable = true,
|
||||
global = false,
|
||||
restrict_above_cwd = false,
|
||||
},
|
||||
open_file = {
|
||||
quit_on_open = false,
|
||||
resize_window = false,
|
||||
window_picker = {
|
||||
enable = true,
|
||||
chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890",
|
||||
exclude = {
|
||||
filetype = { "notify", "qf", "diff", "fugitive", "fugitiveblame" },
|
||||
buftype = { "nofile", "terminal", "help" },
|
||||
},
|
||||
},
|
||||
view = {
|
||||
width = 35,
|
||||
height = 30,
|
||||
hide_root_folder = false,
|
||||
side = "left",
|
||||
auto_resize = true,
|
||||
mappings = {
|
||||
custom_only = false,
|
||||
list = {},
|
||||
},
|
||||
number = false,
|
||||
relativenumber = false,
|
||||
signcolumn = "yes",
|
||||
},
|
||||
trash = {
|
||||
cmd = "trash",
|
||||
require_confirm = true,
|
||||
},
|
||||
})
|
||||
log = {
|
||||
enable = false,
|
||||
truncate = false,
|
||||
types = {
|
||||
all = false,
|
||||
config = false,
|
||||
copy_paste = false,
|
||||
diagnostics = false,
|
||||
git = false,
|
||||
profile = false,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
vim.api.nvim_set_keymap("n", "<space>s", "<cmd>lua require'nvim-tree'.toggle(false, true)<CR>", { noremap = true, silent = true })
|
||||
keymap.set("n", "<space>s", require("nvim-tree.api").tree.toggle, {
|
||||
silent = true,
|
||||
desc = "toggle nvim-tree",
|
||||
})
|
||||
|
||||
@@ -1,11 +1,28 @@
|
||||
vim.cmd[[ hi HopNextKey cterm=bold ctermfg=176 gui=bold guibg=#ff00ff guifg=#ffffff ]]
|
||||
vim.cmd[[ hi HopNextKey1 cterm=bold ctermfg=176 gui=bold guibg=#ff00ff guifg=#ffffff ]]
|
||||
vim.cmd[[ hi HopNextKey2 cterm=bold ctermfg=176 gui=bold guibg=#ff00ff guifg=#ffffff ]]
|
||||
|
||||
require('hop').setup({
|
||||
local keymap = vim.keymap
|
||||
local hop = require("hop")
|
||||
hop.setup {
|
||||
case_insensitive = true,
|
||||
char2_fallback_key = '<CR>',
|
||||
quit_key='<Esc>',
|
||||
char2_fallback_key = "<CR>",
|
||||
quit_key = "<Esc>",
|
||||
match_mappings = { "zh_sc" },
|
||||
}
|
||||
|
||||
keymap.set({ "n", "v", "o" }, "f", "", {
|
||||
silent = true,
|
||||
noremap = true,
|
||||
callback = function()
|
||||
hop.hint_char2()
|
||||
end,
|
||||
desc = "nvim-hop char2",
|
||||
})
|
||||
|
||||
vim.api.nvim_set_keymap('n', 'f', "<cmd>lua require'hop'.hint_char2()<cr>", {noremap = true})
|
||||
vim.api.nvim_create_autocmd("ColorScheme", {
|
||||
pattern = "*",
|
||||
callback = function()
|
||||
vim.cmd([[
|
||||
hi HopNextKey cterm=bold ctermfg=176 gui=bold guibg=#ff00ff guifg=#ffffff
|
||||
hi HopNextKey1 cterm=bold ctermfg=176 gui=bold guibg=#ff00ff guifg=#ffffff
|
||||
hi HopNextKey2 cterm=bold ctermfg=176 gui=bold guibg=#ff00ff guifg=#ffffff
|
||||
]])
|
||||
end,
|
||||
})
|
||||
|
||||
44
lua/config/nvim_ufo.lua
Normal file
44
lua/config/nvim_ufo.lua
Normal file
@@ -0,0 +1,44 @@
|
||||
local handler = function(virtText, lnum, endLnum, width, truncate)
|
||||
local newVirtText = {}
|
||||
local foldedLines = endLnum - lnum
|
||||
local suffix = (" %d"):format(foldedLines)
|
||||
local sufWidth = vim.fn.strdisplaywidth(suffix)
|
||||
local targetWidth = width - sufWidth
|
||||
local curWidth = 0
|
||||
|
||||
for _, chunk in ipairs(virtText) do
|
||||
local chunkText = chunk[1]
|
||||
local chunkWidth = vim.fn.strdisplaywidth(chunkText)
|
||||
if targetWidth > curWidth + chunkWidth then
|
||||
table.insert(newVirtText, chunk)
|
||||
else
|
||||
chunkText = truncate(chunkText, targetWidth - curWidth)
|
||||
local hlGroup = chunk[2]
|
||||
table.insert(newVirtText, { chunkText, hlGroup })
|
||||
chunkWidth = vim.fn.strdisplaywidth(chunkText)
|
||||
-- str width returned from truncate() may less than 2nd argument, need padding
|
||||
if curWidth + chunkWidth < targetWidth then
|
||||
suffix = suffix .. (" "):rep(targetWidth - curWidth - chunkWidth)
|
||||
end
|
||||
break
|
||||
end
|
||||
curWidth = curWidth + chunkWidth
|
||||
end
|
||||
local rAlignAppndx = math.max(math.min(vim.opt.textwidth["_value"], width - 1) - curWidth - sufWidth, 0)
|
||||
suffix = (" "):rep(rAlignAppndx) .. suffix
|
||||
table.insert(newVirtText, { suffix, "MoreMsg" })
|
||||
return newVirtText
|
||||
end
|
||||
|
||||
require("ufo").setup {
|
||||
fold_virt_text_handler = handler,
|
||||
}
|
||||
|
||||
vim.keymap.set("n", "zR", require("ufo").openAllFolds)
|
||||
vim.keymap.set("n", "zM", require("ufo").closeAllFolds)
|
||||
vim.keymap.set("n", "zr", require("ufo").openFoldsExceptKinds)
|
||||
vim.keymap.set("n", "<leader>K", function()
|
||||
local _ = require("ufo").peekFoldedLinesUnderCursor()
|
||||
end, {
|
||||
desc = "Preview folded maps",
|
||||
})
|
||||
@@ -1,124 +0,0 @@
|
||||
local function spell()
|
||||
if vim.o.spell then
|
||||
return string.format("[SPELL]")
|
||||
end
|
||||
|
||||
return ""
|
||||
end
|
||||
|
||||
local function ime_state()
|
||||
if vim.g.is_mac then
|
||||
-- ref: https://github.com/vim-airline/vim-airline/blob/master/autoload/airline/extensions/xkblayout.vim#L11
|
||||
local layout = vim.fn.libcall(vim.g.XkbSwitchLib, 'Xkb_Switch_getXkbLayout', '')
|
||||
if layout == '0' then
|
||||
return '[CN]'
|
||||
end
|
||||
end
|
||||
|
||||
return ""
|
||||
end
|
||||
|
||||
local function trailing_space()
|
||||
-- Get the positions of trailing whitespaces from plugin 'jdhao/whitespace.nvim'.
|
||||
local trailing_space_pos = vim.b.trailing_whitespace_pos
|
||||
|
||||
local msg = ""
|
||||
if #trailing_space_pos > 0 then
|
||||
-- Note that lua index is 1-based, not zero based!!!
|
||||
local line = trailing_space_pos[1][1]
|
||||
msg = string.format("[%d]trailing", line)
|
||||
end
|
||||
|
||||
return msg
|
||||
end
|
||||
|
||||
local function mixed_indent()
|
||||
local space_pat = [[\v^ +]]
|
||||
local tab_pat = [[\v^\t+]]
|
||||
local space_indent = vim.fn.search(space_pat, 'nwc')
|
||||
local tab_indent = vim.fn.search(tab_pat, 'nwc')
|
||||
local mixed = (space_indent > 0 and tab_indent > 0)
|
||||
local mixed_same_line
|
||||
if not mixed then
|
||||
mixed_same_line = vim.fn.search([[\v^(\t+ | +\t)]], 'nwc')
|
||||
mixed = mixed_same_line > 0
|
||||
end
|
||||
if not mixed then return '' end
|
||||
if mixed_same_line ~= nil and mixed_same_line > 0 then
|
||||
return 'MI:'..mixed_same_line
|
||||
end
|
||||
local space_indent_cnt = vim.fn.searchcount({pattern=space_pat, max_count=1e3}).total
|
||||
local tab_indent_cnt = vim.fn.searchcount({pattern=tab_pat, max_count=1e3}).total
|
||||
if space_indent_cnt > tab_indent_cnt then
|
||||
return 'MI:'..tab_indent
|
||||
else
|
||||
return 'MI:'..space_indent
|
||||
end
|
||||
end
|
||||
|
||||
require("lualine").setup({
|
||||
options = {
|
||||
icons_enabled = true,
|
||||
theme = "auto",
|
||||
-- component_separators = { left = "", right = "" },
|
||||
-- section_separators = { left = "", right = "" },
|
||||
section_separators = "",
|
||||
component_separators = "",
|
||||
disabled_filetypes = {},
|
||||
always_divide_middle = true,
|
||||
},
|
||||
sections = {
|
||||
lualine_a = { "mode" },
|
||||
lualine_b = { "branch", "diff" },
|
||||
lualine_c = {
|
||||
"filename",
|
||||
{
|
||||
ime_state,
|
||||
color = {fg = 'black', bg = '#f46868'}
|
||||
},
|
||||
{
|
||||
spell,
|
||||
color = {fg = 'black', bg = '#a7c080'}
|
||||
},
|
||||
},
|
||||
lualine_x = {
|
||||
"encoding",
|
||||
{
|
||||
"fileformat",
|
||||
symbols = {
|
||||
unix = "unix",
|
||||
dos = "win",
|
||||
mac = "mac",
|
||||
},
|
||||
},
|
||||
"filetype",
|
||||
},
|
||||
lualine_y = { "progress" },
|
||||
lualine_z = {
|
||||
"location",
|
||||
{
|
||||
"diagnostics",
|
||||
sources = { "nvim_diagnostic" }
|
||||
},
|
||||
{
|
||||
trailing_space,
|
||||
color = "WarningMsg"
|
||||
},
|
||||
{
|
||||
mixed_indent,
|
||||
color = "WarningMsg"
|
||||
},
|
||||
},
|
||||
},
|
||||
inactive_sections = {
|
||||
lualine_a = {},
|
||||
lualine_b = {},
|
||||
lualine_c = { "filename" },
|
||||
lualine_x = { "location" },
|
||||
lualine_y = {},
|
||||
lualine_z = {},
|
||||
},
|
||||
tabline = {},
|
||||
extensions = {'quickfix', 'fugitive', 'nvim-tree'},
|
||||
})
|
||||
|
||||
44
lua/config/treesitter-textobjects.lua
Normal file
44
lua/config/treesitter-textobjects.lua
Normal file
@@ -0,0 +1,44 @@
|
||||
require("nvim-treesitter.configs").setup {
|
||||
textobjects = {
|
||||
select = {
|
||||
enable = true,
|
||||
|
||||
-- Automatically jump forward to textobj, similar to targets.vim
|
||||
lookahead = true,
|
||||
|
||||
keymaps = {
|
||||
-- You can use the capture groups defined in textobjects.scm
|
||||
["af"] = "@function.outer",
|
||||
["if"] = "@function.inner",
|
||||
["ac"] = "@class.outer",
|
||||
-- You can optionally set descriptions to the mappings (used in the desc parameter of
|
||||
-- nvim_buf_set_keymap) which plugins like which-key display
|
||||
["ic"] = { query = "@class.inner", desc = "Select inner part of a class region" },
|
||||
},
|
||||
-- You can choose the select mode (default is charwise 'v')
|
||||
--
|
||||
-- Can also be a function which gets passed a table with the keys
|
||||
-- * query_string: eg '@function.inner'
|
||||
-- * method: eg 'v' or 'o'
|
||||
-- and should return the mode ('v', 'V', or '<c-v>') or a table
|
||||
-- mapping query_strings to modes.
|
||||
selection_modes = {
|
||||
["@function.inner"] = "V", -- linewise
|
||||
["@function.outer"] = "V", -- linewise
|
||||
["@class.outer"] = "V", -- linewise
|
||||
["@class.inner"] = "V", -- linewise
|
||||
["@parameter.outer"] = "v", -- charwise
|
||||
},
|
||||
-- If you set this to `true` (default is `false`) then any textobject is
|
||||
-- extended to include preceding or succeeding whitespace. Succeeding
|
||||
-- whitespace has priority in order to act similarly to eg the built-in
|
||||
-- `ap`.
|
||||
--
|
||||
-- Can also be a function which gets passed a table with the keys
|
||||
-- * query_string: eg '@function.inner'
|
||||
-- * selection_mode: eg 'v'
|
||||
-- and should return true or false
|
||||
include_surrounding_whitespace = false,
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
require("nvim-treesitter.configs").setup({
|
||||
ensure_installed = {"python", "cpp", "lua", "vim"},
|
||||
require("nvim-treesitter.configs").setup {
|
||||
ensure_installed = { "python", "cpp", "lua", "vim", "json", "toml" },
|
||||
ignore_install = {}, -- List of parsers to ignore installing
|
||||
highlight = {
|
||||
enable = true, -- false will disable the whole extension
|
||||
disable = {}, -- list of language that will be disabled
|
||||
disable = { "help" }, -- list of language that will be disabled
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,60 +1,6 @@
|
||||
require("which-key").setup({
|
||||
plugins = {
|
||||
marks = true, -- shows a list of your marks on ' and `
|
||||
registers = true, -- shows your registers on " in NORMAL or <C-r> in INSERT mode
|
||||
spelling = {
|
||||
enabled = true, -- enabling this will show WhichKey when pressing z= to select spelling suggestions
|
||||
suggestions = 9, -- how many suggestions should be shown in the list?
|
||||
},
|
||||
-- the presets plugin, adds help for a bunch of default keybindings in Neovim
|
||||
-- No actual key bindings are created
|
||||
presets = {
|
||||
operators = true, -- adds help for operators like d, y, ... and registers them for motion / text object completion
|
||||
motions = true, -- adds help for motions
|
||||
text_objects = true, -- help for text objects triggered after entering an operator
|
||||
windows = true, -- default bindings on <c-w>
|
||||
nav = true, -- misc bindings to work with windows
|
||||
z = true, -- bindings for folds, spelling and others prefixed with z
|
||||
g = true, -- bindings for prefixed with g
|
||||
},
|
||||
},
|
||||
-- add operators that will trigger motion and text object completion
|
||||
-- to enable all native operators, set the preset / operators plugin above
|
||||
operators = { gc = "Comments" },
|
||||
key_labels = {
|
||||
-- override the label used to display some keys. It doesn't effect WK in any other way.
|
||||
-- For example:
|
||||
-- ["<space>"] = "SPC",
|
||||
-- ["<cr>"] = "RET",
|
||||
-- ["<tab>"] = "TAB",
|
||||
},
|
||||
require("which-key").setup {
|
||||
preset = "modern",
|
||||
icons = {
|
||||
breadcrumb = "»", -- symbol used in the command line area that shows your active key combo
|
||||
separator = "➜", -- symbol used between a key and it's label
|
||||
group = "+", -- symbol prepended to a group
|
||||
mappings = false,
|
||||
},
|
||||
window = {
|
||||
border = "none", -- none, single, double, shadow
|
||||
position = "bottom", -- bottom, top
|
||||
margin = { 0, 0, 0, 0 }, -- extra window margin [top, right, bottom, left]
|
||||
padding = { 1, 0, 1, 0 }, -- extra window padding [top, right, bottom, left]
|
||||
},
|
||||
layout = {
|
||||
height = { min = 1, max = 25 }, -- min and max height of the columns
|
||||
width = { min = 20, max = 50 }, -- min and max width of the columns
|
||||
spacing = 1, -- spacing between columns
|
||||
align = "center", -- align columns left, center or right
|
||||
},
|
||||
ignore_missing = false, -- enable this to hide mappings for which you didn't specify a label
|
||||
hidden = { "<silent>", "<cmd>", "<Cmd>", "<CR>", "call", "lua", "^:", "^ "}, -- hide mapping boilerplate
|
||||
show_help = true, -- show help message on the command line when the popup is visible
|
||||
triggers = "auto", -- automatically setup triggers
|
||||
-- triggers = {"<leader>"} -- or specify a list manually
|
||||
|
||||
triggers_blacklist = {
|
||||
-- list of mode / prefixes that should never be hooked by WhichKey
|
||||
-- this is mostly relevant for key maps that start with a native binding
|
||||
-- most people should not need to change this
|
||||
n = { "o", "O" },
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
17
lua/config/yanky.lua
Normal file
17
lua/config/yanky.lua
Normal file
@@ -0,0 +1,17 @@
|
||||
require("yanky").setup {
|
||||
preserve_cursor_position = {
|
||||
enabled = false,
|
||||
},
|
||||
highlight = {
|
||||
on_put = true,
|
||||
on_yank = false,
|
||||
timer = 300,
|
||||
},
|
||||
}
|
||||
|
||||
vim.keymap.set({ "n", "x" }, "p", "<Plug>(YankyPutAfter)")
|
||||
vim.keymap.set({ "n", "x" }, "P", "<Plug>(YankyPutBefore)")
|
||||
|
||||
-- cycle through the yank history, only work after paste
|
||||
vim.keymap.set("n", "[y", "<Plug>(YankyPreviousEntry)")
|
||||
vim.keymap.set("n", "]y", "<Plug>(YankyNextEntry)")
|
||||
@@ -1,15 +0,0 @@
|
||||
require("zen-mode").setup({
|
||||
window = {
|
||||
backdrop = 0.8, -- shade the backdrop of the Zen window. Set to 1 to keep the same as Normal
|
||||
width = 120,
|
||||
options = {
|
||||
-- signcolumn = "no", -- disable signcolumn
|
||||
-- number = false, -- disable number column
|
||||
-- relativenumber = false, -- disable relative numbers
|
||||
cursorline = false, -- disable cursorline
|
||||
cursorcolumn = false, -- disable cursor column
|
||||
foldcolumn = "0", -- disable fold column
|
||||
list = false, -- disable whitespace characters
|
||||
},
|
||||
},
|
||||
})
|
||||
244
lua/custom-autocmd.lua
Normal file
244
lua/custom-autocmd.lua
Normal file
@@ -0,0 +1,244 @@
|
||||
local fn = vim.fn
|
||||
local api = vim.api
|
||||
|
||||
local utils = require("utils")
|
||||
|
||||
-- Display a message when the current file is not in utf-8 format.
|
||||
-- Note that we need to use `unsilent` command here because of this issue:
|
||||
-- https://github.com/vim/vim/issues/4379
|
||||
api.nvim_create_autocmd({ "BufRead" }, {
|
||||
pattern = "*",
|
||||
group = api.nvim_create_augroup("non_utf8_file", { clear = true }),
|
||||
callback = function()
|
||||
if vim.bo.fileencoding ~= "utf-8" then
|
||||
vim.notify("File not in UTF-8 format!", vim.log.levels.WARN, { title = "nvim-config" })
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
-- highlight yanked region, see `:h lua-highlight`
|
||||
local yank_group = api.nvim_create_augroup("highlight_yank", { clear = true })
|
||||
api.nvim_create_autocmd({ "TextYankPost" }, {
|
||||
pattern = "*",
|
||||
group = yank_group,
|
||||
callback = function()
|
||||
vim.hl.on_yank { higroup = "YankColor", timeout = 300 }
|
||||
end,
|
||||
})
|
||||
|
||||
api.nvim_create_autocmd({ "CursorMoved" }, {
|
||||
pattern = "*",
|
||||
group = yank_group,
|
||||
callback = function()
|
||||
vim.g.current_cursor_pos = vim.fn.getcurpos()
|
||||
end,
|
||||
})
|
||||
|
||||
api.nvim_create_autocmd("TextYankPost", {
|
||||
pattern = "*",
|
||||
group = yank_group,
|
||||
---@diagnostic disable-next-line: unused-local
|
||||
callback = function(context)
|
||||
if vim.v.event.operator == "y" then
|
||||
vim.fn.setpos(".", vim.g.current_cursor_pos)
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
-- Auto-create dir when saving a file, in case some intermediate directory does not exist
|
||||
api.nvim_create_autocmd({ "BufWritePre" }, {
|
||||
pattern = "*",
|
||||
group = api.nvim_create_augroup("auto_create_dir", { clear = true }),
|
||||
callback = function(ctx)
|
||||
local dir = fn.fnamemodify(ctx.file, ":p:h")
|
||||
utils.may_create_dir(dir)
|
||||
end,
|
||||
})
|
||||
|
||||
-- Automatically reload the file if it is changed outside of Nvim, see https://unix.stackexchange.com/a/383044/221410.
|
||||
-- It seems that `checktime` does not work in command line. We need to check if we are in command
|
||||
-- line before executing this command, see also https://vi.stackexchange.com/a/20397/15292 .
|
||||
api.nvim_create_augroup("auto_read", { clear = true })
|
||||
|
||||
api.nvim_create_autocmd({ "FileChangedShellPost" }, {
|
||||
pattern = "*",
|
||||
group = "auto_read",
|
||||
callback = function()
|
||||
vim.notify("File changed on disk. Buffer reloaded!", vim.log.levels.WARN, { title = "nvim-config" })
|
||||
end,
|
||||
})
|
||||
|
||||
api.nvim_create_autocmd({ "FocusGained", "CursorHold" }, {
|
||||
pattern = "*",
|
||||
group = "auto_read",
|
||||
callback = function()
|
||||
if fn.getcmdwintype() == "" then
|
||||
vim.cmd("checktime")
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
-- Resize all windows when we resize the terminal
|
||||
api.nvim_create_autocmd("VimResized", {
|
||||
group = api.nvim_create_augroup("win_autoresize", { clear = true }),
|
||||
desc = "autoresize windows on resizing operation",
|
||||
command = "wincmd =",
|
||||
})
|
||||
|
||||
local function open_nvim_tree(data)
|
||||
-- check if buffer is a directory
|
||||
local directory = vim.fn.isdirectory(data.file) == 1
|
||||
|
||||
if not directory then
|
||||
return
|
||||
end
|
||||
|
||||
-- create a new, empty buffer
|
||||
vim.cmd.enew()
|
||||
|
||||
-- wipe the directory buffer
|
||||
vim.cmd.bw(data.buf)
|
||||
|
||||
-- open the tree
|
||||
require("nvim-tree.api").tree.open()
|
||||
end
|
||||
|
||||
api.nvim_create_autocmd({ "VimEnter" }, { callback = open_nvim_tree })
|
||||
|
||||
-- Do not use smart case in command line mode, extracted from https://vi.stackexchange.com/a/16511/15292.
|
||||
api.nvim_create_augroup("dynamic_smartcase", { clear = true })
|
||||
api.nvim_create_autocmd("CmdLineEnter", {
|
||||
group = "dynamic_smartcase",
|
||||
pattern = ":",
|
||||
callback = function()
|
||||
vim.o.smartcase = false
|
||||
end,
|
||||
})
|
||||
|
||||
api.nvim_create_autocmd("CmdLineLeave", {
|
||||
group = "dynamic_smartcase",
|
||||
pattern = ":",
|
||||
callback = function()
|
||||
vim.o.smartcase = true
|
||||
end,
|
||||
})
|
||||
|
||||
api.nvim_create_autocmd("TermOpen", {
|
||||
group = api.nvim_create_augroup("term_start", { clear = true }),
|
||||
pattern = "*",
|
||||
callback = function()
|
||||
-- Do not use number and relative number for terminal inside nvim
|
||||
vim.wo.relativenumber = false
|
||||
vim.wo.number = false
|
||||
|
||||
-- Go to insert mode by default to start typing command
|
||||
vim.cmd("startinsert")
|
||||
end,
|
||||
})
|
||||
|
||||
local number_toggle_group = api.nvim_create_augroup("numbertoggle", { clear = true })
|
||||
api.nvim_create_autocmd({ "BufEnter", "FocusGained", "InsertLeave", "WinEnter" }, {
|
||||
pattern = "*",
|
||||
group = number_toggle_group,
|
||||
desc = "togger line number",
|
||||
callback = function()
|
||||
if vim.wo.number then
|
||||
vim.wo.relativenumber = true
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
api.nvim_create_autocmd({ "BufLeave", "FocusLost", "InsertEnter", "WinLeave" }, {
|
||||
group = number_toggle_group,
|
||||
desc = "togger line number",
|
||||
callback = function()
|
||||
if vim.wo.number then
|
||||
vim.wo.relativenumber = false
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
api.nvim_create_autocmd("ColorScheme", {
|
||||
group = api.nvim_create_augroup("custom_highlight", { clear = true }),
|
||||
pattern = "*",
|
||||
desc = "Define or overrride some highlight groups",
|
||||
callback = function()
|
||||
-- For yank highlight
|
||||
vim.api.nvim_set_hl(0, "YankColor", { fg = "#34495E", bg = "#2ECC71", ctermfg = 59, ctermbg = 41 })
|
||||
|
||||
-- For cursor colors
|
||||
vim.api.nvim_set_hl(0, "Cursor", { fg = "black", bg = "#00c918", bold = true })
|
||||
vim.api.nvim_set_hl(0, "Cursor2", { fg = "red", bg = "red" })
|
||||
|
||||
-- For floating windows border highlight
|
||||
vim.api.nvim_set_hl(0, "FloatBorder", { fg = "LightGreen", bg = "None", bold = true })
|
||||
|
||||
local hl = vim.api.nvim_get_hl(0, { name = "NormalFloat" })
|
||||
-- change the background color of floating window to None, so it blenders better
|
||||
vim.api.nvim_set_hl(0, "NormalFloat", { fg = hl.fg, bg = "None" })
|
||||
|
||||
-- highlight for matching parentheses
|
||||
vim.api.nvim_set_hl(0, "MatchParen", { bold = true, underline = true })
|
||||
end,
|
||||
})
|
||||
|
||||
api.nvim_create_autocmd("BufEnter", {
|
||||
pattern = "*",
|
||||
group = api.nvim_create_augroup("auto_close_win", { clear = true }),
|
||||
desc = "Quit Nvim if we have only one window, and its filetype match our pattern",
|
||||
---@diagnostic disable-next-line: unused-local
|
||||
callback = function(context)
|
||||
local quit_filetypes = { "qf", "vista", "NvimTree" }
|
||||
|
||||
local should_quit = true
|
||||
local tabwins = api.nvim_tabpage_list_wins(0)
|
||||
|
||||
for _, win in pairs(tabwins) do
|
||||
local buf = api.nvim_win_get_buf(win)
|
||||
local buf_type = vim.api.nvim_get_option_value("filetype", { buf = buf })
|
||||
|
||||
if not vim.tbl_contains(quit_filetypes, buf_type) then
|
||||
should_quit = false
|
||||
end
|
||||
end
|
||||
|
||||
if should_quit then
|
||||
vim.cmd("qall")
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
api.nvim_create_autocmd({ "VimEnter", "DirChanged" }, {
|
||||
group = api.nvim_create_augroup("git_repo_check", { clear = true }),
|
||||
pattern = "*",
|
||||
desc = "check if we are inside Git repo",
|
||||
callback = function()
|
||||
utils.inside_git_repo()
|
||||
end,
|
||||
})
|
||||
|
||||
-- ref: https://vi.stackexchange.com/a/169/15292
|
||||
api.nvim_create_autocmd("BufReadPre", {
|
||||
group = api.nvim_create_augroup("large_file", { clear = true }),
|
||||
pattern = "*",
|
||||
desc = "optimize for large file",
|
||||
callback = function(ev)
|
||||
local file_size_limit = 524288 -- 0.5MB
|
||||
local f = ev.file
|
||||
|
||||
if fn.getfsize(f) > file_size_limit or fn.getfsize(f) == -2 then
|
||||
vim.o.eventignore = "all"
|
||||
|
||||
-- show ruler
|
||||
vim.o.ruler = true
|
||||
|
||||
-- turning off relative number helps a lot
|
||||
vim.wo.relativenumber = false
|
||||
vim.wo.number = false
|
||||
|
||||
vim.bo.swapfile = false
|
||||
vim.bo.bufhidden = "unload"
|
||||
vim.bo.undolevels = -1
|
||||
end
|
||||
end,
|
||||
})
|
||||
66
lua/diagnostic-conf.lua
Normal file
66
lua/diagnostic-conf.lua
Normal file
@@ -0,0 +1,66 @@
|
||||
local diagnostic = vim.diagnostic
|
||||
local api = vim.api
|
||||
|
||||
-- global config for diagnostic
|
||||
diagnostic.config {
|
||||
underline = false,
|
||||
virtual_text = false,
|
||||
virtual_lines = false,
|
||||
signs = {
|
||||
text = {
|
||||
[diagnostic.severity.ERROR] = "🆇",
|
||||
[diagnostic.severity.WARN] = "⚠️",
|
||||
[diagnostic.severity.INFO] = "ℹ️",
|
||||
[diagnostic.severity.HINT] = "",
|
||||
},
|
||||
},
|
||||
severity_sort = true,
|
||||
float = {
|
||||
source = true,
|
||||
header = "Diagnostics:",
|
||||
prefix = " ",
|
||||
border = "single",
|
||||
},
|
||||
}
|
||||
|
||||
-- set quickfix list from diagnostics in a certain buffer, not the whole workspace
|
||||
local set_qflist = function(buf_num, severity)
|
||||
local diagnostics = nil
|
||||
diagnostics = diagnostic.get(buf_num, { severity = severity })
|
||||
|
||||
local qf_items = diagnostic.toqflist(diagnostics)
|
||||
vim.fn.setqflist({}, " ", { title = "Diagnostics", items = qf_items })
|
||||
|
||||
-- open quickfix by default
|
||||
vim.cmd([[copen]])
|
||||
end
|
||||
|
||||
-- this puts diagnostics from opened files to quickfix
|
||||
vim.keymap.set("n", "<space>qw", diagnostic.setqflist, { desc = "put window diagnostics to qf" })
|
||||
|
||||
-- this puts diagnostics from current buffer to quickfix
|
||||
vim.keymap.set("n", "<space>qb", function()
|
||||
set_qflist(0)
|
||||
end, { desc = "put buffer diagnostics to qf" })
|
||||
|
||||
-- automatically show diagnostic in float win for current line
|
||||
api.nvim_create_autocmd("CursorHold", {
|
||||
pattern = "*",
|
||||
callback = function()
|
||||
if #vim.diagnostic.get(0) == 0 then
|
||||
return
|
||||
end
|
||||
|
||||
if not vim.b.diagnostics_pos then
|
||||
vim.b.diagnostics_pos = { nil, nil }
|
||||
end
|
||||
|
||||
local cursor_pos = api.nvim_win_get_cursor(0)
|
||||
|
||||
if not vim.deep_equal(cursor_pos, vim.b.diagnostics_pos) then
|
||||
diagnostic.open_float { width = 100 }
|
||||
end
|
||||
|
||||
vim.b.diagnostics_pos = cursor_pos
|
||||
end,
|
||||
})
|
||||
74
lua/globals.lua
Normal file
74
lua/globals.lua
Normal file
@@ -0,0 +1,74 @@
|
||||
local fn = vim.fn
|
||||
local api = vim.api
|
||||
|
||||
local utils = require("utils")
|
||||
|
||||
------------------------------------------------------------------------
|
||||
-- custom variables --
|
||||
------------------------------------------------------------------------
|
||||
vim.g.is_win = (utils.has("win32") or utils.has("win64")) and true or false
|
||||
vim.g.is_linux = (utils.has("unix") and (not utils.has("macunix"))) and true or false
|
||||
vim.g.is_mac = utils.has("macunix") and true or false
|
||||
|
||||
vim.g.logging_level = vim.log.levels.INFO
|
||||
|
||||
------------------------------------------------------------------------
|
||||
-- builtin variables --
|
||||
------------------------------------------------------------------------
|
||||
vim.g.loaded_perl_provider = 0 -- Disable perl provider
|
||||
vim.g.loaded_ruby_provider = 0 -- Disable ruby provider
|
||||
vim.g.loaded_node_provider = 0 -- Disable node provider
|
||||
vim.g.did_install_default_menus = 1 -- do not load menu
|
||||
|
||||
if utils.executable("python3") then
|
||||
if vim.g.is_win then
|
||||
vim.g.python3_host_prog = fn.substitute(fn.exepath("python3"), ".exe$", "", "g")
|
||||
else
|
||||
vim.g.python3_host_prog = fn.exepath("python3")
|
||||
end
|
||||
else
|
||||
local msg = "Python3 executable not found! You must install Python3 and set its PATH correctly!"
|
||||
api.nvim_echo({ { msg } }, true, { err = true })
|
||||
return
|
||||
end
|
||||
|
||||
-- Custom mapping <leader> (see `:h mapleader` for more info)
|
||||
vim.g.mapleader = ","
|
||||
|
||||
-- Enable highlighting for lua HERE doc inside vim script
|
||||
vim.g.vimsyn_embed = "l"
|
||||
|
||||
-- Use English as main language
|
||||
vim.cmd([[language en_US.UTF-8]])
|
||||
|
||||
-- Disable loading certain plugins
|
||||
|
||||
-- Whether to load netrw by default, see https://github.com/bling/dotvim/issues/4
|
||||
vim.g.loaded_netrw = 1
|
||||
vim.g.loaded_netrwPlugin = 1
|
||||
vim.g.netrw_liststyle = 3
|
||||
if vim.g.is_win then
|
||||
vim.g.netrw_http_cmd = "curl --ssl-no-revoke -Lo"
|
||||
end
|
||||
|
||||
-- Do not load tohtml.vim
|
||||
vim.g.loaded_2html_plugin = 1
|
||||
|
||||
-- Do not load zipPlugin.vim, gzip.vim and tarPlugin.vim (all these plugins are
|
||||
-- related to checking files inside compressed files)
|
||||
vim.g.loaded_zipPlugin = 1
|
||||
vim.g.loaded_gzip = 1
|
||||
vim.g.loaded_tarPlugin = 1
|
||||
|
||||
-- Do not load the tutor plugin
|
||||
vim.g.loaded_tutor_mode_plugin = 1
|
||||
|
||||
-- Do not use builtin matchit.vim and matchparen.vim since we use vim-matchup
|
||||
vim.g.loaded_matchit = 1
|
||||
vim.g.loaded_matchparen = 1
|
||||
|
||||
-- Disable sql omni completion, it is broken.
|
||||
vim.g.loaded_sql_completion = 1
|
||||
|
||||
-- control how to show health check window
|
||||
vim.g.health = { style = nil }
|
||||
@@ -1,5 +0,0 @@
|
||||
-- Some utility stuff
|
||||
require 'utils'
|
||||
|
||||
-- plugin installation
|
||||
require 'plugins'
|
||||
235
lua/mappings.lua
Normal file
235
lua/mappings.lua
Normal file
@@ -0,0 +1,235 @@
|
||||
local keymap = vim.keymap
|
||||
local uv = vim.uv
|
||||
|
||||
-- Save key strokes (now we do not need to press shift to enter command mode).
|
||||
keymap.set({ "n", "x" }, ";", ":")
|
||||
|
||||
-- Turn the word under cursor to upper case
|
||||
keymap.set("i", "<c-u>", "<Esc>viwUea")
|
||||
|
||||
-- Turn the current word into title case
|
||||
keymap.set("i", "<c-t>", "<Esc>b~lea")
|
||||
|
||||
-- Paste non-linewise text above or below current line, see https://stackoverflow.com/a/1346777/6064933
|
||||
keymap.set("n", "<leader>p", "m`o<ESC>p``", { desc = "paste below current line" })
|
||||
keymap.set("n", "<leader>P", "m`O<ESC>p``", { desc = "paste above current line" })
|
||||
|
||||
-- Shortcut for faster save and quit
|
||||
keymap.set("n", "<leader>w", "<cmd>update<cr>", { silent = true, desc = "save buffer" })
|
||||
|
||||
-- Saves the file if modified and quit
|
||||
keymap.set("n", "<leader>q", "<cmd>x<cr>", { silent = true, desc = "quit current window" })
|
||||
|
||||
-- Quit all opened buffers
|
||||
keymap.set("n", "<leader>Q", "<cmd>qa!<cr>", { silent = true, desc = "quit nvim" })
|
||||
|
||||
-- Close location list or quickfix list if they are present, see https://superuser.com/q/355325/736190
|
||||
keymap.set("n", [[\x]], "<cmd>windo lclose <bar> cclose <cr>", {
|
||||
silent = true,
|
||||
desc = "close qf and location list",
|
||||
})
|
||||
|
||||
-- Delete a buffer, without closing the window, see https://stackoverflow.com/q/4465095/6064933
|
||||
keymap.set("n", [[\d]], "<cmd>bprevious <bar> bdelete #<cr>", {
|
||||
silent = true,
|
||||
desc = "delete current buffer",
|
||||
})
|
||||
|
||||
keymap.set("n", [[\D]], function()
|
||||
local buf_ids = vim.api.nvim_list_bufs()
|
||||
local cur_buf = vim.api.nvim_win_get_buf(0)
|
||||
|
||||
for _, buf_id in pairs(buf_ids) do
|
||||
-- do not Delete unlisted buffers, which may lead to unexpected errors
|
||||
if vim.api.nvim_get_option_value("buflisted", { buf = buf_id }) and buf_id ~= cur_buf then
|
||||
vim.api.nvim_buf_delete(buf_id, { force = true })
|
||||
end
|
||||
end
|
||||
end, {
|
||||
desc = "delete other buffers",
|
||||
})
|
||||
|
||||
-- Insert a blank line below or above current line (do not move the cursor),
|
||||
-- see https://stackoverflow.com/a/16136133/6064933
|
||||
keymap.set("n", "<space>o", "printf('m`%so<ESC>``', v:count1)", {
|
||||
expr = true,
|
||||
desc = "insert line below",
|
||||
})
|
||||
|
||||
keymap.set("n", "<space>O", "printf('m`%sO<ESC>``', v:count1)", {
|
||||
expr = true,
|
||||
desc = "insert line above",
|
||||
})
|
||||
|
||||
-- Move the cursor based on physical lines, not the actual lines.
|
||||
keymap.set("n", "j", "v:count == 0 ? 'gj' : 'j'", { expr = true })
|
||||
keymap.set("n", "k", "v:count == 0 ? 'gk' : 'k'", { expr = true })
|
||||
keymap.set("n", "^", "g^")
|
||||
keymap.set("n", "0", "g0")
|
||||
|
||||
-- Do not include white space characters when using $ in visual mode,
|
||||
-- see https://vi.stackexchange.com/q/12607/15292
|
||||
keymap.set("x", "$", "g_")
|
||||
|
||||
-- Go to start or end of line easier
|
||||
keymap.set({ "n", "x" }, "H", "^")
|
||||
keymap.set({ "n", "x" }, "L", "g_")
|
||||
|
||||
-- Continuous visual shifting (does not exit Visual mode), `gv` means
|
||||
-- to reselect previous visual area, see https://superuser.com/q/310417/736190
|
||||
keymap.set("x", "<", "<gv")
|
||||
keymap.set("x", ">", ">gv")
|
||||
|
||||
-- Edit and reload nvim config file quickly
|
||||
keymap.set("n", "<leader>ev", "<cmd>tabnew $MYVIMRC <bar> tcd %:h<cr>", {
|
||||
silent = true,
|
||||
desc = "open init.lua",
|
||||
})
|
||||
|
||||
keymap.set("n", "<leader>sv", function()
|
||||
vim.cmd([[
|
||||
update $MYVIMRC
|
||||
source $MYVIMRC
|
||||
]])
|
||||
vim.notify("Nvim config successfully reloaded!", vim.log.levels.INFO, { title = "nvim-config" })
|
||||
end, {
|
||||
silent = true,
|
||||
desc = "reload init.lua",
|
||||
})
|
||||
|
||||
-- Reselect the text that has just been pasted, see also https://stackoverflow.com/a/4317090/6064933.
|
||||
keymap.set("n", "<leader>v", "printf('`[%s`]', getregtype()[0])", {
|
||||
expr = true,
|
||||
desc = "reselect last pasted area",
|
||||
})
|
||||
|
||||
-- Always use very magic mode for searching
|
||||
keymap.set("n", "/", [[/\v]])
|
||||
|
||||
-- Search in selected region
|
||||
-- xnoremap / :<C-U>call feedkeys('/\%>'.(line("'<")-1).'l\%<'.(line("'>")+1)."l")<CR>
|
||||
|
||||
-- Change current working directory locally and print cwd after that,
|
||||
-- see https://vim.fandom.com/wiki/Set_working_directory_to_the_current_file
|
||||
keymap.set("n", "<leader>cd", "<cmd>lcd %:p:h<cr><cmd>pwd<cr>", { desc = "change cwd" })
|
||||
|
||||
-- Use Esc to quit builtin terminal
|
||||
keymap.set("t", "<Esc>", [[<c-\><c-n>]])
|
||||
|
||||
-- Toggle spell checking
|
||||
keymap.set("n", "<F11>", "<cmd>set spell!<cr>", { desc = "toggle spell" })
|
||||
keymap.set("i", "<F11>", "<c-o><cmd>set spell!<cr>", { desc = "toggle spell" })
|
||||
|
||||
-- Change text without putting it into the vim register,
|
||||
-- see https://stackoverflow.com/q/54255/6064933
|
||||
keymap.set("n", "c", '"_c')
|
||||
keymap.set("n", "C", '"_C')
|
||||
keymap.set("n", "cc", '"_cc')
|
||||
keymap.set("x", "c", '"_c')
|
||||
|
||||
-- Remove trailing whitespace characters
|
||||
keymap.set("n", "<leader><space>", "<cmd>StripTrailingWhitespace<cr>", { desc = "remove trailing space" })
|
||||
|
||||
-- Copy entire buffer.
|
||||
keymap.set("n", "<leader>y", "<cmd>%yank<cr>", { desc = "yank entire buffer" })
|
||||
|
||||
-- Toggle cursor column
|
||||
keymap.set("n", "<leader>cl", "<cmd>call utils#ToggleCursorCol()<cr>", { desc = "toggle cursor column" })
|
||||
|
||||
-- Move current line up and down
|
||||
keymap.set("n", "<A-k>", '<cmd>call utils#SwitchLine(line("."), "up")<cr>', { desc = "move line up" })
|
||||
keymap.set("n", "<A-j>", '<cmd>call utils#SwitchLine(line("."), "down")<cr>', { desc = "move line down" })
|
||||
|
||||
-- Move current visual-line selection up and down
|
||||
keymap.set("x", "<A-k>", '<cmd>call utils#MoveSelection("up")<cr>', { desc = "move selection up" })
|
||||
|
||||
keymap.set("x", "<A-j>", '<cmd>call utils#MoveSelection("down")<cr>', { desc = "move selection down" })
|
||||
|
||||
-- Replace visual selection with text in register, but not contaminate the register,
|
||||
-- see also https://stackoverflow.com/q/10723700/6064933.
|
||||
keymap.set("x", "p", '"_c<Esc>p')
|
||||
|
||||
-- Go to a certain buffer
|
||||
keymap.set("n", "gb", '<cmd>call buf_utils#GoToBuffer(v:count, "forward")<cr>', {
|
||||
desc = "go to buffer (forward)",
|
||||
})
|
||||
keymap.set("n", "gB", '<cmd>call buf_utils#GoToBuffer(v:count, "backward")<cr>', {
|
||||
desc = "go to buffer (backward)",
|
||||
})
|
||||
|
||||
-- Switch windows
|
||||
keymap.set("n", "<left>", "<c-w>h")
|
||||
keymap.set("n", "<Right>", "<C-W>l")
|
||||
keymap.set("n", "<Up>", "<C-W>k")
|
||||
keymap.set("n", "<Down>", "<C-W>j")
|
||||
|
||||
-- Text objects for URL
|
||||
keymap.set({ "x", "o" }, "iu", "<cmd>call text_obj#URL()<cr>", { desc = "URL text object" })
|
||||
|
||||
-- Text objects for entire buffer
|
||||
keymap.set({ "x", "o" }, "iB", ":<C-U>call text_obj#Buffer()<cr>", { desc = "buffer text object" })
|
||||
|
||||
-- Do not move my cursor when joining lines.
|
||||
keymap.set("n", "J", function()
|
||||
vim.cmd([[
|
||||
normal! mzJ`z
|
||||
delmarks z
|
||||
]])
|
||||
end, {
|
||||
desc = "join lines without moving cursor",
|
||||
})
|
||||
|
||||
keymap.set("n", "gJ", function()
|
||||
-- we must use `normal!`, otherwise it will trigger recursive mapping
|
||||
vim.cmd([[
|
||||
normal! mzgJ`z
|
||||
delmarks z
|
||||
]])
|
||||
end, {
|
||||
desc = "join lines without moving cursor",
|
||||
})
|
||||
|
||||
-- Break inserted text into smaller undo units when we insert some punctuation chars.
|
||||
local undo_ch = { ",", ".", "!", "?", ";", ":" }
|
||||
for _, ch in ipairs(undo_ch) do
|
||||
keymap.set("i", ch, ch .. "<c-g>u")
|
||||
end
|
||||
|
||||
-- insert semicolon in the end
|
||||
keymap.set("i", "<A-;>", "<Esc>miA;<Esc>`ii")
|
||||
|
||||
-- Go to the beginning and end of current line in insert mode quickly
|
||||
keymap.set("i", "<C-A>", "<HOME>")
|
||||
keymap.set("i", "<C-E>", "<END>")
|
||||
|
||||
-- Go to beginning of command in command-line mode
|
||||
keymap.set("c", "<C-A>", "<HOME>")
|
||||
|
||||
-- Delete the character to the right of the cursor
|
||||
keymap.set("i", "<C-D>", "<DEL>")
|
||||
|
||||
keymap.set("n", "<leader>cb", function()
|
||||
local cnt = 0
|
||||
local blink_times = 7
|
||||
local timer = uv.new_timer()
|
||||
if timer == nil then
|
||||
return
|
||||
end
|
||||
|
||||
timer:start(
|
||||
0,
|
||||
100,
|
||||
vim.schedule_wrap(function()
|
||||
vim.cmd([[
|
||||
set cursorcolumn!
|
||||
set cursorline!
|
||||
]])
|
||||
|
||||
if cnt == blink_times then
|
||||
timer:close()
|
||||
end
|
||||
|
||||
cnt = cnt + 1
|
||||
end)
|
||||
)
|
||||
end, { desc = "show cursor" })
|
||||
588
lua/plugin_specs.lua
Normal file
588
lua/plugin_specs.lua
Normal file
@@ -0,0 +1,588 @@
|
||||
local utils = require("utils")
|
||||
|
||||
local plugin_dir = vim.fn.stdpath("data") .. "/lazy"
|
||||
local lazypath = plugin_dir .. "/lazy.nvim"
|
||||
|
||||
if not vim.uv.fs_stat(lazypath) then
|
||||
vim.fn.system {
|
||||
"git",
|
||||
"clone",
|
||||
"--filter=blob:none",
|
||||
"https://github.com/folke/lazy.nvim.git",
|
||||
"--branch=stable", -- latest stable release
|
||||
lazypath,
|
||||
}
|
||||
end
|
||||
vim.opt.rtp:prepend(lazypath)
|
||||
|
||||
-- check if firenvim is active
|
||||
local firenvim_not_active = function()
|
||||
return not vim.g.started_by_firenvim
|
||||
end
|
||||
|
||||
local plugin_specs = {
|
||||
-- auto-completion engine
|
||||
{ "hrsh7th/cmp-nvim-lsp", lazy = true },
|
||||
{ "hrsh7th/cmp-path", lazy = true },
|
||||
{ "hrsh7th/cmp-buffer", lazy = true },
|
||||
{ "hrsh7th/cmp-omni", lazy = true },
|
||||
{ "quangnguyen30192/cmp-nvim-ultisnips", lazy = true },
|
||||
{
|
||||
"hrsh7th/nvim-cmp",
|
||||
name = "nvim-cmp",
|
||||
event = "InsertEnter",
|
||||
config = function()
|
||||
require("config.nvim-cmp")
|
||||
end,
|
||||
},
|
||||
{
|
||||
"neovim/nvim-lspconfig",
|
||||
event = { "BufRead", "BufNewFile" },
|
||||
config = function()
|
||||
require("config.lsp")
|
||||
end,
|
||||
},
|
||||
{
|
||||
"dnlhc/glance.nvim",
|
||||
config = function()
|
||||
require("config.glance")
|
||||
end,
|
||||
event = "VeryLazy",
|
||||
},
|
||||
{
|
||||
"nvim-treesitter/nvim-treesitter",
|
||||
lazy = true,
|
||||
build = ":TSUpdate",
|
||||
config = function()
|
||||
require("config.treesitter")
|
||||
end,
|
||||
},
|
||||
{
|
||||
"nvim-treesitter/nvim-treesitter-textobjects",
|
||||
event = "VeryLazy",
|
||||
branch = "master",
|
||||
config = function()
|
||||
require("config.treesitter-textobjects")
|
||||
end,
|
||||
},
|
||||
{ "machakann/vim-swap", event = "VeryLazy" },
|
||||
|
||||
-- IDE for Lisp
|
||||
-- 'kovisoft/slimv'
|
||||
{
|
||||
"vlime/vlime",
|
||||
enabled = function()
|
||||
return utils.executable("sbcl")
|
||||
end,
|
||||
config = function(plugin)
|
||||
vim.opt.rtp:append(plugin.dir .. "/vim")
|
||||
end,
|
||||
ft = { "lisp" },
|
||||
},
|
||||
|
||||
-- Super fast buffer jump
|
||||
{
|
||||
"smoka7/hop.nvim",
|
||||
keys = { "f" },
|
||||
config = function()
|
||||
require("config.nvim_hop")
|
||||
end,
|
||||
},
|
||||
|
||||
-- Show match number and index for searching
|
||||
{
|
||||
"kevinhwang91/nvim-hlslens",
|
||||
branch = "main",
|
||||
keys = { "*", "#", "n", "N" },
|
||||
config = function()
|
||||
require("config.hlslens")
|
||||
end,
|
||||
},
|
||||
{
|
||||
"nvim-telescope/telescope.nvim",
|
||||
cmd = "Telescope",
|
||||
dependencies = {
|
||||
"nvim-telescope/telescope-symbols.nvim",
|
||||
},
|
||||
},
|
||||
{
|
||||
"ibhagwan/fzf-lua",
|
||||
config = function()
|
||||
require("config.fzf-lua")
|
||||
end,
|
||||
event = "VeryLazy",
|
||||
},
|
||||
{
|
||||
"MeanderingProgrammer/markdown.nvim",
|
||||
main = "render-markdown",
|
||||
opts = {},
|
||||
ft = { "markdown" },
|
||||
},
|
||||
-- A list of colorscheme plugin you may want to try. Find what suits you.
|
||||
{ "navarasu/onedark.nvim", lazy = true },
|
||||
{ "sainnhe/edge", lazy = true },
|
||||
{ "sainnhe/sonokai", lazy = true },
|
||||
{ "sainnhe/gruvbox-material", lazy = true },
|
||||
{ "sainnhe/everforest", lazy = true },
|
||||
{ "EdenEast/nightfox.nvim", lazy = true },
|
||||
{ "catppuccin/nvim", name = "catppuccin", lazy = true },
|
||||
{ "olimorris/onedarkpro.nvim", lazy = true },
|
||||
{ "marko-cerovac/material.nvim", lazy = true },
|
||||
{
|
||||
"rockyzhang24/arctic.nvim",
|
||||
dependencies = { "rktjmp/lush.nvim" },
|
||||
name = "arctic",
|
||||
branch = "v2",
|
||||
},
|
||||
{ "rebelot/kanagawa.nvim", lazy = true },
|
||||
|
||||
-- plugins to provide nerdfont icons
|
||||
{
|
||||
"echasnovski/mini.icons",
|
||||
version = false,
|
||||
config = function()
|
||||
-- this is the compatibility fix for plugins that only support nvim-web-devicons
|
||||
require("mini.icons").mock_nvim_web_devicons()
|
||||
require("mini.icons").tweak_lsp_kind()
|
||||
end,
|
||||
lazy = true,
|
||||
},
|
||||
|
||||
{
|
||||
"nvim-lualine/lualine.nvim",
|
||||
event = "BufRead",
|
||||
cond = firenvim_not_active,
|
||||
config = function()
|
||||
require("config.lualine")
|
||||
end,
|
||||
},
|
||||
|
||||
{
|
||||
"akinsho/bufferline.nvim",
|
||||
event = { "BufEnter" },
|
||||
cond = firenvim_not_active,
|
||||
config = function()
|
||||
require("config.bufferline")
|
||||
end,
|
||||
},
|
||||
|
||||
-- fancy start screen
|
||||
{
|
||||
"nvimdev/dashboard-nvim",
|
||||
cond = firenvim_not_active,
|
||||
config = function()
|
||||
require("config.dashboard-nvim")
|
||||
end,
|
||||
},
|
||||
|
||||
{
|
||||
"echasnovski/mini.indentscope",
|
||||
version = false,
|
||||
config = function()
|
||||
local mini_indent = require("mini.indentscope")
|
||||
mini_indent.setup {
|
||||
draw = {
|
||||
animation = mini_indent.gen_animation.none(),
|
||||
},
|
||||
symbol = "▏",
|
||||
}
|
||||
end,
|
||||
},
|
||||
{
|
||||
"luukvbaal/statuscol.nvim",
|
||||
opts = {},
|
||||
config = function()
|
||||
require("config.nvim-statuscol")
|
||||
end,
|
||||
},
|
||||
{
|
||||
"kevinhwang91/nvim-ufo",
|
||||
dependencies = "kevinhwang91/promise-async",
|
||||
event = "VeryLazy",
|
||||
opts = {},
|
||||
init = function()
|
||||
vim.o.foldcolumn = "1" -- '0' is not bad
|
||||
vim.o.foldlevel = 99 -- Using ufo provider need a large value, feel free to decrease the value
|
||||
vim.o.foldlevelstart = 99
|
||||
vim.o.foldenable = true
|
||||
end,
|
||||
config = function()
|
||||
require("config.nvim_ufo")
|
||||
end,
|
||||
},
|
||||
-- Highlight URLs inside vim
|
||||
{ "itchyny/vim-highlighturl", event = "BufReadPost" },
|
||||
|
||||
-- notification plugin
|
||||
{
|
||||
"rcarriga/nvim-notify",
|
||||
event = "VeryLazy",
|
||||
config = function()
|
||||
require("config.nvim-notify")
|
||||
end,
|
||||
},
|
||||
|
||||
{ "nvim-lua/plenary.nvim", lazy = true },
|
||||
|
||||
-- For Windows and Mac, we can open an URL in the browser. For Linux, it may
|
||||
-- not be possible since we maybe in a server which disables GUI.
|
||||
{
|
||||
"chrishrb/gx.nvim",
|
||||
keys = { { "gx", "<cmd>Browse<cr>", mode = { "n", "x" } } },
|
||||
cmd = { "Browse" },
|
||||
init = function()
|
||||
vim.g.netrw_nogx = 1 -- disable netrw gx
|
||||
end,
|
||||
enabled = function()
|
||||
return vim.g.is_win or vim.g.is_mac
|
||||
end,
|
||||
config = true, -- default settings
|
||||
submodules = false, -- not needed, submodules are required only for tests
|
||||
},
|
||||
|
||||
-- Only install these plugins if ctags are installed on the system
|
||||
-- show file tags in vim window
|
||||
{
|
||||
"liuchengxu/vista.vim",
|
||||
enabled = function()
|
||||
return utils.executable("ctags")
|
||||
end,
|
||||
cmd = "Vista",
|
||||
},
|
||||
|
||||
-- Snippet engine and snippet template
|
||||
{ "SirVer/ultisnips", dependencies = {
|
||||
"honza/vim-snippets",
|
||||
}, event = "InsertEnter" },
|
||||
|
||||
-- Automatic insertion and deletion of a pair of characters
|
||||
{
|
||||
"windwp/nvim-autopairs",
|
||||
event = "InsertEnter",
|
||||
config = true,
|
||||
},
|
||||
|
||||
-- Comment plugin
|
||||
{ "tpope/vim-commentary", keys = {
|
||||
{ "gc", mode = "n" },
|
||||
{ "gc", mode = "v" },
|
||||
} },
|
||||
|
||||
-- Multiple cursor plugin like Sublime Text?
|
||||
-- 'mg979/vim-visual-multi'
|
||||
|
||||
-- Show undo history visually
|
||||
{ "simnalamburt/vim-mundo", cmd = { "MundoToggle", "MundoShow" } },
|
||||
|
||||
-- Manage your yank history
|
||||
{
|
||||
"gbprod/yanky.nvim",
|
||||
config = function()
|
||||
require("config.yanky")
|
||||
end,
|
||||
cmd = "YankyRingHistory",
|
||||
},
|
||||
|
||||
-- Handy unix command inside Vim (Rename, Move etc.)
|
||||
{ "tpope/vim-eunuch", cmd = { "Rename", "Delete" } },
|
||||
|
||||
-- Repeat vim motions
|
||||
{ "tpope/vim-repeat", event = "VeryLazy" },
|
||||
|
||||
{ "nvim-zh/better-escape.vim", event = { "InsertEnter" } },
|
||||
|
||||
{
|
||||
"lyokha/vim-xkbswitch",
|
||||
enabled = function()
|
||||
return vim.g.is_mac and utils.executable("xkbswitch")
|
||||
end,
|
||||
event = { "InsertEnter" },
|
||||
},
|
||||
|
||||
{
|
||||
"Neur1n/neuims",
|
||||
enabled = function()
|
||||
return vim.g.is_win
|
||||
end,
|
||||
event = { "InsertEnter" },
|
||||
},
|
||||
|
||||
-- Auto format tools
|
||||
{ "sbdchd/neoformat", cmd = { "Neoformat" } },
|
||||
|
||||
-- Git command inside vim
|
||||
{
|
||||
"tpope/vim-fugitive",
|
||||
event = "User InGitRepo",
|
||||
config = function()
|
||||
require("config.fugitive")
|
||||
end,
|
||||
},
|
||||
|
||||
-- Better git log display
|
||||
{ "rbong/vim-flog", cmd = { "Flog" } },
|
||||
{
|
||||
"akinsho/git-conflict.nvim",
|
||||
version = "*",
|
||||
event = "VeryLazy",
|
||||
config = function()
|
||||
require("config.git-conflict")
|
||||
end,
|
||||
},
|
||||
{
|
||||
"ruifm/gitlinker.nvim",
|
||||
event = "User InGitRepo",
|
||||
config = function()
|
||||
require("config.git-linker")
|
||||
end,
|
||||
},
|
||||
|
||||
-- Show git change (change, delete, add) signs in vim sign column
|
||||
{
|
||||
"lewis6991/gitsigns.nvim",
|
||||
config = function()
|
||||
require("config.gitsigns")
|
||||
end,
|
||||
event = "BufRead",
|
||||
},
|
||||
|
||||
{
|
||||
"sindrets/diffview.nvim",
|
||||
cmd = { "DiffviewOpen" },
|
||||
},
|
||||
|
||||
{
|
||||
"kevinhwang91/nvim-bqf",
|
||||
ft = "qf",
|
||||
config = function()
|
||||
require("config.bqf")
|
||||
end,
|
||||
},
|
||||
|
||||
-- Faster footnote generation
|
||||
{ "vim-pandoc/vim-markdownfootnotes", ft = { "markdown" } },
|
||||
|
||||
-- Vim tabular plugin for manipulate tabular, required by markdown plugins
|
||||
{ "godlygeek/tabular", ft = { "markdown" } },
|
||||
|
||||
-- Markdown previewing (only for Mac and Windows)
|
||||
{
|
||||
"iamcco/markdown-preview.nvim",
|
||||
enabled = function()
|
||||
return vim.g.is_win or vim.g.is_mac
|
||||
end,
|
||||
build = "cd app && npm install && git restore .",
|
||||
ft = { "markdown" },
|
||||
},
|
||||
|
||||
{
|
||||
"rhysd/vim-grammarous",
|
||||
enabled = function()
|
||||
return vim.g.is_mac
|
||||
end,
|
||||
ft = { "markdown" },
|
||||
},
|
||||
|
||||
{ "chrisbra/unicode.vim", keys = { "ga" }, cmd = { "UnicodeSearch" } },
|
||||
|
||||
-- Additional powerful text object for vim, this plugin should be studied
|
||||
-- carefully to use its full power
|
||||
{ "wellle/targets.vim", event = "VeryLazy" },
|
||||
|
||||
-- Plugin to manipulate character pairs quickly
|
||||
{ "machakann/vim-sandwich", event = "VeryLazy" },
|
||||
|
||||
-- Only use these plugin on Windows and Mac and when LaTeX is installed
|
||||
{
|
||||
"lervag/vimtex",
|
||||
enabled = function()
|
||||
return utils.executable("latex")
|
||||
end,
|
||||
ft = { "tex" },
|
||||
},
|
||||
|
||||
-- Since tmux is only available on Linux and Mac, we only enable these plugins
|
||||
-- for Linux and Mac
|
||||
-- .tmux.conf syntax highlighting and setting check
|
||||
{
|
||||
"tmux-plugins/vim-tmux",
|
||||
enabled = function()
|
||||
return utils.executable("tmux")
|
||||
end,
|
||||
ft = { "tmux" },
|
||||
},
|
||||
|
||||
-- Modern matchit implementation
|
||||
{ "andymass/vim-matchup", event = "BufRead" },
|
||||
{ "tpope/vim-scriptease", cmd = { "Scriptnames", "Messages", "Verbose" } },
|
||||
|
||||
-- Asynchronous command execution
|
||||
{ "skywind3000/asyncrun.vim", lazy = true, cmd = { "AsyncRun" } },
|
||||
{ "cespare/vim-toml", ft = { "toml" }, branch = "main" },
|
||||
|
||||
-- Edit text area in browser using nvim
|
||||
{
|
||||
"glacambre/firenvim",
|
||||
enabled = function()
|
||||
return vim.g.is_win or vim.g.is_mac
|
||||
end,
|
||||
-- it seems that we can only call the firenvim function directly.
|
||||
-- Using vim.fn or vim.cmd to call this function will fail.
|
||||
build = function()
|
||||
local firenvim_path = plugin_dir .. "/firenvim"
|
||||
vim.opt.runtimepath:append(firenvim_path)
|
||||
vim.cmd("runtime! firenvim.vim")
|
||||
|
||||
-- macOS will reset the PATH when firenvim starts a nvim process, causing the PATH variable to change unexpectedly.
|
||||
-- Here we are trying to get the correct PATH and use it for firenvim.
|
||||
-- See also https://github.com/glacambre/firenvim/blob/master/TROUBLESHOOTING.md#make-sure-firenvims-path-is-the-same-as-neovims
|
||||
local path_env = vim.env.PATH
|
||||
local prologue = string.format('export PATH="%s"', path_env)
|
||||
-- local prologue = "echo"
|
||||
local cmd_str = string.format(":call firenvim#install(0, '%s')", prologue)
|
||||
vim.cmd(cmd_str)
|
||||
end,
|
||||
},
|
||||
-- Debugger plugin
|
||||
{
|
||||
"sakhnik/nvim-gdb",
|
||||
enabled = function()
|
||||
return vim.g.is_win or vim.g.is_linux
|
||||
end,
|
||||
build = { "bash install.sh" },
|
||||
lazy = true,
|
||||
},
|
||||
|
||||
-- Session management plugin
|
||||
{ "tpope/vim-obsession", cmd = "Obsession" },
|
||||
|
||||
{
|
||||
"ojroques/vim-oscyank",
|
||||
enabled = function()
|
||||
return vim.g.is_linux
|
||||
end,
|
||||
cmd = { "OSCYank", "OSCYankReg" },
|
||||
},
|
||||
|
||||
-- The missing auto-completion for cmdline!
|
||||
{
|
||||
"gelguy/wilder.nvim",
|
||||
build = ":UpdateRemotePlugins",
|
||||
},
|
||||
|
||||
-- showing keybindings
|
||||
{
|
||||
"folke/which-key.nvim",
|
||||
event = "VeryLazy",
|
||||
config = function()
|
||||
require("config.which-key")
|
||||
end,
|
||||
},
|
||||
{
|
||||
"folke/snacks.nvim",
|
||||
priority = 1000,
|
||||
lazy = false,
|
||||
opts = {
|
||||
-- more beautiful vim.ui.input
|
||||
input = {
|
||||
enabled = true,
|
||||
win = {
|
||||
relative = "cursor",
|
||||
backdrop = true,
|
||||
},
|
||||
},
|
||||
-- more beautiful vim.ui.select
|
||||
picker = { enabled = true },
|
||||
},
|
||||
},
|
||||
-- show and trim trailing whitespaces
|
||||
{ "jdhao/whitespace.nvim", event = "VeryLazy" },
|
||||
|
||||
-- file explorer
|
||||
{
|
||||
"nvim-tree/nvim-tree.lua",
|
||||
keys = { "<space>s" },
|
||||
config = function()
|
||||
require("config.nvim-tree")
|
||||
end,
|
||||
},
|
||||
|
||||
{
|
||||
"j-hui/fidget.nvim",
|
||||
event = "BufRead",
|
||||
config = function()
|
||||
require("config.fidget-nvim")
|
||||
end,
|
||||
},
|
||||
{
|
||||
"folke/lazydev.nvim",
|
||||
ft = "lua", -- only load on lua files
|
||||
opts = {
|
||||
library = {
|
||||
-- See the configuration section for more details
|
||||
-- Load luvit types when the `vim.uv` word is found
|
||||
{ path = "${3rd}/luv/library", words = { "vim%.uv" } },
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
"CopilotC-Nvim/CopilotChat.nvim",
|
||||
dependencies = {
|
||||
{ "zbirenbaum/copilot.lua" }, -- or github/copilot.vim
|
||||
},
|
||||
opts = {
|
||||
debug = true, -- Enable debugging
|
||||
-- See Configuration section for rest
|
||||
},
|
||||
cmd = { "CopilotChat" },
|
||||
},
|
||||
{
|
||||
"zbirenbaum/copilot.lua",
|
||||
cmd = "Copilot",
|
||||
config = function()
|
||||
require("copilot").setup {}
|
||||
end,
|
||||
},
|
||||
{
|
||||
"smjonas/live-command.nvim",
|
||||
-- live-command supports semantic versioning via Git tags
|
||||
-- tag = "2.*",
|
||||
cmd = "Preview",
|
||||
config = function()
|
||||
require("config.live-command")
|
||||
end,
|
||||
},
|
||||
{
|
||||
-- show hint for code actions, the user can also implement code actions themselves,
|
||||
-- see discussion here: https://github.com/neovim/neovim/issues/14869
|
||||
"kosayoda/nvim-lightbulb",
|
||||
config = function()
|
||||
require("config.lightbulb")
|
||||
end,
|
||||
event = "LspAttach",
|
||||
},
|
||||
{
|
||||
"Bekaboo/dropbar.nvim",
|
||||
event = "VeryLazy",
|
||||
},
|
||||
{
|
||||
"catgoose/nvim-colorizer.lua",
|
||||
event = "BufReadPre",
|
||||
opts = { -- set to setup table
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
---@diagnostic disable-next-line: missing-fields
|
||||
require("lazy").setup {
|
||||
spec = plugin_specs,
|
||||
ui = {
|
||||
border = "rounded",
|
||||
title = "Plugin Manager",
|
||||
title_pos = "center",
|
||||
},
|
||||
rocks = {
|
||||
enabled = false,
|
||||
hererocks = false,
|
||||
},
|
||||
}
|
||||
369
lua/plugins.lua
369
lua/plugins.lua
@@ -1,369 +0,0 @@
|
||||
local utils = require("utils")
|
||||
local fn = vim.fn
|
||||
|
||||
vim.g.package_home = fn.stdpath("data") .. "/site/pack/packer/"
|
||||
local packer_install_dir = vim.g.package_home .. "/opt/packer.nvim"
|
||||
|
||||
local packer_repo = "https://github.com/wbthomason/packer.nvim"
|
||||
local install_cmd = string.format("10split |term git clone --depth=1 %s %s", packer_repo, packer_install_dir)
|
||||
|
||||
-- Auto-install packer in case it hasn't been installed.
|
||||
if fn.glob(packer_install_dir) == "" then
|
||||
vim.api.nvim_echo({ { "Installing packer.nvim", "Type" } }, true, {})
|
||||
vim.cmd(install_cmd)
|
||||
end
|
||||
|
||||
-- Load packer.nvim
|
||||
vim.cmd("packadd packer.nvim")
|
||||
local util = require('packer.util')
|
||||
|
||||
require("packer").startup({
|
||||
function(use)
|
||||
-- it is recommened to put impatient.nvim before any other plugins
|
||||
use {'lewis6991/impatient.nvim', config = [[require('impatient')]]}
|
||||
|
||||
use({"wbthomason/packer.nvim", opt = true})
|
||||
|
||||
use({"onsails/lspkind-nvim", event = "VimEnter"})
|
||||
-- auto-completion engine
|
||||
use {"hrsh7th/nvim-cmp", after = "lspkind-nvim", config = [[require('config.nvim-cmp')]]}
|
||||
|
||||
-- nvim-cmp completion sources
|
||||
use {"hrsh7th/cmp-nvim-lsp", after = "nvim-cmp"}
|
||||
use {"hrsh7th/cmp-nvim-lua", after = "nvim-cmp"}
|
||||
use {"hrsh7th/cmp-path", after = "nvim-cmp"}
|
||||
use {"hrsh7th/cmp-buffer", after = "nvim-cmp"}
|
||||
use { "hrsh7th/cmp-omni", after = "nvim-cmp" }
|
||||
|
||||
-- use {"hrsh7th/cmp-cmdline", after = "nvim-cmp"}
|
||||
use {"quangnguyen30192/cmp-nvim-ultisnips", after = {'nvim-cmp', 'ultisnips'}}
|
||||
if vim.g.is_mac then
|
||||
use {"hrsh7th/cmp-emoji", after = 'nvim-cmp'}
|
||||
end
|
||||
|
||||
-- nvim-lsp configuration (it relies on cmp-nvim-lsp, so it should be loaded after cmp-nvim-lsp).
|
||||
use({ "neovim/nvim-lspconfig", after = "cmp-nvim-lsp", config = [[require('config.lsp')]] })
|
||||
|
||||
if vim.g.is_mac then
|
||||
use({ "nvim-treesitter/nvim-treesitter", event = 'BufEnter', run = ":TSUpdate", config = [[require('config.treesitter')]] })
|
||||
end
|
||||
|
||||
-- Python indent (follows the PEP8 style)
|
||||
use({ "Vimjas/vim-python-pep8-indent", ft = { "python" } })
|
||||
|
||||
-- Python-related text object
|
||||
use({ "jeetsukumaran/vim-pythonsense", ft = { "python" } })
|
||||
|
||||
use({"machakann/vim-swap", event = "VimEnter"})
|
||||
|
||||
-- IDE for Lisp
|
||||
if utils.executable("sbcl") then
|
||||
-- use 'kovisoft/slimv'
|
||||
use({ "vlime/vlime", rtp = "vim/", ft = { "lisp" } })
|
||||
end
|
||||
|
||||
-- Super fast buffer jump
|
||||
use {
|
||||
'phaazon/hop.nvim',
|
||||
event = "VimEnter",
|
||||
config = function()
|
||||
vim.defer_fn(function() require('config.nvim_hop') end, 2000)
|
||||
end
|
||||
}
|
||||
|
||||
-- Clear highlight search automatically for you
|
||||
-- use({"romainl/vim-cool", event = "VimEnter"})
|
||||
|
||||
-- Show match number and index for searching
|
||||
use {
|
||||
'kevinhwang91/nvim-hlslens',
|
||||
branch = 'main',
|
||||
keys = {{'n', '*'}, {'n', '#'}, {'n', 'n'}, {'n', 'N'}},
|
||||
config = [[require('config.hlslens')]]
|
||||
}
|
||||
|
||||
-- Stay after pressing * and search selected text
|
||||
use({"haya14busa/vim-asterisk", event = 'VimEnter'})
|
||||
|
||||
-- File search, tag search and more
|
||||
if vim.g.is_win then
|
||||
use({"Yggdroot/LeaderF", cmd = "Leaderf"})
|
||||
else
|
||||
use({ "Yggdroot/LeaderF", cmd = "Leaderf", run = ":LeaderfInstallCExtension" })
|
||||
end
|
||||
|
||||
use {
|
||||
'nvim-telescope/telescope.nvim', cmd = 'Telescope',
|
||||
requires = { {'nvim-lua/plenary.nvim'} }
|
||||
}
|
||||
-- search emoji and other symbols
|
||||
use {'nvim-telescope/telescope-symbols.nvim', after = 'telescope.nvim'}
|
||||
|
||||
-- Another similar plugin is command-t
|
||||
-- use 'wincent/command-t'
|
||||
|
||||
-- Another grep tool (similar to Sublime Text Ctrl+Shift+F)
|
||||
-- use 'dyng/ctrlsf.vim'
|
||||
|
||||
-- A grepping tool
|
||||
-- use {'mhinz/vim-grepper', cmd = {'Grepper', '<plug>(GrepperOperator)'}}
|
||||
|
||||
-- A list of colorscheme plugin you may want to try. Find what suits you.
|
||||
use({"lifepillar/vim-gruvbox8", opt = true})
|
||||
use({"navarasu/onedark.nvim", opt = true})
|
||||
use({"sainnhe/edge", opt = true})
|
||||
use({"sainnhe/sonokai", opt = true})
|
||||
use({"sainnhe/gruvbox-material", opt = true})
|
||||
use({"shaunsingh/nord.nvim", opt = true})
|
||||
use({"NTBBloodbath/doom-one.nvim", opt = true})
|
||||
use({"sainnhe/everforest", opt = true})
|
||||
use({"EdenEast/nightfox.nvim", opt = true})
|
||||
use({"rebelot/kanagawa.nvim", opt = true})
|
||||
|
||||
-- Show git change (change, delete, add) signs in vim sign column
|
||||
use({"mhinz/vim-signify", event = 'BufEnter'})
|
||||
-- Another similar plugin
|
||||
-- use 'airblade/vim-gitgutter'
|
||||
|
||||
use {'kyazdani42/nvim-web-devicons', event = 'VimEnter'}
|
||||
|
||||
use {
|
||||
'nvim-lualine/lualine.nvim',
|
||||
event = 'VimEnter',
|
||||
config = [[require('config.statusline')]]
|
||||
}
|
||||
|
||||
use({ "akinsho/bufferline.nvim", event = "VimEnter", config = [[require('config.bufferline')]] })
|
||||
|
||||
-- fancy start screen
|
||||
use { 'goolord/alpha-nvim', event = 'VimEnter', config = [[require('config.alpha-nvim')]] }
|
||||
|
||||
use({
|
||||
"lukas-reineke/indent-blankline.nvim",
|
||||
event = 'VimEnter',
|
||||
config = [[require('config.indent-blankline')]]
|
||||
})
|
||||
|
||||
-- Highlight URLs inside vim
|
||||
use({"itchyny/vim-highlighturl", event = "VimEnter"})
|
||||
|
||||
-- notification plugin
|
||||
use({
|
||||
"rcarriga/nvim-notify",
|
||||
event = "BufEnter",
|
||||
config = function()
|
||||
vim.defer_fn(function() require('config.nvim-notify') end, 2000)
|
||||
end
|
||||
})
|
||||
|
||||
-- For Windows and Mac, we can open an URL in the browser. For Linux, it may
|
||||
-- not be possible since we maybe in a server which disables GUI.
|
||||
if vim.g.is_win or vim.g.is_mac then
|
||||
-- open URL in browser
|
||||
use({"tyru/open-browser.vim", event = "VimEnter"})
|
||||
end
|
||||
|
||||
-- Only install these plugins if ctags are installed on the system
|
||||
if utils.executable("ctags") then
|
||||
-- show file tags in vim window
|
||||
use({"liuchengxu/vista.vim", cmd = "Vista"})
|
||||
end
|
||||
|
||||
-- Snippet engine and snippet template
|
||||
use({"SirVer/ultisnips", event = 'InsertEnter'})
|
||||
use({ "honza/vim-snippets", after = 'ultisnips'})
|
||||
|
||||
-- Automatic insertion and deletion of a pair of characters
|
||||
use({"Raimondi/delimitMate", event = "InsertEnter"})
|
||||
|
||||
-- Comment plugin
|
||||
use({"tpope/vim-commentary", event = "VimEnter"})
|
||||
|
||||
-- Multiple cursor plugin like Sublime Text?
|
||||
-- use 'mg979/vim-visual-multi'
|
||||
|
||||
-- Autosave files on certain events
|
||||
use({
|
||||
"Pocco81/AutoSave.nvim",
|
||||
event = "VimEnter",
|
||||
config = function()
|
||||
vim.defer_fn(function() require('config.autosave') end, 1500)
|
||||
end
|
||||
})
|
||||
|
||||
-- Show undo history visually
|
||||
use({"simnalamburt/vim-mundo", cmd = {"MundoToggle", "MundoShow"}})
|
||||
|
||||
-- Manage your yank history
|
||||
if vim.g.is_win or vim.g.is_mac then
|
||||
use({"svermeulen/vim-yoink", event = "VimEnter"})
|
||||
end
|
||||
|
||||
-- Handy unix command inside Vim (Rename, Move etc.)
|
||||
use({"tpope/vim-eunuch", cmd = {"Rename", "Delete"}})
|
||||
|
||||
-- Repeat vim motions
|
||||
use({"tpope/vim-repeat", event = "VimEnter"})
|
||||
|
||||
-- Show the content of register in preview window
|
||||
-- Plug 'junegunn/vim-peekaboo'
|
||||
use({ "jdhao/better-escape.vim", event = { "InsertEnter" } })
|
||||
|
||||
if vim.g.is_mac then
|
||||
use({ "lyokha/vim-xkbswitch", event = { "InsertEnter" } })
|
||||
elseif vim.g.is_win then
|
||||
use({ "Neur1n/neuims", event = { "InsertEnter" } })
|
||||
end
|
||||
|
||||
-- Syntax check and make
|
||||
-- use 'neomake/neomake'
|
||||
|
||||
-- Auto format tools
|
||||
use({ "sbdchd/neoformat", cmd = { "Neoformat" } })
|
||||
-- use 'Chiel92/vim-autoformat'
|
||||
|
||||
-- Git command inside vim
|
||||
use({ "tpope/vim-fugitive", event = "User InGitRepo" })
|
||||
|
||||
-- Better git log display
|
||||
use({ "rbong/vim-flog", requires = "tpope/vim-fugitive", cmd = { "Flog" } })
|
||||
|
||||
use({ "christoomey/vim-conflicted", requires = "tpope/vim-fugitive", cmd = {"Conflicted"}})
|
||||
|
||||
use({ "kevinhwang91/nvim-bqf", ft = "qf", config = [[require('config.bqf')]] })
|
||||
|
||||
-- Better git commit experience
|
||||
use({"rhysd/committia.vim", opt = true, setup = [[vim.cmd('packadd committia.vim')]]})
|
||||
|
||||
-- Another markdown plugin
|
||||
use({ "plasticboy/vim-markdown", ft = { "markdown" } })
|
||||
|
||||
-- Faster footnote generation
|
||||
use({ "vim-pandoc/vim-markdownfootnotes", ft = { "markdown" } })
|
||||
|
||||
-- Vim tabular plugin for manipulate tabular, required by markdown plugins
|
||||
use({ "godlygeek/tabular", cmd = { "Tabularize" } })
|
||||
|
||||
-- Markdown JSON header highlight plugin
|
||||
use({ "elzr/vim-json", ft = { "json", "markdown" } })
|
||||
|
||||
-- Markdown previewing (only for Mac and Windows)
|
||||
if vim.g.is_win or vim.g.is_mac then
|
||||
use({
|
||||
"iamcco/markdown-preview.nvim",
|
||||
run = function()
|
||||
fn["mkdp#util#install"]()
|
||||
end,
|
||||
ft = { "markdown" },
|
||||
})
|
||||
end
|
||||
|
||||
use({'folke/zen-mode.nvim', cmd = 'ZenMode', config = [[require('config.zen-mode')]]})
|
||||
|
||||
if vim.g.is_mac then
|
||||
use({ "rhysd/vim-grammarous", ft = { "markdown" } })
|
||||
end
|
||||
|
||||
use({"chrisbra/unicode.vim", event = "VimEnter"})
|
||||
|
||||
-- Additional powerful text object for vim, this plugin should be studied
|
||||
-- carefully to use its full power
|
||||
use({"wellle/targets.vim", event = "VimEnter"})
|
||||
|
||||
-- Plugin to manipulate character pairs quickly
|
||||
-- use 'tpope/vim-surround'
|
||||
use({"machakann/vim-sandwich", event = "VimEnter"})
|
||||
|
||||
-- Add indent object for vim (useful for languages like Python)
|
||||
use({"michaeljsmith/vim-indent-object", event = "VimEnter"})
|
||||
|
||||
-- Only use these plugin on Windows and Mac and when LaTeX is installed
|
||||
if vim.g.is_win or vim.g.is_mac and utils.executable("latex") then
|
||||
use({ "lervag/vimtex", ft = { "tex" } })
|
||||
|
||||
-- use {'matze/vim-tex-fold', ft = {'tex', }}
|
||||
-- use 'Konfekt/FastFold'
|
||||
end
|
||||
|
||||
-- Since tmux is only available on Linux and Mac, we only enable these plugins
|
||||
-- for Linux and Mac
|
||||
if utils.executable("tmux") then
|
||||
-- .tmux.conf syntax highlighting and setting check
|
||||
use({ "tmux-plugins/vim-tmux", ft = { "tmux" } })
|
||||
end
|
||||
|
||||
-- Modern matchit implementation
|
||||
use({"andymass/vim-matchup", event = "VimEnter"})
|
||||
|
||||
-- Smoothie motions
|
||||
-- use 'psliwka/vim-smoothie'
|
||||
use({
|
||||
"karb94/neoscroll.nvim",
|
||||
event = "VimEnter",
|
||||
config = function()
|
||||
vim.defer_fn(function() require('config.neoscroll') end, 2000)
|
||||
end
|
||||
})
|
||||
|
||||
use({"tpope/vim-scriptease", cmd = {"Scriptnames", "Message", "Verbose"}})
|
||||
|
||||
-- Asynchronous command execution
|
||||
use({ "skywind3000/asyncrun.vim", opt = true, cmd = { "AsyncRun" } })
|
||||
-- Another asynchronous plugin
|
||||
-- Plug 'tpope/vim-dispatch'
|
||||
|
||||
use({ "cespare/vim-toml", ft = { "toml" }, branch = "main" })
|
||||
|
||||
-- Edit text area in browser using nvim
|
||||
if vim.g.is_win or vim.g.is_mac then
|
||||
use({
|
||||
"glacambre/firenvim",
|
||||
run = function() fn["firenvim#install"](0) end,
|
||||
opt = true,
|
||||
setup = [[vim.cmd('packadd firenvim')]],
|
||||
})
|
||||
end
|
||||
|
||||
-- Debugger plugin
|
||||
if vim.g.is_win or vim.g.is_linux then
|
||||
use({ "sakhnik/nvim-gdb", run = { "bash install.sh" }, opt = true, setup = [[vim.cmd('packadd nvim-gdb')]] })
|
||||
end
|
||||
|
||||
-- Session management plugin
|
||||
use({"tpope/vim-obsession", cmd = 'Obsession'})
|
||||
|
||||
if vim.g.is_linux then
|
||||
use({"ojroques/vim-oscyank", cmd = {'OSCYank', 'OSCYankReg'}})
|
||||
end
|
||||
|
||||
-- The missing auto-completion for cmdline!
|
||||
use({"gelguy/wilder.nvim", opt = true, setup = [[vim.cmd('packadd wilder.nvim')]]})
|
||||
|
||||
-- showing keybindings
|
||||
use {"folke/which-key.nvim",
|
||||
event = "VimEnter",
|
||||
config = function()
|
||||
vim.defer_fn(function() require('config.which-key') end, 2000)
|
||||
end
|
||||
}
|
||||
|
||||
-- show and trim trailing whitespaces
|
||||
use {'jdhao/whitespace.nvim', event = 'VimEnter'}
|
||||
|
||||
-- file explorer
|
||||
use {
|
||||
'kyazdani42/nvim-tree.lua',
|
||||
requires = { 'kyazdani42/nvim-web-devicons' },
|
||||
config = [[require('config.nvim-tree')]]
|
||||
}
|
||||
end,
|
||||
config = {
|
||||
max_jobs = 16,
|
||||
compile_path = util.join_paths(vim.fn.stdpath('config'), 'lua', 'packer_compiled.lua'),
|
||||
},
|
||||
})
|
||||
|
||||
local status, _ = pcall(require, 'packer_compiled')
|
||||
if not status then
|
||||
vim.notify("Error requiring packer_compiled.lua: run PackerSync to fix!")
|
||||
end
|
||||
@@ -1,27 +1,95 @@
|
||||
-- inspect something
|
||||
-- Taken from https://github.com/jamestthompson3/vimConfig/blob/eeef4a8eeb5a24938f8a0969a35f69c78643fb66/lua/tt/nvim_utils.lua#L106
|
||||
function inspect(item)
|
||||
print(vim.inspect(item))
|
||||
end
|
||||
local fn = vim.fn
|
||||
local version = vim.version
|
||||
|
||||
local M = {}
|
||||
|
||||
--- Check if an executable exists
|
||||
--- @param name string An executable name/path
|
||||
--- @return boolean
|
||||
function M.executable(name)
|
||||
if vim.fn.executable(name) > 0 then
|
||||
return fn.executable(name) > 0
|
||||
end
|
||||
|
||||
--- check whether a feature exists in Nvim
|
||||
--- @param feat string the feature name, like `nvim-0.7` or `unix`.
|
||||
--- @return boolean
|
||||
M.has = function(feat)
|
||||
if fn.has(feat) == 1 then
|
||||
return true
|
||||
end
|
||||
|
||||
return false
|
||||
end
|
||||
|
||||
function M.may_create_dir()
|
||||
local fpath = vim.fn.expand('<afile>')
|
||||
local parent_dir = vim.fn.fnamemodify(fpath, ":p:h")
|
||||
local res = vim.fn.isdirectory(parent_dir)
|
||||
--- Create a dir if it does not exist
|
||||
function M.may_create_dir(dir)
|
||||
local res = fn.isdirectory(dir)
|
||||
|
||||
if res == 0 then
|
||||
vim.fn.mkdir(parent_dir, 'p')
|
||||
fn.mkdir(dir, "p")
|
||||
end
|
||||
end
|
||||
|
||||
--- Generate random integers in the range [Low, High], inclusive,
|
||||
--- adapted from https://stackoverflow.com/a/12739441/6064933
|
||||
--- @param low integer the lower value for this range
|
||||
--- @param high integer the upper value for this range
|
||||
--- @return integer
|
||||
function M.rand_int(low, high)
|
||||
-- Use lua to generate random int, see also: https://stackoverflow.com/a/20157671/6064933
|
||||
math.randomseed(os.time())
|
||||
|
||||
return math.random(low, high)
|
||||
end
|
||||
|
||||
--- Select a random element from a sequence/list.
|
||||
--- @param seq any[] the sequence to choose an element
|
||||
function M.rand_element(seq)
|
||||
local idx = M.rand_int(1, #seq)
|
||||
|
||||
return seq[idx]
|
||||
end
|
||||
|
||||
--- check if the current nvim version is compatible with the allowed version
|
||||
--- @param expected_version string
|
||||
--- @return boolean
|
||||
function M.is_compatible_version(expected_version)
|
||||
-- check if we have the latest stable version of nvim
|
||||
local expect_ver = version.parse(expected_version)
|
||||
local actual_ver = vim.version()
|
||||
|
||||
if expect_ver == nil then
|
||||
local msg = string.format("Unsupported version string: %s", expected_version)
|
||||
vim.api.nvim_echo({ { msg } }, true, { err = true })
|
||||
return false
|
||||
end
|
||||
|
||||
local result = version.cmp(expect_ver, actual_ver)
|
||||
if result ~= 0 then
|
||||
local _ver = string.format("%s.%s.%s", actual_ver.major, actual_ver.minor, actual_ver.patch)
|
||||
local msg = string.format(
|
||||
"Expect nvim version %s, but your current nvim version is %s. Use at your own risk!",
|
||||
expected_version,
|
||||
_ver
|
||||
)
|
||||
vim.api.nvim_echo({ { msg } }, true, { err = true })
|
||||
end
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
--- check if we are inside a git repo
|
||||
--- @return boolean
|
||||
function M.inside_git_repo()
|
||||
local result = vim.system({ "git", "rev-parse", "--is-inside-work-tree" }, { text = true }):wait()
|
||||
if result.code ~= 0 then
|
||||
return false
|
||||
end
|
||||
|
||||
-- Manually trigger a special user autocmd InGitRepo (used lazyloading.
|
||||
vim.cmd([[doautocmd User InGitRepo]])
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
return M
|
||||
|
||||
@@ -47,7 +47,7 @@ $0
|
||||
endsnippet
|
||||
|
||||
snippet font "HTML font tag"
|
||||
<font color="${1:red}">${2:TEXT}</font>
|
||||
<font color="${1:blue}">${2:TEXT}</font>
|
||||
endsnippet
|
||||
|
||||
snippet link "Markdown links"
|
||||
|
||||
@@ -24,3 +24,7 @@ def main():
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
endsnippet
|
||||
|
||||
snippet sol "solution" b
|
||||
solution = Solution()
|
||||
endsnippet
|
||||
|
||||
@@ -2,7 +2,7 @@ snippet use "usepackage" b
|
||||
\usepackage{${1:package}}
|
||||
endsnippet
|
||||
|
||||
snippet eqa "equation enviroment" b
|
||||
snippet eqa "equation environment" b
|
||||
\begin{equation}\label{$1}
|
||||
$2
|
||||
\end{equation}
|
||||
|
||||
3
plugin/abbrev.vim
Normal file
3
plugin/abbrev.vim
Normal file
@@ -0,0 +1,3 @@
|
||||
" some abbreviations
|
||||
iabbrev reqire require
|
||||
iabbrev serveral several
|
||||
59
plugin/command.lua
Normal file
59
plugin/command.lua
Normal file
@@ -0,0 +1,59 @@
|
||||
-- Copy file path to clipboard
|
||||
vim.api.nvim_create_user_command("CopyPath", function(context)
|
||||
local full_path = vim.fn.glob("%:p")
|
||||
|
||||
local file_path = nil
|
||||
if context["args"] == "nameonly" then
|
||||
file_path = vim.fn.fnamemodify(full_path, ":t")
|
||||
end
|
||||
|
||||
-- get the file path relative to project root
|
||||
if context["args"] == "relative" then
|
||||
local project_marker = { ".git", "pyproject.toml" }
|
||||
local project_root = vim.fs.root(0, project_marker)
|
||||
if project_root == nil then
|
||||
vim.print("can not find project root")
|
||||
return
|
||||
end
|
||||
|
||||
file_path = vim.fn.substitute(full_path, project_root, "<project-root>", "g")
|
||||
end
|
||||
|
||||
if context["args"] == "absolute" then
|
||||
file_path = full_path
|
||||
end
|
||||
|
||||
vim.fn.setreg("+", file_path)
|
||||
vim.print("Filepath copied to clipboard!")
|
||||
end, {
|
||||
bang = false,
|
||||
nargs = 1,
|
||||
force = true,
|
||||
desc = "Copy current file path to clipboard",
|
||||
complete = function()
|
||||
return { "nameonly", "relative", "absolute" }
|
||||
end,
|
||||
})
|
||||
|
||||
-- JSON format part of or the whole file
|
||||
vim.api.nvim_create_user_command("JSONFormat", function(context)
|
||||
local range = context["range"]
|
||||
local line1 = context["line1"]
|
||||
local line2 = context["line2"]
|
||||
|
||||
if range == 0 then
|
||||
-- the command is invoked without range, then we assume whole buffer
|
||||
local cmd_str = string.format("%s,%s!python -m json.tool", line1, line2)
|
||||
vim.fn.execute(cmd_str)
|
||||
elseif range == 2 then
|
||||
-- the command is invoked with some range
|
||||
local cmd_str = string.format("%s,%s!python -m json.tool", line1, line2)
|
||||
vim.fn.execute(cmd_str)
|
||||
else
|
||||
local msg = string.format("unsupported range: %s", range)
|
||||
vim.api.nvim_echo({ { msg } }, true, { err = true })
|
||||
end
|
||||
end, {
|
||||
desc = "Format JSON string",
|
||||
range = "%",
|
||||
})
|
||||
@@ -8,3 +8,40 @@ call utils#Cabbrev('man', 'Man')
|
||||
|
||||
" show current date and time in human readable format
|
||||
command! -nargs=? Datetime echo utils#iso_time(<q-args>)
|
||||
|
||||
" Convert Markdown file to PDF
|
||||
command! ToPDF call s:md_to_pdf()
|
||||
|
||||
function! s:md_to_pdf() abort
|
||||
" check if pandoc is installed
|
||||
if executable('pandoc') != 1
|
||||
echoerr "pandoc not found"
|
||||
return
|
||||
endif
|
||||
|
||||
let l:md_path = expand("%:p")
|
||||
let l:pdf_path = fnamemodify(l:md_path, ":r") .. ".pdf"
|
||||
|
||||
let l:header_path = stdpath('config') . '/resources/head.tex'
|
||||
|
||||
let l:cmd = "pandoc --pdf-engine=xelatex --highlight-style=zenburn --table-of-content " .
|
||||
\ "--include-in-header=" . l:header_path . " -V fontsize=10pt -V colorlinks -V toccolor=NavyBlue " .
|
||||
\ "-V linkcolor=red -V urlcolor=teal -V filecolor=magenta -s " .
|
||||
\ l:md_path . " -o " . l:pdf_path
|
||||
|
||||
if g:is_mac
|
||||
let l:cmd = l:cmd . '&& open ' . l:pdf_path
|
||||
endif
|
||||
|
||||
if g:is_win
|
||||
let l:cmd = l:cmd . '&& start ' . l:pdf_path
|
||||
endif
|
||||
|
||||
" echomsg l:cmd
|
||||
|
||||
let l:id = jobstart(l:cmd)
|
||||
|
||||
if l:id == 0 || l:id == -1
|
||||
echoerr "Error running command"
|
||||
endif
|
||||
endfunction
|
||||
|
||||
78
resources/head.tex
Normal file
78
resources/head.tex
Normal file
@@ -0,0 +1,78 @@
|
||||
\usepackage{fancyvrb,newverbs}
|
||||
\usepackage[top=2cm, bottom=1.5cm, left=2cm, right=2cm]{geometry}
|
||||
|
||||
\PassOptionsToPackage{dvipsnames,svgnames,x11names}{xcolor}
|
||||
\usepackage{hyperref}
|
||||
|
||||
% begin a new page for each section (first level header),
|
||||
% we need to combine this with `-V subparagraph` when invoking pandc
|
||||
% \usepackage{titlesec}
|
||||
% \newcommand{\sectionbreak}{\clearpage}
|
||||
|
||||
% change background color for inline code in markdown files.
|
||||
% The following code does not work well for long text, because the text will exceed the page boundary.
|
||||
\definecolor{bgcolor}{HTML}{DADADA}
|
||||
\let\oldtexttt\texttt
|
||||
|
||||
\renewcommand{\texttt}[1]{
|
||||
\colorbox{bgcolor}{\oldtexttt{#1}}
|
||||
}
|
||||
|
||||
% change style of quote, see also https://tex.stackexchange.com/a/436253/114857
|
||||
\usepackage[most]{tcolorbox}
|
||||
|
||||
\definecolor{linequote}{RGB}{224,215,188}
|
||||
\definecolor{backquote}{RGB}{249,245,233}
|
||||
\definecolor{bordercolor}{RGB}{221,221,221}
|
||||
|
||||
% change left border: https://tex.stackexchange.com/a/475716/114857
|
||||
% change left margin: https://tex.stackexchange.com/a/457936/114857
|
||||
\newtcolorbox{myquote}[1][]{%
|
||||
enhanced,
|
||||
breakable,
|
||||
size=minimal,
|
||||
left=10pt,
|
||||
top=5pt,
|
||||
bottom=5pt,
|
||||
frame hidden,
|
||||
boxrule=0pt,
|
||||
sharp corners=all,
|
||||
colback=backquote,
|
||||
borderline west={2pt}{0pt}{bordercolor},
|
||||
#1
|
||||
}
|
||||
|
||||
% redefine quote environment to use the myquote environment, see https://tex.stackexchange.com/a/337587/114857
|
||||
\renewenvironment{quote}{\begin{myquote}}{\end{myquote}}
|
||||
|
||||
% start a new page after toc, we need to save the old command before defining
|
||||
% new one to avoid recursive command calls,
|
||||
% see https://tex.stackexchange.com/questions/47351/can-i-redefine-a-command-to-contain-itself
|
||||
\let\oldtoc\tableofcontents
|
||||
\renewcommand{\tableofcontents}{\oldtoc\newpage}
|
||||
|
||||
% fix header level issue
|
||||
\usepackage{enumitem}
|
||||
\setlistdepth{9}
|
||||
|
||||
\setlist[itemize,1]{label=$\bullet$}
|
||||
\setlist[itemize,2]{label=$\bullet$}
|
||||
\setlist[itemize,3]{label=$\bullet$}
|
||||
\setlist[itemize,4]{label=$\bullet$}
|
||||
\setlist[itemize,5]{label=$\bullet$}
|
||||
\setlist[itemize,6]{label=$\bullet$}
|
||||
\setlist[itemize,7]{label=$\bullet$}
|
||||
\setlist[itemize,8]{label=$\bullet$}
|
||||
\setlist[itemize,9]{label=$\bullet$}
|
||||
\renewlist{itemize}{itemize}{9}
|
||||
|
||||
\setlist[enumerate,1]{label=$\arabic*.$}
|
||||
\setlist[enumerate,2]{label=$\alph*.$}
|
||||
\setlist[enumerate,3]{label=$\roman*.$}
|
||||
\setlist[enumerate,4]{label=$\arabic*.$}
|
||||
\setlist[enumerate,5]{label=$\alpha*$}
|
||||
\setlist[enumerate,6]{label=$\roman*.$}
|
||||
\setlist[enumerate,7]{label=$\arabic*.$}
|
||||
\setlist[enumerate,8]{label=$\alph*.$}
|
||||
\setlist[enumerate,9]{label=$\roman*.$}
|
||||
\renewlist{enumerate}{enumerate}{9}
|
||||
@@ -194,7 +194,6 @@ wiki
|
||||
backticks
|
||||
Reddit
|
||||
LeaderF
|
||||
gruvbox8
|
||||
tabpage
|
||||
ccls
|
||||
cmake
|
||||
@@ -203,6 +202,8 @@ llvm
|
||||
subsampling
|
||||
refactor
|
||||
colorschemes
|
||||
gruvbox8
|
||||
gruvbox
|
||||
Gruvbox
|
||||
monokai
|
||||
NeoSolarized
|
||||
@@ -415,3 +416,63 @@ src
|
||||
RGBA
|
||||
yapf
|
||||
Vimming
|
||||
overfitting
|
||||
PCA
|
||||
SVM
|
||||
KNN
|
||||
leetcode
|
||||
Logitech
|
||||
WTF
|
||||
tensorboard
|
||||
Nvidia
|
||||
GPG
|
||||
manpage
|
||||
metatable
|
||||
open3d
|
||||
pyntcloud
|
||||
param
|
||||
reddit
|
||||
viml
|
||||
PostgreSQL
|
||||
CNY
|
||||
wechat
|
||||
ziroom
|
||||
Postgres
|
||||
plpgsql
|
||||
postgres
|
||||
PySpark
|
||||
winbar
|
||||
cmdline
|
||||
shada
|
||||
async
|
||||
localhost
|
||||
JetBrains
|
||||
localhost
|
||||
MariaDB
|
||||
SQLite
|
||||
Pgadmin
|
||||
Datagrip
|
||||
mysql
|
||||
cwd
|
||||
pyright
|
||||
stubgen
|
||||
pylance
|
||||
variadic
|
||||
Vimium
|
||||
Databricks
|
||||
Jira
|
||||
databricks
|
||||
FastAPI
|
||||
pylintrc
|
||||
PYTHONPATH
|
||||
Uvicorn
|
||||
qpdf
|
||||
Elasticsearch
|
||||
kibana
|
||||
submodule
|
||||
unix
|
||||
GCP
|
||||
Kubernetes
|
||||
pubsub
|
||||
Luarocks
|
||||
luarocks
|
||||
|
||||
@@ -1,15 +1,14 @@
|
||||
scriptencoding utf-8
|
||||
|
||||
" change fillchars for folding, vertical split, end of buffer, and message separator
|
||||
set fillchars=fold:\ ,vert:\│,eob:\ ,msgsep:‾
|
||||
|
||||
" Paste mode toggle, it seems that Nvim's bracketed paste mode
|
||||
" does not work very well for nvim-qt, so we use good-old paste mode
|
||||
set pastetoggle=<F12>
|
||||
set fillchars=fold:\ ,foldsep:\ ,foldopen:,foldclose:,vert:\│,eob:\ ,msgsep:‾,diff:╱
|
||||
|
||||
" Split window below/right when creating horizontal/vertical windows
|
||||
set splitbelow splitright
|
||||
|
||||
" avoid the flickering when splitting window horizontal
|
||||
set splitkeep=screen
|
||||
|
||||
" Time in milliseconds to wait for a mapped sequence to complete,
|
||||
" see https://unix.stackexchange.com/q/36882/221410 for more info
|
||||
set timeoutlen=500
|
||||
@@ -44,9 +43,9 @@ set backup " create backup for files
|
||||
set backupcopy=yes " copy the original file to backupdir and overwrite it
|
||||
|
||||
" General tab settings
|
||||
set tabstop=4 " number of visual spaces per TAB
|
||||
set softtabstop=4 " number of spaces in tab when editing
|
||||
set shiftwidth=4 " number of spaces to use for autoindent
|
||||
set tabstop=2 " number of visual spaces per TAB
|
||||
set softtabstop=2 " number of spaces in tab when editing
|
||||
set shiftwidth=2 " number of spaces to use for autoindent
|
||||
set expandtab " expand tab to spaces so that tabs are spaces
|
||||
|
||||
" Set matching pairs of characters and highlight matching brackets
|
||||
@@ -73,8 +72,9 @@ set wildmode=list:longest
|
||||
set scrolloff=3
|
||||
|
||||
" Use mouse to select and resize windows, etc.
|
||||
set mouse=nic " Enable mouse in several mode
|
||||
set mouse=n
|
||||
set mousemodel=popup " Set the behaviour of mouse
|
||||
set mousescroll=ver:1,hor:0
|
||||
|
||||
" Disable showing current mode on command line since statusline plugins can show it.
|
||||
set noshowmode
|
||||
@@ -112,15 +112,21 @@ set shortmess+=c
|
||||
" choice, IMHO.
|
||||
set shortmess+=S
|
||||
|
||||
" Disable showing intro message (:intro)
|
||||
set shortmess+=I
|
||||
|
||||
set messagesopt=hit-enter,history:500
|
||||
|
||||
" Completion behaviour
|
||||
" set completeopt+=noinsert " Auto select the first completion entry
|
||||
set completeopt+=menuone " Show menu even if there is only one item
|
||||
set completeopt-=preview " Disable the preview window
|
||||
|
||||
set pumheight=10 " Maximum number of items to show in popup menu
|
||||
set pumblend=10 " pseudo transparency for completion menu
|
||||
set pumblend=5 " pseudo transparency for completion menu
|
||||
|
||||
set winblend=5 " pseudo transparency for floating window
|
||||
set winblend=0 " pseudo transparency for floating window
|
||||
set winborder=none
|
||||
|
||||
" Insert mode key word completion setting
|
||||
set complete+=kspell complete-=w complete-=b complete-=u complete-=t
|
||||
@@ -141,7 +147,7 @@ set formatoptions+=mM
|
||||
" Tilde (~) is an operator, thus must be followed by motions like `e` or `w`.
|
||||
set tildeop
|
||||
|
||||
set synmaxcol=200 " Text after this column number is not highlighted
|
||||
set synmaxcol=250 " Text after this column number is not highlighted
|
||||
set nostartofline
|
||||
|
||||
" External program to use for grep command
|
||||
@@ -159,7 +165,7 @@ set termguicolors
|
||||
" https://github.com/neovim/neovim/wiki/FAQ#how-to-change-cursor-color-in-the-terminal
|
||||
set guicursor=n-v-c:block-Cursor/lCursor,i-ci-ve:ver25-Cursor2/lCursor2,r-cr:hor20,o:hor20
|
||||
|
||||
set signcolumn=auto:2
|
||||
set signcolumn=yes:1
|
||||
|
||||
" Remove certain character from file name pattern matching
|
||||
set isfname-==
|
||||
@@ -172,5 +178,9 @@ set diffopt+=filler " show filler for deleted lines
|
||||
set diffopt+=closeoff " turn off diff when one file window is closed
|
||||
set diffopt+=context:3 " context for diff
|
||||
set diffopt+=internal,indent-heuristic,algorithm:histogram
|
||||
set diffopt+=linematch:60
|
||||
|
||||
set nowrap " do no wrap
|
||||
set noruler
|
||||
|
||||
set showcmdloc=statusline
|
||||
@@ -1,16 +1,16 @@
|
||||
scriptencoding utf-8
|
||||
|
||||
" Plugin specification and lua stuff
|
||||
lua require('lua-init')
|
||||
lua require('plugin_specs')
|
||||
|
||||
" Use short names for common plugin manager commands to simplify typing.
|
||||
" To use these shortcuts: first activate command line with `:`, then input the
|
||||
" short alias, e.g., `pi`, then press <space>, the alias will be expanded to
|
||||
" the full command automatically.
|
||||
call utils#Cabbrev('pi', 'PackerInstall')
|
||||
call utils#Cabbrev('pud', 'PackerUpdate')
|
||||
call utils#Cabbrev('pc', 'PackerClean')
|
||||
call utils#Cabbrev('ps', 'PackerSync')
|
||||
call utils#Cabbrev('pi', 'Lazy install')
|
||||
call utils#Cabbrev('pud', 'Lazy update')
|
||||
call utils#Cabbrev('pc', 'Lazy clean')
|
||||
call utils#Cabbrev('ps', 'Lazy sync')
|
||||
|
||||
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
" configurations for vim script plugin "
|
||||
@@ -34,91 +34,6 @@ let g:UltiSnipsSnippetDirectories=['UltiSnips', 'my_snippets']
|
||||
"""""""""""""""""""""""""" vlime settings """"""""""""""""""""""""""""""""
|
||||
command! -nargs=0 StartVlime call jobstart(printf("sbcl --load %s/vlime/lisp/start-vlime.lisp", g:package_home))
|
||||
|
||||
"""""""""""""""""""""""""""""LeaderF settings"""""""""""""""""""""
|
||||
" Do not use cache file
|
||||
let g:Lf_UseCache = 0
|
||||
" Refresh each time we call leaderf
|
||||
let g:Lf_UseMemoryCache = 0
|
||||
|
||||
" Ignore certain files and directories when searching files
|
||||
let g:Lf_WildIgnore = {
|
||||
\ 'dir': ['.git', '__pycache__', '.DS_Store'],
|
||||
\ 'file': ['*.exe', '*.dll', '*.so', '*.o', '*.pyc', '*.jpg', '*.png',
|
||||
\ '*.gif', '*.svg', '*.ico', '*.db', '*.tgz', '*.tar.gz', '*.gz',
|
||||
\ '*.zip', '*.bin', '*.pptx', '*.xlsx', '*.docx', '*.pdf', '*.tmp',
|
||||
\ '*.wmv', '*.mkv', '*.mp4', '*.rmvb', '*.ttf', '*.ttc', '*.otf',
|
||||
\ '*.mp3', '*.aac']
|
||||
\}
|
||||
|
||||
" Do not show fancy icons for Linux server.
|
||||
if g:is_linux
|
||||
let g:Lf_ShowDevIcons = 0
|
||||
endif
|
||||
|
||||
" Only fuzzy-search files names
|
||||
let g:Lf_DefaultMode = 'FullPath'
|
||||
|
||||
" Popup window settings
|
||||
let w = float2nr(&columns * 0.8)
|
||||
if w > 140
|
||||
let g:Lf_PopupWidth = 140
|
||||
else
|
||||
let g:Lf_PopupWidth = w
|
||||
endif
|
||||
|
||||
let g:Lf_PopupPosition = [0, float2nr((&columns - g:Lf_PopupWidth)/2)]
|
||||
|
||||
" Do not use version control tool to list files under a directory since
|
||||
" submodules are not searched by default.
|
||||
let g:Lf_UseVersionControlTool = 0
|
||||
|
||||
" Use rg as the default search tool
|
||||
let g:Lf_DefaultExternalTool = "rg"
|
||||
|
||||
" show dot files
|
||||
let g:Lf_ShowHidden = 1
|
||||
|
||||
" Disable default mapping
|
||||
let g:Lf_ShortcutF = ''
|
||||
let g:Lf_ShortcutB = ''
|
||||
|
||||
" set up working directory for git repository
|
||||
let g:Lf_WorkingDirectoryMode = 'a'
|
||||
|
||||
" Search files in popup window
|
||||
nnoremap <silent> <leader>ff :<C-U>Leaderf file --popup<CR>
|
||||
|
||||
" Grep project files in popup window
|
||||
nnoremap <silent> <leader>fg :<C-U>Leaderf rg --no-messages --popup<CR>
|
||||
|
||||
" Search vim help files
|
||||
nnoremap <silent> <leader>fh :<C-U>Leaderf help --popup<CR>
|
||||
|
||||
" Search tags in current buffer
|
||||
nnoremap <silent> <leader>ft :<C-U>Leaderf bufTag --popup<CR>
|
||||
|
||||
" Switch buffers
|
||||
nnoremap <silent> <leader>fb :<C-U>Leaderf buffer --popup<CR>
|
||||
|
||||
" Search recent files
|
||||
nnoremap <silent> <leader>fr :<C-U>Leaderf mru --popup<CR>
|
||||
|
||||
let g:Lf_PopupColorscheme = 'gruvbox_material'
|
||||
|
||||
" Change keybinding in LeaderF prompt mode, use ctrl-n and ctrl-p to navigate
|
||||
" items.
|
||||
let g:Lf_CommandMap = {'<C-J>': ['<C-N>'], '<C-K>': ['<C-P>']}
|
||||
|
||||
""""""""""""""""""""""""""""open-browser.vim settings"""""""""""""""""""
|
||||
if g:is_win || g:is_mac
|
||||
" Disable netrw's gx mapping.
|
||||
let g:netrw_nogx = 1
|
||||
|
||||
" Use another mapping for the open URL method
|
||||
nmap ob <Plug>(openbrowser-smart-search)
|
||||
xmap ob <Plug>(openbrowser-smart-search)
|
||||
endif
|
||||
|
||||
""""""""""""""""""""""""""" vista settings """"""""""""""""""""""""""""""""""
|
||||
let g:vista#renderer#icons = {
|
||||
\ 'member': '',
|
||||
@@ -137,31 +52,6 @@ let g:mundo_width = 80
|
||||
|
||||
nnoremap <silent> <Space>u :MundoToggle<CR>
|
||||
|
||||
""""""""""""""""""""""""""""vim-yoink settings"""""""""""""""""""""""""
|
||||
if g:is_win || g:is_mac
|
||||
" ctrl-n and ctrl-p will not work if you add the TextChanged event to vim-auto-save events.
|
||||
" nmap <c-n> <plug>(YoinkPostPasteSwapBack)
|
||||
" nmap <c-p> <plug>(YoinkPostPasteSwapForward)
|
||||
|
||||
" The following p/P mappings are also needed for ctrl-n and ctrl-p to work
|
||||
" nmap p <plug>(YoinkPaste_p)
|
||||
" nmap P <plug>(YoinkPaste_P)
|
||||
|
||||
" Cycle the yank stack with the following mappings
|
||||
nmap [y <plug>(YoinkRotateBack)
|
||||
nmap ]y <plug>(YoinkRotateForward)
|
||||
|
||||
" Do not change the cursor position
|
||||
nmap y <plug>(YoinkYankPreserveCursorPosition)
|
||||
xmap y <plug>(YoinkYankPreserveCursorPosition)
|
||||
|
||||
" Move cursor to end of paste after multiline paste
|
||||
let g:yoinkMoveCursorToEndOfPaste = 0
|
||||
|
||||
" Record yanks in system clipboard
|
||||
let g:yoinkSyncSystemClipboardOnFocus = 1
|
||||
endif
|
||||
|
||||
""""""""""""""""""""""""""""better-escape.vim settings"""""""""""""""""""""""""
|
||||
let g:better_escape_interval = 200
|
||||
|
||||
@@ -182,41 +72,6 @@ let g:neoformat_c_clangformat = {
|
||||
let g:neoformat_enabled_cpp = ['clangformat']
|
||||
let g:neoformat_enabled_c = ['clangformat']
|
||||
|
||||
"""""""""""""""""""""""""vim-signify settings""""""""""""""""""""""""""""""
|
||||
" The VCS to use
|
||||
let g:signify_vcs_list = [ 'git' ]
|
||||
|
||||
" Change the sign for certain operations
|
||||
let g:signify_sign_change = '~'
|
||||
|
||||
"""""""""""""""""""""""""vim-fugitive settings""""""""""""""""""""""""""""""
|
||||
nnoremap <silent> <leader>gs :Git<CR>
|
||||
nnoremap <silent> <leader>gw :Gwrite<CR>
|
||||
nnoremap <silent> <leader>gc :Git commit<CR>
|
||||
nnoremap <silent> <leader>gd :Gdiffsplit<CR>
|
||||
nnoremap <silent> <leader>gpl :Git pull<CR>
|
||||
" Note that to use bar literally, we need backslash it, see also `:h :bar`.
|
||||
nnoremap <silent> <leader>gpu :15split \| term git push<CR>
|
||||
|
||||
"""""""""""""""""""""""""plasticboy/vim-markdown settings"""""""""""""""""""
|
||||
" Disable header folding
|
||||
let g:vim_markdown_folding_disabled = 1
|
||||
|
||||
" Whether to use conceal feature in markdown
|
||||
let g:vim_markdown_conceal = 1
|
||||
|
||||
" Disable math tex conceal and syntax highlight
|
||||
let g:tex_conceal = ''
|
||||
let g:vim_markdown_math = 0
|
||||
|
||||
" Support front matter of various format
|
||||
let g:vim_markdown_frontmatter = 1 " for YAML format
|
||||
let g:vim_markdown_toml_frontmatter = 1 " for TOML format
|
||||
let g:vim_markdown_json_frontmatter = 1 " for JSON format
|
||||
|
||||
" Let the TOC window autofit so that it doesn't take too much space
|
||||
let g:vim_markdown_toc_autofit = 1
|
||||
|
||||
"""""""""""""""""""""""""markdown-preview settings"""""""""""""""""""
|
||||
" Only setting this for suitable platforms
|
||||
if g:is_win || g:is_mac
|
||||
@@ -259,8 +114,8 @@ nmap s <Nop>
|
||||
omap s <Nop>
|
||||
|
||||
""""""""""""""""""""""""""""vimtex settings"""""""""""""""""""""""""""""
|
||||
if ( g:is_win || g:is_mac ) && executable('latex')
|
||||
" Hacks for inverse serach to work semi-automatically,
|
||||
if executable('latex')
|
||||
" Hacks for inverse search to work semi-automatically,
|
||||
" see https://jdhao.github.io/2021/02/20/inverse_search_setup_neovim_vimtex/.
|
||||
function! s:write_server_name() abort
|
||||
let nvim_server_file = (has('win32') ? $TEMP : '/tmp') . '/vimtexserver.txt'
|
||||
@@ -292,7 +147,6 @@ if ( g:is_win || g:is_mac ) && executable('latex')
|
||||
" Viewer settings for different platforms
|
||||
if g:is_win
|
||||
let g:vimtex_view_general_viewer = 'SumatraPDF'
|
||||
let g:vimtex_view_general_options_latexmk = '-reuse-instance'
|
||||
let g:vimtex_view_general_options = '-reuse-instance -forward-search @tex @line @pdf'
|
||||
endif
|
||||
|
||||
@@ -321,11 +175,6 @@ if ( g:is_win || g:is_mac ) && executable('latex')
|
||||
endif
|
||||
endif
|
||||
|
||||
""""""""""""""""""""""""""""vim-startify settings""""""""""""""""""""""""""""
|
||||
" Do not change working directory when opening files.
|
||||
let g:startify_change_to_dir = 0
|
||||
let g:startify_fortune_use_unicode = 1
|
||||
|
||||
""""""""""""""""""""""""""""vim-matchup settings"""""""""""""""""""""""""""""
|
||||
" Improve performance
|
||||
let g:matchup_matchparen_deferred = 1
|
||||
@@ -372,9 +221,20 @@ if exists('g:started_by_firenvim') && g:started_by_firenvim
|
||||
\ }
|
||||
\ }
|
||||
|
||||
function s:setup_firenvim() abort
|
||||
set signcolumn=no
|
||||
set noruler
|
||||
set noshowcmd
|
||||
set laststatus=0
|
||||
set showtabline=0
|
||||
endfunction
|
||||
|
||||
augroup firenvim
|
||||
autocmd!
|
||||
autocmd BufEnter *.txt setlocal filetype=markdown laststatus=0 nonumber noshowcmd noruler showtabline=1
|
||||
autocmd BufEnter * call s:setup_firenvim()
|
||||
autocmd BufEnter sqlzoo*.txt set filetype=sql
|
||||
autocmd BufEnter github.com_*.txt set filetype=markdown
|
||||
autocmd BufEnter stackoverflow.com_*.txt set filetype=markdown
|
||||
augroup END
|
||||
endif
|
||||
|
||||
@@ -423,6 +283,6 @@ function! s:wilder_init() abort
|
||||
\ 'apply_incsearch_fix': 0,
|
||||
\ }))
|
||||
catch /^Vim\%((\a\+)\)\=:E117/
|
||||
echohl Error |echomsg "Wilder.nvim missing: run :PackerSync to fix."|echohl None
|
||||
echohl Error |echomsg "Wilder.nvim missing"| echohl None
|
||||
endtry
|
||||
endfunction
|
||||
Reference in New Issue
Block a user