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

200 Commits

Author SHA1 Message Date
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
jdhao
092ea88703 bump minimum supported nvim version to 0.6.1 2022-01-02 11:26:32 +08:00
jdhao
67d59bfc2c docs: add section on custom commands 2021-12-31 12:30:23 +08:00
jdhao
77a5dfacd6 fix: broken link in README 2021-12-31 12:17:51 +08:00
jdhao
1373c418b9 restore reg content after using it 2021-12-30 23:39:42 +08:00
jdhao
e82b450464 split command output to list of string and set the buffer 2021-12-30 23:39:03 +08:00
jdhao
08818dbf01 remove logging 2021-12-30 23:38:49 +08:00
jdhao
0ed8814aef fix: command output captured by a register not formatted properly
Newline is converted to NUL character, which is nasty, see also https://vi.stackexchange.com/q/6697/15292.
2021-12-30 22:33:39 +08:00
jdhao
a86f1d2f31 refactor: capture command output silently 2021-12-30 22:33:06 +08:00
jdhao
c1b27ee818 fix url link in README 2021-12-29 23:34:59 +08:00
jdhao
7eb7b4450f update README 2021-12-29 23:33:07 +08:00
jdhao
5443078805 g:mapleader 2021-12-29 00:42:00 +08:00
jdhao
dcffbf9a71 fix: lsp reference highlight isn't correctly linked
! is need to overwrite possible existing highlight group of the same
name.
2021-12-28 23:49:43 +08:00
jdhao
85de00f374 refactor: resume edit position --> resume cursor position 2021-12-28 00:11:10 +08:00
jdhao
9adc3fdf16 remove double quotes for snippet trigger 2021-12-23 22:41:16 +08:00
jdhao
6cf31e2dcb add colorscheme kanagawa 2021-12-23 22:36:29 +08:00
jdhao
08d3d7ec08 fix bug in go to last edit position
If a go-to-line command is given, do not go to last edit position for
the file.
2021-12-20 22:15:34 +08:00
jdhao
ed52ca5914 add ref for checking IME state 2021-12-19 20:54:13 +08:00
jdhao
1d0609f753 change SPELL location on statusline 2021-12-19 20:53:09 +08:00
jdhao
56a43e4009 show IME on statusline on macOS 2021-12-19 20:52:23 +08:00
jdhao
22c7c6ee05 update plugin.lua 2021-12-19 19:55:00 +08:00
jdhao
3d0f00e7e4 update README 2021-12-16 23:31:13 +08:00
jdhao
bbd642af1a renaming variables 2021-12-15 00:21:34 +08:00
jdhao
5215a601b9 update fold conf for vim script
When setting foldlevel to 0 and load some plugin via InsertEnter event
using packer.nvim, if we press i to go to insert mode, the fold for vim
script file will be automatically closed. It is really annoying.

I have pinpoint the issue to the combination of packer.nvim and setting
foldlevel to 0 in after/ftplugin/vim.vim. What is interesting is that
default value for foldlevel is also 0. However, if we do not set it in
vim.vim, the above issue won't occur, which is strange.
2021-12-14 21:48:58 +08:00
jdhao
9bac7fa4f7 refactor: remove folding for init.vim 2021-12-14 21:47:59 +08:00
jdhao
06910bac87 remove plugin vim-cool
nvim-hlslens can replace it if calm_down option is enabled.
2021-12-12 17:30:11 +08:00
jdhao
85427c6424 remove plugin semshi 2021-12-12 16:47:58 +08:00
jdhao
cf9761e9a3 update plugin load condition 2021-12-11 18:15:24 +08:00
jdhao
7d3647ac61 remove oo and OO normal mode mapping 2021-12-11 15:47:15 +08:00
jdhao
a466339092 update nvim-hlslens settings 2021-12-11 15:46:25 +08:00
jdhao
6fb30f0cf2 use en_US.utf-8 as default 2021-12-10 22:52:03 +08:00
jdhao
9b41825c2c update lualine conf
diagnostic interface change
2021-12-10 22:51:06 +08:00
jdhao
e9319b0460 update README 2021-12-10 00:48:19 +08:00
jdhao
49596fb5ab update README 2021-12-09 21:41:59 +08:00
48 changed files with 1551 additions and 545 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
*.exe
.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"
no_call_parentheses = true

View File

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

207
README.md
View File

