1
0
mirror of https://github.com/jdhao/nvim-config.git synced 2025-06-08 14:14:33 +02:00

436 Commits

Author SHA1 Message Date
jdhao
3040fa7969 use a cmp-fork for now
Until cmp is maintained again or switch??
2024-10-09 17:37:21 +02:00
jdhao
b9cf3cc6ed update conf for plugin live-command.nvim 2024-09-20 21:26:28 +02:00
jdhao
154cde3d71 Add plugin live-command.nvim 2024-09-19 22:07:03 +02:00
jdhao
81f64ed32e Use absolute path for viml config
Full path should be used to load viml config, otherwise, when we open
nvim in other directories, we see errors that the viml config can not be
found.
2024-09-02 22:19:52 +02:00
jdhao
db380ca7a7 remove inspect() from lua _G table
Nvim nows provides `vim.inspect()` and `vim.print()`.
2024-09-01 21:47:21 +02:00
jdhao
51f81093da restructure init.lua 2024-08-31 21:25:18 +02:00
jdhao
a9fc298063 update documentation for resuming cursor position 2024-08-30 01:03:13 +02:00
jdhao
9071e045eb Make * and # search case aware
By default, when you press `*` to search word under the cursor, the
option `smartcase` is ignored. This means that if you press `*` when
your cursor is on `The`, the lower case one `the` is also searched.

In this commit, we translate star and # search into normal search so that
'smartcase' option is respected.
2024-08-30 01:01:04 +02:00
jdhao
fa79647a63 Fix type for option relativenumber
"relativenumber" should be window local option, not buffer local option.
2024-08-29 21:45:07 +02:00
jdhao
4b4ff5f549 Add error handling for resuming the cursor
This will close issue #328.
2024-08-29 21:41:13 +02:00
jdhao
12b0ff02b6 Move autocmd in viml to Lua 2024-08-27 23:12:33 +02:00
jdhao
e3930e8aa7 remove unused plugins 2024-08-25 23:36:29 +02:00
jdhao
21522bd194 update config for yanky 2024-08-25 23:34:03 +02:00
jdhao
a3c8b3d5b5 Update configuration for nvim-cmp
1. restrict max width of the completion menu. Here I am using
   lspkind.nvim to achieve this. There are other native ways to do this,
   see also https://github.com/hrsh7th/nvim-cmp/discussions/609 and
   https://github.com/hrsh7th/nvim-cmp/issues/980
2. remove cmp-emoji as it is rarely used and interfere when I write
   Python
3. lower the transparency for popup menu
2024-08-20 01:04:02 +02:00
jdhao
d150f39afc Add new plugins 2024-08-19 23:37:57 +02:00
jdhao
3904cd4ccf Update config for handling large files 2024-08-19 23:34:21 +02:00
jdhao
95d3b2f2d8 remove setting for JSON file 2024-08-19 22:36:58 +02:00
jdhao
c3d8dc3e1d Add mapping to delete other buffers 2024-08-17 17:33:36 +02:00
jdhao
f9780c2dff update config for bufferline.nvim
Do not show buffer number and use a mapping to pick buffer instead.
2024-08-17 17:29:33 +02:00
jdhao
256c37a946 update vim-fugitive mapping 2024-08-17 15:16:08 +02:00
jdhao
eff98d036d update README 2024-08-17 15:10:33 +02:00
jdhao
6e60475f3f Use gx.nvim for browsing in Browser 2024-08-16 00:03:43 +02:00
jdhao
d90273df8e remove lua_ls conf in favor of lazydev.nvim
The removed settings are already set by lazydev.nvim.
2024-08-15 23:44:50 +02:00
jdhao
659f410b9e move version check into function 2024-08-15 23:38:31 +02:00
jdhao
a602d98819 fix git mapping issue
`<cmd> `mapping must end with `<CR>`
2024-08-09 22:23:04 +02:00
jdhao
9ff76931e3 update git related mappings 2024-08-09 22:19:13 +02:00
jdhao
85232b82a8 Update mapping of plugin open-browser.vim 2024-08-09 22:05:54 +02:00
jdhao
cfc0089bb5 add plugin lazydev.nvim 2024-08-07 00:48:21 +08:00
jdhao
f1062a3d8f filter fold level sign for statuscol.nvim
Only show fold signs for fold level below a certain level to avoid
clutter the left side columns with a lot of folding signs
2024-08-07 00:14:19 +08:00
jdhao
fd6df981cd Update nvim-ufo settings 2024-08-06 23:58:54 +08:00
jdhao
8af8ebd72a remove statusline.lua 2024-08-06 17:25:33 +02:00
jdhao
4c697d89f3 change name of lualine config 2024-08-06 23:04:37 +08:00
jdhao
e6f95cedb1 Update installation doc 2024-08-06 06:51:39 +08:00
jdhao
262ad6aa38 Add new colorscheme kanagawa 2024-08-06 06:16:07 +08:00
jdhao
b30cc9ed78 update user dictionary 2024-08-06 06:05:20 +08:00
jdhao
b3a26e4226 update load condtion for nvim-tree 2024-08-06 06:02:02 +08:00
jdhao
794b098090 Add git blame mapping 2024-08-06 05:59:14 +08:00
jdhao
b728b39784 update type hint for functions 2024-08-06 05:35:19 +08:00
jdhao
acc3ed7829 show error message only when no word is under cursor 2024-08-06 05:33:24 +08:00
jdhao
44e9e5a1ce Fix lua_ls diagnostic warnings 2024-08-06 05:24:16 +08:00
jdhao
5502d29f40 update config related to folding
1. For python and lua, rely on LSP for folding
2. show fold signs on the right of the number column
2024-08-06 05:17:51 +08:00
jdhao
fe95658319 Add colorscheme arctic.nvim 2024-08-05 06:25:28 +08:00
jdhao
e165276763 fix error when there is no cursor word 2024-08-05 06:23:18 +08:00
jdhao
933b887281 update config for nvim-ufo 2024-08-05 05:50:45 +08:00
jdhao
69643e143a use plugin nvim-ufo for better folding
The settings are copied from https://github.com/kevinhwang91/nvim-ufo/issues/4#issuecomment-1514537245,
with some modification.
2024-08-05 05:27:49 +08:00
jdhao
7f4772fd31 update setting for colorscheme gruvbox-material 2024-08-05 05:04:35 +08:00
jdhao
bf49e90947 change value for option 'splitkeep' 2024-08-05 05:03:02 +08:00
jdhao
784b435f0e update LeaderF settings 2024-08-02 23:41:36 +08:00
jdhao
beec97c086 Fix firenvim and LeaderF build issues
In lazy.nvim, the `build` parameter accept value in different format.
If the value is
1. a string and starts with `:`, it will be treated as vim command
2. a string and starts without `:`, it will be treated as shell command
3. a function. Lazy.nvim will run this function

I compared closely between case 1 and case 3. In case 1, when lazy.nvim
runs the viml command, the runtimepath is already populated with the
current plugin we are trying to build.
However in case 3, the runtimepath is not populated with the plugin
path, which means that any command you run by this plugin is not
available.

So I did it in a hacky way to add the plugin path to runtimepath
manually, and source it manually using `:runtime` command. The `:
runtime` command is needed because in the init process, adding the
plugin path to runtimepath does not ensure that the script under this
plugin is sourced immediately. So if we want to use the command/function
immediately, we need to source it manually, see also https://github.com/neovim/neovim/issues/29957.
2024-08-02 23:38:16 +08:00
jdhao
bbb8545403 update lualine config
- rearrange a few components
- add and remove a few components
2024-08-02 06:23:21 +08:00
jdhao
9efadac8fb update lazy.nvim config 2024-08-01 04:14:34 +08:00
jdhao
6e137fe9a3 make firenvim work again
1. fix build issue
2. fix PATH env issue
2024-07-31 07:09:50 +08:00
jdhao
719fbfc1ab update lua_ls settings 2024-07-31 05:42:33 +08:00
jdhao
e815de294f update plugin for markdown preview 2024-07-27 03:25:36 +08:00
jdhao
ca7430056c update to neovim version 0.10.1 2024-07-26 03:32:54 +08:00
jdhao
cb8c9208e1 update which-key conf and some mappings 2024-07-25 04:00:17 +08:00
jdhao
ce1e13e2c9 use plugin nvim-autopairs for autopair
delimitMate is not updated for a long time.
2024-07-14 05:17:49 +08:00
jdhao
2af616bb0d Update hop.nvim conf to support Chinese 2024-06-26 03:33:24 +08:00
jdhao
3694d3c237 Update config for GitSigns 2024-06-26 03:25:01 +08:00
jdhao
69d8543495 remove emmylua since neovim has builtin annotation
Seee also this https://github.com/neovim/neovim/pull/24493
2024-05-20 22:09:07 +02:00
jdhao
be3d134c37 use vim.uv instead of vim.loop 2024-05-20 21:52:52 +02:00
jdhao
601396f700 upgrade neovim to latest stable
The way to compare versions are changed due to a bug in comparing
versions in the neovim core: https://github.com/neovim/neovim/issues/28782
2024-05-20 21:33:38 +02:00
jdhao
e462ebcbcc Enable treesitter folding for Python and Lua 2024-05-08 03:46:45 +08:00
jdhao
2f8482639d update some mappings
1. fix a typo in gJ mapping when setting the mark, the correct syntax is
   `mz` (set mark `z`), not `zm`

2. fix bug with `iB` text object: previously `viB` does not work as
   expected, because it does not select the entire buffer as expected.
   After much investigation, I found it is because the `<cmd>` mapping
   argument. If we use `<cmd>` argument for mapping, the mode does not
   change. So if we use `viB`, inititally we are still in visual mode.
   Later in the implementation, when we use `` normal! `<V`>  `` to
   select the entire buffer, it interferes with original visual mode. As
   a result, the entire buffer is not selected. In the text obj
   implementation, we can use `exe "normal! \<Esc>"` to clear the visual
   mode and make `viB`, but this is not ideal. I think it is eaiser to
   just not use the `<cmd>` argument and use `:<C-U>` instead.
2024-02-28 06:36:05 +08:00
jdhao
050eacaee2 Stop showing percent location
The percent location is useless and just noise.
2024-02-23 06:11:21 +08:00
jdhao
01bc4b40d3 update used plugins 2024-02-02 03:52:26 +08:00
jdhao
c06d46e84d remove lazylock
I don't use this feature at all.
2024-02-02 03:43:55 +08:00
jdhao
7cf70f31af Update colorscheme conf
1. remove some colorscheme that doesn't work well with Markdown
2. change how the colorscheme conf is organized.
2024-02-02 03:40:11 +08:00
jdhao
8416508686 Enable nvim-tree to open dir during startup
Now when you open a directory when starting nvim, nvim-tree will be
opened to handle the directory correctly, see also issue #257.
2024-01-07 15:24:47 +01:00
jdhao
df9491b05b bump neovim version to 0.9.5 2024-01-07 14:45:29 +01:00
jdhao
17d2e3ab3e Deal with other variant of unix timestamp 2023-10-21 00:53:15 +02:00
jdhao
2c9948300d Add diffview.nvim for viewing diffs 2023-10-18 22:10:11 +02:00
jdhao
dfaa3d97a5 update plugin spec 2023-10-12 23:26:43 +02:00
jdhao
8d74fcb75c Remove obsolete options for nvim-tree 2023-10-11 20:43:24 +02:00
jdhao
b1f0ef63ef Rename vimscript conf directory 2023-10-11 20:41:25 +02:00
jdhao
54ca6d4191 update to nvim 0.9.4 2023-10-11 20:35:50 +02:00
jdhao
97af59e670 remove obsolete option for indent-blankline 2023-10-03 15:14:34 +02:00
jdhao
4d8ef868ad upgrade indent-blankline to v3 2023-09-28 23:41:42 +02:00
jdhao
3137850db6 Show Py virtual env on statusline 2023-09-28 09:42:27 +02:00
jdhao
eccdc62f38 remove colorschemes rose-pine 2023-09-22 19:38:28 +02:00
jdhao
ad483a7dc0 Use the matained fork of hop.nvim 2023-09-16 14:47:43 +02:00
jdhao
6df27d1c22 upgrade to neovim 0.9.2 2023-09-16 14:26:38 +02:00
jdhao
7f6627cfa1 update plugin conf for Lazy.nvim 2023-09-10 22:16:16 +02:00
jdhao
7ff11a9760 update plugin lazy loading events 2023-09-05 00:22:02 +02:00
jdhao
cc4688d089 Loosen the version check condition
Other version of nvim can still run this config, but should use with
care.
2023-09-01 21:39:08 +02:00
jdhao
8a1b3193a4 fix bufferline loading issue 2023-09-01 21:27:13 +02:00
jdhao
e92362041c fix hlslens issue when no pattern is found
The captured error message is not correct before.
2023-09-01 21:22:22 +02:00
jdhao
63ff776758 fix loading order of nvim-cmp and nvim-lsp 2023-09-01 20:52:46 +02:00
jdhao
41c8c81f21 update spell 2023-09-01 01:08:41 +02:00
jdhao
997c6286df Optimize plugin loading speed 2023-09-01 01:07:16 +02:00
jdhao
359621b126 fix multi visual line delete issue
For TextYankPost event, it includes both yank and delete, we should only
restore cursor position for yank, not for delete. Otherwise, it messes
up with text deletion when you visually select multiple lines and delete
them. See also issue reported here: https://github.com/jdhao/nvim-config/pull/222#issuecomment-1698634645
2023-09-01 00:26:08 +02:00
jdhao
4dc2d9575b disable horizontal scroll by mouse 2023-08-29 23:44:07 +02:00
jdhao
fc1c447319 fix multi-line yank issue, close #220
The previous way of keep the cursor while yanking is not perfect.
It will break multi-line yank (`{count}yy`).
2023-08-28 21:11:32 +02:00
jdhao
1391ca7ff1 feat: switch from packer.nvim to lazy.nvim 2023-08-27 23:14:31 +02:00
jdhao
6a6f8ff597 Update condition for installing vim-xkbswitch 2023-08-23 00:48:21 +02:00
jdhao
946e65662b fix nvimtree conf, close #215 2023-08-14 23:55:17 +02:00
jdhao
4a6379ca5d update git-linker conf
1. Add configuration for azure devops
2. change the mappings slightly
2023-08-09 19:52:58 +02:00
jdhao
855a88b532 fix: user lua conf reloading fails
The cache should be invalidated. This fix does not work 100%, because, e.g.,
there are other configs hiding deeper under lua/config/ directory.
A restart is the best way to reload the config.
2023-07-29 14:34:42 +02:00
jdhao
892cd49f06 doc: update doc and install guide for pylsp 2023-07-29 13:09:37 +02:00
jdhao
e53ee104ec feat: move lua conf under lua directory 2023-07-28 22:28:36 +02:00
jdhao
671c78df9b feat: more ignore files for LeaderF (#209) 2023-07-29 04:09:50 +08:00
jdhao
1608a36dd3 fix: conf is not local 2023-07-25 23:00:25 +02:00
jdhao
450f058da5 feat: support venv in Mypy
Specify the correct python executable path for mypy to work well.
2023-07-25 22:59:06 +02:00
jdhao
e2f348cb37 fix: missing nerdfonts
Since wezterm upgrade its support for Nerd Fonts 3.0, we should update
the codepoints used for some of the Unicode Icons. Their code points are
changed due to breaking changes in Nerd Fonts.
2023-07-25 22:53:20 +02:00
jdhao
fc8175d32d feat: update diagnostic mappings
Use separate key mappings to show diagnostics for the current buffer and
all opened files.
2023-07-22 15:01:41 +02:00
jdhao
4034b6b673 feat: update pylsp conf
1. support using black as formatter
2. replace obsolete pyls-isort with maintained ones
2023-07-22 14:51:27 +02:00
jdhao
67a4b6e6d0 feat: add treesitter toml 2023-07-22 14:46:10 +02:00
jdhao
bb27d93433 fix: move location indication to the right of statusline 2023-07-20 23:00:06 +02:00
jdhao
9d9c3ef32f feat: update diagnostic position in statusline
Do not show it in far right, move it to the left side for easier
visibility.
2023-07-20 22:52:55 +02:00
jdhao
00e8c77b23 Fix LeaderF bug
It will add files to buffer list even if we have not confirmed the
selection. This behavior is really annoying.
See also 27bd938a42.
2023-06-27 20:39:26 +02:00
jdhao
7bb3ccc275 use legacy version of fidget for now 2023-06-17 00:08:02 +02:00
jdhao
ee38046ebc Add folding support for JSON files 2023-06-13 22:25:25 +02:00
jdhao
6c873a32da update to nvim 0.9.1 2023-06-03 21:37:14 +02:00
jdhao
9ca65fd942 update conf for nvim-dashboard 2023-05-22 20:50:15 +02:00
jdhao
cc3a7d6ebd remove impatient.nvim
It is not needed since nvim 0.9.0
2023-05-07 20:10:52 +02:00
jdhao
f3a359a2fa conf for nvim 0.9.0 2023-04-20 22:36:48 +02:00
jdhao
9a4d71db88 update nvim-tree conf 2023-04-17 22:05:36 +02:00
jdhao
dc597004df Merge pull request #187 from mr-cal/nvim-tree-update
nvim-tree: fix shortcut and repo
2023-04-17 21:59:43 +02:00
jdhao
644993a89e bump to nvim version 0.9.0 (#188) 2023-04-08 04:42:24 +08:00
Callahan Kovacs
164d6129f8 nvim-tree: update other references
Signed-off-by: Callahan Kovacs <callahankovacs@gmail.com>
2023-04-05 08:37:16 -05:00
Callahan Kovacs
cde21f6f67 nvim-tree: use api and new repository url
Signed-off-by: Callahan Kovacs <callahankovacs@gmail.com>
2023-03-30 08:41:15 -05:00
jdhao
8746c7eb11 fix: omit the clangd missing message, close #180 (#186)
It is not necessary to install clangd if the user does not use neovim with CPP/C.
2023-03-13 19:55:00 +08:00
jdhao
7c44997289 refactor: lua language server rename (#185)
The lua language server from sumneko had changed its repo and created a
new organizational repo. See also https://github.com/neovim/nvim-lspconfig/pull/2439.
2023-02-16 17:39:23 +08:00
jdhao
bfdb3f5a26 bump supported nvim version (#184) 2023-02-11 11:42:57 +08:00
jdhao
76ced0e265 update contact info 2023-01-18 13:27:55 +08:00
jdhao
e84d18a204 update license year (#175) 2023-01-04 01:01:59 +08:00
jdhao
6429e8364c update nvim to version 0.8.2 (#173) 2022-12-31 10:13:39 +08:00
jdhao
f2c6900a8d update setting for onedarkpro (#172) 2022-12-28 22:29:49 +08:00
jdhao
116aaa0675 update spell 2022-12-14 12:55:41 +08:00
jdhao
12f3ca9d1f more abbr (#169) 2022-12-14 12:54:54 +08:00
jdhao
7e7944a30c use yanky.nvim to replace vim-yoink (#168) 2022-12-14 12:52:40 +08:00
bldur
53c17aea96 Add ltex-ls support to lsp. (#166)
* Add ltex-ls support to lsp.

Co-authored-by: bldur (https://github.com/bldur)
2022-11-28 17:35:43 +08:00
jdhao
43c1615822 fix: cmp-omni messes with the lsp completion
If we use cmp-omni and lsp together, it seems that it will mess the
autocompletion. So we only use it with tex file, where lsp in not used.
2022-11-22 21:19:53 +08:00
jdhao
509a8bce8c upgrade to latest stable 0.8.1 2022-11-22 21:16:17 +08:00
jdhao
8b10be60d4 update colorscheme list
- remove other gruvbox variant
- remove doom-one casue it has bugs
- add more colorschemes
2022-11-16 02:26:28 +08:00
jdhao
074d2bbdfd make filetype mapping local
Otherwise, the mapping will be global and leak to unrelated to files.
2022-11-15 01:10:26 +08:00
jdhao
7f9af87185 Merge branch 'master' of https://github.com/jdhao/nvim-config 2022-11-15 01:07:29 +08:00
jdhao
bb0b0c5e25 chore: relax vimtex install condition 2022-11-15 01:06:59 +08:00
jdhao
7bb12e4b70 chore: relax vimtex install condition 2022-11-15 01:04:31 +08:00
jdhao
41da56b823 Add my own abbreivations for some spell mistakes 2022-11-13 19:53:14 +08:00
jdhao
82f2332281 chore: update gitsigns highlight 2022-11-10 00:43:15 +08:00
jdhao
075326ee2e fix: make xkbswitch work on mac M1 CPU
For the details, see https://jdhao.github.io/2021/02/25/nvim_ime_mode_auto_switch/.
2022-11-07 00:47:04 +08:00
jdhao
baa8f26bc2 update spell 2022-11-01 22:27:35 +08:00
jdhao
e9760ae9b8 remove smooth scroll
I do not really need it.
2022-11-01 22:19:03 +08:00
jdhao
0d50eb723f chore: add notification for packer compile
Also move the autocmd location.
2022-11-01 22:02:45 +08:00
jdhao
b893bdc099 fix incorrect comment string for gitconf 2022-10-27 21:59:05 +08:00
jdhao
2073f72e67 refactor: use local diagnostic module 2022-10-23 15:18:03 +08:00
jdhao
364be4b5dc fix links 2022-10-20 13:23:38 +08:00
jdhao
d30d402128 update option 2022-10-19 20:52:51 +08:00
jdhao
fc144e0895 update badge 2022-10-19 12:13:13 +08:00
jdhao
18abfa7754 feat: add a mapping to blink cursor 2022-10-17 00:07:34 +08:00
jdhao
6c1dbdf8fc update spell 2022-10-16 10:26:41 +08:00
jdhao
202a9a088d remove vim-json
rarely used and it changes the conceal settings
2022-10-16 10:24:53 +08:00
jdhao
d939cc75c6 refactor: make packer installation a function 2022-10-16 10:23:40 +08:00
jdhao
26921309ec replace more viml with native lua code 2022-10-15 19:00:34 +08:00
jdhao
a6f716558b update nvim-cmp lsp conf 2022-10-15 18:30:14 +08:00
jdhao
3539207913 use 2 spaces for tabs by default
This removes a lot of code duplication. If we want to use 4 spaces, we
can set it separately in their ftplugin settings.
2022-10-15 11:28:15 +08:00
jdhao
d8b92965e8 change tab size for sql 2022-10-11 00:51:00 +08:00
jdhao
ebf7170916 use UTF-8 instead of utf-8, closes #134 2022-10-09 13:23:01 +08:00
jdhao
696466469b update spell 2022-10-05 23:01:23 +08:00
jdhao
7a5be43600 use lua func in rhs instead of callback 2022-10-05 22:42:02 +08:00
jdhao
3b39067097 update mousescroll 2022-10-05 22:39:13 +08:00
jdhao
e6b3be0777 remove language workaround for macOS
The issue has been fixed in https://github.com/neovim/neovim/pull/19139.
2022-10-05 22:33:13 +08:00
jdhao
acb423984a remove vim-asterisk
The * can now search selected text by default. The cursor stay feature
can also be simulated.
2022-10-05 12:42:45 +08:00
jdhao
d40d87cb61 nvim 0.8 update 2022-10-04 19:34:20 +08:00
jdhao
81663c8f3c update markdown-preview.nvim install method 2022-10-04 13:15:26 +08:00
jdhao
2c7e4aa87a Merge pull request #123 from jdhao/repolink
update repo link for transferred plugins
2022-09-29 00:00:12 +08:00
jdhao
07dd60206b update repo link for transferred plugins 2022-09-28 23:57:36 +08:00
jdhao
c3d4eb371b Merge pull request #122 from jdhao/opt
always use sign column
2022-09-28 23:40:12 +08:00
jdhao
597a2aba80 always use sign column 2022-09-28 23:39:09 +08:00
jdhao
f1f6d0b351 Merge pull request #121 from jdhao/clean
remove config for unused plugins
2022-09-28 23:37:54 +08:00
jdhao
e1930ba153 remove config for unused plugins
vim-signify, vim-startify
2022-09-28 23:36:44 +08:00
jdhao
a8db734e75 Merge pull request #120 from jdhao/firenvim
update conf related to firenvim
2022-09-28 23:32:48 +08:00
jdhao
4026baef19 update conf related to firenvim
1. Change autocmd for buffers started by firenivm, it seems that
   BufNewFile does not work as intended, in contrast, BufEnter, BufRead,
   BufWinEnter seem to work.
2. Disable several plugins if we are using firenvim, these plugins
   include dashboard-nvim, lualine, bufferline.nvim
2022-09-28 23:22:23 +08:00
jdhao
f63152f79b Merge pull request #118 from jdhao/gitsign
hilight update for gitsigns.nvim
2022-09-28 00:32:57 +08:00
jdhao
5229c460ea hilight update for gitsigns.nvim 2022-09-28 00:32:07 +08:00
jdhao
f308ccad7b Merge pull request #116 from jdhao/fugitive
correct :git to :Git
2022-09-25 23:44:13 +08:00
jdhao
09dd81bf67 correct :git to :Git 2022-09-25 23:42:50 +08:00
jdhao
5ecb74ad85 more mapping and doc update for gitlinker 2022-09-25 23:39:33 +08:00
jdhao
773003b71b Merge pull request #115 from jdhao/sql
change sql comment style
2022-09-25 23:15:51 +08:00
jdhao
f5097b44b9 change sql comment style 2022-09-25 23:02:16 +08:00
jdhao
238886c136 Merge pull request #114 from jdhao/setup
fix: variable case not consistent, close #113
2022-09-25 11:02:47 +08:00
jdhao
2fccb59293 fix: variable case not consistent, close #113 2022-09-25 11:01:30 +08:00
jdhao
830297a973 Merge pull request #111 from jdhao/gitsign
enable word diff for gitsigns.nvim
2022-09-24 15:37:15 +08:00
jdhao
1f3fcc604a enable word diff for gitsigns.nvim
Also tweak the highlight for word diff to make clear. The default
highlgiht for word diff is TermCursor, which is unreadable.
2022-09-24 15:34:54 +08:00
jdhao
7f5bf5a1b2 Merge pull request #110 from jdhao/nvimtree
update nvim-tree conf
2022-09-23 20:46:49 +08:00
jdhao
81bc5e46f1 update nvim-tree conf 2022-09-23 20:45:58 +08:00
jdhao
b4c3b7eba0 Merge pull request #109 from jdhao/spell
update spell
2022-09-20 01:20:19 +08:00
jdhao
4203410878 update spell 2022-09-20 01:19:44 +08:00
jdhao
9f58c3b7a5 Merge pull request #108 from jdhao/gitsign
update gitsigns conf
2022-09-20 01:18:00 +08:00
jdhao
45d0d68b9e update gitsigns conf 2022-09-20 01:15:16 +08:00
jdhao
74a9767018 Merge pull request #107 from jdhao/option
noruler
2022-09-15 12:19:31 +08:00
jdhao
ab25bfc9c4 noruler 2022-09-15 12:18:26 +08:00
jdhao
ebbdb27d01 Merge pull request #106 from chaoqunya/chaoqunya-fix-typo-in-mappings
typo fixed
2022-09-13 14:27:15 +08:00
chaoqunya
1b1f0199da typo fixed 2022-09-13 14:22:46 +08:00
jdhao
40fa9aab1c Merge pull request #104 from jdhao/global
global.vim --> global.lua
2022-09-11 18:24:10 +08:00
jdhao
6e8e61e53a global.vim --> global.lua
fix 2

fix 3
2022-09-11 18:21:56 +08:00
jdhao
89effe8b17 Merge pull request #103 from jdhao/format
format with stylua
2022-09-10 23:56:04 +08:00
jdhao
aaeb6a813a format with stylua 2022-09-10 23:55:22 +08:00
jdhao
9ba728e201 Merge pull request #102 from jdhao/lualine
use gitsigns for diff
2022-09-10 22:57:06 +08:00
jdhao
e5f1b4d224 use gitsigns for diff
Lualine's builtin diff often disappears and is not reliable, which is really frustrating for me.
2022-09-10 22:55:22 +08:00
jdhao
eaddee0c5c Merge pull request #101 from jdhao/lsp-map
refactor: lsp mapping
2022-09-09 19:42:42 +08:00
jdhao
0582f26abe refactor: lsp mapping 2022-09-09 19:42:01 +08:00
jdhao
e209ef686a Merge pull request #100 from jdhao/hlslens
update hlslens conf
2022-09-09 19:22:18 +08:00
jdhao
8b3610ed3d update hlslens conf 2022-09-09 19:21:25 +08:00
jdhao
bde6083f22 Merge pull request #99 from jonghoonseo/master
Use node dir when already installed
2022-09-09 19:15:02 +08:00
Jonghoon Seo
c1f139108a Use node dir when already installed 2022-09-09 05:30:41 +09:00
jdhao
3bb8b224e7 Merge pull request #98 from jdhao/clean-plug
remove unused plugins
2022-09-08 20:36:19 +08:00
jdhao
b69320b4e2 remove unused plugins 2022-09-08 20:35:34 +08:00
jdhao
5c63ade4a0 Merge pull request #97 from jdhao/gitsigns
use gitsigns instead of signify
2022-09-08 20:33:06 +08:00
jdhao
b504c932e6 use gitsigns instead of signify 2022-09-08 20:31:33 +08:00
jdhao
a39befff93 Merge pull request #96 from jdhao/map
update mapping
2022-09-08 13:20:45 +08:00
jdhao
309c8ad636 update mapping 2022-09-08 13:19:34 +08:00
jdhao
954a4a1cad Merge pull request #95 from jdhao/error-msg
refactor: use nvim_err_writeln for error msg
2022-09-07 23:36:49 +08:00
jdhao
67a322c26c refactor: use nvim_err_writeln for error msg 2022-09-07 23:35:18 +08:00
jdhao
91c9dbe40d Merge pull request #94 from jdhao/neovide
add neovide conf
2022-09-07 23:31:57 +08:00
jdhao
6a5f1d24a7 add neovide conf 2022-09-07 23:30:52 +08:00
jdhao
4dcafbe2bc Merge pull request #93 from jdhao/local-keymap
use local keymap
2022-09-06 21:54:18 +08:00
jdhao
14860072d0 use local keymap 2022-09-06 21:53:44 +08:00
jdhao
5a69d43cab Merge pull request #92 from jdhao/lua-map
refactor: convert mapping from viml to lua
2022-09-06 21:26:12 +08:00
jdhao
11e6797cb5 refactor: convert mapping from viml to lua 2022-09-06 21:22:45 +08:00
jdhao
858848128f Merge pull request #91 from jdhao/spell
update spell
2022-09-06 13:25:44 +08:00
jdhao
d436227f65 update spell 2022-09-06 13:24:44 +08:00
jdhao
acb8b7fcf8 Merge pull request #90 from jdhao/reorg
better-escape.vim is now under nvim-zh org
2022-09-05 01:02:06 +08:00
jdhao
46cbdc2d7f better-escape.vim is now under nvim-zh org 2022-09-05 01:00:42 +08:00
jdhao
c71ad44cd3 Merge pull request #89 from jdhao/hop
update hop.nvim conf
2022-09-05 00:54:05 +08:00
jdhao
db378b858b update hop.nvim conf 2022-09-05 00:53:23 +08:00
jdhao
ee45f1f5a1 Merge pull request #88 from jdhao/gitlinker
add plugin gitlinkder.nvim
2022-09-05 00:48:57 +08:00
jdhao
43660dd540 add plugin gitlinkder.nvim 2022-09-05 00:48:10 +08:00
jdhao
17acda10a0 fix 2022-09-01 13:24:52 +08:00
jdhao
eb87c5b0c3 Merge pull request #87 from jdhao/autocmd
simplify and add new autocmd
2022-09-01 13:24:05 +08:00
jdhao
b35956e6cd simplify and add new autocmd 2022-09-01 13:22:49 +08:00
jdhao
82f4c0e399 Merge pull request #86 from jdhao/hop
update hop.nvim conf
2022-08-31 23:57:49 +08:00
jdhao
16be5e0499 update hop.nvim conf 2022-08-31 23:56:52 +08:00
jdhao
a39b53b7c1 Merge pull request #85 from jdhao/packer
update packer conf
2022-08-31 00:02:32 +08:00
jdhao
b9616aeab0 update packer conf 2022-08-31 00:01:38 +08:00
jdhao
208b190a65 Merge pull request #84 from jdhao/indentline
update indent-blankline conf
2022-08-28 14:56:35 +08:00
jdhao
602254a881 update indent-blankline conf 2022-08-28 14:55:42 +08:00
jdhao
7022eefe22 Merge pull request #83 from jdhao/colorscheme
use colorscheme instead of theme
2022-08-28 13:09:17 +08:00
jdhao
dee7768162 use colorscheme instead of theme 2022-08-28 13:08:22 +08:00
jdhao
22b33871ef Merge pull request #82 from jdhao/linux-setup
update linux setup
2022-08-28 12:47:30 +08:00
jdhao
aab74751f4 update linux setup 2022-08-28 12:47:01 +08:00
jdhao
5dbe643ea2 Merge pull request #81 from jdhao/reorg
refactor a bit
2022-08-28 12:46:15 +08:00
jdhao
b41998828d refactor a bit
1. change theme to colorscheme
2. update plugin load logic
2022-08-28 12:43:50 +08:00
jdhao
3670a19e51 Merge pull request #80 from jdhao/cmp-conf
update nvim-cmp conf
2022-08-28 11:13:32 +08:00
jdhao
545c6f4b92 update nvim-cmp conf 2022-08-28 11:02:01 +08:00
jdhao
86e3b29730 Merge pull request #79 from jdhao/fix-notify
fix parameter for vim.notify
2022-08-26 20:01:56 +08:00
jdhao
bc9b0a8cf8 fix parameter for vim.notify 2022-08-26 19:47:56 +08:00
jdhao
fb9a0bb2dd Merge pull request #78 from jdhao/theme
refactor: theme.vim --> theme.lua
2022-08-26 18:44:11 +08:00
jdhao
59525c5577 refactor: theme.vim --> theme.lua 2022-08-26 18:42:30 +08:00
jdhao
6539e72a5d Merge pull request #75 from jdhao/typo-fix
fix some typos
2022-08-23 21:12:50 +08:00
jdhao
b279c0cd95 fix some typos 2022-08-23 21:12:04 +08:00
jdhao
96129335ad Merge pull request #74 from jdhao/delimitMate
update delimitMate conf for lua
2022-08-23 13:19:52 +08:00
jdhao
b6fa0b7aa5 update delimitMate conf for lua 2022-08-23 13:19:02 +08:00
jdhao
dff469ddc4 spell 2022-08-22 21:03:37 +08:00
jdhao
6d5cda0f97 Merge pull request #73 from jdhao/bufferline
update bufferline.nvim conf
2022-08-22 21:00:14 +08:00
jdhao
4d35362e83 update bufferline.nvim conf 2022-08-22 20:59:26 +08:00
jdhao
e57e747b26 Merge pull request #72 from jdhao/lua-au-ctx
refactor: use ctx table for lua autocmd callback
2022-08-21 18:21:22 +08:00
jdhao
c3f8d75ece refactor: use ctx table for lua autocmd callback 2022-08-21 18:20:21 +08:00
jdhao
78baf8d015 Merge pull request #71 from jdhao/snip
update markdown snippet
2022-08-21 11:48:15 +08:00
jdhao
9d8a58be17 update markdown snippet 2022-08-21 11:47:03 +08:00
jdhao
2372d9159f Merge pull request #70 from jdhao/lua-autuocmd
refactor: move part of autocmd to lua script
2022-08-20 02:02:12 -05:00
jdhao
e9a3d16260 refactor: move part of autocmd to lua script 2022-08-20 15:00:10 +08:00
jdhao
fdf8236fc2 Merge pull request #69 from jdhao/fix-autocmd
update the autocmd for saving a file
2022-08-20 00:52:33 -05:00
jdhao
085c8017d8 update the autocmd for saving a file 2022-08-20 13:50:23 +08:00
jdhao
efa7b215e7 Merge pull request #68 from jdhao/install-win
update install script for Windows
2022-08-19 07:06:43 -05:00
jdhao
e68c687f23 update install script for Windows 2022-08-19 20:05:40 +08:00
jdhao
497f93d6c7 Merge pull request #67 from jdhao/packer-autoinstall
feat: auto-install plugins for fresh install
2022-08-18 11:43:49 -05:00
jdhao
cfe2e0611d feat: auto-install plugins for fresh install 2022-08-19 00:42:02 +08:00
jdhao
9de08d0afe Merge pull request #66 from jdhao/lsp
add config dir to workspace.library for lua lsp
2022-08-18 13:16:51 +08:00
jdhao
d5b7584e68 add config dir to workspace.library for lua lsp 2022-08-18 13:15:20 +08:00
jdhao
64a7a23309 Merge pull request #64 from jdhao/fix-firenvim
update firenvim conf
2022-08-15 22:57:50 +08:00
jdhao
c1efc0bad6 update firenvim conf 2022-08-15 22:56:56 +08:00
jdhao
b3b69f21f4 update mapping 2022-08-15 00:22:24 +08:00
jdhao
f491e26676 Merge pull request #63 from jdhao/large-file
handle large file better
2022-08-15 00:08:16 +08:00
jdhao
e7e4892c22 handle large file better 2022-08-15 00:06:52 +08:00
jdhao
a52a362b02 update version check 2022-08-14 22:54:19 +08:00
jdhao
2880d7bce3 chore: renaming 2022-08-14 20:16:00 +08:00
jdhao
7e6dd23d37 add fidget-nvim for lsp-progress 2022-08-14 20:12:52 +08:00
jdhao
fcbd7d3a0d Merge pull request #62 from jdhao/lua-lsp
update lua lsp conf
2022-08-14 18:11:41 +08:00
jdhao
97f302084f update sumneko lua settings
1. remove runtime.path settings. It seems that it is not necessary, 03a047ef52.
2. update workspace.library, ref plugin ii14/emmylua-nvim
2022-08-14 17:53:40 +08:00
jdhao
9d29544d72 update linux setup script
1. lua-language-server
2. format fix
2022-08-14 12:01:38 +08:00
jdhao
cad9f5a214 make inspect() global 2022-08-14 11:39:37 +08:00
jdhao
ecde08941b update lua-language-server conf
lua-language-server has changed its running method significantly, so we
need to change it in the nvim-lspconfig.
2022-08-13 23:08:25 +08:00
jdhao
ab88c112ff make dashboard-nvim an opt plugin 2022-08-13 23:03:42 +08:00
jdhao
4c96243a4c init.vim --> init.lua cleanup 2022-08-13 22:45:13 +08:00
jdhao
fdc158272b init.vim --> init.lua follow 2022-08-13 22:43:33 +08:00
jdhao
b331cddc73 Merge pull request #61 from jdhao/init.lua
Transition from init.vim to init.lua
2022-08-13 22:39:47 +08:00
jdhao
b11c57e36f Transition from init.vim to init.lua 2022-08-13 22:37:49 +08:00
jdhao
84d73660fa add stylua conf 2022-08-13 17:12:08 +08:00
jdhao
a9cc10b2ef Merge pull request #60 from jdhao/doc
update setup doc
2022-08-12 20:32:48 +08:00
jdhao
cad6112cc2 update setup doc 2022-08-12 20:31:32 +08:00
jdhao
4d7fd6580a Merge pull request #58 from jdhao/mapping-doc
update readme about mappings
2022-08-11 01:29:33 +08:00
jdhao
f492a94db6 update readme about mappings 2022-08-11 01:28:14 +08:00
jdhao
0c92d9a018 update mappings
1. add mapping for gJ
2. remove mappings for <C-H>, since I rarely use them
2022-08-10 21:24:14 +08:00
jdhao
369687b047 refactor: disable showing trailing space and mix indent for non-modifiable buffers 2022-08-07 00:25:08 +08:00
jdhao
54908dfe9f fix: dashboard map is not local 2022-08-07 00:24:37 +08:00
jdhao
2e5f5c5991 update demo image in README 2022-08-07 00:12:55 +08:00
jdhao
8291b15599 remove alpha-nvim, use dashboard-nvim 2022-08-07 00:01:23 +08:00
jdhao
3de31f7d0a disable language command in macOS for now
Due to packaging issue, nvim version 0.7.2 for macOS does not have
`:language` command built in, see also neovim/neovim#19127.
2022-08-06 22:36:49 +08:00
jdhao
6b59c268f9 Merge pull request #57 from jdhao/fix-trailing-space
fix: trailing white sapces do not show as expected
2022-08-06 17:22:32 +08:00
jdhao
dd550dc3d0 fix: trailing white sapces do not show as expected
The plugin whitespace.nvim has changed its internal implementation.
It is not reliable to depend on external plugins.
2022-08-06 17:19:13 +08:00
jdhao
3aae07df56 Merge pull request #56 from jdhao/js-setup
add setup for javascript
2022-08-06 14:23:31 +08:00
jdhao
ed5ddf60cc add setup for javascript 2022-08-06 14:20:28 +08:00
jdhao
bcdc8d3f66 small fix 2022-08-01 20:57:37 +08:00
jdhao
5498a05bf7 revert to vim-auto-save
auto-save.nvim is erroring out
2022-08-01 01:14:09 +08:00
jdhao
644f8b6e2d add theme catppuccin 2022-07-28 01:32:41 +08:00
jdhao
3af7dd51b8 update packer config 2022-07-28 01:22:10 +08:00
jdhao
e0fc068f2e update nvim-cmp conf since cmp-nvim-lua is removed 2022-07-28 00:51:48 +08:00
jdhao
58ed71f870 use emmylua-nvim instead of cmp-nvim-lua for better completion 2022-07-27 21:08:03 +08:00
jdhao
aae9a7b7a7 update winblend 2022-07-27 13:17:22 +08:00
jdhao
33270f3257 add command ToPDF 2022-07-19 01:18:26 +08:00
jdhao
99d5a0343b update title str format 2022-07-11 23:14:16 +08:00
jdhao
3678da1b3c update titlestring 2022-07-02 16:47:58 +08:00
jdhao
a8fdbf3573 disable showing current theme used 2022-06-28 00:36:37 +08:00
jdhao
351ba5fc63 update option shortmess 2022-06-28 00:36:19 +08:00
jdhao
6dfaf2c521 minor tweak: version checking 2022-06-28 00:23:53 +08:00
jdhao
ae759477c7 bump version to 0.7.2 2022-06-28 00:09:42 +08:00
jdhao
921fd17221 update macos install script 2022-06-27 23:34:23 +08:00
jdhao
81696c9e13 update python snippet 2022-06-14 22:02:26 +08:00
jdhao
32b1d3ac16 disable sql omni completion 2022-06-05 21:10:04 +08:00
jdhao
e3b15da059 add lua map module and more mappings 2022-05-29 12:27:26 +08:00
jdhao
934ef7fb13 update spell 2022-05-29 11:03:18 +08:00
jdhao
3ee785506c disable alpha-nvim
There are errors with nvim 0.7.
2022-05-29 11:01:36 +08:00
jdhao
428f612bb3 update linux setup script 2022-05-21 10:43:15 +08:00
jdhao
95b7ee5bc8 lsp: only show diagnostic once for each line if cursor is not moved
This will help use to check signature help without it being overwritten
by diagnostic popups.
2022-05-18 13:32:35 +08:00
jdhao
4899a82b35 refactor: local fn = vim.fn 2022-05-15 21:16:02 +08:00
jdhao
424981683e change location of packer_compiled.lua 2022-05-15 17:58:47 +08:00
jdhao
c3253a5731 use vim.pretty_print for checking lua objects 2022-05-14 00:59:00 +08:00
jdhao
a9be0d0b20 add mapping to run vim script file 2022-05-09 22:10:35 +08:00
jdhao
13111596b8 check if nvim version is correct, see also #51 2022-05-09 22:06:17 +08:00
jdhao
6cea10fcc5 update nvim-cmp conf
The issue has been fixed by the maintainer.
2022-05-04 23:14:06 +08:00
jdhao
58102f182a fix nvim-cmp issue, see hrsh7th/nvim-cmp#964 2022-05-04 17:11:34 +08:00
jdhao
9e284f58cb add new map 2022-05-03 19:15:33 +08:00
jdhao
a5dc045acc update issue template 2022-05-03 17:00:49 +08:00
jdhao
dd3e9dd2f4 add map to run lua file 2022-05-03 00:59:32 +08:00
jdhao
6784a87e26 update vimtex conf, close #50
Fix deprecated options
2022-05-02 09:48:43 +08:00
jdhao
99637c86f9 update doc 2022-05-01 23:25:15 +08:00
jdhao
3817525441 update hlslens conf 2022-04-29 22:00:10 +08:00
jdhao
4b4331d394 refactor: simplify hlslens conf 2022-04-29 21:51:23 +08:00
jdhao
aaafaf58d6 fix: error when pressing n/N if pattern not present in buffer 2022-04-29 02:21:05 +08:00
jdhao
1b9bd9ceef use vim.keymap for key mappings in lua 2022-04-27 23:38:09 +08:00
jdhao
e043f07b71 update nvim-tree conf 2022-04-27 22:08:25 +08:00
jdhao
b20b21b5dd update LeaderF conf 2022-04-20 01:29:19 +08:00
jdhao
c3ced68bea spell 2022-04-19 13:06:28 +08:00
jdhao
905efeb53f update README 2022-04-17 23:20:30 +08:00
jdhao
a3795cd043 [nvim 0.7] use native lua autocmd for cleaner code 2022-04-16 12:07:48 +08:00
jdhao
b4c55edb44 doc: bump supported version to nvim 0.7.0 2022-04-16 01:04:42 +08:00
jdhao
58b1e0aa9f [nvim 0.7] use filetype.lua for detecting ft 2022-04-16 01:00:36 +08:00
jdhao
f7bb7caba6 [nvim 0.7] vim.keymap.set opts update 2022-04-16 01:00:21 +08:00
jdhao
617fb733d7 [nvim 0.7] use the new vim.keymap interface 2022-04-16 00:17:10 +08:00
jdhao
9082e124a5 [nvim 0.7] no more py2 support 2022-04-16 00:16:23 +08:00
jdhao
2ffba14a6c Merge pull request #48 from soda92/patch-1
fix small typo
2022-04-14 19:20:33 +08:00
Maple
1a36e711df fix small typo 2022-04-14 19:17:17 +08:00
jdhao
4ab3d0414f fix nvim-cmp error
check https://github.com/hrsh7th/nvim-cmp/issues/231#issuecomment-1098175017
2022-04-14 00:14:25 +08:00
jdhao
8059940caa update spell file 2022-04-10 13:27:24 +08:00
jdhao
081c2717b3 update doc 2022-04-10 13:26:49 +08:00
jdhao
1d3bfc5c5f update issue template 2022-04-10 13:26:24 +08:00
jdhao
3c5d7bf0e5 update wilder.nvim conf 2022-04-10 13:23:18 +08:00
jdhao
3134f088cd update nvim-cmp conf, fix hrsh7th/nvim-cmp#880 2022-04-10 13:07:02 +08:00
jdhao
639b3d6067 update tex snippets 2022-04-05 00:43:01 +08:00
jdhao
4f55f53958 chore: use ft for FileType lazyloading 2022-04-03 15:30:47 +08:00
jdhao
085f0eb7e3 update nvim-tree conf: stay focus 2022-04-02 19:48:41 +08:00
jdhao
9f41333378 Merge pull request #46 from jdhao/fix-quit-condition
[fix] quit does not work for 2 windows
2022-03-29 21:46:27 +08:00
jdhao
e9ffd6c39d [fix] quit does not work for 2 windows
If current buf in remaning two or more windows are filetypes in the quit
list, we should also quit nvim also.
2022-03-29 21:41:44 +08:00
jdhao
988cf54f26 update nvim-tree conf 2022-03-29 12:58:52 +08:00
jdhao
9dbeb67de5 [feat] add mapping to add hard linebreak for Markdown 2022-03-27 00:04:39 +08:00
jdhao
36bdde7fc9 update C++ snippets 2022-03-19 14:48:46 +08:00
jdhao
4dd1350f25 working config for cmp-omni and vimtex 2022-03-15 20:25:30 +08:00
jdhao
311768ce72 add cmp-omni for working with tex 2022-03-14 00:34:06 +08:00
jdhao
a1942e6142 update spell 2022-03-08 13:15:38 +08:00
jdhao
e528acd799 update hop.nvim conf 2022-03-07 22:42:32 +08:00
jdhao
3c7b40bc15 add snip for ultisnips snippets files 2022-03-05 22:15:35 +08:00
jdhao
a0179d01c1 add new markdown snippet 2022-03-05 22:15:02 +08:00
jdhao
377c54c88c update tex conf 2022-02-28 23:31:01 +08:00
jdhao
3f78429c81 update spell 2022-02-27 15:52:09 +08:00
jdhao
414a4593ce update config doc 2022-02-14 20:43:00 +08:00
jdhao
aa891f7acd spell update 2022-02-12 22:46:46 +08:00
jdhao
a522cf7c5e update issue template 2022-02-12 14:31:15 +08:00
jdhao
5b7944031e update doc 2022-02-12 14:31:00 +08:00
jdhao
1efec8bc8f update issue template 2022-02-11 21:23:07 +08:00
jdhao
ec6549948a update Markdown snippet 2022-02-11 21:11:27 +08:00
jdhao
528aa2f19a update nvim-cmp conf 2022-02-11 20:15:07 +08:00
jdhao
295f47b1fb fix: wilder.nvim auto-start improvement
Using CursorHold to start wilder.nvim is not ideal, since it depends on
the value of option 'updatetime'. Using a timer may be a better idea.
2022-02-11 19:19:23 +08:00
jdhao
8ce677a50f update spell 2022-02-10 13:17:33 +08:00
jdhao
6322c7c212 chore: update theme hint message 2022-02-09 01:17:50 +08:00
jdhao
aa0cf40591 update Markdown snippets 2022-02-08 23:13:10 +08:00
jdhao
15dfccf81e [breaking change] remove direct reference to fastgit
fastgit may be blocked by GFW (see https://t.me/fastgitchannel/81), so
hard-coding its URL is not a good option. Using git URL rewrite feature
is a better choice: https://jdhao.github.io/2021/11/27/git_notes_s4/#use-a-git-mirror-site-for-cloning.

This is a breaking change, since previously I use hub.fastgit.org as the
url, now the url will be default github.com unless the user change it
using the above mentioned method to change the cloning URL.
2022-02-08 13:11:20 +08:00
jdhao
0aed2b42ac add nvim-tree.lua to readme 2022-02-08 00:11:28 +08:00
jdhao
1e84dd6248 update spell 2022-02-08 00:10:34 +08:00
jdhao
1b937d80af chore: update setup script for Linux 2022-02-06 12:41:23 +08:00
jdhao
78a8804f77 chore: update links for Anaconda/miniconda package 2022-02-06 12:19:04 +08:00
jdhao
6759171794 update ignore setting 2022-02-05 13:44:28 +08:00
jdhao
f357b0bee8 nvim-tree: auto-close when it is the only win 2022-02-05 13:42:53 +08:00
jdhao
2b24d0794e Use nvim-tree as file explorer when we open a folder
netrw plugin needs to be disabled, and nvim-tree needs to be start
package. Otherwise, the hijacking won't work, and when we open a folder,
it just open a new file with the same name.
2022-02-05 13:40:54 +08:00
jdhao
f10f688374 update nvim-tree conf 2022-02-05 12:27:17 +08:00
jdhao
d6b83710c4 enable lualine's support for nvim-tree
See also https://github.com/nvim-lualine/lualine.nvim#extensions.
2022-02-05 12:26:27 +08:00
jdhao
590baf4ca9 add plugin nvim-tree.lua 2022-02-05 00:11:58 +08:00
jdhao
dc4ff3d499 change param for plugin lspkind-nvim
See also 06872e887e.
2022-02-04 23:18:31 +08:00
jdhao
6b76b7781c add comment for ginit.vim 2022-02-04 11:06:38 +08:00
jdhao
21127b3170 update README 2022-02-04 11:02:40 +08:00
jdhao
b542bec561 update logging conf 2022-02-03 17:27:45 +08:00
jdhao
7ce35a0a5f chore: add comment 2022-02-03 12:59:07 +08:00
jdhao
61ae7acc14 refactor: rename 2022-02-03 12:52:30 +08:00
jdhao
d533859af9 update LeaderF conf 2022-02-02 17:08:45 +08:00
jdhao
74e8aed170 update README 2022-01-30 14:11:01 +08:00
jdhao
532e457ad4 update README 2022-01-30 14:04:32 +08:00
jdhao
9555052f94 use debug mode 2022-01-30 11:58:50 +08:00
jdhao
b84d57ccec update README 2022-01-30 02:23:30 +08:00
jdhao
4741291176 update spell 2022-01-29 13:11:24 +08:00
jdhao
38883b3fc5 fix: check if language server exists before using 2022-01-28 13:13:24 +08:00
jdhao
597b11638f chore: use local variable lspconfig 2022-01-28 13:13:01 +08:00
jdhao
694f4d0ca1 add bash-language-server 2022-01-26 22:54:49 +08:00
jdhao
e5c506aae3 update ignore files 2022-01-26 19:12:31 +08:00
jdhao
22eead5d0f update matchparen highlight 2022-01-26 19:10:15 +08:00
jdhao
a6ded3a154 add log-autocmd 2022-01-24 00:16:00 +08:00
jdhao
91b4d85592 change load condition of lspkind-nvim
If we use BufEnter, nvim-cmp autocompletion may not work sometimes,
which is really annoying
2022-01-23 16:47:52 +08:00
jdhao
a19a91397f update spell 2022-01-23 16:14:18 +08:00
jdhao
3928935402 update lsp setting 2022-01-23 16:13:34 +08:00
jdhao
3604449b6a doc: update description for init.vim 2022-01-16 17:22:23 +08:00
jdhao
146ef5d0b8 use lua for may_create_dir 2022-01-13 20:27:48 +08:00
jdhao
6fd7155787 feat: create parent dir of current file if it does not exist 2022-01-13 01:51:19 +08:00
jdhao
665250fe58 new year 2022-01-11 23:59:27 +08:00
jdhao
6a2ded6ca8 add plugin vim-conflicted for merge conflict handling 2022-01-09 22:02:18 +08:00
jdhao
41db6639d6 add issue template for easier debugging 2022-01-09 00:43:01 +08:00
jdhao
1b9b208653 update README 2022-01-09 00:14:37 +08:00
jdhao
97fcc581e6 chore: remove semshi settings
That plugin has been deleted before
2022-01-09 00:08:36 +08:00
jdhao
2e9f5fedfa more startup screen menu item 2022-01-08 15:02:20 +08:00
jdhao
1280c98314 add icon and scrollbar for wilder.nvim 2022-01-07 00:41:14 +08:00
jdhao
9cd43dcba9 simplify wilder.nvim settings 2022-01-07 00:40:48 +08:00
jdhao
d02fd0a69d fix: link is broken for wilder.nvim 2022-01-07 00:40:14 +08:00
jdhao
980fd531a8 wilder.nvim popup menu now respects pumblend
See also https://github.com/gelguy/wilder.nvim/pull/115.
2022-01-06 23:42:23 +08:00
jdhao
148dabd7ad docs: use latest stable version of nvim 2022-01-04 23:31:03 +08:00
jdhao
b9d1f2ee92 remove two mappings that warn of mapping deprecation 2022-01-04 00:40:11 +08:00
jdhao
b2959e8acf docs: update mappings 2022-01-04 00:38:34 +08:00
jdhao
b5ec8d2a91 Update README 2022-01-02 22:50:49 +08:00
78 changed files with 3413 additions and 1791 deletions

40
.github/ISSUE_TEMPLATE/bug_report.md vendored Normal file
View File

@@ -0,0 +1,40 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: ''
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`: <!--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):
- Output of command `set runtimepath`:
<!-- paste your runtimepath below --->
```
```
**Describe the bug**
<!-- A clear and concise description of what the bug is. -->
Steps to reproduce the issue:
1.
2.
3.
**Expected behavior**
<!-- A clear and concise description of what you expected to happen. -->
**Screenshots**
<!-- If applicable, add screenshots to help explain your problem. -->
**Additional context**
<!-- Add any other context about the problem here. -->

View File

@@ -0,0 +1,19 @@
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: ''
assignees: ''
---
**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
**Describe the solution you'd like**
A clear and concise description of what you want to happen.
**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.
**Additional context**
Add any other context or screenshots about the feature request here.

3
.gitignore vendored
View File

@@ -2,4 +2,5 @@ tags
en.utf-8.add.spl en.utf-8.add.spl
*.exe *.exe
.netrwhist .netrwhist
packer_compiled.lua *.log
.DS_Store

6
.stylua.toml Normal file
View 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"

View File

@@ -1,6 +1,6 @@
MIT License MIT License
Copyright (c) 2018-2021 jdhao Copyright (c) 2018-2023 jdhao
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal

222
README.md
View File

@@ -1,25 +1,35 @@
``` <div align="center">
███ ██ ██ ██ ██ ███ ███ ██████ ██████ ███ ██ ███████ ██ ██████ <p>
████ ██ ██ ██ ██ ████ ████ ██ ██ ██ ████ ██ ██ ██ ██ <a>
██ ██ ██ ██ ██ ██ ██ ████ ██ ██ ██ ██ ██ ██ ██ █████ ██ ██ ███ <img alt="Linux" src="https://img.shields.io/badge/Linux-%23.svg?style=flat-square&logo=linux&color=FCC624&logoColor=black" />
██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ </a>
██ ████ ████ ██ ██ ██ ██████ ██████ ██ ████ ██ ██ ██████ <a>
``` <img alt="macOS" src="https://img.shields.io/badge/macOS-%23.svg?style=flat-square&logo=apple&color=000000&logoColor=white" />
</a>
<div align="center"><p> <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/releases/latest"> <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" /> <img alt="Latest release" src="https://img.shields.io/github/v/release/jdhao/nvim-config" />
</a> </a>
<a href="https://github.com/jdhao/nvim-config/commits"> <a href="https://github.com/neovim/neovim/releases/tag/stable">
<img src="https://badgen.net/github/commits/jdhao/nvim-config" alt="Commit number" /> <img src="https://img.shields.io/badge/Neovim-0.10.1-blueviolet.svg?style=flat-square&logo=Neovim&logoColor=green" alt="Neovim minimum version"/>
</a> </a>
<a href="https://github.com/jdhao/nvim-config"> <a href="https://github.com/jdhao/nvim-config/search?l=vim-script">
<img src="https://img.shields.io/github/repo-size/jdhao/nvim-config?style=flat-square&label=Repo" alt="Repo size"> <img src="https://img.shields.io/github/languages/top/jdhao/nvim-config" alt="Top languages"/>
</a> </a>
<a href="https://github.com/neovim/neovim/releases/tag/v0.6.1"> <a href="https://github.com/jdhao/nvim-config/graphs/commit-activity">
<img src="https://img.shields.io/badge/Neovim-0.6.1-blueviolet.svg?style=flat-square&logo=Neovim&logoColor=green" alt="Neovim minimum version"/> <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/releases/tag/v0.10.0">
<img src="https://img.shields.io/github/commits-since/jdhao/nvim-config/v0.10.0?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>
<img src="https://img.shields.io/github/languages/top/jdhao/nvim-config" />
<a href="https://github.com/jdhao/nvim-config/blob/master/LICENSE"> <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"/> <img src="https://img.shields.io/github/license/jdhao/nvim-config?style=flat-square&logo=GNU&label=License" alt="License"/>
</a> </a>
@@ -28,67 +38,69 @@
# Introduction # Introduction
This repo hosts my Nvim configuration for all the platforms I am using (Linux, This repo hosts my Nvim configuration for Linux, macOS, and Windows.
Windows and macOS). `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 (I am and `ginit.vim` is the additional config file for [GUI client of Nvim](https://github.com/neovim/neovim/wiki/Related-projects#gui).
using [neovim-qt](https://github.com/equalsraf/neovim-qt) for now on Windows).
My configurations are heavily documented to make it as clear as possible. While My configurations are heavily documented to make it as clear as possible.
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 Good configurations are personal. Everyone should have his or her unique config file.
file. You are encouraged to copy from this repo the part you feel useful and You are encouraged to copy from this repo the part you want and add it to your own config.
add it to your own Nvim config.
See [doc here](docs/README.md) on how to install Nvim's dependencies, Nvim 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).
itself, and how to set up on different platforms (Linux, macOS and Windows). No effort is spent on maintaining backward compatibility.**
**This config is tested against [Nvim v0.6.1 release](https://github.com/neovim/neovim/releases/tag/v0.6.0). # Install and setup
No backward compatibility is guaranteed.**
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).
# Features # # Features #
+ Plugin management via [Packer.nvim](https://github.com/wbthomason/packer.nvim). + Plugin management via [Lazy.nvim](https://github.com/folke/lazy.nvim).
+ Code auto-completion via [nvim-cmp](https://github.com/hrsh7th/nvim-cmp) and [nvim-lspconfig](https://github.com/neovim/nvim-lspconfig). + 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). + 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). + Better escaping from insert mode via [better-escape.vim](https://github.com/nvim-zh/better-escape.vim).
+ Ultra-fast project-wide fuzzy searching via [LeaderF](https://github.com/Yggdroot/LeaderF). + Ultra-fast project-wide fuzzy searching via [LeaderF](https://github.com/Yggdroot/LeaderF).
+ Faster code commenting via [vim-commentary](https://github.com/tpope/vim-commentary). + 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). + 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). + Fast buffer jump via [hop.nvim](https://github.com/phaazon/hop.nvim).
+ Ultra fast snippet insertion via [Ultisnips](https://github.com/SirVer/ultisnips). + Powerful snippet insertion via [Ultisnips](https://github.com/SirVer/ultisnips).
+ Beautiful status line via [lualine.nvim](https://github.com/nvim-lualine/lualine.nvim). + 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). + 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). + 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). + 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). + 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 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). + 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. + 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/plasticboy/vim-markdown) and [markdown-preview.nvim](https://github.com/iamcco/markdown-preview.nvim). + 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). + 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). + Tags navigation via [vista](https://github.com/liuchengxu/vista.vim).
+ Code formatting via [Neoformat](https://github.com/sbdchd/neoformat). + Code formatting via [Neoformat](https://github.com/sbdchd/neoformat).
+ Undo management via [vim-mundo](https://github.com/simnalamburt/vim-mundo) + 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 # 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"> <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> </p>
## fuzzy finding using LeaderF ## File fuzzy finding using LeaderF
<p align="center"> <p align="center">
<img src="https://user-images.githubusercontent.com/16662357/139462025-7bce98c5-d2d5-413f-9659-20545865cdca.gif" width="800"> <img src="https://user-images.githubusercontent.com/16662357/183257017-2d9d7605-3c4b-4e1d-8955-30998f9b6f28.gif" width="800">
</p> </p>
## Code autocompletion with nvim-cmp ## Code autocompletion with nvim-cmp
@@ -129,76 +141,88 @@ Go to a string starting with `se`
<img src="https://user-images.githubusercontent.com/16662357/128589873-aadb8264-1098-4834-9876-fa66a309be05.gif" width="800"> <img src="https://user-images.githubusercontent.com/16662357/128589873-aadb8264-1098-4834-9876-fa66a309be05.gif" width="800">
</p> </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 # Shortcuts
Some of the shortcuts I use frequently. In the following shortcuts, `<leader>` Some of the shortcuts I use frequently are listed here. In the following shortcuts, `<leader>` represents ASCII character `,`.
represents ASCII character `,`.
| Shortcut | Mode | platform | Description | | Shortcut | Mode | platform | Description |
|-------------------|---------------|-----------------|------------------------------------------------------------------| |-------------------|---------------|-----------------|--------------------------------------------------------------------------|
| `<leader>ff` | Normal | Linux/macOS/Win | Fuzzy file searching in a floating window | | `<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>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 | | `<leader>fg` | Normal | Linux/macOS/Win | Fuzzy project-wide grepping in a floating window |
| `<leader>ft` | Normal | Linux/macOS/Win | Fuzzy buffer tag searching in a floating window | | `<leader>ft` | Normal | Linux/macOS/Win | Fuzzy buffer tag searching in a floating window |
| `<leader>fb` | Normal | Linux/macOS/Win | Fuzzy buffer switching in a floating window | | `<leader>fb` | Normal | Linux/macOS/Win | Fuzzy buffer switching in a floating window |
| `<leader><Space>` | Normal | Linux/macOS/Win | Remove trailing white spaces | | `<leader><Space>` | Normal | Linux/macOS/Win | Remove trailing white spaces |
| `<leader>v` | Normal | Linux/macOS/Win | Reselect last pasted text | | `<leader>v` | Normal | Linux/macOS/Win | Reselect last pasted text |
| `<leader>ev` | Normal | Linux/macOS/Win | Edit Nvim config in a new tabpage | | `<leader>ev` | Normal | Linux/macOS/Win | Edit Nvim config in a new tabpage |
| `<leader>sv` | Normal | Linux/macOS/Win | Reload Nvim config | | `<leader>sv` | Normal | Linux/macOS/Win | Reload Nvim config |
| `<leader>st` | Normal | Linux/macOS/Win | Show highlight group for cursor text | | `<leader>st` | Normal | Linux/macOS/Win | Show highlight group for cursor text |
| `<leader>q` | Normal | Linux/macOS/Win | Quit current window | | `<leader>q` | Normal | Linux/macOS/Win | Quit current window |
| `<leader>Q` | Normal | Linux/macOS/Win | Quit all window and close Nvim | | `<leader>Q` | Normal | Linux/macOS/Win | Quit all window and close Nvim |
| `<leader>w` | Normal | Linux/macOS/Win | Save current buffer content | | `<leader>w` | Normal | Linux/macOS/Win | Save current buffer content |
| `<leader>cd` | Normal | Linux/macOS/Win | Change current directory to where current file is | | `<leader>y` | Normal | Linux/macOS/Win | Copy the content of entire buffer to default register |
| `<leader>y` | Normal | Linux/macOS/Win | Copy the content of entire buffer to default register | | `<leader>cl` | Normal | Linux/macOS/Win | Toggle cursor column |
| `<leader>cl` | Normal | Linux/macOS/Win | Toggle cursor column | | `<leader>cd` | Normal | Linux/macOS/Win | Change current working directory to to the dir of current buffer |
| `<leader>cd` | Normal | Linux/macOS/Win | Change current working directory to to the dir of current buffer | | `<space>t` | Normal | Linux/macOS/Win | Toggle tag window (show project tags in the right window) |
| `<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>gs` | Normal | Linux/macOS/Win | Show Git status result | | `<leader>gw` | Normal | Linux/macOS/Win | Run Git add for current file |
| `<leader>gw` | Normal | Linux/macOS/Win | Run Git add for current file | | `<leader>gc` | Normal | Linux/macOS/Win | Run git commit |
| `<leader>gd` | Normal | Linux/macOS/Win | Run git diff for current file | | `<leader>gpl` | Normal | Linux/macOS/Win | Run git pull |
| `<leader>gc` | Normal | Linux/macOS/Win | Run git commit | | `<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 |
| `<F11>` | Normal | Linux/macOS/Win | Toggle spell checking | | `<leader>gbn` | Normal | Linux/macOS/Win | Create a new branch |
| `<F12>` | Normal | Linux/macOS/Win | Toggle paste mode | | `<leader>gl` | Normal/Visual | Linux/macOS/Win | Get perm link for current/visually-select lines |
| `\x` | Normal | Linux/macOS/Win | Close location or quickfix window | | `<leader>gbr` | Normal | macOS | Browse current git repo in browser |
| `\d` | Normal | Linux/macOS/Win | Close current buffer and go to previous buffer | | `<leader>gb` | Visual | macOS | Blame current line |
| `{count}gb` | Normal | Linux/macOS/Win | Go to buffer {count} or next buffer in the buffer list. | | `<F9>` | Normal | Linux/macOS/Win | Compile&run current source file (for C++, LaTeX, Lua, Python) |
| `Alt-m` | Normal | macOS/Win | Markdown previewing in system browser | | `<F11>` | Normal | Linux/macOS/Win | Toggle spell checking |
| `Alt-Shift-m` | Normal | macOS/Win | Stopping Markdown previewing in system browser | | `<F12>` | Normal | Linux/macOS/Win | Toggle paste mode |
| `ob` | Normal/Visual | macOS/Win | Open link under cursor or search visual selection | | `\x` | Normal | Linux/macOS/Win | Close location or quickfix window |
| `ctrl-u` | Insert | Linux/macOS/Win | Turn word under cursor to upper case | | `\d` | Normal | Linux/macOS/Win | Close current buffer and go to previous buffer |
| `ctrl-t` | Insert | Linux/macOS/Win | Turn word under cursor to title case | | `{count}gb` | Normal | Linux/macOS/Win | Go to buffer `{count}` or next buffer in the buffer list. |
| `jk` | Insert | Linux/macOS/Win | Return to Normal mode without lagging | | `{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 |
# Custom commands # Custom commands
In addition to commands provided by various plugins, I have also created In addition to commands provided by various plugins, I have also created some custom commands for personal use.
several custom commands for personal use.
| command | description | example | | command | description | example |
|------------|-------------------------------------------------------------------------|--------------------------------| |--------------|-------------------------------------------------------------------------|--------------------------------|
| `Redir` | capture command output to a tabpage for easier inspection. | `Redir hi` | | `Redir` | capture command output to a tabpage for easier inspection. | `Redir hi` |
| `Edit` | edit multiple files at the same time, supports globing | `Edit *.vim` | | `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` | | `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` |
# Trouble shooting # Contributing
If you come across an issue, you can first use `:checkhealth` command provided If you find anything that needs improving, do not hesitate to point it out or create a PR.
by `nvim` to trouble-shoot yourself. Please read carefully the messages
provided by health check. If you come across an issue, you can first use `:checkhealth` command provided by `nvim` to trouble-shoot yourself.
Please read carefully the messages provided by health check.
If you still have an issue, [open a new issue](https://github.com/jdhao/nvim-config/issues). If you still have an issue, [open a new issue](https://github.com/jdhao/nvim-config/issues).
# Further readings # Further readings
Some of the resources that I find helpful in mastering Vim is documented [here](docs/nvim_resources.md). Some of the resources that I find helpful in mastering Nvim is documented [here](docs/nvim_resources.md).
You may also be interested in my post in configuring Vim on different platforms: You may also be interested in my posts on configuring Nvim:
+ My nvim notes can be found [here](https://jdhao.github.io/categories/Nvim/)
+ [Using Neovim for Three years](https://jdhao.github.io/2021/12/31/using_nvim_after_three_years/)
+ [Config nvim on Linux for Python development](https://jdhao.github.io/2018/12/24/centos_nvim_install_use_guide_en/) + [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 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/) + [Nvim-qt config on Windows 10](https://jdhao.github.io/2019/01/17/nvim_qt_settings_on_windows/)
+ My nvim notes can be found [here](https://jdhao.github.io/categories/Nvim/)
<b id="f1">1:</b> Not enabled by default for Linux, see [this issue](https://github.com/jdhao/nvim-config/issues/4) on how to enable vimtex on Linux. [](#a1)

View File

@@ -1,10 +1,5 @@
set commentstring=//\ %s 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> " Disable inserting comment leader after hitting o or O or <Enter>
set formatoptions-=o set formatoptions-=o
set formatoptions-=r set formatoptions-=r
@@ -39,6 +34,3 @@ function s:create_term_buf(_type, size) abort
endif endif
execute 'resize ' . a:size execute 'resize ' . a:size
endfunction endfunction
" For delimitMate
let b:delimitMate_matchpairs = "(:),[:],{:}"

View File

@@ -0,0 +1 @@
set commentstring=#\ %s

View File

@@ -0,0 +1,3 @@
" Disable inserting comment leader after hitting o or O or <Enter>
set formatoptions-=o
set formatoptions-=r

View File

@@ -2,7 +2,4 @@
set formatoptions-=o set formatoptions-=o
set formatoptions-=r set formatoptions-=r
set tabstop=2 " number of visual spaces per TAB nnoremap <buffer><silent> <F9> :luafile %<CR>
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

View File

@@ -45,3 +45,25 @@ function! AddListSymbol(type, ...) abort
call setline(line, new_text) call setline(line, new_text)
endfor endfor
endfunction endfunction
" Add hard line breaks for Markdown
nnoremap <buffer><silent> \ :set operatorfunc=AddLineBreak<CR>g@
xnoremap <buffer><silent> \ :<C-U> call AddLineBreak(visualmode(), 1)<CR>
function! AddLineBreak(type, ...) abort
if a:0
let line_start = line("'<")
let line_end = line("'>")
else
let line_start = line("'[")
let line_end = line("']")
endif
for line in range(line_start, line_end)
let text = getline(line)
" add backslash to each line
let new_text = text . "\\"
call setline(line, new_text)
endfor
endfunction

View File

@@ -8,5 +8,7 @@ set sidescroll=5
set sidescrolloff=2 set sidescrolloff=2
set colorcolumn=100 set colorcolumn=100
" For delimitMate set tabstop=4 " number of visual spaces per TAB
let b:delimitMate_matchpairs = "(:),[:],{:}" 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

1
after/ftplugin/sql.vim Normal file
View File

@@ -0,0 +1 @@
set commentstring=--\ %s

2
after/ftplugin/tex.lua Normal file
View File

@@ -0,0 +1,2 @@
vim.o.textwidth = 120
vim.o.wrap = true

View File

@@ -1,3 +0,0 @@
set textwidth=79
set wrap

View File

@@ -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

View File

@@ -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 " see `:h K` and https://stackoverflow.com/q/15867323/6064933
set keywordprg=:help set keywordprg=:help
set tabstop=2 " number of visual spaces per TAB nnoremap <buffer><silent> <F9> :source %<CR>
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

View File

@@ -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. " Turn off syntax highlighting for large YAML files.
if line('$') > 500 if line('$') > 500
setlocal syntax=OFF setlocal syntax=OFF

View File

@@ -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 " 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 " 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. " 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 return
endif endif

View File

@@ -27,21 +27,6 @@ function! utils#HasColorscheme(name) abort
return !empty(globpath(&runtimepath, l:pat)) return !empty(globpath(&runtimepath, l:pat))
endfunction 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 " Custom fold expr, adapted from https://vi.stackexchange.com/a/9094/15292
function! utils#VimFolds(lnum) abort function! utils#VimFolds(lnum) abort
" get content of current line and the line below " get content of current line and the line below
@@ -131,9 +116,11 @@ function! utils#Get_titlestr() abort
if g:is_linux if g:is_linux
let l:title_str = hostname() . ' ' let l:title_str = hostname() . ' '
endif endif
let l:title_str = l:title_str . expand('%:p:~') . ' '
if &buflisted let l:buf_path = expand('%:p:~')
let l:title_str = l:title_str . strftime('%Y-%m-%d %H:%M',getftime(expand('%'))) 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 endif
return l:title_str return l:title_str
@@ -141,11 +128,22 @@ endfunction
" Output current time or unix timestamp in human-readable format. " Output current time or unix timestamp in human-readable format.
function! utils#iso_time(timestamp) abort function! utils#iso_time(timestamp) abort
if a:timestamp " Get current datetime
return strftime('%Y-%m-%d %H:%M:%S%z', a:timestamp) if !a:timestamp
return strftime('%Y-%m-%d %H:%M:%S%z')
endif endif
return strftime('%Y-%m-%d %H:%M:%S%z') " 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
let l:timestamp = a:timestamp
endif
return strftime('%Y-%m-%d %H:%M:%S%z', l:timestamp)
endfunction endfunction
" Check if we are inside a Git repo. " Check if we are inside a Git repo.
@@ -154,9 +152,7 @@ function! utils#Inside_git_repo() abort
if match(res, 'true') == -1 if match(res, 'true') == -1
return v:false return v:false
else else
" Manually trigger a specical user autocmd InGitRepo (to use it for " Manually trigger a special user autocmd InGitRepo (used lazyloading.
" lazyloading of fugitive by packer.nvim).
" See also https://github.com/wbthomason/packer.nvim/discussions/534.
doautocmd User InGitRepo doautocmd User InGitRepo
return v:true return v:true
endif endif
@@ -196,14 +192,3 @@ function! utils#MultiEdit(patterns) abort
endfor endfor
endfor endfor
endfunction 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

View File

@@ -1,120 +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,reverse,underline gui=bold,reverse,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 quit_filetypes = ['qf', 'vista']
let buftype = getbufvar(bufnr(), '&filetype')
if winnr('$') == 1 && index(quit_filetypes, buftype) != -1
quit
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

View File

@@ -1,71 +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 Python2 support
let g:loaded_python_provider = 0
" 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
"}}
"{{ Disable loading certain plugins
" Whether to load netrw by default, see
" https://github.com/bling/dotvim/issues/4
" let g:loaded_netrw = 0
" let g:loaded_netrwPlugin = 0
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
"}}
"}

View File

@@ -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

View File

@@ -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 == 'debug'
let s:msg1 = "Currently loaded theme: " . s:theme
call v:lua.vim.notify(s:msg1, 'info', {'title': 'nvim-config'})
endif

View File

@@ -1,37 +1,81 @@
This doc summarizes how to install and use this configuration in detail.
# Pre-requisite # Pre-requisite
There are a few dependencies if we want to use Nvim for efficient editing and ## Terminal emulators
development work.
## Python 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).
A lot of Nvim plugins are mainly written in Python. To use auto-completion and 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).
other features, we must install Python 3. The easiest way to install is via
[Anaconda](https://www.anaconda.com/distribution/#download-section) or [Miniconda](https://docs.conda.io/en/latest/miniconda.html). Make sure that
you can run `python --version`, and that the output should be Python 3.x.
## Pynvim 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).
Nvim relies on [pynvim](https://github.com/neovim/pynvim) to communicate with ## Patched Fonts
plugins that utilize its Python binding. Pynvim is required by plugins such as
[Semshi](https://github.com/numirias/semshi). 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.
## 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).
After installation, make sure that you can run `python --version`,
and that the output should be Python 3.x.
### 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).
``` ```
pip install -U pynvim pip install -U pynvim
``` ```
## python-lsp-server ### python-lsp-server
[python-lsp-server](https://github.com/python-lsp/python-lsp-server) is the community-fork of [pyls](https://github.com/palantir/python-language-server), and it is a Python Language Server for completion, [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.
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
``` ```
## Node 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`
We need to install node.js from [here](https://nodejs.org/en/download/): ### Node
We need to install node.js from [here](https://nodejs.org/en/download/).
For Linux, you can use the following script:
```bash ```bash
# Ref: https://johnpapa.net/node-and-npm-without-sudo/ # Ref: https://johnpapa.net/node-and-npm-without-sudo/
@@ -55,36 +99,35 @@ source ~/.bash_profile
# source ~/.zshrc # source ~/.zshrc
``` ```
## vim-language-server ### vim-language-server
[vim-language-server](https://github.com/iamcco/vim-language-server) provides [vim-language-server](https://github.com/iamcco/vim-language-server) provides completion for vim script. We can install vim-language-server globally:
completion for vim script. We can install vim-language-server globally and set
its path:
```bash ```bash
npm install -g vim-language-server npm install -g vim-language-server
export PATH="$HOME/.npm-packages/bin:$PATH"
``` ```
## Git vim-language-server is installed in the same directory as the node executable.
Git is used by the plugin manager [packer.nvim](https://github.com/wbthomason/packer.nvim) to clone plugins from GitHub or ### Git
other Git repositories.
Since Git is usually pre-installed on Linux and macOS, we do not need to worry Git is required by plugin manager [lazy.nvim](https://github.com/folke/lazy.nvim) and other git-related plugins.
if we are on these two platforms. For Windows, install [Git for Windows](https://git-scm.com/download/win)
and make sure you can call `git` from the command line.
## ctags 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.
In order to use tags related plugins such as [vista.vim](https://github.com/liuchengxu/vista.vim), we need to ### universal-ctags
install a ctags distribution. Universal-ctags is preferred.
To install ctags on macOS, use [Homebrew](https://github.com/universal-ctags/homebrew-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://formulae.brew.sh/formula/universal-ctags):
```bash ```bash
brew install ctags brew install universal-ctags
``` ```
To install it Windows, use [chocolatey](https://chocolatey.org/) or [scoop](https://scoop.sh/) To install it Windows, use [chocolatey](https://chocolatey.org/) or [scoop](https://scoop.sh/)
@@ -93,134 +136,57 @@ To install it Windows, use [chocolatey](https://chocolatey.org/) or [scoop](http
choco install universal-ctags choco install universal-ctags
# scoop bucket add extras # scoop bucket add extras
# scoop install univeral-ctags # scoop install universal-ctags
``` ```
To install it on Linux, we need to build it from source. See [here](https://askubuntu.com/a/836521/768311) Set its PATH properly and make sure you can run `ctags` from command line.
for the details.
Set its PATH properly and make sure you can call `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.
[Ripgrep](https://github.com/BurntSushi/ripgrep), aka, `rg`, is a fast grepping For Windows and macOS, we can install it via chocolatey and homebrew respectively.
tool available for both Linux, Windows and macOS. It is used by several For Linux, we can download the [binary release](https://github.com/BurntSushi/ripgrep/releases) and install it.
searching plugins.
For Windows and macOS, we can install it via chocolatey and homebrew Set its PATH properly and make sure you can run `rg` from command line.
respectively. For Linux, we can download the executable file from its [release
page](https://github.com/BurntSushi/ripgrep/releases) and install it.
## Linters ### Linters
A linter is a tool to check the source code for possible style and syntax A linter is a tool to check the source code for possible style and syntax issues.
issues. Based on the programming languages we use, we may need to install Based on the programming languages we use, we may need to install various linters.
various linters.
+ Python: [pylint](https://github.com/PyCQA/pylint) and [flake8](https://github.com/PyCQA/flake8). + Python: [pylint](https://github.com/PyCQA/pylint) and [flake8](https://github.com/PyCQA/flake8).
+ Vim script: [vint](https://github.com/Kuniwak/vint). + Vim script: [vint](https://github.com/Kuniwak/vint).
## Terminal emulators Set their PATH properly and make sure you can run `pylint`, `flake8` and `vint` from command line.
Which [terminal emulator](https://en.wikipedia.org/wiki/Terminal_emulator) we ## Install Nvim
choose to use greatly affects the appearance and functionalities 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/), or [Alacritty](https://github.com/jwilm/alacritty). There are various ways to install Nvim depending on your system.
If you connect to Linux server on Windows, I recommend [wsltty](https://github.com/mintty/wsltty) and This config is only maintained for [the latest nvim stable release](https://github.com/neovim/neovim/releases/tag/stable).
[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 the new [Windows Please check the official doc on how to install Neovim on different systems: https://github.com/neovim/neovim/blob/master/INSTALL.md
Terminal](https://github.com/microsoft/terminal).
## Font 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**.
Since statusline or file explorer plugins often use Unicode symbols not ## Setting up Nvim
available in normal font, we need to install a patched font from the [nerd-fonts](https://github.com/ryanoasis/nerd-fonts) project.
# Install Nvim After installing nvim and all the dependencies, we will install plugin managers and set up this config.
There are various ways to install Nvim depending on your system. Current ### How to install this configuration
configuration is tested against nvim v0.6.0.
## Linux On Linux and macOS, the directory is `~/.config/nvim`.
On Windows, the config directory is `$HOME/AppData/Local/nvim`[^1].
We can directly download the binary release from [here](https://github.com/neovim/neovim/releases/download/v0.6.0/nvim-linux64.tar.gz). First, we need to remove all the files under the config directory (including dot files),
then go to this directory, and run the following command:
## Windows
The easiest way to install Nvim on Windows is via chocolatey:
```
choco install neovim
```
You may download from [nvim release](https://github.com/neovim/neovim/releases/download/v0.6.0/nvim-win64.zip) from GitHub and manually extract it.
## 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 add the directory where the Nvim executable
(`nvim` on Linux and macOS, `nvim.exe` on Windows) resides to the system `PATH`.
Make sure that you can call `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, use 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, use 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
On Windows, the config directory is `$HOME/AppData/Local/nvim`[^1]. On Linux
and macOS, the directory is `~/.config/nvim`. First, we need to remove all the
files under the config directory (including dot files), then go to this
directory, and run the following command to install this configuration:
``` ```
git clone --depth=1 https://github.com/jdhao/nvim-config.git . git clone --depth=1 https://github.com/jdhao/nvim-config.git .
``` ```
After that, when we first open nvim, run command `:PackerSync` to install all After that, when we first open nvim, all the plugins will be installed automatically.
the plugins and generate `packer_compiled.lua`. Since I use quite a lot of Since I use quite a lot of plugins (more than 60), it may take some time to install all of them.
plugins (more than 60), it may take some time to install all of them, depending
on your network condition.
# Automatic installation
## Automatic Installation for Linux #
To set up a workable Nvim environment on Linux, I use [this bash script](nvim_setup_linux.sh) to automatically install necessary
dependencies, Nvim itself and Nvim configs in this repo.
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. [^1]: Use `echo %userprofile%` to see where your `$HOME` is.

View File

@@ -2,15 +2,16 @@
#!/bin/bash #!/bin/bash
set -eux set -eux
wget https://github.com/neovim/neovim/releases/download/v0.6.0/nvim-macos.tar.gz wget https://github.com/neovim/neovim/releases/download/stable/nvim-macos.tar.gz
if [[ ! -d "$HOME/tools/" ]]; then if [[ ! -d "$HOME/tools/" ]]; then
mkdir -p "$HOME/tools" mkdir -p "$HOME/tools"
fi fi
# Delete existing nvim installation. # Delete existing nvim installation.
if [[ -d "$HOME/tools/nvim-osx64" ]]; then # For newer release, the directory name is nvim-macos
rm -rf "$HOME/tools/nvim-osx64" if [[ -d "$HOME/tools/nvim-macos" ]]; then
rm -rf "$HOME/tools/nvim-macos"
fi fi
# Extract the tar ball # Extract the tar ball

View File

@@ -34,11 +34,11 @@ fi
if [[ "$INSTALL_ANACONDA" = true ]]; then if [[ "$INSTALL_ANACONDA" = true ]]; then
CONDA_DIR=$HOME/tools/anaconda CONDA_DIR=$HOME/tools/anaconda
CONDA_NAME=Anaconda.sh CONDA_NAME=Anaconda.sh
CONDA_LINK="https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/Anaconda3-2021.05-Linux-x86_64.sh" CONDA_LINK="https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/Anaconda3-2021.11-Linux-x86_64.sh"
else else
CONDA_DIR=$HOME/tools/miniconda CONDA_DIR=$HOME/tools/miniconda
CONDA_NAME=Miniconda.sh CONDA_NAME=Miniconda.sh
CONDA_LINK="https://mirrors.tuna.tsinghua.edu.cn/anaconda/miniconda/Miniconda3-latest-Linux-x86_64.sh" CONDA_LINK="https://mirrors.tuna.tsinghua.edu.cn/anaconda/miniconda/Miniconda3-py39_4.10.3-Linux-x86_64.sh"
fi fi
if [[ ! "$PYTHON_INSTALLED" = true ]]; then if [[ ! "$PYTHON_INSTALLED" = true ]]; then
@@ -68,7 +68,7 @@ fi
# Install some Python packages used by Nvim plugins. # Install some Python packages used by Nvim plugins.
echo "Installing Python packages" 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 if [[ "$SYSTEM_PYTHON" = true ]]; then
echo "Using system Python to install $(PY_PACKAGES)" echo "Using system Python to install $(PY_PACKAGES)"
@@ -76,32 +76,32 @@ if [[ "$SYSTEM_PYTHON" = true ]]; then
# If we use system Python, we need to install these Python packages under # 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 # user HOME, since we do not have permissions to install them under system
# directories. # directories.
for p in "${py_packages[@]}"; do for p in "${PY_PACKAGES[@]}"; do
pip install --user "$p" pip install --user "$p"
done done
else else
echo "Using custom Python to install $(PY_PACKAGES)" 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" "$CONDA_DIR/bin/pip" install "$p"
done done
fi fi
####################################################################### #######################################################################
# Install node and vim-language-server # # Install node and js-based language server #
####################################################################### #######################################################################
NODE_DIR=$HOME/tools/nodejs NODE_DIR=$HOME/tools/nodejs
NODE_SRC_NAME=$HOME/packages/nodejs.tar.gz NODE_SRC_NAME=$HOME/packages/nodejs.tar.gz
# when download speed is slow, we can also use its mirror site: https://mirrors.ustc.edu.cn/node/v15.0.0/ # when download speed is slow, we can also use its mirror site: https://mirrors.ustc.edu.cn/node/v15.0.0/
NODE_LINK="https://mirrors.ustc.edu.cn/node/v15.0.0/node-v15.0.0-linux-x64.tar.xz" NODE_LINK="https://mirrors.ustc.edu.cn/node/v15.0.0/node-v15.0.0-linux-x64.tar.xz"
if [[ -z "$(command -v node)" ]]; then if [[ -z "$(command -v node)" ]]; then
echo "Install Nodejs" echo "Install Node.js"
if [[ ! -f $NODE_SRC_NAME ]]; then if [[ ! -f $NODE_SRC_NAME ]]; then
echo "Downloading nodejs and renaming" echo "Downloading Node.js and renaming"
wget $NODE_LINK -O "$NODE_SRC_NAME" wget $NODE_LINK -O "$NODE_SRC_NAME"
fi fi
if [[ ! -d "$NODE_DIR" ]]; then if [[ ! -d "$NODE_DIR" ]]; then
echo "Creating nodejs directory under tools directory" echo "Creating Node.js directory under tools directory"
mkdir -p "$NODE_DIR" mkdir -p "$NODE_DIR"
echo "Extracting to $HOME/tools/nodejs directory" echo "Extracting to $HOME/tools/nodejs directory"
tar xvf "$NODE_SRC_NAME" -C "$NODE_DIR" --strip-components 1 tar xvf "$NODE_SRC_NAME" -C "$NODE_DIR" --strip-components 1
@@ -111,18 +111,51 @@ if [[ -z "$(command -v node)" ]]; then
echo "export PATH=\"$NODE_DIR/bin:\$PATH\"" >> "$HOME/.bash_profile" echo "export PATH=\"$NODE_DIR/bin:\$PATH\"" >> "$HOME/.bash_profile"
fi fi
else else
echo "Nodejs is already installed. Skip installing it." echo "Node.js is already installed. Skip installing it."
NODE_DIR="$(realpath $(dirname $(which node))/..)"
fi fi
# Install vim-language-server # Install vim-language-server
"$NODE_DIR/bin/npm" install -g vim-language-server "$NODE_DIR/bin/npm" install -g vim-language-server
# 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 # # Ripgrep part #
####################################################################### #######################################################################
RIPGREP_DIR=$HOME/tools/ripgrep RIPGREP_DIR=$HOME/tools/ripgrep
RIPGREP_SRC_NAME=$HOME/packages/ripgrep.tar.gz RIPGREP_SRC_NAME=$HOME/packages/ripgrep.tar.gz
RIPGREP_LINK="https://hub.fastgit.org/BurntSushi/ripgrep/releases/download/12.0.0/ripgrep-12.0.0-x86_64-unknown-linux-musl.tar.gz" RIPGREP_LINK="https://github.com/BurntSushi/ripgrep/releases/download/12.0.0/ripgrep-12.0.0-x86_64-unknown-linux-musl.tar.gz"
if [[ -z "$(command -v rg)" ]] && [[ ! -f "$RIPGREP_DIR/rg" ]]; then if [[ -z "$(command -v rg)" ]] && [[ ! -f "$RIPGREP_DIR/rg" ]]; then
echo "Install ripgrep" echo "Install ripgrep"
if [[ ! -f $RIPGREP_SRC_NAME ]]; then if [[ ! -f $RIPGREP_SRC_NAME ]]; then
@@ -142,8 +175,8 @@ if [[ -z "$(command -v rg)" ]] && [[ ! -f "$RIPGREP_DIR/rg" ]]; then
fi fi
# set up manpath and zsh completion for ripgrep # set up manpath and zsh completion for ripgrep
mkdir -p $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 mv "$HOME/tools/ripgrep/doc/rg.1" "$HOME/tools/ripgrep/doc/man/man1"
if [[ "$USE_BASH_SHELL" = true ]]; then if [[ "$USE_BASH_SHELL" = true ]]; then
echo 'export MANPATH=$HOME/tools/ripgrep/doc/man:$MANPATH' >> "$HOME/.bash_profile" echo 'export MANPATH=$HOME/tools/ripgrep/doc/man:$MANPATH' >> "$HOME/.bash_profile"
@@ -160,7 +193,7 @@ fi
####################################################################### #######################################################################
CTAGS_SRC_DIR=$HOME/packages/ctags CTAGS_SRC_DIR=$HOME/packages/ctags
CTAGS_DIR=$HOME/tools/ctags CTAGS_DIR=$HOME/tools/ctags
CTAGS_LINK="https://hub.fastgit.org/universal-ctags/ctags.git" CTAGS_LINK="https://github.com/universal-ctags/ctags.git"
if [[ ! -f "$CTAGS_DIR/bin/ctags" ]]; then if [[ ! -f "$CTAGS_DIR/bin/ctags" ]]; then
echo "Install ctags" echo "Install ctags"
@@ -188,7 +221,7 @@ fi
NVIM_DIR=$HOME/tools/nvim NVIM_DIR=$HOME/tools/nvim
NVIM_SRC_NAME=$HOME/packages/nvim-linux64.tar.gz NVIM_SRC_NAME=$HOME/packages/nvim-linux64.tar.gz
NVIM_CONFIG_DIR=$HOME/.config/nvim NVIM_CONFIG_DIR=$HOME/.config/nvim
NVIM_LINK="https://github.com/neovim/neovim/releases/download/v0.6.0/nvim-linux64.tar.gz" NVIM_LINK="https://github.com/neovim/neovim/releases/download/stable/nvim-linux64.tar.gz"
if [[ ! -f "$NVIM_DIR/bin/nvim" ]]; then if [[ ! -f "$NVIM_DIR/bin/nvim" ]]; then
echo "Installing Nvim" echo "Installing Nvim"
echo "Creating nvim directory under tools directory" echo "Creating nvim directory under tools directory"
@@ -213,16 +246,13 @@ fi
echo "Setting up config and installing plugins" echo "Setting up config and installing plugins"
if [[ -d "$NVIM_CONFIG_DIR" ]]; then if [[ -d "$NVIM_CONFIG_DIR" ]]; then
rm -rf "$NVIM_CONFIG_DIR.backup"
mv "$NVIM_CONFIG_DIR" "$NVIM_CONFIG_DIR.backup" mv "$NVIM_CONFIG_DIR" "$NVIM_CONFIG_DIR.backup"
fi fi
git clone --depth=1 https://hub.fastgit.org/jdhao/nvim-config.git "$NVIM_CONFIG_DIR" git clone --depth=1 https://github.com/jdhao/nvim-config.git "$NVIM_CONFIG_DIR"
echo "Installing packer.nvim"
git clone --depth=1 https://hub.fastgit.org/wbthomason/packer.nvim \
~/.local/share/nvim/site/pack/packer/opt/packer.nvim
echo "Installing nvim plugins, please wait" 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!" echo "Finished installing Nvim and its dependencies!"

View File

@@ -1,6 +1,8 @@
# Install scoop # Set policy to avoid errors
Set-ExecutionPolicy RemoteSigned -scope CurrentUser Set-ExecutionPolicy RemoteSigned -scope CurrentUser
iwr -useb get.scoop.sh | iex
# Install scoop
Invoke-WebRequest -UseBasicParsing get.scoop.sh | Invoke-Expression
# Install node # Install node
scoop install nodejs scoop install nodejs
@@ -15,15 +17,39 @@ scoop install universal-ctags
# Install vim-language-server # Install vim-language-server
npm install -g vim-language-server npm install -g vim-language-server
# Install miniconda3 # Install bash-language-server
npm install -g bash-language-server
# Install miniconda3 (for Python)
scoop install miniconda3 scoop install miniconda3
# Install pynvim # Install pynvim
pip install -U pynvim pip install -U pynvim
# Install python-language-server # 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 # Install neovim nightly
scoop bucket add versions scoop bucket add versions
scoop install neovim-nightly scoop install neovim

View File

@@ -3,6 +3,9 @@ inoremap <silent> <S-Insert> <C-R>+
cnoremap <S-Insert> <C-R>+ cnoremap <S-Insert> <C-R>+
nnoremap <silent> <C-6> <C-^> nnoremap <silent> <C-6> <C-^>
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" config for nvim-qt "
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" To check if neovim-qt is running, use `exists('g:GuiLoaded')`, " To check if neovim-qt is running, use `exists('g:GuiLoaded')`,
" see https://github.com/equalsraf/neovim-qt/issues/219 " see https://github.com/equalsraf/neovim-qt/issues/219
if exists('g:GuiLoaded') if exists('g:GuiLoaded')
@@ -13,6 +16,9 @@ if exists('g:GuiLoaded')
GuiFont! Hack\ NF:h10:l GuiFont! Hack\ NF:h10:l
endif endif
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" config for fvim "
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
if exists('g:fvim_loaded') if exists('g:fvim_loaded')
set termguicolors set termguicolors
colorscheme gruvbox8_hard colorscheme gruvbox8_hard
@@ -53,3 +59,16 @@ if exists('g:fvim_loaded')
FVimUIPopupMenu v:false FVimUIPopupMenu v:false
endif 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

33
init.lua Normal file
View File

@@ -0,0 +1,33 @@
-- 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.10.1"
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"))
-- colorscheme settings
require("colorschemes")

View File

@@ -1,22 +0,0 @@
" Description: 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 becomes more proficient in using Nvim. Since it
" is very long (more than 1000 lines!), you should read it carefully and take
" only the settings and options that suits 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
let g:config_files = [
\ 'globals.vim',
\ 'options.vim',
\ 'autocommands.vim',
\ 'mappings.vim',
\ 'plugins.vim',
\ 'themes.vim'
\ ]
for s:fname in g:config_files
execute printf('source %s/core/%s', stdpath('config'), s:fname)
endfor

89
lua/colorschemes.lua Normal file
View File

@@ -0,0 +1,89 @@
--- 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()
vim.cmd([[colorscheme onedark]])
end,
edge = function()
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 = "medium"
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_enable_italic = 1
vim.g.everforest_better_performance = 1
vim.cmd([[colorscheme everforest]])
end,
nightfox = function()
vim.cmd([[colorscheme nordfox]])
end,
catppuccin = function()
-- available option: latte, frappe, macchiato, mocha
vim.g.catppuccin_flavour = "frappe"
require("catppuccin").setup()
vim.cmd([[colorscheme catppuccin]])
end,
onedarkpro = function()
-- set colorscheme after options
vim.cmd('colorscheme onedark_vivid')
end,
material = function()
vim.g.material_style = "oceanic"
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))
if not vim.tbl_contains(vim.tbl_keys(M.colorscheme_conf), colorscheme) then
local msg = "Invalid colorscheme: " .. colorscheme
vim.notify(msg, vim.log.levels.ERROR, { title = "nvim-config" })
return
end
-- Load the colorscheme and its settings
M.colorscheme_conf[colorscheme]()
if vim.g.logging_level == "debug" then
local msg = "Colorscheme: " .. colorscheme
vim.notify(msg, vim.log.levels.DEBUG, { title = "nvim-config" })
end
end
-- Load a random colorscheme
M.rand_colorscheme()

View File

@@ -1,31 +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( "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)

View File

@@ -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,
})

View File

@@ -1,6 +1,6 @@
require("bqf").setup({ require("bqf").setup {
auto_resize_height = false, auto_resize_height = false,
preview = { preview = {
auto_preview = false, auto_preview = false,
} },
}) }

View File

@@ -1,12 +1,15 @@
require("bufferline").setup({ require("bufferline").setup {
options = { options = {
numbers = "buffer_id", numbers = "none",
close_command = "bdelete! %d", close_command = "bdelete! %d",
right_mouse_command = nil, right_mouse_command = nil,
left_mouse_command = "buffer %d", left_mouse_command = "buffer %d",
middle_mouse_command = nil, middle_mouse_command = nil,
indicator_icon = "", indicator = {
buffer_close_icon = "", icon = "", -- this should be omitted if indicator style is not 'icon'
style = "icon",
},
buffer_close_icon = "",
modified_icon = "", modified_icon = "",
close_icon = "", close_icon = "",
left_trunc_marker = "", left_trunc_marker = "",
@@ -40,4 +43,8 @@ require("bufferline").setup({
always_show_bufferline = true, always_show_bufferline = true,
sort_by = "id", sort_by = "id",
}, },
}
vim.keymap.set("n", "<space>bp", "<cmd>BufferLinePick<CR>", {
desc = "pick a buffer",
}) })

View 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 = "Leaderf file --popup",
key = "<Leader> f f",
},
{
icon = "󰈢 ",
desc = "Recently opened files ",
action = "Leaderf mru --popup",
key = "<Leader> f r",
},
{
icon = "󰈬 ",
desc = "Project grep ",
action = "Leaderf rg --popup",
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
})

View File

@@ -0,0 +1 @@
require("fidget").setup {}

27
lua/config/fugitive.lua Normal file
View 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" })

37
lua/config/git-linker.lua Normal file
View File

@@ -0,0 +1,37 @@
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
View File

@@ -0,0 +1,57 @@
local gs = require("gitsigns")
gs.setup {
signs = {
add = { text = "+" },
change = { text = "~" },
delete = { text = "_" },
topdelete = { text = "" },
changedelete = { text = "" },
},
word_diff = true,
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)
map("n", "<leader>hb", function()
gs.blame_line { full = true }
end)
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
})

View File

@@ -1,21 +1,82 @@
require('hlslens').setup({ local api = vim.api
calm_down = true, local keymap = vim.keymap
nearest_only = true,
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_err_writeln(msg_part)
return
end
hlslens.start()
end
keymap.set("n", "n", "", {
callback = function()
activate_hlslens("n")
end,
}) })
vim.api.nvim_set_keymap( keymap.set("n", "N", "", {
"n", callback = function()
"n", activate_hlslens("N")
"<Cmd>execute('normal! ' . v:count1 . 'nzzzv')<CR><Cmd>lua require('hlslens').start()<CR>", end,
{ noremap = true, silent = true } })
)
vim.api.nvim_set_keymap( local check_cursor_word = function()
"n", local cursor_word = vim.fn.expand("<cword>")
"N", local result = cursor_word == ""
"<Cmd>execute('normal! ' . v:count1 . 'Nzzzv')<CR><Cmd>lua require('hlslens').start()<CR>", if result then
{ noremap = true, silent = true } local msg = "E348: No string under cursor"
) api.nvim_err_writeln(msg)
end
vim.api.nvim_set_keymap("n", "*", "<Plug>(asterisk-z*)<Cmd>lua require('hlslens').start()<CR>", { silent = true }) return result, cursor_word
vim.api.nvim_set_keymap("n", "#", "<Plug>(asterisk-z#)<Cmd>lua require('hlslens').start()<CR>", { silent = true }) 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,
})

View File

@@ -1,23 +1,36 @@
require("indent_blankline").setup({ local api = vim.api
-- U+2502 may also be a good choice, it will be on the middle of cursor.
-- U+250A is also a good choice local exclude_ft = { "help", "git", "markdown", "snippets", "text", "gitconfig", "alpha", "dashboard" }
char = "",
show_end_of_line = false, require("ibl").setup {
disable_with_nolist = true, indent = {
buftype_exclude = { "terminal" }, -- -- U+2502 may also be a good choice, it will be on the middle of cursor.
filetype_exclude = { "help", "git", "markdown", "snippets", "text", "gitconfig", "alpha" }, -- -- U+250A is also a good choice
char = "",
},
scope = {
show_start = false,
show_end = false,
},
exclude = {
filetypes = exclude_ft,
buftypes = { "terminal" },
},
}
local gid = api.nvim_create_augroup("indent_blankline", { clear = true })
api.nvim_create_autocmd("InsertEnter", {
pattern = "*",
group = gid,
command = "IBLDisable",
}) })
vim.cmd([[ api.nvim_create_autocmd("InsertLeave", {
function! Should_activate_indentblankline() abort pattern = "*",
if index(g:indent_blankline_filetype_exclude, &filetype) == -1 group = gid,
IndentBlanklineEnable callback = function()
endif if not vim.tbl_contains(exclude_ft, vim.bo.filetype) then
endfunction vim.cmd([[IBLEnable]])
end
augroup indent_blankline end,
autocmd! })
autocmd InsertEnter * IndentBlanklineDisable
autocmd InsertLeave * call Should_activate_indentblankline()
augroup END
]])

View File

@@ -1,7 +1,7 @@
local iron = require("iron") local iron = require("iron")
iron.core.set_config({ iron.core.set_config {
preferred = { preferred = {
python = "ipython", python = "ipython",
}, },
repl_open_cmd = "vertical 120 split", repl_open_cmd = "vertical 120 split",
}) }

View File

@@ -0,0 +1,4 @@
require("live-command").setup {
enable_highlighting = true,
inline_highlighting = true,
}

View File

@@ -1,170 +1,254 @@
local fn = vim.fn
local api = vim.api local api = vim.api
local keymap = vim.keymap
local lsp = vim.lsp local lsp = vim.lsp
local diagnostic = vim.diagnostic
local M = {} local utils = require("utils")
function M.show_line_diagnostics() -- set quickfix list from diagnostics in a certain buffer, not the whole workspace
local opts = { local set_qflist = function(buf_num, severity)
focusable = false, local diagnostics = nil
close_events = { "BufLeave", "CursorMoved", "InsertEnter", "FocusLost" }, diagnostics = diagnostic.get(buf_num, { severity = severity })
border = 'rounded',
source = 'always', -- show source in diagnostic popup window local qf_items = diagnostic.toqflist(diagnostics)
prefix = ' ' vim.fn.setqflist({}, ' ', { title = 'Diagnostics', items = qf_items })
}
vim.diagnostic.open_float(nil, opts) -- open quickfix by default
vim.cmd[[copen]]
end end
local custom_attach = function(client, bufnr) local custom_attach = function(client, bufnr)
local function buf_set_keymap(...) -- Mappings.
api.nvim_buf_set_keymap(bufnr, ...) local map = function(mode, l, r, opts)
opts = opts or {}
opts.silent = true
opts.buffer = bufnr
keymap.set(mode, l, r, opts)
end end
-- Mappings. map("n", "gd", vim.lsp.buf.definition, { desc = "go to definition" })
local opts = { noremap = true, silent = true } map("n", "<C-]>", vim.lsp.buf.definition)
buf_set_keymap("n", "gd", "<Cmd>lua vim.lsp.buf.definition()<CR>", opts) map("n", "K", vim.lsp.buf.hover)
buf_set_keymap("n", "<C-]>", "<Cmd>lua vim.lsp.buf.definition()<CR>", opts) map("n", "<C-k>", vim.lsp.buf.signature_help)
buf_set_keymap("n", "K", "<Cmd>lua vim.lsp.buf.hover()<CR>", opts) map("n", "<space>rn", vim.lsp.buf.rename, { desc = "varialbe rename" })
buf_set_keymap("n", "<C-k>", "<cmd>lua vim.lsp.buf.signature_help()<CR>", opts) map("n", "gr", vim.lsp.buf.references, { desc = "show references" })
buf_set_keymap("n", "<space>wa", "<cmd>lua vim.lsp.buf.add_workspace_folder()<CR>", opts) map("n", "[d", diagnostic.goto_prev, { desc = "previous diagnostic" })
buf_set_keymap("n", "<space>wr", "<cmd>lua vim.lsp.buf.remove_workspace_folder()<CR>", opts) map("n", "]d", diagnostic.goto_next, { desc = "next diagnostic" })
buf_set_keymap("n", "<space>wl", "<cmd>lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<CR>", opts) -- this puts diagnostics from opened files to quickfix
buf_set_keymap("n", "<space>rn", "<cmd>lua vim.lsp.buf.rename()<CR>", opts) map("n", "<space>qw", diagnostic.setqflist, { desc = "put window diagnostics to qf" })
buf_set_keymap("n", "gr", "<cmd>lua vim.lsp.buf.references()<CR>", opts) -- this puts diagnostics from current buffer to quickfix
buf_set_keymap("n", "[d", "<cmd>lua vim.diagnostic.goto_prev()<CR>", opts) map("n", "<space>qb", function() set_qflist(bufnr) end, { desc = "put buffer diagnostics to qf" })
buf_set_keymap("n", "]d", "<cmd>lua vim.diagnostic.goto_next()<CR>", opts) map("n", "<space>ca", vim.lsp.buf.code_action, { desc = "LSP code action" })
buf_set_keymap("n", "<space>q", "<cmd>lua vim.diagnostic.setqflist({open = true})<CR>", opts) map("n", "<space>wa", vim.lsp.buf.add_workspace_folder, { desc = "add workspace folder" })
buf_set_keymap("n", "<space>ca", "<cmd>lua vim.lsp.buf.code_action()<CR>", opts) map("n", "<space>wr", vim.lsp.buf.remove_workspace_folder, { desc = "remove workspace folder" })
map("n", "<space>wl", function()
vim.cmd([[ vim.print(vim.lsp.buf.list_workspace_folders())
autocmd CursorHold <buffer> lua require('config.lsp').show_line_diagnostics() end, { desc = "list workspace folder" })
]])
-- Set some key bindings conditional on server capabilities -- Set some key bindings conditional on server capabilities
if client.resolved_capabilities.document_formatting then if client.server_capabilities.documentFormattingProvider then
buf_set_keymap("n", "<space>f", "<cmd>lua vim.lsp.buf.formatting_sync()<CR>", opts) map("n", "<space>f", vim.lsp.buf.format, { desc = "format code" })
end
if client.resolved_capabilities.document_range_formatting then
buf_set_keymap("x", "<space>f", "<cmd>lua vim.lsp.buf.range_formatting()<CR><ESC>", opts)
end end
api.nvim_create_autocmd("CursorHold", {
buffer = bufnr,
callback = function()
local float_opts = {
focusable = false,
close_events = { "BufLeave", "CursorMoved", "InsertEnter", "FocusLost" },
border = "rounded",
source = "always", -- show source in diagnostic popup window
prefix = " ",
}
if not vim.b.diagnostics_pos then
vim.b.diagnostics_pos = { nil, nil }
end
local cursor_pos = api.nvim_win_get_cursor(0)
if (cursor_pos[1] ~= vim.b.diagnostics_pos[1] or cursor_pos[2] ~= vim.b.diagnostics_pos[2])
and #diagnostic.get() > 0
then
diagnostic.open_float(nil, float_opts)
end
vim.b.diagnostics_pos = cursor_pos
end,
})
-- The blow command will highlight the current variable and its usages in the buffer. -- The blow command will highlight the current variable and its usages in the buffer.
if client.resolved_capabilities.document_highlight then if client.server_capabilities.documentHighlightProvider then
vim.cmd([[ vim.cmd([[
hi! link LspReferenceRead Visual hi! link LspReferenceRead Visual
hi! link LspReferenceText Visual hi! link LspReferenceText Visual
hi! link LspReferenceWrite 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
]]) ]])
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
if vim.g.logging_level == 'debug' then if vim.g.logging_level == "debug" then
local msg = string.format("Language server %s started!", client.name) local msg = string.format("Language server %s started!", client.name)
vim.notify(msg, 'info', {title = 'Nvim-config'}) vim.notify(msg, vim.log.levels.DEBUG, { title = "Nvim-config" })
end end
end end
local capabilities = require('cmp_nvim_lsp').update_capabilities(lsp.protocol.make_client_capabilities()) local capabilities = require('cmp_nvim_lsp').default_capabilities()
capabilities.textDocument.completion.completionItem.snippetSupport = true -- required by nvim-ufo
capabilities.textDocument.foldingRange = {
dynamicRegistration = false,
lineFoldingOnly = true
}
local lspconfig = require("lspconfig") local lspconfig = require("lspconfig")
lspconfig.pylsp.setup({ if utils.executable("pylsp") then
on_attach = custom_attach, local venv_path = os.getenv('VIRTUAL_ENV')
settings = { local py_path = nil
pylsp = { -- decide which python executable to use for mypy
plugins = { if venv_path ~= nil then
pylint = { enabled = true, executable = "pylint" }, py_path = venv_path .. "/bin/python3"
pyflakes = { enabled = false }, else
pycodestyle = { enabled = false }, py_path = vim.g.python3_host_prog
jedi_completion = { fuzzy = true }, end
pyls_isort = { enabled = true },
pylsp_mypy = { enabled = true }, lspconfig.pylsp.setup {
on_attach = custom_attach,
settings = {
pylsp = {
plugins = {
-- formatter options
black = { enabled = true },
autopep8 = { enabled = false },
yapf = { enabled = false },
-- linter options
pylint = { enabled = true, executable = "pylint" },
ruff = { enabled = false },
pyflakes = { enabled = false },
pycodestyle = { enabled = false },
-- type checker
pylsp_mypy = {
enabled = true,
overrides = { "--python-executable", py_path, true },
report_progress = true,
live_mode = false
},
-- auto-completion options
jedi_completion = { fuzzy = true },
-- import sorting
isort = { enabled = true },
},
}, },
}, },
}, flags = {
flags = { debounce_text_changes = 200,
debounce_text_changes = 200, },
}, capabilities = capabilities,
capabilities = capabilities, }
}) else
vim.notify("pylsp not found!", vim.log.levels.WARN, { title = "Nvim-config" })
end
-- lspconfig.pyright.setup{ -- if utils.executable('pyright') then
-- on_attach = custom_attach, -- lspconfig.pyright.setup{
-- capabilities = capabilities -- on_attach = custom_attach,
-- } -- capabilities = capabilities
-- }
-- else
-- vim.notify("pyright not found!", vim.log.levels.WARN, {title = 'Nvim-config'})
-- end
lspconfig.clangd.setup({ if utils.executable("ltex-ls") then
on_attach = custom_attach, lspconfig.ltex.setup {
capabilities = capabilities, on_attach = custom_attach,
filetypes = { "c", "cpp", "cc" }, cmd = { "ltex-ls" },
flags = { filetypes = { "text", "plaintex", "tex", "markdown" },
debounce_text_changes = 500, settings = {
}, ltex = {
}) language = "en"
},
},
flags = { debounce_text_changes = 300 },
}
end
if utils.executable("clangd") then
lspconfig.clangd.setup {
on_attach = custom_attach,
capabilities = capabilities,
filetypes = { "c", "cpp", "cc" },
flags = {
debounce_text_changes = 500,
},
}
end
-- set up vim-language-server -- set up vim-language-server
lspconfig.vimls.setup({ if utils.executable("vim-language-server") then
on_attach = custom_attach, lspconfig.vimls.setup {
flags = { on_attach = custom_attach,
debounce_text_changes = 500, flags = {
}, debounce_text_changes = 500,
capabilities = capabilities, },
}) capabilities = capabilities,
}
local sumneko_binary_path = vim.fn.exepath("lua-language-server") else
if vim.g.is_mac or vim.g.is_linux and sumneko_binary_path ~= "" then vim.notify("vim-language-server not found!", vim.log.levels.WARN, { title = "Nvim-config" })
local sumneko_root_path = vim.fn.fnamemodify(sumneko_binary_path, ":h:h:h") end
local runtime_path = vim.split(package.path, ";") -- set up bash-language-server
table.insert(runtime_path, "lua/?.lua") if utils.executable("bash-language-server") then
table.insert(runtime_path, "lua/?/init.lua") lspconfig.bashls.setup {
on_attach = custom_attach,
require("lspconfig").sumneko_lua.setup({ capabilities = capabilities,
}
end
if utils.executable("lua-language-server") then
-- settings for lua-language-server can be found on https://github.com/LuaLS/lua-language-server/wiki/Settings .
lspconfig.lua_ls.setup {
on_attach = custom_attach, on_attach = custom_attach,
cmd = { sumneko_binary_path, "-E", sumneko_root_path .. "/main.lua" },
settings = { settings = {
Lua = { Lua = {
runtime = { runtime = {
-- Tell the language server which version of Lua you're using (most likely LuaJIT in the case of Neovim) -- Tell the language server which version of Lua you're using (most likely LuaJIT in the case of Neovim)
version = "LuaJIT", 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,
}, },
}, },
}, },
capabilities = capabilities, capabilities = capabilities,
}) }
end end
-- Change diagnostic signs. -- Change diagnostic signs.
vim.fn.sign_define("DiagnosticSignError", { text = "", texthl = "DiagnosticSignError" }) fn.sign_define("DiagnosticSignError", { text = '🆇', texthl = "DiagnosticSignError" })
vim.fn.sign_define("DiagnosticSignWarn", { text = "!", texthl = "DiagnosticSignWarn" }) fn.sign_define("DiagnosticSignWarn", { text = '⚠️', texthl = "DiagnosticSignWarn" })
vim.fn.sign_define("DiagnosticSignInformation", { text = "", texthl = "DiagnosticSignInfo" }) fn.sign_define("DiagnosticSignInfo", { text = '', texthl = "DiagnosticSignInfo" })
vim.fn.sign_define("DiagnosticSignHint", { text = "", texthl = "DiagnosticSignHint" }) fn.sign_define("DiagnosticSignHint", { text = '', texthl = "DiagnosticSignHint" })
-- global config for diagnostic -- global config for diagnostic
vim.diagnostic.config({ diagnostic.config {
underline = false, underline = false,
virtual_text = false, virtual_text = false,
signs = true, signs = true,
severity_sort = true, severity_sort = true,
}) }
-- lsp.handlers["textDocument/publishDiagnostics"] = lsp.with(lsp.diagnostic.on_publish_diagnostics, { -- lsp.handlers["textDocument/publishDiagnostics"] = lsp.with(lsp.diagnostic.on_publish_diagnostics, {
-- underline = false, -- underline = false,
@@ -177,5 +261,3 @@ vim.diagnostic.config({
lsp.handlers["textDocument/hover"] = lsp.with(vim.lsp.handlers.hover, { lsp.handlers["textDocument/hover"] = lsp.with(vim.lsp.handlers.hover, {
border = "rounded", border = "rounded",
}) })
return M

228
lua/config/lualine.lua Normal file
View File

@@ -0,0 +1,228 @@
local fn = vim.fn
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 = "No Active Lsp"
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",
section_separators = "",
component_separators = "",
disabled_filetypes = {},
always_divide_middle = true,
},
sections = {
lualine_a = { "mode" },
lualine_b = {
{
"branch",
fmt = function(name, _)
-- truncate branch name in case the name is too long
return string.sub(name, 1, 20)
end,
},
{
virtual_env,
color = { fg = "black", bg = "#F1CA81" },
},
},
lualine_c = {
{
"filename",
symbols = {
readonly = "[🔒]",
},
},
{
"diff",
source = diff,
},
{
ime_state,
color = { fg = "black", bg = "#f46868" },
},
{
spell,
color = { fg = "black", bg = "#a7c080" },
},
},
lualine_x = {
{
get_active_lsp,
icon = " LSP:",
},
{
"diagnostics",
sources = { "nvim_diagnostic" },
symbols = { error = "🆇 ", warn = "⚠️ ", info = " ", hint = "" },
},
},
lualine_y = {
"encoding",
{
"fileformat",
symbols = {
unix = "unix",
dos = "win",
mac = "mac",
},
},
"filetype",
},
lualine_z = {
{
trailing_space,
color = "WarningMsg",
},
{
mixed_indent,
color = "WarningMsg",
},
"progress"
},
},
inactive_sections = {
lualine_a = {},
lualine_b = {},
lualine_c = { "filename" },
lualine_x = { "location" },
lualine_y = {},
lualine_z = {},
},
tabline = {},
extensions = { "quickfix", "fugitive", "nvim-tree" },
}

View File

@@ -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)

View File

@@ -1,62 +1,92 @@
-- Setup nvim-cmp. -- Setup nvim-cmp.
local cmp = require'cmp' local cmp = require("cmp")
local lspkind = require'lspkind' local lspkind = require("lspkind")
cmp.setup({ cmp.setup {
snippet = { snippet = {
expand = function(args) expand = function(args)
-- For `ultisnips` user. -- For `ultisnips` user.
vim.fn["UltiSnips#Anon"](args.body) vim.fn["UltiSnips#Anon"](args.body)
end, end,
}, },
mapping = { mapping = cmp.mapping.preset.insert {
['<Tab>'] = function(fallback) ["<Tab>"] = function(fallback)
if cmp.visible() then if cmp.visible() then
cmp.select_next_item() cmp.select_next_item()
else else
fallback() fallback()
end end
end, end,
['<S-Tab>'] = function(fallback) ["<S-Tab>"] = function(fallback)
if cmp.visible() then if cmp.visible() then
cmp.select_prev_item() cmp.select_prev_item()
else else
fallback() fallback()
end end
end, end,
['<Esc>'] = cmp.mapping.close(), ["<CR>"] = cmp.mapping.confirm { select = true },
['<CR>'] = cmp.mapping.confirm({ select = true }), ["<C-e>"] = cmp.mapping.abort(),
['<C-d>'] = cmp.mapping.scroll_docs(-4), ["<Esc>"] = cmp.mapping.close(),
['<C-f>'] = cmp.mapping.scroll_docs(4), ["<C-d>"] = cmp.mapping.scroll_docs(-4),
["<C-f>"] = cmp.mapping.scroll_docs(4),
}, },
sources = { sources = {
{ name = 'nvim_lsp' }, -- For nvim-lsp { name = "nvim_lsp" }, -- For nvim-lsp
{ name = 'ultisnips' }, -- For ultisnips user. { name = "ultisnips" }, -- For ultisnips user.
{ name = 'nvim_lua' }, -- for nvim lua function { name = "path" }, -- for path completion
{ name = 'path' }, -- for path completion { name = "buffer", keyword_length = 2 }, -- for buffer word completion
{ name = 'buffer', keyword_length = 4 }, -- for buffer word completion
{ name = 'emoji', insert = true, } -- emoji completion
}, },
completion = { completion = {
keyword_length = 1, keyword_length = 1,
completeopt = "menu,noselect" completeopt = "menu,noselect",
}, },
experimental = { view = {
ghost_text = false entries = "custom",
}, },
formatting = { formatting = {
format = lspkind.cmp_format({ format = lspkind.cmp_format {
with_text = false, mode = "symbol_text",
menu = { menu = {
nvim_lsp = "[LSP]", nvim_lsp = "[LSP]",
ultisnips = "[US]", ultisnips = "[US]",
nvim_lua = "[Lua]",
path = "[Path]", path = "[Path]",
buffer = "[Buffer]", buffer = "[Buffer]",
emoji = "[Emoji]", emoji = "[Emoji]",
omni = "[Omni]",
}, },
}), show_labelDetails = true,
maxwidth = 40,
ellipsis_char = "...",
},
},
}
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
}, },
}) })
vim.cmd("hi link CmpItemMenu Comment") -- see https://github.com/hrsh7th/nvim-cmp/wiki/Menu-Appearance#how-to-add-visual-studio-code-dark-theme-colors-to-the-menu
vim.cmd([[
highlight! link CmpItemMenu Comment
" gray
highlight! CmpItemAbbrDeprecated guibg=NONE gui=strikethrough guifg=#808080
" blue
highlight! CmpItemAbbrMatch guibg=NONE guifg=#569CD6
highlight! CmpItemAbbrMatchFuzzy guibg=NONE guifg=#569CD6
" light blue
highlight! CmpItemKindVariable guibg=NONE guifg=#9CDCFE
highlight! CmpItemKindInterface guibg=NONE guifg=#9CDCFE
highlight! CmpItemKindText guibg=NONE guifg=#9CDCFE
" pink
highlight! CmpItemKindFunction guibg=NONE guifg=#C586C0
highlight! CmpItemKindMethod guibg=NONE guifg=#C586C0
" front
highlight! CmpItemKindKeyword guibg=NONE guifg=#D4D4D4
highlight! CmpItemKindProperty guibg=NONE guifg=#D4D4D4
highlight! CmpItemKindUnit guibg=NONE guifg=#D4D4D4
]])

View File

@@ -1,10 +1,10 @@
local nvim_notify = require("notify") local nvim_notify = require("notify")
nvim_notify.setup({ nvim_notify.setup {
-- Animation style -- Animation style
stages = "fade_in_slide_out", stages = "fade_in_slide_out",
-- Default timeout for notifications -- Default timeout for notifications
timeout = 1500, timeout = 1500,
background_colour = "#2E3440", background_colour = "#2E3440",
}) }
vim.notify = nvim_notify vim.notify = nvim_notify

View 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 = 2
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" },
},
}

108
lua/config/nvim-tree.lua Normal file
View File

@@ -0,0 +1,108 @@
local keymap = vim.keymap
local nvim_tree = require("nvim-tree")
nvim_tree.setup {
auto_reload_on_write = true,
disable_netrw = false,
hijack_netrw = true,
hijack_cursor = false,
hijack_unnamed_buffer_when_opening = false,
open_on_tab = false,
sort_by = "name",
update_cwd = false,
view = {
width = 30,
side = "left",
preserve_window_proportions = false,
number = false,
relativenumber = false,
signcolumn = "yes",
},
renderer = {
indent_markers = {
enable = false,
icons = {
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 = "",
args = {},
},
diagnostics = {
enable = false,
show_on_dirs = false,
icons = {
hint = "",
info = "",
warning = "",
error = "",
},
},
filters = {
dotfiles = false,
custom = {},
exclude = {},
},
git = {
enable = true,
ignore = true,
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" },
},
},
},
},
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,
},
},
}
keymap.set("n", "<space>s", require("nvim-tree.api").tree.toggle, {
silent = true,
desc = "toggle nvim-tree",
})

View File

@@ -1,10 +1,28 @@
vim.cmd[[ hi HopNextKey cterm=bold ctermfg=176 gui=bold guibg=#ff00ff guifg=#ffffff ]] local keymap = vim.keymap
vim.cmd[[ hi HopNextKey1 cterm=bold ctermfg=176 gui=bold guibg=#ff00ff guifg=#ffffff ]] local hop = require("hop")
vim.cmd[[ hi HopNextKey2 cterm=bold ctermfg=176 gui=bold guibg=#ff00ff guifg=#ffffff ]] hop.setup {
require('hop').setup({
case_insensitive = true, case_insensitive = true,
char2_fallback_key = '<CR>', 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
View 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",
})

View File

@@ -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'},
})

View File

@@ -1,8 +1,8 @@
require("nvim-treesitter.configs").setup({ require("nvim-treesitter.configs").setup {
ensure_installed = {"python", "cpp", "lua", "vim"}, ensure_installed = { "python", "cpp", "lua", "vim", "json", "toml" },
ignore_install = {}, -- List of parsers to ignore installing ignore_install = {}, -- List of parsers to ignore installing
highlight = { highlight = {
enable = true, -- false will disable the whole extension 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
}, },
}) }

View File

@@ -1,60 +1,6 @@
require("which-key").setup({ require("which-key").setup {
plugins = { preset = "modern",
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",
},
icons = { icons = {
breadcrumb = "»", -- symbol used in the command line area that shows your active key combo mappings = false
separator = "", -- symbol used between a key and it's label }
group = "+", -- symbol prepended to a group }
},
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
View 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)")

View File

@@ -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
},
},
})

275
lua/custom-autocmd.lua Normal file
View File

@@ -0,0 +1,275 @@
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.highlight.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,
callback = function(ev)
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,
})
-- Return to last cursor position when opening a file, note that here we cannot use BufReadPost
-- as event. It seems that when BufReadPost is triggered, FileType event is still not run.
-- So the filetype for this buffer is empty string.
api.nvim_create_autocmd("FileType", {
group = api.nvim_create_augroup("resume_cursor_position", { clear = true }),
pattern = "*",
callback = function(ev)
local mark_pos = api.nvim_buf_get_mark(ev.buf, '"')
local last_cursor_line = mark_pos[1]
local max_line = vim.fn.line("$")
local buf_filetype = api.nvim_get_option_value("filetype", { buf = ev.buf })
local buftype = api.nvim_get_option_value("buftype", { buf = ev.buf })
-- only handle normal files
if buf_filetype == "" or buftype ~= "" then
return
end
-- Only resume last cursor position when there is no go-to-line command (something like '+23').
if vim.fn.match(vim.v.argv, [[\v^\+(\d){1,}$]]) ~= -1 then
return
end
if last_cursor_line > 1 and last_cursor_line <= max_line then
-- vim.print(string.format("mark_pos: %s", vim.inspect(mark_pos)))
-- it seems that without vim.schedule, the cursor position can not be set correctly
vim.schedule(function()
local status, result = pcall(api.nvim_win_set_cursor, 0, mark_pos)
if not status then
api.nvim_err_writeln(string.format("Failed to resume cursor position. Context %s, error: %s",
vim.inspect(ev), result))
end
end)
-- the following two ways also seem to work,
-- ref: https://www.reddit.com/r/neovim/comments/104lc26/how_can_i_press_escape_key_using_lua/
-- vim.api.nvim_feedkeys("g`\"", "n", true)
-- vim.fn.execute("normal! g`\"")
end
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()
vim.cmd([[
" 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
]])
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",
callback = function(ev)
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 bf = fn.getbufvar(buf, '&filetype')
if fn.index(quit_filetypes, bf) == -1 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",
command = "call utils#Inside_git_repo()"
})
-- ref: https://vi.stackexchange.com/a/169/15292
api.nvim_create_autocmd("BufReadPre", {
group = api.nvim_create_augroup("large_file", { clear = true }),
pattern = "*",
desc = "check if we are inside Git repo",
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"
-- turning off relative number helps a lot
vim.wo.relativenumber = false
vim.bo.swapfile = false
vim.bo.bufhidden = "unload"
vim.bo.undolevels = -1
end
end
})

70
lua/globals.lua Normal file
View File

@@ -0,0 +1,70 @@
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 = "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
api.nvim_err_writeln("Python3 executable not found! You must install Python3 and set its PATH correctly!")
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

View File

@@ -1,5 +0,0 @@
-- Some utility stuff
require 'utils'
-- plugin installation
require 'plugins'

251
lua/mappings.lua Normal file
View File

@@ -0,0 +1,251 @@
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" })
-- Navigation in the location and quickfix list
keymap.set("n", "[l", "<cmd>lprevious<cr>zv", { silent = true, desc = "previous location item" })
keymap.set("n", "]l", "<cmd>lnext<cr>zv", { silent = true, desc = "next location item" })
keymap.set("n", "[L", "<cmd>lfirst<cr>zv", { silent = true, desc = "first location item" })
keymap.set("n", "]L", "<cmd>llast<cr>zv", { silent = true, desc = "last location item" })
keymap.set("n", "[q", "<cmd>cprevious<cr>zv", { silent = true, desc = "previous qf item" })
keymap.set("n", "]q", "<cmd>cnext<cr>zv", { silent = true, desc = "next qf item" })
keymap.set("n", "[Q", "<cmd>cfirst<cr>zv", { silent = true, desc = "first qf item" })
keymap.set("n", "]Q", "<cmd>clast<cr>zv", { silent = true, desc = "last qf item" })
-- 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" })
-- check the syntax group of current cursor position
keymap.set("n", "<leader>st", "<cmd>call utils#SynGroup()<cr>", { desc = "check syntax group" })
-- 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
View 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
{
"iguanacucumber/magazine.nvim",
name = "nvim-cmp",
-- event = 'InsertEnter',
event = "VeryLazy",
dependencies = {
"hrsh7th/cmp-nvim-lsp",
"onsails/lspkind-nvim",
"hrsh7th/cmp-path",
"hrsh7th/cmp-buffer",
"hrsh7th/cmp-omni",
"quangnguyen30192/cmp-nvim-ultisnips",
},
config = function()
require("config.nvim-cmp")
end,
},
{
"neovim/nvim-lspconfig",
event = { "BufRead", "BufNewFile" },
config = function()
require("config.lsp")
end,
},
{
"nvim-treesitter/nvim-treesitter",
enabled = function()
if vim.g.is_mac then
return true
end
return false
end,
event = "VeryLazy",
build = ":TSUpdate",
config = function()
require("config.treesitter")
end,
},
-- Python-related text object
{ "jeetsukumaran/vim-pythonsense", ft = { "python" } },
{ "machakann/vim-swap", event = "VeryLazy" },
-- IDE for Lisp
-- 'kovisoft/slimv'
{
"vlime/vlime",
enabled = function()
if utils.executable("sbcl") then
return true
end
return false
end,
config = function(plugin)
vim.opt.rtp:append(plugin.dir .. "/vim")
end,
ft = { "lisp" },
},
-- Super fast buffer jump
{
"smoka7/hop.nvim",
event = "VeryLazy",
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,
},
{
"Yggdroot/LeaderF",
cmd = "Leaderf",
build = function()
local leaderf_path = plugin_dir .. "/LeaderF"
vim.opt.runtimepath:append(leaderf_path)
vim.cmd("runtime! plugin/leaderf.vim")
if not vim.g.is_win then
vim.cmd("LeaderfInstallCExtension")
end
end,
},
"nvim-lua/plenary.nvim",
{
"nvim-telescope/telescope.nvim",
cmd = "Telescope",
dependencies = {
"nvim-telescope/telescope-symbols.nvim",
},
},
{
"ibhagwan/fzf-lua",
-- optional for icon support
dependencies = { "nvim-tree/nvim-web-devicons" },
config = function()
-- calling `setup` is optional for customization
require("fzf-lua").setup {}
end,
},
{
"MeanderingProgrammer/markdown.nvim",
main = "render-markdown",
opts = {},
dependencies = { "nvim-treesitter/nvim-treesitter", "nvim-tree/nvim-web-devicons" },
},
-- 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 },
{ "nvim-tree/nvim-web-devicons", event = "VeryLazy" },
{
"nvim-lualine/lualine.nvim",
event = "VeryLazy",
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,
},
{
"lukas-reineke/indent-blankline.nvim",
event = "VeryLazy",
main = "ibl",
config = function()
require("config.indent-blankline")
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 = "VeryLazy" },
-- notification plugin
{
"rcarriga/nvim-notify",
event = "VeryLazy",
config = function()
require("config.nvim-notify")
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.
{
"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()
if vim.g.is_win or vim.g.is_mac then
return true
else
return false
end
end,
dependencies = { "nvim-lua/plenary.nvim" },
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()
if utils.executable("ctags") then
return true
else
return false
end
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", event = "VeryLazy" },
-- Multiple cursor plugin like Sublime Text?
-- 'mg979/vim-visual-multi'
-- Autosave files on certain events
{ "907th/vim-auto-save", event = "InsertEnter" },
-- Show undo history visually
{ "simnalamburt/vim-mundo", cmd = { "MundoToggle", "MundoShow" } },
-- better UI for some nvim actions
{ "stevearc/dressing.nvim" },
-- Manage your yank history
{
"gbprod/yanky.nvim",
config = function()
require("config.yanky")
end,
event = "VeryLazy",
},
-- 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()
if vim.g.is_mac and utils.executable("xkbswitch") then
return true
end
return false
end,
event = { "InsertEnter" },
},
{
"Neur1n/neuims",
enabled = function()
if vim.g.is_win then
return true
end
return false
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 = "*", config = true },
{
"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,
},
-- Better git commit experience
{ "rhysd/committia.vim", lazy = true },
{
"sindrets/diffview.nvim",
},
{
"kevinhwang91/nvim-bqf",
ft = "qf",
config = function()
require("config.bqf")
end,
},
-- Another markdown plugin
{ "preservim/vim-markdown", ft = { "markdown" } },
-- Faster footnote generation
{ "vim-pandoc/vim-markdownfootnotes", ft = { "markdown" } },
-- Vim tabular plugin for manipulate tabular, required by markdown plugins
{ "godlygeek/tabular", cmd = { "Tabularize" } },
-- Markdown previewing (only for Mac and Windows)
{
"iamcco/markdown-preview.nvim",
enabled = function()
if vim.g.is_win or vim.g.is_mac then
return true
end
return false
end,
build = "cd app && npm install",
ft = { "markdown" },
},
{
"rhysd/vim-grammarous",
enabled = function()
if vim.g.is_mac then
return true
end
return false
end,
ft = { "markdown" },
},
{ "chrisbra/unicode.vim", event = "VeryLazy" },
-- 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" },
-- Add indent object for vim (useful for languages like Python)
{ "michaeljsmith/vim-indent-object", event = "VeryLazy" },
-- Only use these plugin on Windows and Mac and when LaTeX is installed
{
"lervag/vimtex",
enabled = function()
if utils.executable("latex") then
return true
end
return false
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()
if utils.executable("tmux") then
return true
end
return false
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()
local result = vim.g.is_win or vim.g.is_mac
return result
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()
if vim.g.is_win or vim.g.is_linux then
return true
end
return false
end,
build = { "bash install.sh" },
lazy = true,
},
-- Session management plugin
{ "tpope/vim-obsession", cmd = "Obsession" },
{
"ojroques/vim-oscyank",
enabled = function()
if vim.g.is_linux then
return true
end
return false
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,
},
-- show and trim trailing whitespaces
{ "jdhao/whitespace.nvim", event = "VeryLazy" },
-- file explorer
{
"nvim-tree/nvim-tree.lua",
event = "VeryLazy",
dependencies = { "nvim-tree/nvim-web-devicons" },
config = function()
require("config.nvim-tree")
end,
},
{
"j-hui/fidget.nvim",
event = "VeryLazy",
tag = "legacy",
config = function()
require("config.fidget-nvim")
end,
},
{
"folke/lazydev.nvim",
ft = "lua", -- only load on lua files
opts = {},
},
{
"CopilotC-Nvim/CopilotChat.nvim",
branch = "canary",
dependencies = {
{ "zbirenbaum/copilot.lua" }, -- or github/copilot.vim
{ "nvim-lua/plenary.nvim" }, -- for curl, log wrapper
},
opts = {
debug = true, -- Enable debugging
-- See Configuration section for rest
},
-- See Commands section for default commands if you want to lazy load on them
},
{
"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,
event = "VeryLazy",
},
}
require("lazy").setup {
spec = plugin_specs,
ui = {
border = "rounded",
title = "Plugin Manager",
title_pos = "center",
},
rocks = {
enabled = false,
},
}

View File

@@ -1,368 +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 plug_url_format = ""
if vim.g.is_linux then
plug_url_format = "https://hub.fastgit.org/%s"
else
plug_url_format = "https://github.com/%s"
end
local packer_repo = string.format(plug_url_format, "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 = "BufEnter"}
-- 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-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({ "kevinhwang91/nvim-bqf", event = "FileType 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'}
end,
config = {
max_jobs = 16,
compile_path = util.join_paths(vim.fn.stdpath('config'), 'lua', 'packer_compiled.lua'),
git = {
default_url_format = plug_url_format,
},
},
})
local status, _ = pcall(require, 'packer_compiled')
if not status then
vim.notify("Error requiring packer_compiled.lua: run PackerSync to fix!")
end

View File

@@ -1,17 +1,82 @@
-- inspect something local fn = vim.fn
-- Taken from https://github.com/jamestthompson3/vimConfig/blob/eeef4a8eeb5a24938f8a0969a35f69c78643fb66/lua/tt/nvim_utils.lua#L106 local version = vim.version
function inspect(item)
print(vim.inspect(item))
end
local M = {} local M = {}
function M.executable(name) function M.executable(name)
if vim.fn.executable(name) > 0 then if fn.executable(name) > 0 then
return true return true
end end
return false return false
end 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
--- Create a dir if it does not exist
function M.may_create_dir(dir)
local res = fn.isdirectory(dir)
if res == 0 then
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_err_writeln(msg)
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_err_writeln(msg)
end
return true
end
return M return M

View File

@@ -8,6 +8,7 @@ snippet bare "barebone code template"
#include <unordered_set> #include <unordered_set>
#include <stack> #include <stack>
#include <queue> #include <queue>
#include <numeric>
using std::cout; using std::cout;
using std::endl; using std::endl;

View File

@@ -47,7 +47,7 @@ $0
endsnippet endsnippet
snippet font "HTML font tag" snippet font "HTML font tag"
<font color="${1:red}">${2:TEXT}</font> <font color="${1:blue}">${2:TEXT}</font>
endsnippet endsnippet
snippet link "Markdown links" snippet link "Markdown links"
@@ -70,3 +70,99 @@ endsnippet
snippet yh "直角引号" w snippet yh "直角引号" w
「$1」 「$1」
endsnippet endsnippet
snippet info "info box"
<style type="text/css">
@import url('//maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css');
.info-msg {
color: #059;
background-color: #BEF;
margin: 5px 0;
margin-bottom: 20px;
padding: 10px;
border-radius: 5px 5px 5px 5px;
border: 2px solid transparent;
border-color: transparent;
}
</style>
<div class="info-msg">
<i class="fa fa-info-circle"> Info</i></br>
${1:info text}
</div>
$0
endsnippet
snippet warn "warning box"
<style type="text/css">
@import url('//maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css');
.warning-msg {
color: #9F6000;
background-color: #FEEFB3;
margin: 5px 0;
margin-bottom: 20px;
padding: 10px;
border-radius: 5px 5px 5px 5px;
border: 2px solid transparent;
border-color: transparent;
}
</style>
<div class="warning-msg">
<i class="fa fa-warning"> Warning</i></br>
${1:warning text}
</div>
$0
endsnippet
snippet error "error box"
<style type="text/css">
@import url('//maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css');
.error-msg {
color: #D8000C;
background-color: #FFBABA;
margin: 5px 0;
margin-bottom: 20px;
padding: 10px;
border-radius: 5px 5px 5px 5px;
border: 2px solid transparent;
border-color: transparent;
}
</style>
<div class="error-msg">
<i class="fa fa-times-circle"> Error</i></br>
${1:error text}
</div>
$0
endsnippet
snippet success "success box"
<style type="text/css">
@import url('//maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css');
.success-msg {
color: #270;
background-color: #DFF2BF;
margin: 5px 0;
margin-bottom: 20px;
padding: 10px;
border-radius: 5px 5px 5px 5px;
border: 2px solid transparent;
border-color: transparent;
}
</style>
<div class="success-msg">
<i class="fa fa-check"></i>
${1:success text}
</div>
$0
endsnippet
snippet td "too long do not read" bw
tl;dr: $1
endsnippet

View File

@@ -24,3 +24,7 @@ def main():
if __name__ == "__main__": if __name__ == "__main__":
main() main()
endsnippet endsnippet
snippet sol "solution" b
solution = Solution()
endsnippet

View File

@@ -0,0 +1,6 @@
# copied from https://github.com/honza/vim-snippets/blob/master/UltiSnips/snippets.snippets
snippet snip "Ultisnips snippet definition" b
`!p snip.rv = "snippet"` ${1:Tab_trigger} "${2:Description}" ${3:b}
${0:${VISUAL}}
`!p snip.rv = "endsnippet"`
endsnippet

View File

@@ -1,3 +1,9 @@
snippet frac "Math fractions" snippet use "usepackage" b
\frac{${1:NUM}}{${2:DEN}} $0 \usepackage{${1:package}}
endsnippet
snippet eqa "equation environment" b
\begin{equation}\label{$1}
$2
\end{equation}
endsnippet endsnippet

3
plugin/abbrev.vim Normal file
View File

@@ -0,0 +1,3 @@
" some abbreviations
iabbrev reqire require
iabbrev serveral several

View File

@@ -8,3 +8,43 @@ call utils#Cabbrev('man', 'Man')
" show current date and time in human readable format " show current date and time in human readable format
command! -nargs=? Datetime echo utils#iso_time(<q-args>) 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
" json format
command! -range JSONFormat <line1>,<line2>!python -m json.tool

119
plugin/log-autocmds.vim Normal file
View File

@@ -0,0 +1,119 @@
command! LogAutocmds call s:log_autocmds_toggle()
function! s:log_autocmds_toggle()
augroup LogAutocmd
autocmd!
augroup END
let l:date = strftime('%F', localtime())
let s:activate = get(s:, 'activate', 0) ? 0 : 1
if !s:activate
call s:log('Stopped autocmd log (' . l:date . ')')
return
endif
call s:log('Started autocmd log (' . l:date . ')')
augroup LogAutocmd
for l:au in s:aulist
silent execute 'autocmd' l:au '* call s:log(''' . l:au . ''')'
endfor
augroup END
endfunction
function! s:log(message)
silent execute '!echo "'
\ . strftime('%T', localtime()) . ' - ' . a:message . '"'
\ '>> /tmp/vim_log_autocommands'
endfunction
" These are deliberately left out due to side effects
" - SourceCmd
" - FileAppendCmd
" - FileWriteCmd
" - BufWriteCmd
" - FileReadCmd
" - BufReadCmd
" - FuncUndefined
let s:aulist = [
\ 'BufNewFile',
\ 'BufReadPre',
\ 'BufRead',
\ 'BufReadPost',
\ 'FileReadPre',
\ 'FileReadPost',
\ 'FilterReadPre',
\ 'FilterReadPost',
\ 'StdinReadPre',
\ 'StdinReadPost',
\ 'BufWrite',
\ 'BufWritePre',
\ 'BufWritePost',
\ 'FileWritePre',
\ 'FileWritePost',
\ 'FileAppendPre',
\ 'FileAppendPost',
\ 'FilterWritePre',
\ 'FilterWritePost',
\ 'BufAdd',
\ 'BufCreate',
\ 'BufDelete',
\ 'BufWipeout',
\ 'BufFilePre',
\ 'BufFilePost',
\ 'BufEnter',
\ 'BufLeave',
\ 'BufWinEnter',
\ 'BufWinLeave',
\ 'BufUnload',
\ 'BufHidden',
\ 'BufNew',
\ 'SwapExists',
\ 'FileType',
\ 'Syntax',
\ 'EncodingChanged',
\ 'TermChanged',
\ 'VimEnter',
\ 'GUIEnter',
\ 'GUIFailed',
\ 'TermResponse',
\ 'QuitPre',
\ 'VimLeavePre',
\ 'VimLeave',
\ 'FileChangedShell',
\ 'FileChangedShellPost',
\ 'FileChangedRO',
\ 'ShellCmdPost',
\ 'ShellFilterPost',
\ 'CmdUndefined',
\ 'SpellFileMissing',
\ 'SourcePre',
\ 'VimResized',
\ 'FocusGained',
\ 'FocusLost',
\ 'CursorHold',
\ 'CursorHoldI',
\ 'CursorMoved',
\ 'CursorMovedI',
\ 'WinEnter',
\ 'WinLeave',
\ 'TabEnter',
\ 'TabLeave',
\ 'CmdwinEnter',
\ 'CmdwinLeave',
\ 'InsertEnter',
\ 'InsertChange',
\ 'InsertLeave',
\ 'InsertCharPre',
\ 'TextChanged',
\ 'TextChangedI',
\ 'ColorScheme',
\ 'RemoteReply',
\ 'QuickFixCmdPre',
\ 'QuickFixCmdPost',
\ 'SessionLoadPost',
\ 'MenuPopup',
\ 'CompleteDone',
\ 'User',
\ ]

78
resources/head.tex Normal file
View 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}

View File

@@ -194,7 +194,6 @@ wiki
backticks backticks
Reddit Reddit
LeaderF LeaderF
gruvbox8
tabpage tabpage
ccls ccls
cmake cmake
@@ -203,6 +202,8 @@ llvm
subsampling subsampling
refactor refactor
colorschemes colorschemes
gruvbox8
gruvbox
Gruvbox Gruvbox
monokai monokai
NeoSolarized NeoSolarized
@@ -355,3 +356,117 @@ Keymap
iCloud iCloud
keyframe keyframe
maskRCNN maskRCNN
vundle
ycm
ftplugin
vim9
dotfile
magit
xelatex
subarray
fvim
CUDA
cuda
cpu
jdhao
whitelisted
BST
autocmd
init
miniconda
tsinghua
pylsp
mypy
isort
ustc
PyTorch
maxcdn
torchvision
FFmpeg
pyav
wezterm
frac
argmax
NeruIPS
InfoNCE
LSTM
linkedin
hotmail
datetime
csv
iterable
dataframe
CRNN
ICPR
matplotlib
scikit
NumPy
cudnn
SGD
ImageNet
ReLU
CIFAR
ResNet
XGBoost
Shenzhen
Tanh
Kaggle
minist
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

View File

@@ -1,15 +1,14 @@
scriptencoding utf-8 scriptencoding utf-8
" change fillchars for folding, vertical split, end of buffer, and message separator " change fillchars for folding, vertical split, end of buffer, and message separator
set fillchars=fold:\ ,vert:\│,eob:\ ,msgsep:‾ set fillchars=fold:\ ,foldsep:\ ,foldopen:,foldclose:,vert:\│,eob:\ ,msgsep:‾,diff:
" 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>
" Split window below/right when creating horizontal/vertical windows " Split window below/right when creating horizontal/vertical windows
set splitbelow splitright set splitbelow splitright
" avoid the flickering when splitting window horizontal
set splitkeep=screen
" Time in milliseconds to wait for a mapped sequence to complete, " Time in milliseconds to wait for a mapped sequence to complete,
" see https://unix.stackexchange.com/q/36882/221410 for more info " see https://unix.stackexchange.com/q/36882/221410 for more info
set timeoutlen=500 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 set backupcopy=yes " copy the original file to backupdir and overwrite it
" General tab settings " General tab settings
set tabstop=4 " number of visual spaces per TAB set tabstop=2 " number of visual spaces per TAB
set softtabstop=4 " number of spaces in tab when editing set softtabstop=2 " number of spaces in tab when editing
set shiftwidth=4 " number of spaces to use for autoindent set shiftwidth=2 " number of spaces to use for autoindent
set expandtab " expand tab to spaces so that tabs are spaces set expandtab " expand tab to spaces so that tabs are spaces
" Set matching pairs of characters and highlight matching brackets " Set matching pairs of characters and highlight matching brackets
@@ -75,6 +74,7 @@ set scrolloff=3
" Use mouse to select and resize windows, etc. " Use mouse to select and resize windows, etc.
set mouse=nic " Enable mouse in several mode set mouse=nic " Enable mouse in several mode
set mousemodel=popup " Set the behaviour of mouse 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. " Disable showing current mode on command line since statusline plugins can show it.
set noshowmode set noshowmode
@@ -112,15 +112,18 @@ set shortmess+=c
" choice, IMHO. " choice, IMHO.
set shortmess+=S set shortmess+=S
" Disable showing intro message (:intro)
set shortmess+=I
" Completion behaviour " Completion behaviour
" set completeopt+=noinsert " Auto select the first completion entry " set completeopt+=noinsert " Auto select the first completion entry
set completeopt+=menuone " Show menu even if there is only one item set completeopt+=menuone " Show menu even if there is only one item
set completeopt-=preview " Disable the preview window set completeopt-=preview " Disable the preview window
set pumheight=10 " Maximum number of items to show in popup menu 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
" Insert mode key word completion setting " Insert mode key word completion setting
set complete+=kspell complete-=w complete-=b complete-=u complete-=t set complete+=kspell complete-=w complete-=b complete-=u complete-=t
@@ -141,7 +144,7 @@ set formatoptions+=mM
" Tilde (~) is an operator, thus must be followed by motions like `e` or `w`. " Tilde (~) is an operator, thus must be followed by motions like `e` or `w`.
set tildeop 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 set nostartofline
" External program to use for grep command " External program to use for grep command
@@ -159,7 +162,7 @@ set termguicolors
" https://github.com/neovim/neovim/wiki/FAQ#how-to-change-cursor-color-in-the-terminal " 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 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 " Remove certain character from file name pattern matching
set isfname-== set isfname-==
@@ -172,5 +175,7 @@ set diffopt+=filler " show filler for deleted lines
set diffopt+=closeoff " turn off diff when one file window is closed set diffopt+=closeoff " turn off diff when one file window is closed
set diffopt+=context:3 " context for diff set diffopt+=context:3 " context for diff
set diffopt+=internal,indent-heuristic,algorithm:histogram set diffopt+=internal,indent-heuristic,algorithm:histogram
set diffopt+=linematch:60
set nowrap " do no wrap set nowrap " do no wrap
set noruler

View File

@@ -1,16 +1,20 @@
scriptencoding utf-8 scriptencoding utf-8
" Plugin specification and lua stuff " Plugin specification and lua stuff
lua require('lua-init') lua require('plugin_specs')
" Use short names for common plugin manager commands to simplify typing. " Use short names for common plugin manager commands to simplify typing.
" To use these shortcuts: first activate command line with `:`, then input the " 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 " short alias, e.g., `pi`, then press <space>, the alias will be expanded to
" the full command automatically. " the full command automatically.
call utils#Cabbrev('pi', 'PackerInstall') call utils#Cabbrev('pi', 'Lazy install')
call utils#Cabbrev('pud', 'PackerUpdate') call utils#Cabbrev('pud', 'Lazy update')
call utils#Cabbrev('pc', 'PackerClean') call utils#Cabbrev('pc', 'Lazy clean')
call utils#Cabbrev('ps', 'PackerSync') call utils#Cabbrev('ps', 'Lazy sync')
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" configurations for vim script plugin "
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"""""""""""""""""""""""""UltiSnips settings""""""""""""""""""" """""""""""""""""""""""""UltiSnips settings"""""""""""""""""""
" Trigger configuration. Do not use <tab> if you use YouCompleteMe " Trigger configuration. Do not use <tab> if you use YouCompleteMe
@@ -27,13 +31,6 @@ let g:UltiSnipsJumpBackwardTrigger='<c-k>'
" https://jdhao.github.io/2019/04/17/neovim_snippet_s1/ for details. " https://jdhao.github.io/2019/04/17/neovim_snippet_s1/ for details.
let g:UltiSnipsSnippetDirectories=['UltiSnips', 'my_snippets'] let g:UltiSnipsSnippetDirectories=['UltiSnips', 'my_snippets']
"""""""""""""""""""""""""" semshi settings """""""""""""""""""""""""""""""
" Do not highlight for all occurrences of variable under cursor
let g:semshi#mark_selected_nodes=0
" Do not show error sign since linting plugin is specialized for that
let g:semshi#error_sign=v:false
"""""""""""""""""""""""""" vlime settings """""""""""""""""""""""""""""""" """""""""""""""""""""""""" vlime settings """"""""""""""""""""""""""""""""
command! -nargs=0 StartVlime call jobstart(printf("sbcl --load %s/vlime/lisp/start-vlime.lisp", g:package_home)) command! -nargs=0 StartVlime call jobstart(printf("sbcl --load %s/vlime/lisp/start-vlime.lisp", g:package_home))
@@ -45,7 +42,7 @@ let g:Lf_UseMemoryCache = 0
" Ignore certain files and directories when searching files " Ignore certain files and directories when searching files
let g:Lf_WildIgnore = { let g:Lf_WildIgnore = {
\ 'dir': ['.git', '__pycache__', '.DS_Store'], \ 'dir': ['.git', '__pycache__', '.DS_Store', '*_cache'],
\ 'file': ['*.exe', '*.dll', '*.so', '*.o', '*.pyc', '*.jpg', '*.png', \ 'file': ['*.exe', '*.dll', '*.so', '*.o', '*.pyc', '*.jpg', '*.png',
\ '*.gif', '*.svg', '*.ico', '*.db', '*.tgz', '*.tar.gz', '*.gz', \ '*.gif', '*.svg', '*.ico', '*.db', '*.tgz', '*.tar.gz', '*.gz',
\ '*.zip', '*.bin', '*.pptx', '*.xlsx', '*.docx', '*.pdf', '*.tmp', \ '*.zip', '*.bin', '*.pptx', '*.xlsx', '*.docx', '*.pdf', '*.tmp',
@@ -59,17 +56,7 @@ if g:is_linux
endif endif
" Only fuzzy-search files names " Only fuzzy-search files names
let g:Lf_DefaultMode = 'NameOnly' 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 " Do not use version control tool to list files under a directory since
" submodules are not searched by default. " submodules are not searched by default.
@@ -96,17 +83,15 @@ nnoremap <silent> <leader>fg :<C-U>Leaderf rg --no-messages --popup<CR>
" Search vim help files " Search vim help files
nnoremap <silent> <leader>fh :<C-U>Leaderf help --popup<CR> nnoremap <silent> <leader>fh :<C-U>Leaderf help --popup<CR>
nnoremap <silent> <leader>h :<C-U>echoerr "Use \<lt>leader>fh instead!"<CR>
" Search tags in current buffer " Search tags in current buffer
nnoremap <silent> <leader>ft :<C-U>Leaderf bufTag --popup<CR> nnoremap <silent> <leader>ft :<C-U>Leaderf bufTag --popup<CR>
nnoremap <silent> <leader>t :<C-U>echoerr "Use \<lt>leader>ft instead!"<CR>
" Switch buffers " Switch buffers
nnoremap <silent> <leader>fb :<C-U>Leaderf buffer --popup<CR> nnoremap <silent> <leader>fb :<C-U>Leaderf buffer --popup<CR>
" Search recent files " Search recent files
nnoremap <silent> <leader>fr :<C-U>Leaderf mru --popup<CR> nnoremap <silent> <leader>fr :<C-U>Leaderf mru --popup --absolute-path<CR>
let g:Lf_PopupColorscheme = 'gruvbox_material' let g:Lf_PopupColorscheme = 'gruvbox_material'
@@ -114,15 +99,19 @@ let g:Lf_PopupColorscheme = 'gruvbox_material'
" items. " items.
let g:Lf_CommandMap = {'<C-J>': ['<C-N>'], '<C-K>': ['<C-P>']} let g:Lf_CommandMap = {'<C-J>': ['<C-N>'], '<C-K>': ['<C-P>']}
""""""""""""""""""""""""""""open-browser.vim settings""""""""""""""""""" " do not preview results, it will add the file to buffer list
if g:is_win || g:is_mac let g:Lf_PreviewResult = {
" Disable netrw's gx mapping. \ 'File': 0,
let g:netrw_nogx = 1 \ 'Buffer': 0,
\ 'Mru': 0,
" Use another mapping for the open URL method \ 'Tag': 0,
nmap ob <Plug>(openbrowser-smart-search) \ 'BufTag': 1,
xmap ob <Plug>(openbrowser-smart-search) \ 'Function': 1,
endif \ 'Line': 0,
\ 'Colorscheme': 0,
\ 'Rg': 0,
\ 'Gtags': 0
\}
""""""""""""""""""""""""""" vista settings """""""""""""""""""""""""""""""""" """"""""""""""""""""""""""" vista settings """"""""""""""""""""""""""""""""""
let g:vista#renderer#icons = { let g:vista#renderer#icons = {
@@ -142,31 +131,6 @@ let g:mundo_width = 80
nnoremap <silent> <Space>u :MundoToggle<CR> 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""""""""""""""""""""""""" """"""""""""""""""""""""""""better-escape.vim settings"""""""""""""""""""""""""
let g:better_escape_interval = 200 let g:better_escape_interval = 200
@@ -187,23 +151,7 @@ let g:neoformat_c_clangformat = {
let g:neoformat_enabled_cpp = ['clangformat'] let g:neoformat_enabled_cpp = ['clangformat']
let g:neoformat_enabled_c = ['clangformat'] let g:neoformat_enabled_c = ['clangformat']
"""""""""""""""""""""""""vim-signify settings"""""""""""""""""""""""""""""" """""""""""""""""""""""""vim-markdown 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 " Disable header folding
let g:vim_markdown_folding_disabled = 1 let g:vim_markdown_folding_disabled = 1
@@ -264,8 +212,8 @@ nmap s <Nop>
omap s <Nop> omap s <Nop>
""""""""""""""""""""""""""""vimtex settings""""""""""""""""""""""""""""" """"""""""""""""""""""""""""vimtex settings"""""""""""""""""""""""""""""
if ( g:is_win || g:is_mac ) && executable('latex') if executable('latex')
" Hacks for inverse serach to work semi-automatically, " Hacks for inverse search to work semi-automatically,
" see https://jdhao.github.io/2021/02/20/inverse_search_setup_neovim_vimtex/. " see https://jdhao.github.io/2021/02/20/inverse_search_setup_neovim_vimtex/.
function! s:write_server_name() abort function! s:write_server_name() abort
let nvim_server_file = (has('win32') ? $TEMP : '/tmp') . '/vimtexserver.txt' let nvim_server_file = (has('win32') ? $TEMP : '/tmp') . '/vimtexserver.txt'
@@ -297,7 +245,6 @@ if ( g:is_win || g:is_mac ) && executable('latex')
" Viewer settings for different platforms " Viewer settings for different platforms
if g:is_win if g:is_win
let g:vimtex_view_general_viewer = 'SumatraPDF' 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' let g:vimtex_view_general_options = '-reuse-instance -forward-search @tex @line @pdf'
endif endif
@@ -326,11 +273,6 @@ if ( g:is_win || g:is_mac ) && executable('latex')
endif endif
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""""""""""""""""""""""""""""" """"""""""""""""""""""""""""vim-matchup settings"""""""""""""""""""""""""""""
" Improve performance " Improve performance
let g:matchup_matchparen_deferred = 1 let g:matchup_matchparen_deferred = 1
@@ -377,9 +319,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 augroup firenvim
autocmd! 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 augroup END
endif endif
@@ -387,21 +340,17 @@ endif
nnoremap <leader>dp :<C-U>GdbStartPDB python -m pdb %<CR> nnoremap <leader>dp :<C-U>GdbStartPDB python -m pdb %<CR>
""""""""""""""""""""""""""""""wilder.nvim settings"""""""""""""""""""""""""""""" """"""""""""""""""""""""""""""wilder.nvim settings""""""""""""""""""""""""""""""
augroup wilder_init call timer_start(250, { -> s:wilder_init() })
autocmd!
" CursorHold is suggested here: https: //github.com/gelguy/wilder.nvim/issues/89#issuecomment-934465957.
autocmd CursorHold * ++once call s:wilder_init()
augroup END
function! s:wilder_init() abort function! s:wilder_init() abort
try try
call wilder#enable_cmdline_enter() call wilder#setup({
set wildcharm=<Tab> \ 'modes': [':', '/', '?'],
cmap <expr> <Tab> wilder#in_context() ? wilder#next() : "\<Tab>" \ 'next_key': '<Tab>',
cmap <expr> <S-Tab> wilder#in_context() ? wilder#previous() : "\<S-Tab>" \ 'previous_key': '<S-Tab>',
\ 'accept_key': '<C-y>',
" only / and ? are enabled by default \ 'reject_key': '<C-e>'
call wilder#set_option('modes', ['/', '?', ':']) \ })
call wilder#set_option('pipeline', [ call wilder#set_option('pipeline', [
\ wilder#branch( \ wilder#branch(
@@ -423,14 +372,18 @@ function! s:wilder_init() abort
let l:hl = wilder#make_hl('WilderAccent', 'Pmenu', [{}, {}, {'foreground': '#f4468f'}]) let l:hl = wilder#make_hl('WilderAccent', 'Pmenu', [{}, {}, {'foreground': '#f4468f'}])
call wilder#set_option('renderer', wilder#popupmenu_renderer({ call wilder#set_option('renderer', wilder#popupmenu_renderer({
\ 'highlighter': wilder#basic_highlighter(), \ 'highlighter': wilder#basic_highlighter(),
\ 'winblend': 5,
\ 'max_height': 15, \ 'max_height': 15,
\ 'highlights': { \ 'highlights': {
\ 'accent': l:hl, \ 'accent': l:hl,
\ }, \ },
\ 'left': [' ', wilder#popupmenu_devicons(),],
\ 'right': [' ', wilder#popupmenu_scrollbar(),],
\ 'apply_incsearch_fix': 0, \ 'apply_incsearch_fix': 0,
\ })) \ }))
catch /^Vim\%((\a\+)\)\=:E117/ 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 endtry
endfunction endfunction
""""""""""""""""""""""""""""""vim-auto-save settings""""""""""""""""""""""""""""""
let g:auto_save = 1 " enable AutoSave on Vim startup