@@ -1,34 +1,62 @@
```
███ ██ ██ ██ ██ ███ ███ ██████ ██████ ███ ██ ███████ ██ ██████
████ ██ ██ ██ ██ ████ ████ ██ ██ ██ ████ ██ ██ ██ ██
██ ██ ██ ██ ██ ██ ██ ████ ██ ██ ██ ██ ██ ██ ██ █████ ██ ██ ███
██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
██ ████ ████ ██ ██ ██ ██████ ██████ ██ ████ ██ ██ ██████
```
<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>
<a>
<img alt="Windows" src="https://img.shields.io/badge/Windows-%23.svg?style=flat-square&logo=windows&color=0078D6&logoColor=white" />
</a>
<a href="https://github.com/jdhao/nvim-config/commits">
<img src="https://badgen.net/github/commits/jdhao/nvim-config" alt="Commit number" />
</a>
<a href="https://github.com/jdhao/nvim-config/network">
<img alt="Forks" src="https://badgen.net/github/forks/jdhao/nvim-config">
</a>
<a href="https://github.com/jdhao/nvim-config/stargazers">
<img alt="Stars" src="https://badgen.net/github/stars/jdhao/nvim-config">
</a>
<a href="https://github.com/jdhao/nvim-config/releases/latest">
<img alt="Latest release" src="https://img.shields.io/github/v/release/jdhao/nvim-config" />
</a>
<a href="https://github.com/neovim/neovim/releases/tag/stable">
<img src="https://img.shields.io/badge/Neovim-0.7.2-blueviolet.svg?style=flat-square&logo=Neovim&logoColor=green" alt="Neovim minimum version"/>
</a>
<a href="https://github.com/jdhao/nvim-config/search?l=vim-script">
<img src="https://img.shields.io/github/languages/top/jdhao/nvim-config" alt="Top languages"/>
</a>
<a href="https://github.com/jdhao/nvim-config/blob/master/LICENSE">
<img src="https://img.shields.io/github/license/jdhao/nvim-config?style=flat-square&logo=GNU&label=License" alt="License"/>
</a>
</p>
</div>
# Introduction
This repo hosts my Nvim configuration for all the platforms I am using (Linux,
Windows and macOS). `init.vim` is the config entry point for terminal Nvim,
and `ginit.vim` is the additional config file for GUI client of Nvim (I am
using [neovim-qt](https://github.com/equalsraf/neovim-qt) for now on Windows).
This repo hosts my Nvim configuration for Linux, macOS, and Windows.
`init.lua` is the config entry point for terminal Nvim,
and `ginit.vim` is the additional config file for [GUI client of Nvim](https://github.com/neovim/neovim/wiki/Related-projects#gui).
My configurations are heavily documented to make it as clear as possible. While
you can download the whole repository and use it, it is not recommended though.
Good configurations are personal. Everyone should have his or her unique config
file. You are encouraged to copy from this repo the part you feel useful and
add it to your own Nvim config.
My configurations are heavily documented to make it as clear as possible.
While you can clone the whole repository and use it, it is not recommended though.
Good configurations are personal. Everyone should have his or her unique config file.
You are encouraged to copy from this repo the part you want and add it to your own config.
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).
To reduce the possibility of breakage, **this config is only maintained for [the latest nvim stable release](https://github.com/neovim/neovim/releases/tag/stable).
No effort is spent on maintaining backward compatibility.**
**This config is tested against [Nvim 0.6.0 release](https://github.com/neovim/neovim/releases/tag/v0.6.0). No backward compatibility
is guaranteed.**
# Install and setup
See [doc here](docs/README.md) on how to install Nvim's dependencies, Nvim itself,
and how to set up on different platforms (Linux, macOS, and Windows).
# Features #
+ Plugin management via [Packer.nvim](https://github.com/wbthomason/packer.nvim).
+ Code auto-completion via [nvim-cmp](https://github.com/hrsh7th/nvim-cmp) and [nvim-lspconfig](https://github.com/neovim/nvim-lspconfig).
+ Code, snippet, word auto-completion via [nvim-cmp](https://github.com/hrsh7th/nvim-cmp).
+ Language server protocol (LSP) support via [nvim-lspconfig](https://github.com/neovim/nvim-lspconfig).
+ Git integration via [vim-fugitive](https://github.com/tpope/vim-fugitive).
+ Better escaping from insert mode via [better-escape.vim](https://github.com/jdhao/better-escape.vim).
+ Ultra-fast project-wide fuzzy searching via [LeaderF](https://github.com/Yggdroot/LeaderF).
@@ -36,42 +64,43 @@ is guaranteed.**
+ Faster matching pair insertion and jump via [delimitMate](https://github.com/Raimondi/delimitMate).
+ Smarter and faster matching pair management (add, replace or delete) via [vim-sandwich](https://github.com/machakann/vim-sandwich).
+ Fast buffer jump via [hop.nvim](https://github.com/phaazon/hop.nvim).
+ Ultra fast snippet insertion via [Ultisnips](https://github.com/SirVer/ultisnips).
+ Beautiful status line via [lualine.nvim](https://github.com/nvim-lualine/lualine.nvim).
+ Powerful snippet insertion via [Ultisnips](https://github.com/SirVer/ultisnips).
+ Beautiful statusline via [lualine.nvim](https://github.com/nvim-lualine/lualine.nvim).
+ File tree explorer via [nvim-tree.lua](https://github.com/kyazdani42/nvim-tree.lua).
+ Better quickfix list with [nvim-bqf](https://github.com/kevinhwang91/nvim-bqf).
+ Show search index and count with [nvim-hlslens](https://github.com/kevinhwang91/nvim-hlslens).
+ Command line auto-completion via [wilder.nvim](https://github.com/gelguy/wilder.nvim).
+ Keymap display via [which-key.nvim](https://github.com/folke/which-key.nvim).
+ User-defined mapping hint via [which-key.nvim](https://github.com/folke/which-key.nvim).
+ Asynchronous code execution via [asyncrun.vim](https://github.com/skywind3000/asyncrun.vim).
+ Code highlighting via [nvim-treesitter](https://github.com/nvim-treesitter/nvim-treesitter).
+ Code editing using true nvim inside browser via [firenvim](https://github.com/glacambre/firenvim).
+ Color theme via [vim-gruvbox8](https://github.com/lifepillar/vim-gruvbox8) and other beautiful themes.
+ Markdown writing and previewing via [vim-markdown](https://github.com/plasticboy/vim-markdown) and [markdown-preview.nvim](https://github.com/iamcco/markdown-preview.nvim).
+ LaTeX editing and previewing via [vimtex](https://github.com/lervag/vimtex) <sup id="a1">[1](#f1)</sup>.
+ Animated GUI style notification via [nvim-notify](https://github.com/rcarriga/nvim-notify).
+ Smooth scroll experience via [neoscroll](https://github.com/karb94/neoscroll.nvim).
+ Tags navigation via [vista](https://github.com/liuchengxu/vista.vim).
+ Code formatting via [Neoformat](https://github.com/sbdchd/neoformat).
+ Undo management via [vim-mundo](https://github.com/simnalamburt/vim-mundo)
+ LaTeX editing via [vimtex](https://github.com/lervag/vimtex) <sup id="a1">[1](#f1)</sup>.
+ ......
# UI Demo
For more UI demos, see [here](https://github.com/jdhao/nvim-config/issues/15).
For more UI demos, check [here](https://github.com/jdhao/nvim-config/issues/15).
## Start screen with alpha-nvim
## Start screen with dashboard-nvim
<p align="center">
<img src="https://user-images.githubusercontent.com/16662357/139459989-0537ded4-c119-4749-99bf-b551ca1ba118.jpg" width="800">
<img src="https://user-images.githubusercontent.com/16662357/183256752-fb23b215-a6b8-4646-beed-9999f52d53f1.png" width="800">
</p>
## fuzzy finding using LeaderF
## File fuzzy finding using LeaderF
<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>
## Autocompletion
## Code autocompletion with nvim-cmp
<p align="center">
<img src="https://user-images.githubusercontent.com/16662357/128590006-0fc1451f-fac1-49b2-bb95-8aba21bfa44e.gif" width="800">
@@ -83,6 +112,12 @@ For more UI demos, see [here](https://github.com/jdhao/nvim-config/issues/15).
<img src="https://user-images.githubusercontent.com/16662357/128590833-aaa05d53-19ef-441d-a5a9-ba1bbd3936c1.gif" width="800">
</p>
## Command-line autocompletion with wilder.nvim
<p align="center">
<img src="https://user-images.githubusercontent.com/16662357/147677787-8e5d229a-a16a-420e-98f5-88f2a1be84a2.gif" width="800">
</p>
## Tags
<p align="center">
@@ -97,71 +132,85 @@ Go to a string starting with `se`
<img src="https://user-images.githubusercontent.com/16662357/139459219-8a7e6ac4-1d24-4008-a370-b56773d7cb85.gif" width="800">
</p>
## GUI-style notification
## GUI-style notification with nvim-notify
<p align="center">
<img src="https://user-images.githubusercontent.com/16662357/128589873-aadb8264-1098-4834-9876-fa66a309be05.gif" width="800">
</p>
# Shortcuts
Some of the shortcuts I use frequently. In the following shortcuts, `<leader>`
represents ASCII character `,`.
Some of the shortcuts I use frequently are listed here. In the following shortcuts, `<leader>` represents ASCII character `,`.
| Shortcut | Mode | platform | Description |
|-------------------|---------------|-----------------|------------------------------------------------------------------|
| `<leader>ff` | Normal | Linux/macOS/Win | Fuzzy file searching in a floating window |
| `<leader>fh` | Normal | Linux/macOS/Win | Fuzzy help file grepping in a floating window |
| `<leader>fg` | Normal | Linux/macOS/Win | Fuzzy project-wide grepping in a floating window |
| `<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><Space>` | Normal | Linux/macOS/Win | Remove trailing white spaces |
| `<leader>v` | Normal | Linux/macOS/Win | Reselect last pasted text |
| `<leader>ev` | Normal | Linux/macOS/Win | Edit Nvim config in a new tabpage |
| `<leader>sv` | Normal | Linux/macOS/Win | Reload Nvim config |
| `<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 all window and close Nvim |
| `<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>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 |
| `<space>t` | Normal | Linux/macOS/Win | Toggle tag window (show project tags in the right window) |
| `<leader>gs` | Normal | Linux/macOS/Win | Show Git status result |
| `<leader>gw` | Normal | Linux/macOS/Win | Run Git add for current file |
| `<leader>gd` | Normal | Linux/macOS/Win | Run git diff for current file |
| `<leader>gc` | Normal | Linux/macOS/Win | Run git commit |
| `<F9>` | Normal | Linux/macOS/Win | Run current source file (for Python, C++) |
| `<F11>` | Normal | Linux/macOS/Win | Toggle spell checking |
| `<F12>` | Normal | Linux/macOS/Win | Toggle paste mode |
| `\x` | Normal | Linux/macOS/Win | Close location or quickfix window |
| `\d` | Normal | Linux/macOS/Win | Close current buffer and go to previous buffer |
| `{count}gb` | Normal | Linux/macOS/Win | Go to buffer {count} or next buffer in the buffer list. |
| `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 |
| Shortcut | Mode | platform | Description |
|-------------------|---------------|-----------------|--------------------------------------------------------------------------|
| `<leader>ff` | Normal | Linux/macOS/Win | Fuzzy file searching in a floating window |
| `<leader>fh` | Normal | Linux/macOS/Win | Fuzzy help file grepping in a floating window |
| `<leader>fg` | Normal | Linux/macOS/Win | Fuzzy project-wide grepping in a floating window |
| `<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><Space>` | Normal | Linux/macOS/Win | Remove trailing white spaces |
| `<leader>v` | Normal | Linux/macOS/Win | Reselect last pasted text |
| `<leader>ev` | Normal | Linux/macOS/Win | Edit Nvim config in a new tabpage |
| `<leader>sv` | Normal | Linux/macOS/Win | Reload Nvim config |
| `<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 all window and close Nvim |
| `<leader>w` | Normal | Linux/macOS/Win | Save current buffer content |
| `<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>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) |
| `<leader>gs` | Normal | Linux/macOS/Win | Show Git status result |
| `<leader>gw` | Normal | Linux/macOS/Win | Run Git add for current file |
| `<leader>gd` | Normal | Linux/macOS/Win | Run git diff for current file |
| `<leader>gc` | Normal | Linux/macOS/Win | Run git commit |
| `<leader>gpl` | Normal | Linux/macOS/Win | Run git pull |
| `<leader>gpu` | Normal | Linux/macOS/Win | Run git push |
| `<F9>` | Normal | Linux/macOS/Win | Compile&run current source file (for C++, LaTeX, Lua, Python) |
| `<F11>` | Normal | Linux/macOS/Win | Toggle spell checking |
| `<F12>` | Normal | Linux/macOS/Win | Toggle paste mode |
| `\x` | Normal | Linux/macOS/Win | Close location or quickfix window |
| `\d` | Normal | Linux/macOS/Win | Close current buffer and go to previous buffer |
| `{count}gb` | Normal | Linux/macOS/Win | Go to buffer `{count}` or next buffer in the buffer list. |
| `{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 |
# Trouble shooting
# Custom commands
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.
In addition to commands provided by various plugins, I have also created some custom commands for personal use.
| command | description | example |
|------------|-------------------------------------------------------------------------|--------------------------------|
| `Redir` | capture command output to a tabpage for easier inspection. | `Redir hi` |
| `Edit` | edit multiple files at the same time, supports globing | `Edit *.vim` |
| `Datetime` | print current date and time or convert Unix time stamp to date and time | `Datetime 12345` or `Datetime` |
# Contributing
If you find anything that needs improving, do not hesitate to point it out or create a PR.
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).
# Further readings
Some of the resources that I find helpful in mastering Vim is documented [here](docs/vim_resources.md).
You may also be interested in my post in configuring Vim on different platforms:
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 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/)
+ [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/)
+ 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)
<b id="f1">1:</b> Not enabled for Linux, you need to tweak [`lua/plugins.lua`](lua/plugins.lua) and change the condition for installing vimtex.[](#a1)

View File

@@ -0,0 +1,8 @@
" Disable inserting comment leader after hitting o or O or <Enter>
set formatoptions-=o
set formatoptions-=r
set tabstop=2 " number of visual spaces per TAB
set softtabstop=2 " number of spaces in tab when editing
set shiftwidth=2 " number of spaces to use for autoindent
set expandtab " expand tab to spaces so that tabs are spaces

View File

@@ -6,3 +6,5 @@ set tabstop=2 " number of visual spaces per TAB
set softtabstop=2 " number of spaces in tab when editing
set shiftwidth=2 " number of spaces to use for autoindent
set expandtab " expand tab to spaces so that tabs are spaces
nnoremap <silent> <F9> :luafile %<CR>

View File

@@ -45,3 +45,25 @@ function! AddListSymbol(type, ...) abort
call setline(line, new_text)
endfor
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

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

@@ -6,8 +6,7 @@ set formatoptions-=r
" modeline is annoying in that the modeline get executed each time the window
" focus is lost (see
" https://github.com/tmux-plugins/vim-tmux-focus-events/issues/14)
set foldmethod=expr foldlevel=0 foldlevelstart=-1
\ foldexpr=utils#VimFolds(v:lnum) foldtext=utils#MyFoldText()
set foldmethod=expr foldexpr=utils#VimFolds(v:lnum) foldtext=utils#MyFoldText()
" Use :help command for keyword when pressing `K` in vim file,
" see `:h K` and https://stackoverflow.com/q/15867323/6064933
@@ -17,3 +16,5 @@ set tabstop=2 " number of visual spaces per TAB
set softtabstop=2 " number of spaces in tab when editing
set shiftwidth=2 " number of spaces to use for autoindent
set expandtab " expand tab to spaces so that tabs are spaces
nnoremap <silent> <F9> :source %<CR>

View File

@@ -131,9 +131,11 @@ function! utils#Get_titlestr() abort
if g:is_linux
let l:title_str = hostname() . ' '
endif
let l:title_str = l:title_str . expand('%:p:~') . ' '
if &buflisted
let l:title_str = l:title_str . strftime('%Y-%m-%d %H:%M',getftime(expand('%')))
let l:buf_path = expand('%:p:~')
let l:title_str = l:title_str . l:buf_path . ' '
if &buflisted && l:buf_path != ""
let l:title_str = l:title_str . strftime('%Y-%m-%d %H:%M:%S%z', getftime(expand('%')))
endif
return l:title_str
@@ -174,13 +176,18 @@ endfunction
" Redirect command output to a register for later processing.
" Ref: https://stackoverflow.com/q/2573021/6064933 and https://unix.stackexchange.com/q/8101/221410 .
function! utils#CaptureCommandOutput(command) abort
let l:tmp = @m
redir @m
execute a:command
silent! execute a:command
redir END
call v:lua.vim.notify("command output captured to register m", "info", {'title': 'nvim-config'})
"create a scratch buffer for dumping the text, ref: https://vi.stackexchange.com/a/11311/15292.
tabnew | setlocal buftype=nofile bufhidden=wipe nobuflisted noswapfile
call nvim_buf_set_lines(0, 0, 0, 0, [@m])
let l:lines = split(@m, '\n')
call nvim_buf_set_lines(0, 0, 0, 0, l:lines)
let @m = l:tmp
endfunction
" Edit all files matching the given patterns.
@@ -193,12 +200,12 @@ function! utils#MultiEdit(patterns) abort
endfunction
function! utils#add_pack(name) abort
let l:success = v:true
let l:status = v:true
try
execute printf("packadd! %s", a:name)
catch /^Vim\%((\a\+)\)\=:E919/
let l:success = v:false
let l:status = v:false
endtry
return l:success
return l:status
endfunction

View File

@@ -19,13 +19,28 @@ augroup accurate_syn_highlight
autocmd BufEnter * :syntax sync fromstart
augroup END
" Return to last edit position when opening a file
augroup resume_edit_position
" Return to last cursor position when opening a file
augroup resume_cursor_position
autocmd!
autocmd BufReadPost *
\ if line("'\"") > 1 && line("'\"") <= line("$") && &ft !~# 'commit' | execute "normal! g`\"zvzz" | endif
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
@@ -70,7 +85,7 @@ function! s:custom_highlight() abort
highlight FloatBorder guifg=LightGreen guibg=NONE
" highlight for matching parentheses
highlight MatchParen cterm=bold,reverse,underline gui=bold,reverse,underline
highlight MatchParen cterm=bold,underline gui=bold,underline
endfunction
" highlight yanked region, see `:h lua-highlight`
@@ -86,10 +101,22 @@ 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
let l:quit_filetypes = ['qf', 'vista', 'NvimTree']
let l:should_quit = v:true
let l:tabwins = nvim_tabpage_list_wins(0)
for w in l:tabwins
let l:buf = nvim_win_get_buf(w)
let l:bf = getbufvar(l:buf, '&filetype')
if index(l:quit_filetypes, l:bf) == -1
let l:should_quit = v:false
endif
endfor
if l:should_quit
qall
endif
endfunction
@@ -103,3 +130,28 @@ augroup packer_auto_compile
autocmd!
autocmd BufWritePost */nvim/lua/plugins.lua source <afile> | PackerCompile
augroup END
augroup auto_create_dir
autocmd!
autocmd BufWritePre * lua require('utils').may_create_dir()
augroup END
" ref: https://vi.stackexchange.com/a/169/15292
function! s:handle_large_file() abort
let g:large_file = 10485760 " 10MB
let f = expand("<afile>")
if getfsize(f) > g:large_file || getfsize(f) == -2
set eventignore+=all
" turning off relative number helps a lot
set norelativenumber
setlocal noswapfile bufhidden=unload buftype=nowrite undolevels=-1
else
set eventignore-=all relativenumber
endif
endfunction
augroup LargeFile
autocmd!
autocmd BufReadPre * call s:handle_large_file()
augroup END

View File

@@ -7,9 +7,6 @@ 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
@@ -34,17 +31,26 @@ else
endif
" Custom mapping <leader> (see `:h mapleader` for more info)
let mapleader = ','
let g:mapleader = ','
" Enable highlighting for lua HERE doc inside vim script
let g:vimsyn_embed = 'l'
" Use English as main language
if !g:is_mac
language en_US.utf-8
endif
" use filetype.lua instead of filetype.vim
let g:do_filetype_lua = 1
let g:did_load_filetypes = 0
"}}
"{{ Disable loading certain plugins
" Whether to load netrw by default, see
" https://github.com/bling/dotvim/issues/4
" let g:loaded_netrw = 0
" let g:loaded_netrwPlugin = 0
let g:loaded_netrw = 1
let g:loaded_netrwPlugin = 1
let g:netrw_liststyle = 3
if g:is_win
let g:netrw_http_cmd = 'curl --ssl-no-revoke -Lo'
@@ -65,4 +71,7 @@ let g:loaded_tutor_mode_plugin = 1 " do not load the tutor plugin
let g:loaded_matchit = 1
let g:loaded_matchparen = 1
"}}
" Disable sql omni completion, it is broken.
let g:loaded_sql_completion = 1
"}

View File

@@ -45,8 +45,6 @@ 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 oo :echo 'Please use <lt>space>o instead'<CR>
nnoremap OO :echo 'Please use <lt>space>O instead'<CR>
nnoremap <expr> <Space>o printf('m`%so<ESC>``', v:count1)
nnoremap <expr> <Space>O printf('m`%sO<ESC>``', v:count1)
@@ -89,7 +87,7 @@ xnoremap > >gv
inoremap <expr> <tab> pumvisible() ? "\<c-n>" : "\<tab>"
inoremap <expr> <s-tab> pumvisible() ? "\<c-p>" : "\<s-tab>"
" Edit and reload init.vim quickly
" Edit and reload nvim config file 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>
@@ -97,13 +95,12 @@ nnoremap <silent> <leader>sv :<C-U>silent update $MYVIMRC <bar> source $MYVIMRC
" Reselect the text that has just been pasted, see also https://stackoverflow.com/a/4317090/6064933.
nnoremap <expr> <leader>v printf('`[%s`]', getregtype()[0])
" Always use very magic mode for searching
nnoremap / /\v
" 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>
@@ -170,6 +167,7 @@ onoremap <silent> iB :<C-U>call text_obj#Buffer()<CR>
" Do not move my cursor when joining lines.
nnoremap J mzJ`z
nnoremap gJ mzgJ`z
" Break inserted text into smaller undo units.
for ch in [',', '.', '!', '?', ';', ':']
@@ -192,3 +190,6 @@ function! s:restore_cursor() abort
silent! normal `y
silent! delmarks y
endfunction
" for mappings defined in lua
lua require('custom-map')

View File

@@ -112,6 +112,9 @@ set shortmess+=c
" choice, IMHO.
set shortmess+=S
" Disable showing intro message (:intro)
set shortmess+=I
" Completion behaviour
" set completeopt+=noinsert " Auto select the first completion entry
set completeopt+=menuone " Show menu even if there is only one item
@@ -120,7 +123,7 @@ set completeopt-=preview " Disable the preview window
set pumheight=10 " Maximum number of items to show in popup menu
set pumblend=10 " pseudo transparency for completion menu
set winblend=5 " pseudo transparency for floating window
set winblend=0 " pseudo transparency for floating window
" Insert mode key word completion setting
set complete+=kspell complete-=w complete-=b complete-=u complete-=t

View File

@@ -12,6 +12,10 @@ call utils#Cabbrev('pud', 'PackerUpdate')
call utils#Cabbrev('pc', 'PackerClean')
call utils#Cabbrev('ps', 'PackerSync')
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" configurations for vim script plugin "
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"""""""""""""""""""""""""UltiSnips settings"""""""""""""""""""
" Trigger configuration. Do not use <tab> if you use YouCompleteMe
let g:UltiSnipsExpandTrigger='<c-j>'
@@ -27,25 +31,9 @@ let g:UltiSnipsJumpBackwardTrigger='<c-k>'
" https://jdhao.github.io/2019/04/17/neovim_snippet_s1/ for details.
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 """"""""""""""""""""""""""""""""
command! -nargs=0 StartVlime call jobstart(printf("sbcl --load %s/vlime/lisp/start-vlime.lisp", g:package_home))
""""""""""""""""""""""""""""" settings for nvim-hlslens"""""""""""""""
noremap <silent> n <Cmd>execute('normal! ' . v:count1 . 'nzzzv')<CR>
\<Cmd>lua require('hlslens').start()<CR>
noremap <silent> N <Cmd>execute('normal! ' . v:count1 . 'Nzzzv')<CR>
\<Cmd>lua require('hlslens').start()<CR>
map * <Plug>(asterisk-z*)<Cmd>lua require('hlslens').start()<CR>
map # <Plug>(asterisk-z#)<Cmd>lua require('hlslens').start()<CR>
"""""""""""""""""""""""""""""LeaderF settings"""""""""""""""""""""
" Do not use cache file
let g:Lf_UseCache = 0
@@ -68,7 +56,7 @@ if g:is_linux
endif
" Only fuzzy-search files names
let g:Lf_DefaultMode = 'NameOnly'
let g:Lf_DefaultMode = 'FullPath'
" Popup window settings
let w = float2nr(&columns * 0.8)
@@ -105,17 +93,15 @@ nnoremap <silent> <leader>fg :<C-U>Leaderf rg --no-messages --popup<CR>
" Search vim help files
nnoremap <silent> <leader>fh :<C-U>Leaderf help --popup<CR>
nnoremap <silent> <leader>h :<C-U>echoerr "Use \<lt>leader>fh instead!"<CR>
" Search tags in current buffer
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
nnoremap <silent> <leader>fb :<C-U>Leaderf buffer --popup<CR>
" 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'
@@ -306,7 +292,6 @@ if ( g:is_win || g:is_mac ) && executable('latex')
" Viewer settings for different platforms
if g:is_win
let g:vimtex_view_general_viewer = 'SumatraPDF'
let g:vimtex_view_general_options_latexmk = '-reuse-instance'
let g:vimtex_view_general_options = '-reuse-instance -forward-search @tex @line @pdf'
endif
@@ -386,9 +371,16 @@ if exists('g:started_by_firenvim') && g:started_by_firenvim
\ }
\ }
function! s:setup_firenvim() abort
set noruler noshowcmd
set laststatus=0 showtabline=0
endfunction
augroup firenvim
autocmd!
autocmd BufEnter *.txt setlocal filetype=markdown laststatus=0 nonumber noshowcmd noruler showtabline=1
autocmd FileType text call s:setup_firenvim()
autocmd BufNewFile github.com_*.txt set filetype=markdown
autocmd BufNewFile stackoverflow.com_*.txt set filetype=markdown
augroup END
endif
@@ -396,21 +388,17 @@ endif
nnoremap <leader>dp :<C-U>GdbStartPDB python -m pdb %<CR>
""""""""""""""""""""""""""""""wilder.nvim settings""""""""""""""""""""""""""""""
augroup 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
call timer_start(250, { -> s:wilder_init() })
function! s:wilder_init() abort
try
call wilder#enable_cmdline_enter()
set wildcharm=<Tab>
cmap <expr> <Tab> wilder#in_context() ? wilder#next() : "\<Tab>"
cmap <expr> <S-Tab> wilder#in_context() ? wilder#previous() : "\<S-Tab>"
" only / and ? are enabled by default
call wilder#set_option('modes', ['/', '?', ':'])
call wilder#setup({
\ 'modes': [':', '/', '?'],
\ 'next_key': '<Tab>',
\ 'previous_key': '<S-Tab>',
\ 'accept_key': '<C-y>',
\ 'reject_key': '<C-e>'
\ })
call wilder#set_option('pipeline', [
\ wilder#branch(
@@ -432,14 +420,18 @@ function! s:wilder_init() abort
let l:hl = wilder#make_hl('WilderAccent', 'Pmenu', [{}, {}, {'foreground': '#f4468f'}])
call wilder#set_option('renderer', wilder#popupmenu_renderer({
\ 'highlighter': wilder#basic_highlighter(),
\ 'winblend': 5,
\ 'max_height': 15,
\ 'highlights': {
\ 'accent': l:hl,
\ },
\ 'left': [' ', wilder#popupmenu_devicons(),],
\ 'right': [' ', wilder#popupmenu_scrollbar(),],
\ 'apply_incsearch_fix': 0,
\ }))
catch /^Vim\%((\a\+)\)\=:E117/
echohl Error |echomsg "Wilder.nvim missing: run :PackerSync to fix."|echohl None
endtry
endfunction
""""""""""""""""""""""""""""""vim-auto-save settings""""""""""""""""""""""""""""""
let g:auto_save = 1 " enable AutoSave on Vim startup

View File

@@ -50,6 +50,17 @@ function! s:theme_setup_dict.nightfox() dict abort
colorscheme nordfox
endfunction
function! s:theme_setup_dict.kanagawa() dict abort
colorscheme kanagawa
endfunction
function! s:theme_setup_dict.catppuccin() dict abort
let g:catppuccin_flavour = "frappe" " latte, frappe, macchiato, mocha
lua require("catppuccin").setup()
colorscheme catppuccin
endfunction
" Theme to directory name mapping, because theme repo name is not necessarily
" the same as the theme name itself.
let s:theme2dir = {
@@ -61,7 +72,9 @@ let s:theme2dir = {
\ 'nord': 'nord.nvim',
\ 'doom_one': 'doom-one.nvim',
\ 'everforest' :'everforest',
\ 'nightfox': 'nightfox.nvim'
\ 'nightfox': 'nightfox.nvim',
\ 'kanagawa': 'kanagawa.nvim',
\ 'catppuccin': 'catppuccin'
\ }
let s:theme = utils#RandElement(keys(s:theme2dir))
@@ -73,14 +86,14 @@ if !has_key(s:theme_setup_dict, s:theme)
finish
endif
let s:res = utils#add_pack(s:theme2dir[s:theme])
if !s:res
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
let s:msg1 = "Colorscheme: " . s:theme
call v:lua.vim.notify(s:msg1, 'info', {'title': 'nvim-config'})
endif

View File

@@ -1,37 +1,77 @@
This doc summarizes how to install and use this configuration in detail.
# Pre-requisite
There are a few dependencies if we want to use Nvim for efficient editing and
development work.
## Terminal emulators
## 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
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.
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).
## 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
plugins that utilize its Python binding. Pynvim is required by plugins such as
[Semshi](https://github.com/numirias/semshi).
## Patched Fonts
Since statusline or file explorer plugins often use Unicode symbols not available in normal font,
we need to install a patched font from the [nerd-fonts](https://github.com/ryanoasis/nerd-fonts) project.
# Automatic installation
## Automatic Installation for Linux
To set up a workable Nvim environment on Linux,
I use [a bash script](nvim_setup_linux.sh) to automatically install necessary dependencies, Nvim itself and configs.
Note that the variable `PYTHON_INSTALLED`, `SYSTEM_PYTHON` and `ADD_TO_SYSTEM_PATH` in the script
should be set properly based on your environment.
## Automatic installation for Windows
Run script [nvim_setup_windows.ps1](nvim_setup_windows.ps1) under PowerShell.
# 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
```
## 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,
linting, go to definition, etc.
[python-lsp-server (pylsp)](https://github.com/python-lsp/python-lsp-server) is a Python [Language Server](https://microsoft.github.io/language-server-protocol/) for completion, linting, go to definition, etc.
```
pip install 'python-lsp-server[all]' pylsp-mypy pyls-isort
```
## 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
# Ref: https://johnpapa.net/node-and-npm-without-sudo/
@@ -55,32 +95,31 @@ source ~/.bash_profile
# source ~/.zshrc
```
## vim-language-server
### vim-language-server
[vim-language-server](https://github.com/iamcco/vim-language-server) provides
completion for vim script. We can install vim-language-server globally and set
its path:
[vim-language-server](https://github.com/iamcco/vim-language-server) provides completion for vim script. We can install vim-language-server globally:
```bash
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
other Git repositories.
### Git
Since Git is usually pre-installed on Linux and macOS, we do not need to worry
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.
Git is required by plugin manager [packer.nvim](https://github.com/wbthomason/packer.nvim) and other git-related plugins.
## 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
install a ctags distribution. Universal-ctags is preferred.
### ctags
In order to use tags related plugins such as [vista.vim](https://github.com/liuchengxu/vista.vim), we need to install a ctags distribution.
Universal-ctags is preferred.
To install it on Linux, we need to build it from source. See [here](https://askubuntu.com/a/836521/768311) for the details.
To install ctags on macOS, use [Homebrew](https://github.com/universal-ctags/homebrew-universal-ctags):
```bash
@@ -93,134 +132,99 @@ To install it Windows, use [chocolatey](https://chocolatey.org/) or [scoop](http
choco install universal-ctags
# 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)
for the details.
Set its PATH properly and make sure you can run `ctags` from command line.
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
tool available for both Linux, Windows and macOS. It is used by several
searching plugins.
For Windows and macOS, we can install it via chocolatey and homebrew respectively.
For Linux, we can download the [binary release](https://github.com/BurntSushi/ripgrep/releases) and install it.
For Windows and macOS, we can install it via chocolatey and homebrew
respectively. For Linux, we can download the executable file from its [release
page](https://github.com/BurntSushi/ripgrep/releases) and install it.
Set its PATH properly and make sure you can run `rg` from command line.
## Linters
### Linters
A linter is a tool to check the source code for possible style and syntax
issues. Based on the programming languages we use, we may need to install
various linters.
A linter is a tool to check the source code for possible style and syntax issues.
Based on the programming languages we use, we may need to install various linters.
+ Python: [pylint](https://github.com/PyCQA/pylint) and [flake8](https://github.com/PyCQA/flake8).
+ 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
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).
## Install Nvim
For macOS, we can use [kitty](https://sw.kovidgoyal.net/kitty/), [iterm2](https://www.iterm2.com/), or [Alacritty](https://github.com/jwilm/alacritty).
If you connect 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.
There are various ways to install Nvim depending on your system.
This config is only maintained for [the latest nvim stable release](https://github.com/neovim/neovim/releases/tag/stable).
For the latest version of Windows 10, you can also try the new [Windows
Terminal](https://github.com/microsoft/terminal).
### Linux
## Font
You can directly download the binary release from [here](https://github.com/neovim/neovim/releases/download/stable/nvim-linux64.tar.gz).
You can also use the system package manager to install nvim,
but that is not reliable since the latest version may not be available.
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.
### Windows
# Install Nvim
You may download from [nvim release](https://github.com/neovim/neovim/releases/download/stable/nvim-win64.zip) from GitHub and manually extract it.
There are various ways to install Nvim depending on your system. Current
configuration is tested against nvim v0.6.0.
## Linux
We can directly download the binary release from [here](https://github.com/neovim/neovim/releases/download/v0.6.0/nvim-linux64.tar.gz).
## Windows
The easiest way to install Nvim on Windows is via chocolatey:
Another way to install Nvim on Windows is via chocolatey or scoop:
```
choco install neovim
# via scoop
# scoop bucket add versions
# scoop 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
## macOS
It is recommended to install neovim via [Homebrew](https://brew.sh/) on macOS.
Simply run the following command:
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`.
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**.
Make sure that you can call `nvim` from the command line after all these
setups.
## Setting up Nvim
# Setting up Nvim
After installing nvim and all the dependencies, we will install plugin managers and set up this config.
## Install plugin manager packer.nvim
### Install plugin manager packer.nvim
I use packer.nvim to manage my plugins. We need to install packer.nvim on our
system first.
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):
For Windows, if curl is installed, run the following command (on PowerShell):
```
git clone --depth=1 https://github.com/wbthomason/packer.nvim "$env:LOCALAPPDATA\nvim-data\site\pack\packer\opt\packer.nvim"
```
For macOS and Linux, use the following command:
For macOS and Linux, run the following command:
```bash
git clone --depth=1 https://github.com/wbthomason/packer.nvim ~/.local/share/nvim/site/pack/packer/opt/packer.nvim
```
## How to install this configuration
### How to install this configuration
On 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:
On Linux and macOS, the directory is `~/.config/nvim`.
On Windows, the config directory is `$HOME/AppData/Local/nvim`[^1].
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:
```
git clone --depth=1 https://github.com/jdhao/nvim-config.git .
```
After that, when we first open nvim, run command `:PackerSync` to install all
the plugins and generate `packer_compiled.lua`. Since I use quite a lot of
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.
After that, when we first open nvim, run command `:PackerSync` to install all the plugins.
Since I use quite a lot of plugins (more than 60), it may take some time to install all of them.
[^1]: Use `echo %userprofile%` to see where your `$HOME` is.

View File

@@ -2,15 +2,16 @@
#!/bin/bash
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
mkdir -p "$HOME/tools"
fi
# Delete existing nvim installation.
if [[ -d "$HOME/tools/nvim-osx64" ]]; then
rm -rf "$HOME/tools/nvim-osx64"
# For newer release, the directory name is nvim-macos
if [[ -d "$HOME/tools/nvim-macos" ]]; then
rm -rf "$HOME/tools/nvim-macos"
fi
# Extract the tar ball

View File

@@ -34,11 +34,11 @@ fi
if [[ "$INSTALL_ANACONDA" = true ]]; then
CONDA_DIR=$HOME/tools/anaconda
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
CONDA_DIR=$HOME/tools/miniconda
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
if [[ ! "$PYTHON_INSTALLED" = true ]]; then
@@ -87,21 +87,21 @@ else
fi
#######################################################################
# Install node and vim-language-server #
# Install node and js-based language server #
#######################################################################
NODE_DIR=$HOME/tools/nodejs
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/
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
echo "Install Nodejs"
echo "Install Node.js"
if [[ ! -f $NODE_SRC_NAME ]]; then
echo "Downloading nodejs and renaming"
echo "Downloading Node.js and renaming"
wget $NODE_LINK -O "$NODE_SRC_NAME"
fi
if [[ ! -d "$NODE_DIR" ]]; then
echo "Creating nodejs directory under tools directory"
echo "Creating Node.js directory under tools directory"
mkdir -p "$NODE_DIR"
echo "Extracting to $HOME/tools/nodejs directory"
tar xvf "$NODE_SRC_NAME" -C "$NODE_DIR" --strip-components 1
@@ -111,18 +111,50 @@ if [[ -z "$(command -v node)" ]]; then
echo "export PATH=\"$NODE_DIR/bin:\$PATH\"" >> "$HOME/.bash_profile"
fi
else
echo "Nodejs is already installed. Skip installing it."
echo "Node.js is already installed. Skip installing it."
fi
# Install 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 #
#######################################################################
SUMNEKO_LUA_DIR=$HOME/tools/lua-language-server
SUMNEKO_LUA_SRC_NAME=$HOME/packages/lua-language-server.tar.gz
SUMNEKO_LUA_LINK="https://github.com/sumneko/lua-language-server/releases/download/3.5.3/lua-language-server-3.5.3-linux-x64.tar.gz"
if [[ -z "$(command -v lua-language-server)" ]] && [[ ! -f "$SUMNEKO_LUA_DIR/bin/lua-language-server" ]]; then
echo 'Install lua-language-server'
if [[ ! -f $SUMNEKO_LUA_SRC_NAME ]]; then
echo "Downloading lua-language-server and renaming"
wget $SUMNEKO_LUA_LINK -O "$SUMNEKO_LUA_SRC_NAME"
fi
if [[ ! -d "$SUMNEKO_LUA_DIR" ]]; then
echo "Creating lua-language-server directory under tools directory"
mkdir -p "$SUMNEKO_LUA_DIR"
echo "Extracting to directory $SUMNEKO_LUA_DIR"
tar zxvf "$SUMNEKO_LUA_SRC_NAME" -C "$SUMNEKO_LUA_DIR"
fi
if [[ "$ADD_TO_SYSTEM_PATH" = true ]] && [[ "$USE_BASH_SHELL" = true ]]; then
echo "export PATH=\"$SUMNEKO_LUA_DIR/bin:\$PATH\"" >> "$HOME/.bash_profile"
fi
else
echo "lua-language-server is already installed. Skip installing it."
fi
#######################################################################
# Ripgrep part #
#######################################################################
RIPGREP_DIR=$HOME/tools/ripgrep
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
echo "Install ripgrep"
if [[ ! -f $RIPGREP_SRC_NAME ]]; then
@@ -142,8 +174,8 @@ if [[ -z "$(command -v rg)" ]] && [[ ! -f "$RIPGREP_DIR/rg" ]]; then
fi
# set up manpath and zsh completion for ripgrep
mkdir -p $HOME/tools/ripgrep/doc/man/man1
mv $HOME/tools/ripgrep/doc/rg.1 $HOME/tools/ripgrep/doc/man/man1
mkdir -p "$HOME/tools/ripgrep/doc/man/man1"
mv "$HOME/tools/ripgrep/doc/rg.1" "$HOME/tools/ripgrep/doc/man/man1"
if [[ "$USE_BASH_SHELL" = true ]]; then
echo 'export MANPATH=$HOME/tools/ripgrep/doc/man:$MANPATH' >> "$HOME/.bash_profile"
@@ -160,7 +192,7 @@ fi
#######################################################################
CTAGS_SRC_DIR=$HOME/packages/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
echo "Install ctags"
@@ -188,7 +220,7 @@ fi
NVIM_DIR=$HOME/tools/nvim
NVIM_SRC_NAME=$HOME/packages/nvim-linux64.tar.gz
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
echo "Installing Nvim"
echo "Creating nvim directory under tools directory"
@@ -216,11 +248,13 @@ if [[ -d "$NVIM_CONFIG_DIR" ]]; then
mv "$NVIM_CONFIG_DIR" "$NVIM_CONFIG_DIR.backup"
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
if [[ ! -d ~/.local/share/nvim/site/pack/packer/opt/packer.nvim ]]; then
git clone --depth=1 https://github.com/wbthomason/packer.nvim \
~/.local/share/nvim/site/pack/packer/opt/packer.nvim
fi
echo "Installing nvim plugins, please wait"
"$NVIM_DIR/bin/nvim" -c "autocmd User PackerComplete quitall" -c "PackerSync"

View File

@@ -15,6 +15,9 @@ scoop install universal-ctags
# Install vim-language-server
npm install -g vim-language-server
# Install bash-language-server
npm install -g bash-language-server
# Install miniconda3
scoop install miniconda3
@@ -26,4 +29,4 @@ pip install 'python-lsp-server[all]' pylsp-mypy pyls-isort
# Install neovim nightly
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>+
nnoremap <silent> <C-6> <C-^>
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" config for nvim-qt "
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" To check if neovim-qt is running, use `exists('g:GuiLoaded')`,
" see https://github.com/equalsraf/neovim-qt/issues/219
if exists('g:GuiLoaded')
@@ -13,6 +16,9 @@ if exists('g:GuiLoaded')
GuiFont! Hack\ NF:h10:l
endif
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" config for fvim "
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
if exists('g:fvim_loaded')
set termguicolors
colorscheme gruvbox8_hard

37
init.lua Normal file
View File

@@ -0,0 +1,37 @@
-- This is my personal Nvim configuration supporting Mac, Linux and Windows, with various plugins configured.
-- This configuration evolves as I learn more about Nvim and become more proficient in using Nvim.
-- Since it is very long (more than 1000 lines!), you should read it carefully and take only the settings that suit you.
-- I would not recommend cloning this repo and replace your own config. Good configurations are personal,
-- built over time with a lot of polish.
--
-- Author: Jie-dong Hao
-- Email: jdhao@hotmail.com
-- Blog: https://jdhao.github.io/
-- check if we have the latest stable version of nvim
local expected_ver = "0.7.2"
local utils = require "utils"
local nvim_ver = utils.get_nvim_version()
if nvim_ver ~= expected_ver then
local msg = string.format("Unsupported nvim version: expect %s, but got %s instead!", expected_ver, nvim_ver)
vim.api.nvim_echo({ { msg, "ErrorMsg" } }, false, {})
return
end
local core_conf_files = {
"globals.vim",
"options.vim",
"autocommands.vim",
"mappings.vim",
"plugins.vim",
"themes.vim",
}
-- source all the core config files
for _, name in ipairs(core_conf_files) do
local path = string.format("%s/core/%s", vim.fn.stdpath('config'), name)
local source_cmd = "source " .. path
vim.cmd(source_cmd)
end

View File

@@ -1,26 +0,0 @@
"{ Header info
" 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
"}
"{ Main configurations
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
"}

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

@@ -0,0 +1,65 @@
local dashboard = require("dashboard")
dashboard.custom_header = {
" ",
" ",
" ",
" ███╗ ██╗ ███████╗ ██████╗ ██╗ ██╗ ██╗ ███╗ ███╗",
" ████╗ ██║ ██╔════╝██╔═══██╗ ██║ ██║ ██║ ████╗ ████║",
" ██╔██╗ ██║ █████╗ ██║ ██║ ██║ ██║ ██║ ██╔████╔██║",
" ██║╚██╗██║ ██╔══╝ ██║ ██║ ╚██╗ ██╔╝ ██║ ██║╚██╔╝██║",
" ██║ ╚████║ ███████╗╚██████╔╝ ╚████╔╝ ██║ ██║ ╚═╝ ██║",
" ╚═╝ ╚═══╝ ╚══════╝ ╚═════╝ ╚═══╝ ╚═╝ ╚═╝ ╚═╝",
" ",
" ",
" ",
" ",
}
dashboard.custom_center = {
{
icon = "",
desc = "Find File ",
action = "Leaderf file --popup",
shortcut = "<Leader> f f",
},
{
icon = "",
desc = "Recently opened files ",
action = "Leaderf mru --popup",
shortcut = "<Leader> f r",
},
{
icon = "",
desc = "Project grep ",
action = "Leaderf rg --popup",
shortcut = "<Leader> f g",
},
{
icon = "",
desc = "Open Nvim config ",
action = "tabnew $MYVIMRC | tcd %:p:h",
shortcut = "<Leader> e v",
},
{
icon = "",
desc = "New file ",
action = "enew",
shortcut = "e ",
},
{
icon = "",
desc = "Quit Nvim ",
-- desc = "Quit Nvim ",
action = "qa",
shortcut = "q "
}
}
vim.cmd([[
augroup dashboard_enter
au!
autocmd FileType dashboard nnoremap <buffer> q :qa<CR>
autocmd FileType dashboard nnoremap <buffer> e :enew<CR>
augroup END
]])

View File

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

34
lua/config/hlslens.lua Normal file
View File

@@ -0,0 +1,34 @@
require('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.fn.execute, cmd)
-- 13 is the index where real error message starts
msg = msg:sub(13)
if not status then
vim.api.nvim_echo({{msg, "ErrorMsg"}}, false, {})
return
end
require('hlslens').start()
end
vim.keymap.set('n', 'n', '',
{
noremap = true,
silent = true,
callback = function() activate_hlslens('n') end
})
vim.keymap.set('n', 'N', '',
{
noremap = true,
silent = true,
callback = function() activate_hlslens('N') end
})
vim.keymap.set('n', '*', "<Plug>(asterisk-z*)<Cmd>lua require('hlslens').start()<CR>", { silent = true })
vim.keymap.set('n', '#', "<Plug>(asterisk-z#)<Cmd>lua require('hlslens').start()<CR>", { silent = true })

View File

@@ -1,58 +1,66 @@
local fn = vim.fn
local api = vim.api
local lsp = vim.lsp
local M = {}
function M.show_line_diagnostics()
local opts = {
focusable = false,
close_events = { "BufLeave", "CursorMoved", "InsertEnter", "FocusLost" },
border = 'rounded',
source = 'always', -- show source in diagnostic popup window
prefix = ' '
}
vim.diagnostic.open_float(nil, opts)
end
local utils = require("utils")
local custom_attach = function(client, bufnr)
local function buf_set_keymap(...)
api.nvim_buf_set_keymap(bufnr, ...)
end
-- Mappings.
local opts = { noremap = true, silent = true }
buf_set_keymap("n", "gd", "<Cmd>lua vim.lsp.buf.definition()<CR>", opts)
buf_set_keymap("n", "<C-]>", "<Cmd>lua vim.lsp.buf.definition()<CR>", opts)
buf_set_keymap("n", "K", "<Cmd>lua vim.lsp.buf.hover()<CR>", opts)
buf_set_keymap("n", "<C-k>", "<cmd>lua vim.lsp.buf.signature_help()<CR>", opts)
buf_set_keymap("n", "<space>wa", "<cmd>lua vim.lsp.buf.add_workspace_folder()<CR>", opts)
buf_set_keymap("n", "<space>wr", "<cmd>lua vim.lsp.buf.remove_workspace_folder()<CR>", opts)
buf_set_keymap("n", "<space>wl", "<cmd>lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<CR>", opts)
buf_set_keymap("n", "<space>rn", "<cmd>lua vim.lsp.buf.rename()<CR>", opts)
buf_set_keymap("n", "gr", "<cmd>lua vim.lsp.buf.references()<CR>", opts)
buf_set_keymap("n", "[d", "<cmd>lua vim.diagnostic.goto_prev()<CR>", opts)
buf_set_keymap("n", "]d", "<cmd>lua vim.diagnostic.goto_next()<CR>", opts)
buf_set_keymap("n", "<space>q", "<cmd>lua vim.diagnostic.setqflist({open = true})<CR>", opts)
buf_set_keymap("n", "<space>ca", "<cmd>lua vim.lsp.buf.code_action()<CR>", opts)
local opts = { silent = true, buffer = bufnr }
vim.keymap.set("n", "gd", vim.lsp.buf.definition, opts)
vim.keymap.set("n", "<C-]>", vim.lsp.buf.definition, opts)
vim.keymap.set("n", "K", vim.lsp.buf.hover, opts)
vim.keymap.set("n", "<C-k>", vim.lsp.buf.signature_help, opts)
vim.keymap.set("n", "<space>wa", vim.lsp.buf.add_workspace_folder, opts)
vim.keymap.set("n", "<space>wr", vim.lsp.buf.remove_workspace_folder, opts)
vim.keymap.set("n", "<space>wl", function() inspect(vim.lsp.buf.list_workspace_folders()) end, opts)
vim.keymap.set("n", "<space>rn", vim.lsp.buf.rename, opts)
vim.keymap.set("n", "gr", vim.lsp.buf.references, opts)
vim.keymap.set("n", "[d", vim.diagnostic.goto_prev, opts)
vim.keymap.set("n", "]d", vim.diagnostic.goto_next, opts)
vim.keymap.set("n", "<space>q", function() vim.diagnostic.setqflist({open = true}) end, opts)
vim.keymap.set("n", "<space>ca", vim.lsp.buf.code_action, opts)
vim.cmd([[
autocmd CursorHold <buffer> lua require('config.lsp').show_line_diagnostics()
]])
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
#vim.diagnostic.get() > 0
then
vim.diagnostic.open_float(nil, float_opts)
end
vim.b.diagnostics_pos = cursor_pos
end
})
-- Set some key bindings conditional on server capabilities
if client.resolved_capabilities.document_formatting then
buf_set_keymap("n", "<space>f", "<cmd>lua vim.lsp.buf.formatting_sync()<CR>", opts)
vim.keymap.set("n", "<space>f", vim.lsp.buf.formatting_sync, opts)
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)
vim.keymap.set("x", "<space>f", vim.lsp.buf.range_formatting, opts)
end
-- The blow command will highlight the current variable and its usages in the buffer.
if client.resolved_capabilities.document_highlight then
vim.cmd([[
hi link LspReferenceRead Visual
hi link LspReferenceText Visual
hi link LspReferenceWrite Visual
hi! link LspReferenceRead Visual
hi! link LspReferenceText Visual
hi! link LspReferenceWrite Visual
augroup lsp_document_highlight
autocmd! * <buffer>
autocmd CursorHold <buffer> lua vim.lsp.buf.document_highlight()
@@ -67,84 +75,103 @@ local custom_attach = function(client, bufnr)
end
end
local capabilities = require('cmp_nvim_lsp').update_capabilities(lsp.protocol.make_client_capabilities())
local capabilities = lsp.protocol.make_client_capabilities()
capabilities = require('cmp_nvim_lsp').update_capabilities(capabilities)
capabilities.textDocument.completion.completionItem.snippetSupport = true
local lspconfig = require("lspconfig")
lspconfig.pylsp.setup({
on_attach = custom_attach,
settings = {
pylsp = {
plugins = {
pylint = { enabled = true, executable = "pylint" },
pyflakes = { enabled = false },
pycodestyle = { enabled = false },
jedi_completion = { fuzzy = true },
pyls_isort = { enabled = true },
pylsp_mypy = { enabled = true },
if utils.executable('pylsp') then
lspconfig.pylsp.setup({
on_attach = custom_attach,
settings = {
pylsp = {
plugins = {
pylint = { enabled = true, executable = "pylint" },
pyflakes = { enabled = false },
pycodestyle = { enabled = false },
jedi_completion = { fuzzy = true },
pyls_isort = { enabled = true },
pylsp_mypy = { enabled = true },
},
},
},
},
flags = {
debounce_text_changes = 200,
},
capabilities = capabilities,
})
flags = {
debounce_text_changes = 200,
},
capabilities = capabilities,
})
else
vim.notify("pylsp not found!", 'warn', {title = 'Nvim-config'})
end
-- lspconfig.pyright.setup{
-- on_attach = custom_attach,
-- capabilities = capabilities
-- }
-- if utils.executable('pyright') then
-- lspconfig.pyright.setup{
-- on_attach = custom_attach,
-- capabilities = capabilities
-- }
-- else
-- vim.notify("pyright not found!", 'warn', {title = 'Nvim-config'})
-- end
lspconfig.clangd.setup({
on_attach = custom_attach,
capabilities = capabilities,
filetypes = { "c", "cpp", "cc" },
flags = {
debounce_text_changes = 500,
},
})
if utils.executable('clangd') then
lspconfig.clangd.setup({
on_attach = custom_attach,
capabilities = capabilities,
filetypes = { "c", "cpp", "cc" },
flags = {
debounce_text_changes = 500,
},
})
else
vim.notify("clangd not found!", 'warn', {title = 'Nvim-config'})
end
-- set up vim-language-server
lspconfig.vimls.setup({
on_attach = custom_attach,
flags = {
debounce_text_changes = 500,
},
capabilities = capabilities,
})
local sumneko_binary_path = vim.fn.exepath("lua-language-server")
if vim.g.is_mac or vim.g.is_linux and sumneko_binary_path ~= "" then
local sumneko_root_path = vim.fn.fnamemodify(sumneko_binary_path, ":h:h:h")
local runtime_path = vim.split(package.path, ";")
table.insert(runtime_path, "lua/?.lua")
table.insert(runtime_path, "lua/?/init.lua")
require("lspconfig").sumneko_lua.setup({
if utils.executable('vim-language-server') then
lspconfig.vimls.setup({
on_attach = custom_attach,
flags = {
debounce_text_changes = 500,
},
capabilities = capabilities,
})
else
vim.notify("vim-language-server not found!", 'warn', {title = 'Nvim-config'})
end
-- set up bash-language-server
if utils.executable('bash-language-server') then
lspconfig.bashls.setup({
on_attach = custom_attach,
capabilities = capabilities,
})
end
if utils.executable("lua-language-server") then
-- settings for lua-language-server can be found on https://github.com/sumneko/lua-language-server/wiki/Settings .
lspconfig.sumneko_lua.setup({
on_attach = custom_attach,
cmd = { sumneko_binary_path, "-E", sumneko_root_path .. "/main.lua" },
settings = {
Lua = {
runtime = {
-- Tell the language server which version of Lua you're using (most likely LuaJIT in the case of Neovim)
version = "LuaJIT",
-- Setup your lua path
path = runtime_path,
},
diagnostics = {
-- Get the language server to recognize the `vim` global
globals = { "vim" },
},
workspace = {
-- Make the server aware of Neovim runtime files
library = api.nvim_get_runtime_file("", true),
},
-- Do not send telemetry data containing a randomized but unique identifier
telemetry = {
enable = false,
-- Make the server aware of Neovim runtime files,
-- see also https://github.com/sumneko/lua-language-server/wiki/Libraries#link-to-workspace .
-- Lua-dev.nvim also has similar settings for sumneko lua, https://github.com/folke/lua-dev.nvim/blob/main/lua/lua-dev/sumneko.lua .
library = {
fn.stdpath('data') .. "/site/pack/packer/opt/emmylua-nvim",
fn.stdpath('config'),
},
maxPreload = 2000,
preloadFileSize = 50000,
},
},
},
@@ -153,10 +180,10 @@ if vim.g.is_mac or vim.g.is_linux and sumneko_binary_path ~= "" then
end
-- Change diagnostic signs.
vim.fn.sign_define("DiagnosticSignError", { text = "", texthl = "DiagnosticSignError" })
vim.fn.sign_define("DiagnosticSignWarn", { text = "!", texthl = "DiagnosticSignWarn" })
vim.fn.sign_define("DiagnosticSignInformation", { text = "", texthl = "DiagnosticSignInfo" })
vim.fn.sign_define("DiagnosticSignHint", { text = "", texthl = "DiagnosticSignHint" })
fn.sign_define("DiagnosticSignError", { text = "", texthl = "DiagnosticSignError" })
fn.sign_define("DiagnosticSignWarn", { text = "!", texthl = "DiagnosticSignWarn" })
fn.sign_define("DiagnosticSignInformation", { text = "", texthl = "DiagnosticSignInfo" })
fn.sign_define("DiagnosticSignHint", { text = "", texthl = "DiagnosticSignHint" })
-- global config for diagnostic
vim.diagnostic.config({
@@ -177,5 +204,3 @@ vim.diagnostic.config({
lsp.handlers["textDocument/hover"] = lsp.with(vim.lsp.handlers.hover, {
border = "rounded",
})
return M

View File

@@ -9,54 +9,75 @@ cmp.setup({
vim.fn["UltiSnips#Anon"](args.body)
end,
},
mapping = {
['<Tab>'] = function(fallback)
if cmp.visible() then
cmp.select_next_item()
else
fallback()
end
end,
['<S-Tab>'] = function(fallback)
if cmp.visible() then
cmp.select_prev_item()
else
fallback()
end
end,
['<Esc>'] = cmp.mapping.close(),
['<CR>'] = cmp.mapping.confirm({ select = true }),
['<C-d>'] = cmp.mapping.scroll_docs(-4),
['<C-f>'] = cmp.mapping.scroll_docs(4),
},
mapping = cmp.mapping.preset.insert({
['<Tab>'] = function(fallback)
if cmp.visible() then
cmp.select_next_item()
else
fallback()
end
end,
['<S-Tab>'] = function(fallback)
if cmp.visible() then
cmp.select_prev_item()
else
fallback()
end
end,
['<CR>'] = cmp.mapping.confirm({ select = true }),
['<C-e>'] = cmp.mapping.abort(),
['<Esc>'] = cmp.mapping.close(),
['<C-d>'] = cmp.mapping.scroll_docs(-4),
['<C-f>'] = cmp.mapping.scroll_docs(4),
}),
sources = {
{ name = 'nvim_lsp' }, -- For nvim-lsp
{ name = 'ultisnips' }, -- For ultisnips user.
{ name = 'nvim_lua' }, -- for nvim lua function
{ name = 'path' }, -- for path completion
{ name = 'buffer', keyword_length = 4 }, -- for buffer word completion
{ name = 'omni' },
{ name = 'emoji', insert = true, } -- emoji completion
},
completion = {
keyword_length = 1,
completeopt = "menu,noselect"
},
experimental = {
ghost_text = false
view = {
entries = 'custom',
},
formatting = {
format = lspkind.cmp_format({
with_text = false,
menu = {
mode = "symbol_text",
menu = ({
nvim_lsp = "[LSP]",
ultisnips = "[US]",
nvim_lua = "[Lua]",
path = "[Path]",
buffer = "[Buffer]",
emoji = "[Emoji]",
},
omni = "[Omni]",
}),
}),
},
})
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
]]

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

@@ -0,0 +1,119 @@
local nvim_tree = require("nvim-tree")
nvim_tree.setup({
auto_reload_on_write = true,
disable_netrw = false,
hijack_cursor = false,
hijack_netrw = true,
hijack_unnamed_buffer_when_opening = false,
ignore_buffer_on_setup = false,
open_on_setup = false,
open_on_setup_file = false,
open_on_tab = false,
sort_by = "name",
update_cwd = false,
view = {
width = 30,
height = 30,
hide_root_folder = false,
side = "left",
preserve_window_proportions = false,
number = false,
relativenumber = false,
signcolumn = "yes",
mappings = {
custom_only = false,
list = {
-- user mappings go here
},
},
},
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 = {},
},
ignore_ft_on_setup = {},
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", "packer", "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,
},
},
})
vim.keymap.set('n', '<space>s', function()
return require('nvim-tree').toggle(false, true)
end,
{ noremap = true, silent = true, desc = "toggle nvim-tree"})

View File

@@ -5,6 +5,10 @@ vim.cmd[[ hi HopNextKey2 cterm=bold ctermfg=176 gui=bold guibg=#ff00ff guifg=#ff
require('hop').setup({
case_insensitive = true,
char2_fallback_key = '<CR>',
quit_key='<Esc>',
})
vim.api.nvim_set_keymap('n', 'f', "<cmd>lua require'hop'.hint_char2()<cr>", {noremap = true})
vim.keymap.set('n', 'f', function()
return require('hop').hint_char2()
end,
{ silent = true, noremap = true, desc = "nvim-hop char2" })

View File

@@ -1,3 +1,5 @@
local fn = vim.fn
local function spell()
if vim.o.spell then
return string.format("[SPELL]")
@@ -6,37 +8,65 @@ local function spell()
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 = 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
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 #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)
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 = vim.fn.search(space_pat, 'nwc')
local tab_indent = vim.fn.search(tab_pat, 'nwc')
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 = vim.fn.search([[\v^(\t+ | +\t)]], 'nwc')
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 = vim.fn.searchcount({pattern=space_pat, max_count=1e3}).total
local tab_indent_cnt = vim.fn.searchcount({pattern=tab_pat, max_count=1e3}).total
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
@@ -59,11 +89,15 @@ require("lualine").setup({
lualine_a = { "mode" },
lualine_b = { "branch", "diff" },
lualine_c = {
"filename",
{
ime_state,
color = {fg = 'black', bg = '#f46868'}
},
{
spell,
color = {fg = 'black', bg = '#a7c080'}
},
"filename"
},
lualine_x = {
"encoding",
@@ -82,7 +116,7 @@ require("lualine").setup({
"location",
{
"diagnostics",
sources = { "nvim_lsp" }
sources = { "nvim_diagnostic" }
},
{
trailing_space,
@@ -103,6 +137,6 @@ require("lualine").setup({
lualine_z = {},
},
tabline = {},
extensions = {'quickfix', 'fugitive'},
extensions = {'quickfix', 'fugitive', 'nvim-tree'},
})

11
lua/custom-map.lua Normal file
View File

@@ -0,0 +1,11 @@
local keymap = vim.keymap
-- 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>')

View File

@@ -4,14 +4,7 @@ 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 packer_repo = "https://github.com/wbthomason/packer.nvim"
local install_cmd = string.format("10split |term git clone --depth=1 %s %s", packer_repo, packer_install_dir)
-- Auto-install packer in case it hasn't been installed.
@@ -22,43 +15,41 @@ end
-- Load packer.nvim
vim.cmd("packadd packer.nvim")
local util = require('packer.util')
require("packer").startup({
local packer = require("packer")
local packer_util = require('packer.util')
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"}
use({"onsails/lspkind-nvim", event = "VimEnter"})
-- auto-completion engine
use {"hrsh7th/nvim-cmp", after = "lspkind-nvim", config = [[require('config.nvim-cmp')]]}
-- nvim-cmp completion sources
use {"hrsh7th/cmp-nvim-lsp", after = "nvim-cmp"}
-- 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')]] })
use {"hrsh7th/cmp-nvim-lua", after = "nvim-cmp"}
-- use {"hrsh7th/cmp-nvim-lua", after = "nvim-cmp"}
use {"hrsh7th/cmp-path", after = "nvim-cmp"}
use {"hrsh7th/cmp-buffer", after = "nvim-cmp"}
use { "hrsh7th/cmp-omni", after = "nvim-cmp" }
-- use {"hrsh7th/cmp-cmdline", after = "nvim-cmp"}
use {"quangnguyen30192/cmp-nvim-ultisnips", after = {'nvim-cmp', 'ultisnips'}}
if vim.g.is_mac then
use {"hrsh7th/cmp-emoji", after = 'nvim-cmp'}
end
-- nvim-lsp configuration (it relies on cmp-nvim-lsp, so it should be loaded after cmp-nvim-lsp).
use({ "neovim/nvim-lspconfig", after = "cmp-nvim-lsp", config = [[require('config.lsp')]] })
if vim.g.is_mac then
use({ "nvim-treesitter/nvim-treesitter", event = 'BufEnter', run = ":TSUpdate", config = [[require('config.treesitter')]] })
end
-- Python syntax highlighting and more
if vim.g.is_win then
use({ "numirias/semshi", ft = "python", config = "vim.cmd [[UpdateRemotePlugins]]" })
end
-- Python indent (follows the PEP8 style)
use({ "Vimjas/vim-python-pep8-indent", ft = { "python" } })
@@ -83,10 +74,15 @@ require("packer").startup({
}
-- Clear highlight search automatically for you
use({"romainl/vim-cool", event = "VimEnter"})
-- use({"romainl/vim-cool", event = "VimEnter"})
-- Show match number for search
use {'kevinhwang91/nvim-hlslens', branch = 'main', 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'})
@@ -124,25 +120,30 @@ require("packer").startup({
use({"NTBBloodbath/doom-one.nvim", opt = true})
use({"sainnhe/everforest", opt = true})
use({"EdenEast/nightfox.nvim", opt = true})
use({"rebelot/kanagawa.nvim", opt = true})
use({"catppuccin/nvim", as = "catppuccin", 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',
requires = {'kyazdani42/nvim-web-devicons', opt = true},
'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 { 'glepnir/dashboard-nvim', event = "VimEnter", config = [[require('config.dashboard-nvim')]] }
use({
"lukas-reineke/indent-blankline.nvim",
event = 'VimEnter',
config = [[require('config.indent-blankline')]]
})
@@ -185,13 +186,7 @@ require("packer").startup({
-- 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
})
use({"907th/vim-auto-save", event = "InsertEnter"})
-- Show undo history visually
use({"simnalamburt/vim-mundo", cmd = {"MundoToggle", "MundoShow"}})
@@ -230,7 +225,9 @@ require("packer").startup({
-- 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')]] })
use({ "christoomey/vim-conflicted", requires = "tpope/vim-fugitive", cmd = {"Conflicted"}})
use({ "kevinhwang91/nvim-bqf", ft = "qf", config = [[require('config.bqf')]] })
-- Better git commit experience
use({"rhysd/committia.vim", opt = true, setup = [[vim.cmd('packadd committia.vim')]]})
@@ -349,13 +346,21 @@ require("packer").startup({
-- show and trim trailing whitespaces
use {'jdhao/whitespace.nvim', event = 'VimEnter'}
-- file explorer
use {
'kyazdani42/nvim-tree.lua',
requires = { 'kyazdani42/nvim-web-devicons' },
config = [[require('config.nvim-tree')]]
}
use { 'ii14/emmylua-nvim', ft = 'lua' }
use { 'j-hui/fidget.nvim', after = 'nvim-lspconfig', config = [[require('config.fidget-nvim')]]}
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,
},
compile_path = packer_util.join_paths(fn.stdpath('data'), 'site', 'lua', 'packer_compiled.lua'),
},
})

View File

@@ -1,17 +1,35 @@
local fn = vim.fn
-- inspect something
-- Taken from https://github.com/jamestthompson3/vimConfig/blob/eeef4a8eeb5a24938f8a0969a35f69c78643fb66/lua/tt/nvim_utils.lua#L106
function inspect(item)
print(vim.inspect(item))
function _G.inspect(item)
vim.pretty_print(item)
end
local M = {}
function M.executable(name)
if vim.fn.executable(name) > 0 then
if fn.executable(name) > 0 then
return true
end
return false
end
function M.may_create_dir()
local fpath = fn.expand('<afile>')
local parent_dir = fn.fnamemodify(fpath, ":p:h")
local res = fn.isdirectory(parent_dir)
if res == 0 then
fn.mkdir(parent_dir, 'p')
end
end
function M.get_nvim_version()
local actual_ver = vim.version()
local nvim_ver_str = string.format("%d.%d.%d", actual_ver.major, actual_ver.minor, actual_ver.patch)
return nvim_ver_str
end
return M

View File

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

View File

@@ -23,7 +23,7 @@ snippet k3 "Three key strokes shortcut"
<kbd>${1:KEY}</kbd> + <kbd>${2:KEY}</kbd> + <kbd>${3:KEY}</kbd>
endsnippet
snippet "meta" "Markdown front matter (YAML format)" b
snippet meta "Markdown front matter (YAML format)" b
---
title: "$1"
date: `!p from datetime import datetime
@@ -70,3 +70,99 @@ endsnippet
snippet yh "直角引号" w
「$1」
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__":
main()
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"
\frac{${1:NUM}}{${2:DEN}} $0
snippet use "usepackage" b
\usepackage{${1:package}}
endsnippet
snippet eqa "equation enviroment" b
\begin{equation}\label{$1}
$2
\end{equation}
endsnippet

View File

@@ -8,3 +8,40 @@ call utils#Cabbrev('man', 'Man')
" show current date and time in human readable format
command! -nargs=? Datetime echo utils#iso_time(<q-args>)
" Convert Markdown file to PDF
command! ToPDF call s:md_to_pdf()
function! s:md_to_pdf() abort
" check if pandoc is installed
if executable('pandoc') != 1
echoerr "pandoc not found"
return
endif
let l:md_path = expand("%:p")
let l:pdf_path = fnamemodify(l:md_path, ":r") .. ".pdf"
let l:header_path = stdpath('config') . '/resources/head.tex'
let l:cmd = "pandoc --pdf-engine=xelatex --highlight-style=zenburn --table-of-content " .
\ "--include-in-header=" . l:header_path . " -V fontsize=10pt -V colorlinks -V toccolor=NavyBlue " .
\ "-V linkcolor=red -V urlcolor=teal -V filecolor=magenta -s " .
\ l:md_path . " -o " . l:pdf_path
if g:is_mac
let l:cmd = l:cmd . '&& open ' . l:pdf_path
endif
if g:is_win
let l:cmd = l:cmd . '&& start ' . l:pdf_path
endif
" echomsg l:cmd
let l:id = jobstart(l:cmd)
if l:id == 0 || l:id == -1
echoerr "Error running command"
endif
endfunction

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

@@ -345,3 +345,88 @@ teardown
github
fastgit
EOL
PyCharm
deduplication
STL
delimitMate
lspconfig
lualine
Keymap
iCloud
keyframe
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