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

83 Commits

Author SHA1 Message Date
jdhao
6df27d1c22 upgrade to neovim 0.9.2 2023-09-16 14:26:38 +02:00
jdhao
7f6627cfa1 update plugin conf for Lazy.nvim 2023-09-10 22:16:16 +02:00
jdhao
7ff11a9760 update plugin lazy loading events 2023-09-05 00:22:02 +02:00
jdhao
cc4688d089 Loosen the version check condition
Other version of nvim can still run this config, but should use with
care.
2023-09-01 21:39:08 +02:00
jdhao
8a1b3193a4 fix bufferline loading issue 2023-09-01 21:27:13 +02:00
jdhao
e92362041c fix hlslens issue when no pattern is found
The captured error message is not correct before.
2023-09-01 21:22:22 +02:00
jdhao
63ff776758 fix loading order of nvim-cmp and nvim-lsp 2023-09-01 20:52:46 +02:00
jdhao
41c8c81f21 update spell 2023-09-01 01:08:41 +02:00
jdhao
997c6286df Optimize plugin loading speed 2023-09-01 01:07:16 +02:00
jdhao
359621b126 fix multi visual line delete issue
For TextYankPost event, it includes both yank and delete, we should only
restore cursor position for yank, not for delete. Otherwise, it messes
up with text deletion when you visually select multiple lines and delete
them. See also issue reported here: https://github.com/jdhao/nvim-config/pull/222#issuecomment-1698634645
2023-09-01 00:26:08 +02:00
jdhao
4dc2d9575b disable horizontal scroll by mouse 2023-08-29 23:44:07 +02:00
jdhao
fc1c447319 fix multi-line yank issue, close #220
The previous way of keep the cursor while yanking is not perfect.
It will break multi-line yank (`{count}yy`).
2023-08-28 21:11:32 +02:00
jdhao
1391ca7ff1 feat: switch from packer.nvim to lazy.nvim 2023-08-27 23:14:31 +02:00
jdhao
6a6f8ff597 Update condition for installing vim-xkbswitch 2023-08-23 00:48:21 +02:00
jdhao
946e65662b fix nvimtree conf, close #215 2023-08-14 23:55:17 +02:00
jdhao
4a6379ca5d update git-linker conf
1. Add configuration for azure devops
2. change the mappings slightly
2023-08-09 19:52:58 +02:00
jdhao
855a88b532 fix: user lua conf reloading fails
The cache should be invalidated. This fix does not work 100%, because, e.g.,
there are other configs hiding deeper under lua/config/ directory.
A restart is the best way to reload the config.
2023-07-29 14:34:42 +02:00
jdhao
892cd49f06 doc: update doc and install guide for pylsp 2023-07-29 13:09:37 +02:00
jdhao
e53ee104ec feat: move lua conf under lua directory 2023-07-28 22:28:36 +02:00
jdhao
671c78df9b feat: more ignore files for LeaderF (#209) 2023-07-29 04:09:50 +08:00
jdhao
1608a36dd3 fix: conf is not local 2023-07-25 23:00:25 +02:00
jdhao
450f058da5 feat: support venv in Mypy
Specify the correct python executable path for mypy to work well.
2023-07-25 22:59:06 +02:00
jdhao
e2f348cb37 fix: missing nerdfonts
Since wezterm upgrade its support for Nerd Fonts 3.0, we should update
the codepoints used for some of the Unicode Icons. Their code points are
changed due to breaking changes in Nerd Fonts.
2023-07-25 22:53:20 +02:00
jdhao
fc8175d32d feat: update diagnostic mappings
Use separate key mappings to show diagnostics for the current buffer and
all opened files.
2023-07-22 15:01:41 +02:00
jdhao
4034b6b673 feat: update pylsp conf
1. support using black as formatter
2. replace obsolete pyls-isort with maintained ones
2023-07-22 14:51:27 +02:00
jdhao
67a4b6e6d0 feat: add treesitter toml 2023-07-22 14:46:10 +02:00
jdhao
bb27d93433 fix: move location indication to the right of statusline 2023-07-20 23:00:06 +02:00
jdhao
9d9c3ef32f feat: update diagnostic position in statusline
Do not show it in far right, move it to the left side for easier
visibility.
2023-07-20 22:52:55 +02:00
jdhao
00e8c77b23 Fix LeaderF bug
It will add files to buffer list even if we have not confirmed the
selection. This behavior is really annoying.
See also 27bd938a42.
2023-06-27 20:39:26 +02:00
jdhao
7bb3ccc275 use legacy version of fidget for now 2023-06-17 00:08:02 +02:00
jdhao
ee38046ebc Add folding support for JSON files 2023-06-13 22:25:25 +02:00
jdhao
6c873a32da update to nvim 0.9.1 2023-06-03 21:37:14 +02:00
jdhao
9ca65fd942 update conf for nvim-dashboard 2023-05-22 20:50:15 +02:00
jdhao
cc3a7d6ebd remove impatient.nvim
It is not needed since nvim 0.9.0
2023-05-07 20:10:52 +02:00
jdhao
f3a359a2fa conf for nvim 0.9.0 2023-04-20 22:36:48 +02:00
jdhao
9a4d71db88 update nvim-tree conf 2023-04-17 22:05:36 +02:00
jdhao
dc597004df Merge pull request #187 from mr-cal/nvim-tree-update
nvim-tree: fix shortcut and repo
2023-04-17 21:59:43 +02:00
jdhao
644993a89e bump to nvim version 0.9.0 (#188) 2023-04-08 04:42:24 +08:00
Callahan Kovacs
164d6129f8 nvim-tree: update other references
Signed-off-by: Callahan Kovacs <callahankovacs@gmail.com>
2023-04-05 08:37:16 -05:00
Callahan Kovacs
cde21f6f67 nvim-tree: use api and new repository url
Signed-off-by: Callahan Kovacs <callahankovacs@gmail.com>
2023-03-30 08:41:15 -05:00
jdhao
8746c7eb11 fix: omit the clangd missing message, close #180 (#186)
It is not necessary to install clangd if the user does not use neovim with CPP/C.
2023-03-13 19:55:00 +08:00
jdhao
7c44997289 refactor: lua language server rename (#185)
The lua language server from sumneko had changed its repo and created a
new organizational repo. See also https://github.com/neovim/nvim-lspconfig/pull/2439.
2023-02-16 17:39:23 +08:00
jdhao
bfdb3f5a26 bump supported nvim version (#184) 2023-02-11 11:42:57 +08:00
jdhao
76ced0e265 update contact info 2023-01-18 13:27:55 +08:00
jdhao
e84d18a204 update license year (#175) 2023-01-04 01:01:59 +08:00
jdhao
6429e8364c update nvim to version 0.8.2 (#173) 2022-12-31 10:13:39 +08:00
jdhao
f2c6900a8d update setting for onedarkpro (#172) 2022-12-28 22:29:49 +08:00
jdhao
116aaa0675 update spell 2022-12-14 12:55:41 +08:00
jdhao
12f3ca9d1f more abbr (#169) 2022-12-14 12:54:54 +08:00
jdhao
7e7944a30c use yanky.nvim to replace vim-yoink (#168) 2022-12-14 12:52:40 +08:00
bldur
53c17aea96 Add ltex-ls support to lsp. (#166)
* Add ltex-ls support to lsp.

Co-authored-by: bldur (https://github.com/bldur)
2022-11-28 17:35:43 +08:00
jdhao
43c1615822 fix: cmp-omni messes with the lsp completion
If we use cmp-omni and lsp together, it seems that it will mess the
autocompletion. So we only use it with tex file, where lsp in not used.
2022-11-22 21:19:53 +08:00
jdhao
509a8bce8c upgrade to latest stable 0.8.1 2022-11-22 21:16:17 +08:00
jdhao
8b10be60d4 update colorscheme list
- remove other gruvbox variant
- remove doom-one casue it has bugs
- add more colorschemes
2022-11-16 02:26:28 +08:00
jdhao
074d2bbdfd make filetype mapping local
Otherwise, the mapping will be global and leak to unrelated to files.
2022-11-15 01:10:26 +08:00
jdhao
7f9af87185 Merge branch 'master' of https://github.com/jdhao/nvim-config 2022-11-15 01:07:29 +08:00
jdhao
bb0b0c5e25 chore: relax vimtex install condition 2022-11-15 01:06:59 +08:00
jdhao
7bb12e4b70 chore: relax vimtex install condition 2022-11-15 01:04:31 +08:00
jdhao
41da56b823 Add my own abbreivations for some spell mistakes 2022-11-13 19:53:14 +08:00
jdhao
82f2332281 chore: update gitsigns highlight 2022-11-10 00:43:15 +08:00
jdhao
075326ee2e fix: make xkbswitch work on mac M1 CPU
For the details, see https://jdhao.github.io/2021/02/25/nvim_ime_mode_auto_switch/.
2022-11-07 00:47:04 +08:00
jdhao
baa8f26bc2 update spell 2022-11-01 22:27:35 +08:00
jdhao
e9760ae9b8 remove smooth scroll
I do not really need it.
2022-11-01 22:19:03 +08:00
jdhao
0d50eb723f chore: add notification for packer compile
Also move the autocmd location.
2022-11-01 22:02:45 +08:00
jdhao
b893bdc099 fix incorrect comment string for gitconf 2022-10-27 21:59:05 +08:00
jdhao
2073f72e67 refactor: use local diagnostic module 2022-10-23 15:18:03 +08:00
jdhao
364be4b5dc fix links 2022-10-20 13:23:38 +08:00
jdhao
d30d402128 update option 2022-10-19 20:52:51 +08:00
jdhao
fc144e0895 update badge 2022-10-19 12:13:13 +08:00
jdhao
18abfa7754 feat: add a mapping to blink cursor 2022-10-17 00:07:34 +08:00
jdhao
6c1dbdf8fc update spell 2022-10-16 10:26:41 +08:00
jdhao
202a9a088d remove vim-json
rarely used and it changes the conceal settings
2022-10-16 10:24:53 +08:00
jdhao
d939cc75c6 refactor: make packer installation a function 2022-10-16 10:23:40 +08:00
jdhao
26921309ec replace more viml with native lua code 2022-10-15 19:00:34 +08:00
jdhao
a6f716558b update nvim-cmp lsp conf 2022-10-15 18:30:14 +08:00
jdhao
3539207913 use 2 spaces for tabs by default
This removes a lot of code duplication. If we want to use 4 spaces, we
can set it separately in their ftplugin settings.
2022-10-15 11:28:15 +08:00
jdhao
d8b92965e8 change tab size for sql 2022-10-11 00:51:00 +08:00
jdhao
ebf7170916 use UTF-8 instead of utf-8, closes #134 2022-10-09 13:23:01 +08:00
jdhao
696466469b update spell 2022-10-05 23:01:23 +08:00
jdhao
7a5be43600 use lua func in rhs instead of callback 2022-10-05 22:42:02 +08:00
jdhao
3b39067097 update mousescroll 2022-10-05 22:39:13 +08:00
jdhao
e6b3be0777 remove language workaround for macOS
The issue has been fixed in https://github.com/neovim/neovim/pull/19139.
2022-10-05 22:33:13 +08:00
jdhao
acb423984a remove vim-asterisk
The * can now search selected text by default. The cursor stay feature
can also be simulated.
2022-10-05 12:42:45 +08:00
40 changed files with 1009 additions and 706 deletions

View File

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

View File

@@ -9,24 +9,27 @@
<a> <a>
<img alt="Windows" src="https://img.shields.io/badge/Windows-%23.svg?style=flat-square&logo=windows&color=0078D6&logoColor=white" /> <img alt="Windows" src="https://img.shields.io/badge/Windows-%23.svg?style=flat-square&logo=windows&color=0078D6&logoColor=white" />
</a> </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"> <a href="https://github.com/jdhao/nvim-config/releases/latest">
<img alt="Latest release" src="https://img.shields.io/github/v/release/jdhao/nvim-config" /> <img alt="Latest release" src="https://img.shields.io/github/v/release/jdhao/nvim-config" />
</a> </a>
<a href="https://github.com/neovim/neovim/releases/tag/stable"> <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"/> <img src="https://img.shields.io/badge/Neovim-0.9.2-blueviolet.svg?style=flat-square&logo=Neovim&logoColor=green" alt="Neovim minimum version"/>
</a> </a>
<a href="https://github.com/jdhao/nvim-config/search?l=vim-script"> <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"/> <img src="https://img.shields.io/github/languages/top/jdhao/nvim-config" alt="Top languages"/>
</a> </a>
<a href="https://github.com/jdhao/nvim-config/graphs/commit-activity">
<img src="https://img.shields.io/github/commit-activity/m/jdhao/nvim-config?style=flat-square" />
</a>
<a href="https://github.com/jdhao/nvim-config/releases/tag/v0.9.2">
<img src="https://img.shields.io/github/commits-since/jdhao/nvim-config/v0.9.2?style=flat-square" />
</a>
<a href="https://github.com/jdhao/nvim-config/graphs/contributors">
<img src="https://img.shields.io/github/contributors/jdhao/nvim-config?style=flat-square" />
</a>
<a>
<img src="https://img.shields.io/github/repo-size/jdhao/nvim-config?style=flat-square" />
</a>
<a href="https://github.com/jdhao/nvim-config/blob/master/LICENSE"> <a href="https://github.com/jdhao/nvim-config/blob/master/LICENSE">
<img src="https://img.shields.io/github/license/jdhao/nvim-config?style=flat-square&logo=GNU&label=License" alt="License"/> <img src="https://img.shields.io/github/license/jdhao/nvim-config?style=flat-square&logo=GNU&label=License" alt="License"/>
</a> </a>
@@ -54,7 +57,7 @@ and how to set up on different platforms (Linux, macOS, and Windows).
# Features # # Features #
+ Plugin management via [Packer.nvim](https://github.com/wbthomason/packer.nvim). + Plugin management via [Lazy.nvim](https://github.com/folke/lazy.nvim).
+ Code, snippet, word auto-completion via [nvim-cmp](https://github.com/hrsh7th/nvim-cmp). + 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). + Language server protocol (LSP) support via [nvim-lspconfig](https://github.com/neovim/nvim-lspconfig).
+ Git integration via [vim-fugitive](https://github.com/tpope/vim-fugitive). + Git integration via [vim-fugitive](https://github.com/tpope/vim-fugitive).
@@ -66,7 +69,7 @@ and how to set up on different platforms (Linux, macOS, and Windows).
+ Fast buffer jump via [hop.nvim](https://github.com/phaazon/hop.nvim). + Fast buffer jump via [hop.nvim](https://github.com/phaazon/hop.nvim).
+ Powerful snippet insertion via [Ultisnips](https://github.com/SirVer/ultisnips). + Powerful snippet insertion via [Ultisnips](https://github.com/SirVer/ultisnips).
+ Beautiful statusline via [lualine.nvim](https://github.com/nvim-lualine/lualine.nvim). + Beautiful statusline via [lualine.nvim](https://github.com/nvim-lualine/lualine.nvim).
+ File tree explorer via [nvim-tree.lua](https://github.com/kyazdani42/nvim-tree.lua). + File tree explorer via [nvim-tree.lua](https://github.com/nvim-tree/nvim-tree.lua).
+ Better quickfix list with [nvim-bqf](https://github.com/kevinhwang91/nvim-bqf). + Better quickfix list with [nvim-bqf](https://github.com/kevinhwang91/nvim-bqf).
+ Show search index and count with [nvim-hlslens](https://github.com/kevinhwang91/nvim-hlslens). + Show search index and count with [nvim-hlslens](https://github.com/kevinhwang91/nvim-hlslens).
+ Command line auto-completion via [wilder.nvim](https://github.com/gelguy/wilder.nvim). + Command line auto-completion via [wilder.nvim](https://github.com/gelguy/wilder.nvim).
@@ -76,9 +79,8 @@ and how to set up on different platforms (Linux, macOS, and Windows).
+ Code editing using true nvim inside browser via [firenvim](https://github.com/glacambre/firenvim). + Code editing using true nvim inside browser via [firenvim](https://github.com/glacambre/firenvim).
+ Beautiful colorscheme via [sainnhe/gruvbox-material](https://github.com/sainnhe/gruvbox-material) and other colorschemes. + Beautiful colorscheme via [sainnhe/gruvbox-material](https://github.com/sainnhe/gruvbox-material) and other colorschemes.
+ Markdown writing and previewing via [vim-markdown](https://github.com/preservim/vim-markdown) and [markdown-preview.nvim](https://github.com/iamcco/markdown-preview.nvim). + Markdown writing and previewing via [vim-markdown](https://github.com/preservim/vim-markdown) and [markdown-preview.nvim](https://github.com/iamcco/markdown-preview.nvim).
+ LaTeX editing and previewing via [vimtex](https://github.com/lervag/vimtex) <sup id="a1">[1](#f1)</sup>. + LaTeX editing and previewing via [vimtex](https://github.com/lervag/vimtex)
+ Animated GUI style notification via [nvim-notify](https://github.com/rcarriga/nvim-notify). + Animated GUI style notification via [nvim-notify](https://github.com/rcarriga/nvim-notify).
+ Smooth scroll experience via [neoscroll](https://github.com/karb94/neoscroll.nvim).
+ Tags navigation via [vista](https://github.com/liuchengxu/vista.vim). + Tags navigation via [vista](https://github.com/liuchengxu/vista.vim).
+ Code formatting via [Neoformat](https://github.com/sbdchd/neoformat). + Code formatting via [Neoformat](https://github.com/sbdchd/neoformat).
+ Undo management via [vim-mundo](https://github.com/simnalamburt/vim-mundo) + Undo management via [vim-mundo](https://github.com/simnalamburt/vim-mundo)
@@ -214,5 +216,3 @@ You may also be interested in my posts on configuring Nvim:
+ [Config nvim on Linux for Python development](https://jdhao.github.io/2018/12/24/centos_nvim_install_use_guide_en/) + [Config nvim on Linux for Python development](https://jdhao.github.io/2018/12/24/centos_nvim_install_use_guide_en/)
+ [Nvim config on Windows 10](https://jdhao.github.io/2018/11/15/neovim_configuration_windows/) + [Nvim config on Windows 10](https://jdhao.github.io/2018/11/15/neovim_configuration_windows/)
+ [Nvim-qt config on Windows 10](https://jdhao.github.io/2019/01/17/nvim_qt_settings_on_windows/) + [Nvim-qt config on Windows 10](https://jdhao.github.io/2019/01/17/nvim_qt_settings_on_windows/)
<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

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

View File

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

View File

@@ -1,8 +1,3 @@
" Disable inserting comment leader after hitting o or O or <Enter> " Disable inserting comment leader after hitting o or O or <Enter>
set formatoptions-=o set formatoptions-=o
set formatoptions-=r set formatoptions-=r
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

6
after/ftplugin/json.vim Normal file
View File

@@ -0,0 +1,6 @@
" let the initial folding state be that all folds are closed.
set foldlevel=0
" Use nvim-treesitter for folding
set foldmethod=expr
set foldexpr=nvim_treesitter#foldexpr()

View File

@@ -2,12 +2,7 @@
set formatoptions-=o set formatoptions-=o
set formatoptions-=r set formatoptions-=r
set tabstop=2 " number of visual spaces per TAB nnoremap <buffer><silent> <F9> :luafile %<CR>
set softtabstop=2 " number of spaces in tab when editing
set shiftwidth=2 " number of spaces to use for autoindent
set expandtab " expand tab to spaces so that tabs are spaces
nnoremap <silent> <F9> :luafile %<CR>
" For delimitMate " For delimitMate
let b:delimitMate_matchpairs = "(:),[:],{:}" let b:delimitMate_matchpairs = "(:),[:],{:}"

View File

@@ -8,5 +8,10 @@ set sidescroll=5
set sidescrolloff=2 set sidescrolloff=2
set colorcolumn=100 set colorcolumn=100
set tabstop=4 " number of visual spaces per TAB
set softtabstop=4 " number of spaces in tab when editing
set shiftwidth=4 " number of spaces to use for autoindent
set expandtab " expand tab to spaces so that tabs are spaces
" For delimitMate " For delimitMate
let b:delimitMate_matchpairs = "(:),[:],{:}" let b:delimitMate_matchpairs = "(:),[:],{:}"

View File

@@ -1,4 +0,0 @@
set tabstop=2 " number of visual spaces per TAB
set softtabstop=2 " number of spaces in tab when editing
set shiftwidth=2 " number of spaces to use for autoindent
set expandtab " expand tab to spaces so that tabs are spaces

View File

@@ -12,9 +12,4 @@ set foldmethod=expr foldexpr=utils#VimFolds(v:lnum) foldtext=utils#MyFoldText()
" see `:h K` and https://stackoverflow.com/q/15867323/6064933 " see `:h K` and https://stackoverflow.com/q/15867323/6064933
set keywordprg=:help set keywordprg=:help
set tabstop=2 " number of visual spaces per TAB nnoremap <buffer><silent> <F9> :source %<CR>
set softtabstop=2 " number of spaces in tab when editing
set shiftwidth=2 " number of spaces to use for autoindent
set expandtab " expand tab to spaces so that tabs are spaces
nnoremap <silent> <F9> :source %<CR>

View File

@@ -1,8 +1,3 @@
set tabstop=2 " number of visual spaces per TAB
set softtabstop=2 " number of spaces in tab when editing
set shiftwidth=2 " number of spaces to use for autoindent
set expandtab " expand tab to spaces so that tabs are spaces
" Turn off syntax highlighting for large YAML files. " Turn off syntax highlighting for large YAML files.
if line('$') > 500 if line('$') > 500
setlocal syntax=OFF setlocal syntax=OFF

View File

@@ -141,9 +141,7 @@ function! utils#Inside_git_repo() abort
if match(res, 'true') == -1 if match(res, 'true') == -1
return v:false return v:false
else else
" Manually trigger a special user autocmd InGitRepo (to use it for " Manually trigger a special user autocmd InGitRepo (used lazyloading.
" lazyloading of fugitive by packer.nvim).
" See also https://github.com/wbthomason/packer.nvim/discussions/534.
doautocmd User InGitRepo doautocmd User InGitRepo
return v:true return v:true
endif endif

View File

@@ -3,10 +3,6 @@ scriptencoding utf-8
" change fillchars for folding, vertical split, end of buffer, and message separator " change fillchars for folding, vertical split, end of buffer, and message separator
set fillchars=fold:\ ,vert:\│,eob:\ ,msgsep:‾ set fillchars=fold:\ ,vert:\│,eob:\ ,msgsep:‾
" Paste mode toggle, it seems that Nvim's bracketed paste mode
" does not work very well for nvim-qt, so we use good-old paste mode
set pastetoggle=<F12>
" Split window below/right when creating horizontal/vertical windows " Split window below/right when creating horizontal/vertical windows
set splitbelow splitright set splitbelow splitright
@@ -44,9 +40,9 @@ set backup " create backup for files
set backupcopy=yes " copy the original file to backupdir and overwrite it set backupcopy=yes " copy the original file to backupdir and overwrite it
" General tab settings " General tab settings
set tabstop=4 " number of visual spaces per TAB set tabstop=2 " number of visual spaces per TAB
set softtabstop=4 " number of spaces in tab when editing set softtabstop=2 " number of spaces in tab when editing
set shiftwidth=4 " number of spaces to use for autoindent set shiftwidth=2 " number of spaces to use for autoindent
set expandtab " expand tab to spaces so that tabs are spaces set expandtab " expand tab to spaces so that tabs are spaces
" Set matching pairs of characters and highlight matching brackets " Set matching pairs of characters and highlight matching brackets
@@ -75,6 +71,7 @@ set scrolloff=3
" Use mouse to select and resize windows, etc. " Use mouse to select and resize windows, etc.
set mouse=nic " Enable mouse in several mode set mouse=nic " Enable mouse in several mode
set mousemodel=popup " Set the behaviour of mouse set mousemodel=popup " Set the behaviour of mouse
set mousescroll=ver:1,hor:0
" Disable showing current mode on command line since statusline plugins can show it. " Disable showing current mode on command line since statusline plugins can show it.
set noshowmode set noshowmode
@@ -144,7 +141,7 @@ set formatoptions+=mM
" Tilde (~) is an operator, thus must be followed by motions like `e` or `w`. " Tilde (~) is an operator, thus must be followed by motions like `e` or `w`.
set tildeop set tildeop
set synmaxcol=200 " Text after this column number is not highlighted set synmaxcol=250 " Text after this column number is not highlighted
set nostartofline set nostartofline
" External program to use for grep command " External program to use for grep command
@@ -175,6 +172,7 @@ set diffopt+=filler " show filler for deleted lines
set diffopt+=closeoff " turn off diff when one file window is closed set diffopt+=closeoff " turn off diff when one file window is closed
set diffopt+=context:3 " context for diff set diffopt+=context:3 " context for diff
set diffopt+=internal,indent-heuristic,algorithm:histogram set diffopt+=internal,indent-heuristic,algorithm:histogram
set diffopt+=linematch:60
set nowrap " do no wrap set nowrap " do no wrap
set noruler set noruler

View File

@@ -7,10 +7,10 @@ lua require('plugins')
" To use these shortcuts: first activate command line with `:`, then input the " To use these shortcuts: first activate command line with `:`, then input the
" short alias, e.g., `pi`, then press <space>, the alias will be expanded to " short alias, e.g., `pi`, then press <space>, the alias will be expanded to
" the full command automatically. " the full command automatically.
call utils#Cabbrev('pi', 'PackerInstall') call utils#Cabbrev('pi', 'Lazy install')
call utils#Cabbrev('pud', 'PackerUpdate') call utils#Cabbrev('pud', 'Lazy update')
call utils#Cabbrev('pc', 'PackerClean') call utils#Cabbrev('pc', 'Lazy clean')
call utils#Cabbrev('ps', 'PackerSync') call utils#Cabbrev('ps', 'Lazy sync')
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" configurations for vim script plugin " " configurations for vim script plugin "
@@ -42,7 +42,7 @@ let g:Lf_UseMemoryCache = 0
" Ignore certain files and directories when searching files " Ignore certain files and directories when searching files
let g:Lf_WildIgnore = { let g:Lf_WildIgnore = {
\ 'dir': ['.git', '__pycache__', '.DS_Store'], \ 'dir': ['.git', '__pycache__', '.DS_Store', '*_cache'],
\ 'file': ['*.exe', '*.dll', '*.so', '*.o', '*.pyc', '*.jpg', '*.png', \ 'file': ['*.exe', '*.dll', '*.so', '*.o', '*.pyc', '*.jpg', '*.png',
\ '*.gif', '*.svg', '*.ico', '*.db', '*.tgz', '*.tar.gz', '*.gz', \ '*.gif', '*.svg', '*.ico', '*.db', '*.tgz', '*.tar.gz', '*.gz',
\ '*.zip', '*.bin', '*.pptx', '*.xlsx', '*.docx', '*.pdf', '*.tmp', \ '*.zip', '*.bin', '*.pptx', '*.xlsx', '*.docx', '*.pdf', '*.tmp',
@@ -109,6 +109,20 @@ let g:Lf_PopupColorscheme = 'gruvbox_material'
" items. " items.
let g:Lf_CommandMap = {'<C-J>': ['<C-N>'], '<C-K>': ['<C-P>']} let g:Lf_CommandMap = {'<C-J>': ['<C-N>'], '<C-K>': ['<C-P>']}
" do not preview results, it will add the file to buffer list
let g:Lf_PreviewResult = {
\ 'File': 0,
\ 'Buffer': 0,
\ 'Mru': 0,
\ 'Tag': 0,
\ 'BufTag': 1,
\ 'Function': 1,
\ 'Line': 0,
\ 'Colorscheme': 0,
\ 'Rg': 0,
\ 'Gtags': 0
\}
""""""""""""""""""""""""""""open-browser.vim settings""""""""""""""""""" """"""""""""""""""""""""""""open-browser.vim settings"""""""""""""""""""
if g:is_win || g:is_mac if g:is_win || g:is_mac
" Disable netrw's gx mapping. " Disable netrw's gx mapping.
@@ -137,31 +151,6 @@ let g:mundo_width = 80
nnoremap <silent> <Space>u :MundoToggle<CR> nnoremap <silent> <Space>u :MundoToggle<CR>
""""""""""""""""""""""""""""vim-yoink settings"""""""""""""""""""""""""
if g:is_win || g:is_mac
" ctrl-n and ctrl-p will not work if you add the TextChanged event to vim-auto-save events.
" nmap <c-n> <plug>(YoinkPostPasteSwapBack)
" nmap <c-p> <plug>(YoinkPostPasteSwapForward)
" The following p/P mappings are also needed for ctrl-n and ctrl-p to work
" nmap p <plug>(YoinkPaste_p)
" nmap P <plug>(YoinkPaste_P)
" Cycle the yank stack with the following mappings
nmap [y <plug>(YoinkRotateBack)
nmap ]y <plug>(YoinkRotateForward)
" Do not change the cursor position
nmap y <plug>(YoinkYankPreserveCursorPosition)
xmap y <plug>(YoinkYankPreserveCursorPosition)
" Move cursor to end of paste after multiline paste
let g:yoinkMoveCursorToEndOfPaste = 0
" Record yanks in system clipboard
let g:yoinkSyncSystemClipboardOnFocus = 1
endif
""""""""""""""""""""""""""""better-escape.vim settings""""""""""""""""""""""""" """"""""""""""""""""""""""""better-escape.vim settings"""""""""""""""""""""""""
let g:better_escape_interval = 200 let g:better_escape_interval = 200
@@ -243,7 +232,7 @@ nmap s <Nop>
omap s <Nop> omap s <Nop>
""""""""""""""""""""""""""""vimtex settings""""""""""""""""""""""""""""" """"""""""""""""""""""""""""vimtex settings"""""""""""""""""""""""""""""
if ( g:is_win || g:is_mac ) && executable('latex') if executable('latex')
" Hacks for inverse search to work semi-automatically, " Hacks for inverse search to work semi-automatically,
" see https://jdhao.github.io/2021/02/20/inverse_search_setup_neovim_vimtex/. " see https://jdhao.github.io/2021/02/20/inverse_search_setup_neovim_vimtex/.
function! s:write_server_name() abort function! s:write_server_name() abort
@@ -412,7 +401,7 @@ function! s:wilder_init() abort
\ 'apply_incsearch_fix': 0, \ 'apply_incsearch_fix': 0,
\ })) \ }))
catch /^Vim\%((\a\+)\)\=:E117/ catch /^Vim\%((\a\+)\)\=:E117/
echohl Error |echomsg "Wilder.nvim missing: run :PackerSync to fix."|echohl None echohl Error |echomsg "Wilder.nvim missing"| echohl None
endtry endtry
endfunction endfunction

View File

@@ -65,7 +65,7 @@ pip install -U pynvim
[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. [python-lsp-server (pylsp)](https://github.com/python-lsp/python-lsp-server) is a Python [Language Server](https://microsoft.github.io/language-server-protocol/) for completion, linting, go to definition, etc.
``` ```
pip install 'python-lsp-server[all]' pylsp-mypy pyls-isort pip install 'python-lsp-server[all]' pylsp-mypy python-lsp-isort python-lsp-black
``` ```
Note the executable for pylsp is also named `pylsp`. You need to set its PATH correctly. Note the executable for pylsp is also named `pylsp`. You need to set its PATH correctly.
@@ -111,7 +111,7 @@ vim-language-server is installed in the same directory as the node executable.
### Git ### Git
Git is required by plugin manager [packer.nvim](https://github.com/wbthomason/packer.nvim) and other git-related plugins. Git is required by plugin manager [lazy.nvim](https://github.com/folke/lazy.nvim) and other git-related plugins.
For Linux and macOS, Git is usually pre-installed. 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. The version of Git on the Linux system may be too old so that plugins may break.
@@ -201,22 +201,6 @@ After installing Nvim, we need to set the path to nvim correctly.
After installing nvim and all the dependencies, we will install plugin managers and set up this config. After installing nvim and all the dependencies, we will install plugin managers and set up this config.
### Install plugin manager packer.nvim
I use packer.nvim to manage my plugins. We need to install packer.nvim on our system first.
For Windows, if curl is installed, run the following command (on PowerShell):
```
git clone --depth=1 https://github.com/wbthomason/packer.nvim "$env:LOCALAPPDATA\nvim-data\site\pack\packer\opt\packer.nvim"
```
For macOS and Linux, run the following command:
```bash
git clone --depth=1 https://github.com/wbthomason/packer.nvim ~/.local/share/nvim/site/pack/packer/opt/packer.nvim
```
### How to install this configuration ### How to install this configuration
On Linux and macOS, the directory is `~/.config/nvim`. On Linux and macOS, the directory is `~/.config/nvim`.
@@ -228,7 +212,7 @@ then go to this directory, and run the following command:
git clone --depth=1 https://github.com/jdhao/nvim-config.git . git clone --depth=1 https://github.com/jdhao/nvim-config.git .
``` ```
After that, when we first open nvim, run command `:PackerSync` to install all the plugins. After that, when we first open nvim, all the plugins will be installed automatically.
Since I use quite a lot of plugins (more than 60), it may take some time to install all of them. 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. [^1]: Use `echo %userprofile%` to see where your `$HOME` is.

View File

@@ -68,7 +68,7 @@ fi
# Install some Python packages used by Nvim plugins. # Install some Python packages used by Nvim plugins.
echo "Installing Python packages" echo "Installing Python packages"
declare -a PY_PACKAGES=("pynvim" 'python-lsp-server[all]' "black" "vim-vint" "pyls-isort" "pylsp-mypy") declare -a PY_PACKAGES=("pynvim" 'python-lsp-server[all]' "vim-vint" "python-lsp-isort" "pylsp-mypy" "python-lsp-black")
if [[ "$SYSTEM_PYTHON" = true ]]; then if [[ "$SYSTEM_PYTHON" = true ]]; then
echo "Using system Python to install $(PY_PACKAGES)" echo "Using system Python to install $(PY_PACKAGES)"
@@ -124,27 +124,27 @@ fi
####################################################################### #######################################################################
# lua-language-server # # lua-language-server #
####################################################################### #######################################################################
SUMNEKO_LUA_DIR=$HOME/tools/lua-language-server LUA_LS_DIR=$HOME/tools/lua-language-server
SUMNEKO_LUA_SRC_NAME=$HOME/packages/lua-language-server.tar.gz LUA_LS_SRC=$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" LUA_LS_LINK="https://github.com/LuaLS/lua-language-server/releases/download/3.6.11/lua-language-server-3.6.11-linux-x64.tar.gz"
if [[ -z "$(command -v lua-language-server)" ]] && [[ ! -f "$SUMNEKO_LUA_DIR/bin/lua-language-server" ]]; then if [[ -z "$(command -v lua-language-server)" ]] && [[ ! -f "$LUA_LS_DIR/bin/lua-language-server" ]]; then
echo 'Install lua-language-server' echo 'Install lua-language-server'
if [[ ! -f $SUMNEKO_LUA_SRC_NAME ]]; then if [[ ! -f $LUA_LS_SRC ]]; then
echo "Downloading lua-language-server and renaming" echo "Downloading lua-language-server and renaming"
wget $SUMNEKO_LUA_LINK -O "$SUMNEKO_LUA_SRC_NAME" wget $LUA_LS_LINK -O "$LUA_LS_SRC"
fi fi
if [[ ! -d "$SUMNEKO_LUA_DIR" ]]; then if [[ ! -d "$LUA_LS_DIR" ]]; then
echo "Creating lua-language-server directory under tools directory" echo "Creating lua-language-server directory under tools directory"
mkdir -p "$SUMNEKO_LUA_DIR" mkdir -p "$LUA_LS_DIR"
echo "Extracting to directory $SUMNEKO_LUA_DIR" echo "Extracting to directory $LUA_LS_DIR"
tar zxvf "$SUMNEKO_LUA_SRC_NAME" -C "$SUMNEKO_LUA_DIR" tar zxvf "$LUA_LS_SRC" -C "$LUA_LS_DIR"
fi fi
if [[ "$ADD_TO_SYSTEM_PATH" = true ]] && [[ "$USE_BASH_SHELL" = true ]]; then if [[ "$ADD_TO_SYSTEM_PATH" = true ]] && [[ "$USE_BASH_SHELL" = true ]]; then
echo "export PATH=\"$SUMNEKO_LUA_DIR/bin:\$PATH\"" >> "$HOME/.bash_profile" echo "export PATH=\"$LUA_LS_DIR/bin:\$PATH\"" >> "$HOME/.bash_profile"
fi fi
else else
echo "lua-language-server is already installed. Skip installing it." echo "lua-language-server is already installed. Skip installing it."
@@ -252,13 +252,7 @@ fi
git clone --depth=1 https://github.com/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"
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" echo "Installing nvim plugins, please wait"
"$NVIM_DIR/bin/nvim" -c "autocmd User PackerComplete quitall" -c "PackerSync" "$NVIM_DIR/bin/nvim" -c "autocmd User LazyInstall quitall" -c "lua require('lazy').install()"
echo "Finished installing Nvim and its dependencies!" echo "Finished installing Nvim and its dependencies!"

View File

@@ -27,7 +27,7 @@ scoop install miniconda3
pip install -U pynvim pip install -U pynvim
# Install python-language-server # Install python-language-server
pip install 'python-lsp-server[all]' pylsp-mypy pyls-isort pip install 'python-lsp-server[all]' pylsp-mypy python-lsp-isort
# Install visual c++ redistribution # Install visual c++ redistribution
scoop install vcredist2022 scoop install vcredist2022
@@ -36,19 +36,19 @@ scoop install vcredist2022
scoop install 7zip scoop install 7zip
# Install lua-language-server # Install lua-language-server
$sumneko_lua_link = "https://github.com/sumneko/lua-language-server/releases/download/3.5.3/lua-language-server-3.5.3-win32-x64.zip" $lua_ls_link = "https://github.com/LuaLS/lua-language-server/releases/download/3.6.11/lua-language-server-3.6.11-win32-x64.zip"
$sumneko_lua_install_dir = "D:\portable_tools" $lua_ls_install_dir = "D:\portable_tools"
$sumneko_lua_src_dir = "$sumneko_lua_install_dir\lua-language-server.zip" $lua_ls_src_path = "$lua_ls_install_dir\lua-language-server.zip"
$sumneko_lua_dir = "$sumneko_lua_install_dir\lua-language-server" $lua_ls_dir = "$lua_ls_install_dir\lua-language-server"
# Download file, ref: https://stackoverflow.com/a/51225744/6064933 # Download file, ref: https://stackoverflow.com/a/51225744/6064933
Invoke-WebRequest $sumneko_lua_link -OutFile "$sumneko_lua_src_dir" Invoke-WebRequest $lua_ls_link -OutFile "$lua_ls_src_path"
# Extract the zip file using 7zip, ref: https://stackoverflow.com/a/41933215/6064933 # Extract the zip file using 7zip, ref: https://stackoverflow.com/a/41933215/6064933
7z x "$sumneko_lua_src_dir" -o"$sumneko_lua_dir" 7z x "$lua_ls_src_path" -o"$lua_ls_dir"
# Setup PATH env variable, ref: https://stackoverflow.com/q/714877/6064933 # Setup PATH env variable, ref: https://stackoverflow.com/q/714877/6064933
[Environment]::SetEnvironmentVariable("Path", $env:Path + ";$sumneko_lua_dir\bin", "Machine") [Environment]::SetEnvironmentVariable("Path", $env:Path + ";$lua_ls_dir\bin", "Machine")
# Install neovim nightly # Install neovim nightly
scoop bucket add versions scoop bucket add versions

View File

@@ -4,21 +4,24 @@
-- I would not recommend cloning this repo and replace your own config. Good configurations are personal, -- I would not recommend cloning this repo and replace your own config. Good configurations are personal,
-- built over time with a lot of polish. -- built over time with a lot of polish.
-- --
-- Author: Jie-dong Hao -- Author: Jiedong Hao
-- Email: jdhao@hotmail.com -- Email: jdhao@hotmail.com
-- Blog: https://jdhao.github.io/ -- Blog: https://jdhao.github.io/
-- GitHub: https://github.com/jdhao
-- StackOverflow: https://stackoverflow.com/users/6064933/jdhao
vim.loader.enable()
local api = vim.api local version = vim.version
local utils = require("utils")
-- check if we have the latest stable version of nvim -- check if we have the latest stable version of nvim
local expected_ver = "0.8.0" local expected_ver = "0.9.2"
local nvim_ver = utils.get_nvim_version() local ev = version.parse(expected_ver)
local actual_ver = version()
if nvim_ver ~= expected_ver then if version.cmp(ev, actual_ver) ~= 0 then
local msg = string.format("Unsupported nvim version: expect %s, but got %s instead!", expected_ver, nvim_ver) local _ver = string.format("%s.%s.%s", actual_ver.major, actual_ver.minor, actual_ver.patch)
api.nvim_err_writeln(msg) local msg = string.format("Expect nvim %s, but got %s instead. Use at your own risk!", expected_ver, _ver)
return vim.api.nvim_err_writeln(msg)
end end
local core_conf_files = { local core_conf_files = {
@@ -31,8 +34,14 @@ local core_conf_files = {
} }
-- source all the core config files -- source all the core config files
for _, name in ipairs(core_conf_files) do for _, file_name in ipairs(core_conf_files) do
local path = string.format("%s/core/%s", vim.fn.stdpath("config"), name) if vim.endswith(file_name, 'vim') then
local source_cmd = "source " .. path local path = string.format("%s/core/%s", vim.fn.stdpath("config"), file_name)
vim.cmd(source_cmd) local source_cmd = "source " .. path
vim.cmd(source_cmd)
else
local module_name, _ = string.gsub(file_name, "%.lua", "")
package.loaded[module_name] = nil
require(module_name)
end
end end

88
lazy-lock.json Normal file
View File

@@ -0,0 +1,88 @@
{
"LeaderF": { "branch": "master", "commit": "9c4451d2c1a6ea1f32e39fe52d58f6f5655b231d" },
"asyncrun.vim": { "branch": "master", "commit": "42385d54b8546c163b946fd50eed2103ef7993c9" },
"better-escape.vim": { "branch": "master", "commit": "6b16a45a839727977277f6ab11bded63e9ed86bb" },
"bufferline.nvim": { "branch": "main", "commit": "9961d87bb3ec008213c46ba14b3f384a5f520eb5" },
"catppuccin": { "branch": "main", "commit": "85e93601e0f0b48aa2c6bbfae4d0e9d7a1898280" },
"cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" },
"cmp-emoji": { "branch": "main", "commit": "19075c36d5820253d32e2478b6aaf3734aeaafa0" },
"cmp-nvim-lsp": { "branch": "main", "commit": "44b16d11215dce86f253ce0c30949813c0a90765" },
"cmp-nvim-ultisnips": { "branch": "main", "commit": "24bca5c3e137b28cd87442d4fc51a2b312dd99cc" },
"cmp-omni": { "branch": "main", "commit": "9436e6cdd7c5dfa24a99a60d9280b24dbdea3649" },
"cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" },
"committia.vim": { "branch": "master", "commit": "0b4df1a7f48ffbc23b009bd14d58ee1be541917c" },
"dashboard-nvim": { "branch": "master", "commit": "bbe0234168501b8ba46f24b4fb3cb7c5b88c0784" },
"delimitMate": { "branch": "master", "commit": "537a1da0fa5eeb88640425c37e545af933c56e1b" },
"dressing.nvim": { "branch": "master", "commit": "c1e1d5fa44fe08811b6ef4aadac2b50e602f9504" },
"edge": { "branch": "master", "commit": "a4fd4f458331d42677d992f428235c491b2016aa" },
"emmylua-nvim": { "branch": "master", "commit": "38720eb5f1dac8e87254fd944dbe0959b2e67d94" },
"everforest": { "branch": "master", "commit": "83b666410d7ae0eccf96dbbe3b4b6ac5b8172d38" },
"fidget.nvim": { "branch": "main", "commit": "0ba1e16d07627532b6cae915cc992ecac249fb97" },
"firenvim": { "branch": "master", "commit": "138424db463e6c0e862a05166a4ccc781cd7c19d" },
"gitlinker.nvim": { "branch": "master", "commit": "cc59f732f3d043b626c8702cb725c82e54d35c25" },
"gitsigns.nvim": { "branch": "main", "commit": "907ae8636016aab2f283576fc60d46ca3427e579" },
"gruvbox-material": { "branch": "master", "commit": "b5f8c6a6c1cda630c53b061b765068a0898d47a3" },
"hop.nvim": { "branch": "master", "commit": "1a1eceafe54b5081eae4cb91c723abd1d450f34b" },
"indent-blankline.nvim": { "branch": "master", "commit": "9637670896b68805430e2f72cf5d16be5b97a22a" },
"kanagawa.nvim": { "branch": "master", "commit": "a4e99f089110c6d00bc33f5497709200e914e763" },
"lazy.nvim": { "branch": "main", "commit": "2a9354c7d2368d78cbd5575a51a2af5bd8a6ad01" },
"lspkind-nvim": { "branch": "master", "commit": "57610d5ab560c073c465d6faf0c19f200cb67e6e" },
"lualine.nvim": { "branch": "master", "commit": "45e27ca739c7be6c49e5496d14fcf45a303c3a63" },
"markdown-preview.nvim": { "branch": "master", "commit": "02cc3874738bc0f86e4b91f09b8a0ac88aef8e96" },
"material.nvim": { "branch": "main", "commit": "1ecaa2d065a1ea308bd7702a77c2bf35ede8f536" },
"monokai.nvim": { "branch": "master", "commit": "b8bd44d5796503173627d7a1fc51f77ec3a08a63" },
"neoformat": { "branch": "master", "commit": "0c285d7a7c06a6ee88db70871a274797693fce42" },
"nightfox.nvim": { "branch": "main", "commit": "e886e39e592e89f316536a6f070365a9d88901c9" },
"nord.nvim": { "branch": "master", "commit": "15fbfc38a83980b93e169b32a1bf64757f1e2bf4" },
"nvim-bqf": { "branch": "main", "commit": "a906a9dfc1bd7b3ac51ac954e32e157ffad9a7cd" },
"nvim-cmp": { "branch": "main", "commit": "5dce1b778b85c717f6614e3f4da45e9f19f54435" },
"nvim-hlslens": { "branch": "main", "commit": "f0281591a59e95400babf61a96e59ba20e5c9533" },
"nvim-lspconfig": { "branch": "master", "commit": "cc388d3f6b9c7c943ae2b2dcd46ad470fd257f91" },
"nvim-notify": { "branch": "master", "commit": "94859430020f5cf32a1b97ddd9e596fed9db7981" },
"nvim-tree.lua": { "branch": "master", "commit": "94c7c810af205c0f00c8f105dcf490c8eb17658a" },
"nvim-treesitter": { "branch": "master", "commit": "bf8b089eecef9e9e8c1765f81613a2fd5e49175c" },
"nvim-web-devicons": { "branch": "master", "commit": "973ab742f143a796a779af4d786ec409116a0d87" },
"onedark.nvim": { "branch": "master", "commit": "dac8c39812dae025255c9069a260e1f69d967927" },
"onedarkpro.nvim": { "branch": "main", "commit": "fa861b992471d55f653751f1fea8769ca536a554" },
"open-browser.vim": { "branch": "master", "commit": "7d4c1d8198e889d513a030b5a83faa07606bac27" },
"plenary.nvim": { "branch": "master", "commit": "9ce85b0f7dcfe5358c0be937ad23e456907d410b" },
"rose-pine": { "branch": "main", "commit": "e29002cbee4854a9c8c4b148d8a52fae3176070f" },
"sonokai": { "branch": "master", "commit": "17308ee6d9c764bfc1e0fa97213e7a99701b4144" },
"tabular": { "branch": "master", "commit": "339091ac4dd1f17e225fe7d57b48aff55f99b23a" },
"targets.vim": { "branch": "master", "commit": "642d3a4ce306264b05ea3219920b13ea80931767" },
"telescope-symbols.nvim": { "branch": "master", "commit": "f2060117d965df4a626f068a4ebbd8ee051aa076" },
"telescope.nvim": { "branch": "master", "commit": "59812c26d826e8c717e29406267ea1260f71e103" },
"ultisnips": { "branch": "master", "commit": "24a3ebb36687b6d59a19d63173713575b486d739" },
"unicode.vim": { "branch": "master", "commit": "c8aa12b1e2e1b6254885b12bdb239ce6c885fdb1" },
"vim-auto-save": { "branch": "master", "commit": "2e3e54ea4c0fc946c21b0a4ee4c1c295ba736ee8" },
"vim-commentary": { "branch": "master", "commit": "e87cd90dc09c2a203e13af9704bd0ef79303d755" },
"vim-conflicted": { "branch": "master", "commit": "068c320796f807ac4961618e3e62316773803996" },
"vim-eunuch": { "branch": "master", "commit": "67f3dd32b4dcd1c427085f42ff5f29c7adc645c6" },
"vim-flog": { "branch": "master", "commit": "58c1d39ec42f92d23a1204b1869e5d1dece8b86c" },
"vim-fugitive": { "branch": "master", "commit": "6fcb0ad03982de646e3fecb6915e585651b9a9fb" },
"vim-grammarous": { "branch": "master", "commit": "db46357465ce587d5325e816235b5e92415f8c05" },
"vim-highlighturl": { "branch": "master", "commit": "012fee983e03913db6ba6393307eac434999b896" },
"vim-indent-object": { "branch": "master", "commit": "5c5b24c959478929b54a9e831a8e2e651a465965" },
"vim-markdown": { "branch": "master", "commit": "cc82d88e2a791f54d2b6e2b26e41f743351ac947" },
"vim-markdownfootnotes": { "branch": "master", "commit": "2b288149f48cfaf7465d25bb094ed62898f5e5b0" },
"vim-matchup": { "branch": "master", "commit": "6dbe108230c7dbbf00555b7d4d9f6a891837ef07" },
"vim-mundo": { "branch": "master", "commit": "b53d35fb5ca9923302b9ef29e618ab2db4cc675e" },
"vim-obsession": { "branch": "master", "commit": "fe9d3e1a9a50171e7d316a52e1e56d868e4c1fe5" },
"vim-python-pep8-indent": { "branch": "master", "commit": "60ba5e11a61618c0344e2db190210145083c91f8" },
"vim-pythonsense": { "branch": "master", "commit": "9200a57629c904ed2ab8c9b2e8c5649d311794ba" },
"vim-repeat": { "branch": "master", "commit": "24afe922e6a05891756ecf331f39a1f6743d3d5a" },
"vim-sandwich": { "branch": "master", "commit": "c5a2cc438ce6ea2005c556dc833732aa53cae21a" },
"vim-scriptease": { "branch": "master", "commit": "18511d389675d773994215ddb572ccdc2b72f52b" },
"vim-snippets": { "branch": "master", "commit": "ccc2fa1529d372f7ac16d5eb07a385a72b50e05d" },
"vim-swap": { "branch": "master", "commit": "9358bfdc5e377aa13e7c2c2dd8699ba32b0dcf83" },
"vim-tmux": { "branch": "master", "commit": "cfe76281efc29890548cf9eedd42ad51c7a1faf0" },
"vim-toml": { "branch": "main", "commit": "d36caa6b1cf508a4df1c691f915572fc02143258" },
"vim-xkbswitch": { "branch": "master", "commit": "42b55bfec8f6dbd715135ce582a6f769831face1" },
"vimtex": { "branch": "master", "commit": "2b8a5f16a5768b3ae1780c266b73022dbb658af1" },
"vista.vim": { "branch": "master", "commit": "40daf5e97be70a90465182fbbdfba92442bfd8e1" },
"which-key.nvim": { "branch": "main", "commit": "7ccf476ebe0445a741b64e36c78a682c1c6118b7" },
"whitespace.nvim": { "branch": "master", "commit": "f0fc9e9c4ce3f7d2166e9e5a069b64b9ca4a3f15" },
"wilder.nvim": { "branch": "master", "commit": "679f348dc90d80ff9ba0e7c470c40a4d038dcecf" },
"yanky.nvim": { "branch": "main", "commit": "4c85d8d6808d9859e72f8bd6c25302199e6a5eac" },
"zen-mode.nvim": { "branch": "main", "commit": "68f554702de63f4b7b6b6d4bcb10178f41a0acc7" }
}

View File

@@ -7,17 +7,19 @@ local M = {}
-- Colorscheme to its directory name mapping, because colorscheme repo name is not necessarily -- Colorscheme to its directory name mapping, because colorscheme repo name is not necessarily
-- the same as the colorscheme name itself. -- the same as the colorscheme name itself.
M.colorscheme2dir = { M.colorscheme2dir = {
gruvbox8 = "vim-gruvbox8",
onedark = "onedark.nvim", onedark = "onedark.nvim",
edge = "edge", edge = "edge",
sonokai = "sonokai", sonokai = "sonokai",
gruvbox_material = "gruvbox-material", gruvbox_material = "gruvbox-material",
nord = "nord.nvim", nord = "nord.nvim",
doom_one = "doom-one.nvim",
everforest = "everforest", everforest = "everforest",
nightfox = "nightfox.nvim", nightfox = "nightfox.nvim",
kanagawa = "kanagawa.nvim", kanagawa = "kanagawa.nvim",
catppuccin = "catppuccin", catppuccin = "catppuccin",
rose_pine = "rose-pine",
onedarkpro = "onedarkpro.nvim",
monokai = "monokai.nvim",
material = "material.nvim",
} }
M.gruvbox8 = function() M.gruvbox8 = function()
@@ -50,6 +52,10 @@ M.sonokai = function()
end end
M.gruvbox_material = function() M.gruvbox_material = function()
-- foreground option can be material, mix, or original
vim.g.gruvbox_material_foreground = "material"
--background option can be hard, medium, soft
vim.g.gruvbox_material_background = "soft"
vim.g.gruvbox_material_enable_italic = 1 vim.g.gruvbox_material_enable_italic = 1
vim.g.gruvbox_material_better_performance = 1 vim.g.gruvbox_material_better_performance = 1
@@ -88,6 +94,30 @@ M.catppuccin = function()
vim.cmd([[colorscheme catppuccin]]) vim.cmd([[colorscheme catppuccin]])
end end
M.rose_pine = function()
require('rose-pine').setup({
--- @usage 'main' | 'moon'
dark_variant = 'moon',
})
-- set colorscheme after options
vim.cmd('colorscheme rose-pine')
end
M.onedarkpro = function()
-- set colorscheme after options
vim.cmd('colorscheme onedark_vivid')
end
M.monokai = function()
vim.cmd('colorscheme monokai_pro')
end
M.material = function ()
vim.g.material_style = "oceanic"
vim.cmd('colorscheme material')
end
--- Use a random colorscheme from the pre-defined list of colorschemes. --- Use a random colorscheme from the pre-defined list of colorschemes.
M.rand_colorscheme = function() M.rand_colorscheme = function()
local colorscheme = utils.rand_element(vim.tbl_keys(M.colorscheme2dir)) local colorscheme = utils.rand_element(vim.tbl_keys(M.colorscheme2dir))
@@ -99,16 +129,6 @@ M.rand_colorscheme = function()
return return
end end
-- Load the colorscheme, because all the colorschemes are declared as opt plugins, so the colorscheme isn't loaded yet.
local status = utils.add_pack(M.colorscheme2dir[colorscheme])
if not status then
local msg = string.format("Colorscheme %s is not installed. Run PackerSync to install.", colorscheme)
vim.notify(msg, vim.log.levels.ERROR, { title = "nvim-config" })
return
end
-- Load the colorscheme and its settings -- Load the colorscheme and its settings
M[colorscheme]() M[colorscheme]()

View File

@@ -9,7 +9,7 @@ require("bufferline").setup {
icon = "", -- this should be omitted if indicator style is not 'icon' icon = "", -- this should be omitted if indicator style is not 'icon'
style = "icon", style = "icon",
}, },
buffer_close_icon = "", buffer_close_icon = "",
modified_icon = "", modified_icon = "",
close_icon = "", close_icon = "",
left_trunc_marker = "", left_trunc_marker = "",

View File

@@ -1,6 +1,9 @@
local api = vim.api
local keymap = vim.keymap
local dashboard = require("dashboard") local dashboard = require("dashboard")
dashboard.custom_header = { local conf = {}
conf.header = {
" ", " ",
" ", " ",
" ", " ",
@@ -16,50 +19,57 @@ dashboard.custom_header = {
" ", " ",
} }
dashboard.custom_center = { conf.center = {
{ {
icon = " ", icon = "󰈞 ",
desc = "Find File ", desc = "Find File ",
action = "Leaderf file --popup", action = "Leaderf file --popup",
shortcut = "<Leader> f f", key = "<Leader> f f",
}, },
{ {
icon = " ", icon = "󰈢 ",
desc = "Recently opened files ", desc = "Recently opened files ",
action = "Leaderf mru --popup", action = "Leaderf mru --popup",
shortcut = "<Leader> f r", key = "<Leader> f r",
}, },
{ {
icon = " ", icon = "󰈬 ",
desc = "Project grep ", desc = "Project grep ",
action = "Leaderf rg --popup", action = "Leaderf rg --popup",
shortcut = "<Leader> f g", key = "<Leader> f g",
}, },
{ {
icon = " ", icon = " ",
desc = "Open Nvim config ", desc = "Open Nvim config ",
action = "tabnew $MYVIMRC | tcd %:p:h", action = "tabnew $MYVIMRC | tcd %:p:h",
shortcut = "<Leader> e v", key = "<Leader> e v",
}, },
{ {
icon = "", icon = "",
desc = "New file ", desc = "New file ",
action = "enew", action = "enew",
shortcut = "e ", key = "e",
}, },
{ {
icon = " ", icon = "󰗼 ",
desc = "Quit Nvim ", desc = "Quit Nvim ",
-- desc = "Quit Nvim ", -- desc = "Quit Nvim ",
action = "qa", action = "qa",
shortcut = "q ", key = "q",
}, },
} }
vim.cmd([[ dashboard.setup({
augroup dashboard_enter theme = 'doom',
au! shortcut_type = 'number',
autocmd FileType dashboard nnoremap <buffer> q :qa<CR> config = conf
autocmd FileType dashboard nnoremap <buffer> e :enew<CR> })
augroup END
]]) api.nvim_create_autocmd("FileType", {
pattern = "dashboard",
group = api.nvim_create_augroup("dashboard_enter", { clear = true }),
callback = function ()
keymap.set("n", "q", ":qa<CR>", { buffer = true, silent = true })
keymap.set("n", "e", ":enew<CR>", { buffer = true, silent = true })
end
})

View File

@@ -2,24 +2,36 @@ local keymap = vim.keymap
local gitlinker = require("gitlinker") local gitlinker = require("gitlinker")
gitlinker.setup { gitlinker.setup {
callbacks = {
["dev.azure.com"] = function(url_data)
vim.print(url_data)
local url = require"gitlinker.hosts".get_base_https_url(url_data)
if url_data.lstart then
if url_data.lend == nil then
url_data.lend = url_data.lstart
end
url = url .. "?path=/" .. url_data.file .. "&version=GC" .. url_data.rev .. "&line=" .. url_data.lstart .. "&lineEnd=" .. url_data.lend .. "&lineStartColumn=1" .. "&lineEndColumn=120"
end
return url
end
},
mappings = nil, mappings = nil,
} }
keymap.set({ "n", "v" }, "<leader>gl", "", { keymap.set({ "n", "v" }, "<leader>gl", function()
local mode = string.lower(vim.fn.mode())
gitlinker.get_buf_range_url(mode)
end, {
silent = true, silent = true,
desc = "get git permlink", desc = "get git permlink",
callback = function()
local mode = string.lower(vim.fn.mode())
gitlinker.get_buf_range_url(mode)
end,
}) })
keymap.set("n", "<leader>gb", "", { keymap.set("n", "<leader>gb", function()
gitlinker.get_repo_url({
action_callback = gitlinker.actions.open_in_browser
})
end, {
silent = true, silent = true,
desc = "browse repo in browser", desc = "browse repo in browser",
callback = function()
gitlinker.get_repo_url({
action_callback = gitlinker.actions.open_in_browser
})
end
}) })

View File

@@ -49,9 +49,9 @@ vim.api.nvim_create_autocmd('ColorScheme', {
pattern = "*", pattern = "*",
callback = function() callback = function()
vim.cmd [[ vim.cmd [[
hi GitSignsChangeInline guibg=fg guifg=bg hi GitSignsChangeInline gui=reverse
hi GitSignsAddInline guibg=fg guifg=bg hi GitSignsAddInline gui=reverse
hi GitSignsDeleteInline guibg=fg guifg=bg hi GitSignsDeleteInline gui=reverse
]] ]]
end end
}) })

View File

@@ -12,10 +12,11 @@ local activate_hlslens = function(direction)
local cmd = string.format("normal! %s%szzzv", vim.v.count1, direction) local cmd = string.format("normal! %s%szzzv", vim.v.count1, direction)
local status, msg = pcall(vim.cmd, cmd) local status, msg = pcall(vim.cmd, cmd)
-- Deal with the case that there is no such pattern in current buffer.
if not status then if not status then
-- 13 is the index where real error message starts local start_idx, _ = string.find(msg, 'E486', 1, true)
msg = msg:sub(13) local msg_part = string.sub(msg, start_idx)
api.nvim_err_writeln(msg) api.nvim_err_writeln(msg_part)
return return
end end
@@ -34,5 +35,15 @@ keymap.set("n", "N", "", {
end, end,
}) })
keymap.set("n", "*", "<Plug>(asterisk-z*)<Cmd>lua require('hlslens').start()<CR>") keymap.set("n", "*", "", {
keymap.set("n", "#", "<Plug>(asterisk-z#)<Cmd>lua require('hlslens').start()<CR>") callback = function()
vim.fn.execute("normal! *N")
hlslens.start()
end,
})
keymap.set("n", "#", "", {
callback = function()
vim.fn.execute("normal! #N")
hlslens.start()
end,
})

View File

@@ -2,9 +2,22 @@ local fn = vim.fn
local api = vim.api local api = vim.api
local keymap = vim.keymap local keymap = vim.keymap
local lsp = vim.lsp local lsp = vim.lsp
local diagnostic = vim.diagnostic
local utils = require("utils") local utils = require("utils")
-- set quickfix list from diagnostics in a certain buffer, not the whole workspace
local set_qflist = function(buf_num, severity)
local diagnostics = nil
diagnostics = diagnostic.get(buf_num, { severity = severity })
local qf_items = diagnostic.toqflist(diagnostics)
vim.fn.setqflist({}, ' ', { title = 'Diagnostics', items = qf_items })
-- open quickfix by default
vim.cmd[[copen]]
end
local custom_attach = function(client, bufnr) local custom_attach = function(client, bufnr)
-- Mappings. -- Mappings.
local map = function(mode, l, r, opts) local map = function(mode, l, r, opts)
@@ -20,11 +33,12 @@ local custom_attach = function(client, bufnr)
map("n", "<C-k>", vim.lsp.buf.signature_help) map("n", "<C-k>", vim.lsp.buf.signature_help)
map("n", "<space>rn", vim.lsp.buf.rename, { desc = "varialbe rename" }) map("n", "<space>rn", vim.lsp.buf.rename, { desc = "varialbe rename" })
map("n", "gr", vim.lsp.buf.references, { desc = "show references" }) map("n", "gr", vim.lsp.buf.references, { desc = "show references" })
map("n", "[d", vim.diagnostic.goto_prev, { desc = "previous diagnostic" }) map("n", "[d", diagnostic.goto_prev, { desc = "previous diagnostic" })
map("n", "]d", vim.diagnostic.goto_next, { desc = "next diagnostic" }) map("n", "]d", diagnostic.goto_next, { desc = "next diagnostic" })
map("n", "<space>q", function() -- this puts diagnostics from opened files to quickfix
vim.diagnostic.setqflist { open = true } map("n", "<space>qw", diagnostic.setqflist, { desc = "put window diagnostics to qf" })
end, { desc = "put diagnostic to qf" }) -- this puts diagnostics from current buffer to quickfix
map("n", "<space>qb", function() set_qflist(bufnr) end, { desc = "put buffer diagnostics to qf" })
map("n", "<space>ca", vim.lsp.buf.code_action, { desc = "LSP code action" }) map("n", "<space>ca", vim.lsp.buf.code_action, { desc = "LSP code action" })
map("n", "<space>wa", vim.lsp.buf.add_workspace_folder, { desc = "add workspace folder" }) map("n", "<space>wa", vim.lsp.buf.add_workspace_folder, { desc = "add workspace folder" })
map("n", "<space>wr", vim.lsp.buf.remove_workspace_folder, { desc = "remove workspace folder" }) map("n", "<space>wr", vim.lsp.buf.remove_workspace_folder, { desc = "remove workspace folder" })
@@ -54,9 +68,9 @@ local custom_attach = function(client, bufnr)
local cursor_pos = api.nvim_win_get_cursor(0) 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]) if (cursor_pos[1] ~= vim.b.diagnostics_pos[1] or cursor_pos[2] ~= vim.b.diagnostics_pos[2])
and #vim.diagnostic.get() > 0 and #diagnostic.get() > 0
then then
vim.diagnostic.open_float(nil, float_opts) diagnostic.open_float(nil, float_opts)
end end
vim.b.diagnostics_pos = cursor_pos vim.b.diagnostics_pos = cursor_pos
@@ -69,12 +83,24 @@ local custom_attach = function(client, bufnr)
hi! link LspReferenceRead Visual hi! link LspReferenceRead Visual
hi! link LspReferenceText Visual hi! link LspReferenceText Visual
hi! link LspReferenceWrite Visual hi! link LspReferenceWrite Visual
augroup lsp_document_highlight
autocmd! * <buffer>
autocmd CursorHold <buffer> lua vim.lsp.buf.document_highlight()
autocmd CursorMoved <buffer> lua vim.lsp.buf.clear_references()
augroup END
]]) ]])
local gid = api.nvim_create_augroup("lsp_document_highlight", { clear = true })
api.nvim_create_autocmd("CursorHold" , {
group = gid,
buffer = bufnr,
callback = function ()
lsp.buf.document_highlight()
end
})
api.nvim_create_autocmd("CursorMoved" , {
group = gid,
buffer = bufnr,
callback = function ()
lsp.buf.clear_references()
end
})
end end
if vim.g.logging_level == "debug" then if vim.g.logging_level == "debug" then
@@ -83,24 +109,45 @@ local custom_attach = function(client, bufnr)
end end
end end
local capabilities = lsp.protocol.make_client_capabilities() local capabilities = require('cmp_nvim_lsp').default_capabilities()
capabilities = require("cmp_nvim_lsp").update_capabilities(capabilities)
capabilities.textDocument.completion.completionItem.snippetSupport = true
local lspconfig = require("lspconfig") local lspconfig = require("lspconfig")
if utils.executable("pylsp") then if utils.executable("pylsp") then
local venv_path = os.getenv('VIRTUAL_ENV')
local py_path = nil
-- decide which python executable to use for mypy
if venv_path ~= nil then
py_path = venv_path .. "/bin/python3"
else
py_path = vim.g.python3_host_prog
end
lspconfig.pylsp.setup { lspconfig.pylsp.setup {
on_attach = custom_attach, on_attach = custom_attach,
settings = { settings = {
pylsp = { pylsp = {
plugins = { plugins = {
-- formatter options
black = { enabled = true },
autopep8 = { enabled = false },
yapf = { enabled = false },
-- linter options
pylint = { enabled = true, executable = "pylint" }, pylint = { enabled = true, executable = "pylint" },
ruff = { enabled = false },
pyflakes = { enabled = false }, pyflakes = { enabled = false },
pycodestyle = { enabled = false }, pycodestyle = { enabled = false },
-- type checker
pylsp_mypy = {
enabled = true,
overrides = { "--python-executable", py_path, true },
report_progress = true,
live_mode = false
},
-- auto-completion options
jedi_completion = { fuzzy = true }, jedi_completion = { fuzzy = true },
pyls_isort = { enabled = true }, -- import sorting
pylsp_mypy = { enabled = true }, isort = { enabled = true },
}, },
}, },
}, },
@@ -122,6 +169,20 @@ end
-- vim.notify("pyright not found!", vim.log.levels.WARN, {title = 'Nvim-config'}) -- vim.notify("pyright not found!", vim.log.levels.WARN, {title = 'Nvim-config'})
-- end -- end
if utils.executable("ltex-ls") then
lspconfig.ltex.setup {
on_attach = custom_attach,
cmd = { "ltex-ls" },
filetypes = { "text", "plaintex", "tex", "markdown" },
settings = {
ltex = {
language = "en"
},
},
flags = { debounce_text_changes = 300 },
}
end
if utils.executable("clangd") then if utils.executable("clangd") then
lspconfig.clangd.setup { lspconfig.clangd.setup {
on_attach = custom_attach, on_attach = custom_attach,
@@ -131,8 +192,6 @@ if utils.executable("clangd") then
debounce_text_changes = 500, debounce_text_changes = 500,
}, },
} }
else
vim.notify("clangd not found!", vim.log.levels.WARN, { title = "Nvim-config" })
end end
-- set up vim-language-server -- set up vim-language-server
@@ -157,8 +216,8 @@ if utils.executable("bash-language-server") then
end end
if utils.executable("lua-language-server") then 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 . -- settings for lua-language-server can be found on https://github.com/LuaLS/lua-language-server/wiki/Settings .
lspconfig.sumneko_lua.setup { lspconfig.lua_ls.setup {
on_attach = custom_attach, on_attach = custom_attach,
settings = { settings = {
Lua = { Lua = {
@@ -172,10 +231,10 @@ if utils.executable("lua-language-server") then
}, },
workspace = { workspace = {
-- Make the server aware of Neovim runtime files, -- Make the server aware of Neovim runtime files,
-- see also https://github.com/sumneko/lua-language-server/wiki/Libraries#link-to-workspace . -- see also https://github.com/LuaLS/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 . -- Lua-dev.nvim also has similar settings for lua ls, https://github.com/folke/neodev.nvim/blob/main/lua/neodev/luals.lua .
library = { library = {
fn.stdpath("data") .. "/site/pack/packer/opt/emmylua-nvim", fn.stdpath("data") .. "/lazy/emmylua-nvim",
fn.stdpath("config"), fn.stdpath("config"),
}, },
maxPreload = 2000, maxPreload = 2000,
@@ -188,13 +247,13 @@ if utils.executable("lua-language-server") then
end end
-- Change diagnostic signs. -- Change diagnostic signs.
fn.sign_define("DiagnosticSignError", { text = "", texthl = "DiagnosticSignError" }) fn.sign_define("DiagnosticSignError", { text = '🆇', texthl = "DiagnosticSignError" })
fn.sign_define("DiagnosticSignWarn", { text = "!", texthl = "DiagnosticSignWarn" }) fn.sign_define("DiagnosticSignWarn", { text = '⚠️', texthl = "DiagnosticSignWarn" })
fn.sign_define("DiagnosticSignInformation", { text = "", texthl = "DiagnosticSignInfo" }) fn.sign_define("DiagnosticSignInfo", { text = '', texthl = "DiagnosticSignInfo" })
fn.sign_define("DiagnosticSignHint", { text = "", texthl = "DiagnosticSignHint" }) fn.sign_define("DiagnosticSignHint", { text = '', texthl = "DiagnosticSignHint" })
-- global config for diagnostic -- global config for diagnostic
vim.diagnostic.config { diagnostic.config {
underline = false, underline = false,
virtual_text = false, virtual_text = false,
signs = true, signs = true,

View File

@@ -1,21 +0,0 @@
require("neoscroll").setup {
easing_function = "quadratic",
}
local t = {}
-- Syntax: t[keys] = {function, {function arguments}}
-- Use the "sine" easing function
t["<C-u>"] = { "scroll", { "-vim.wo.scroll", "true", "20", [['cubic']] } }
t["<C-d>"] = { "scroll", { "vim.wo.scroll", "true", "20", [['cubic']] } }
-- Use the "circular" easing function
t["<C-b>"] = { "scroll", { "-vim.api.nvim_win_get_height(0)", "true", "50", [['cubic']] } }
t["<C-f>"] = { "scroll", { "vim.api.nvim_win_get_height(0)", "true", "50", [['cubic']] } }
-- Pass "nil" to disable the easing animation (constant scrolling speed)
t["<C-y>"] = { "scroll", { "-0.10", "false", "100", nil } }
t["<C-e>"] = { "scroll", { "0.10", "false", "100", nil } }
-- When no easing function is provided the default easing function (in this case "quadratic") will be used
t["zt"] = { "zt", { "10" } }
t["zz"] = { "zz", { "10" } }
t["zb"] = { "zb", { "10" } }
require("neoscroll.config").set_mappings(t)

View File

@@ -35,7 +35,6 @@ cmp.setup {
{ name = "ultisnips" }, -- For ultisnips user. { name = "ultisnips" }, -- For ultisnips user.
{ name = "path" }, -- for path completion { name = "path" }, -- for path completion
{ name = "buffer", keyword_length = 2 }, -- for buffer word completion { name = "buffer", keyword_length = 2 }, -- for buffer word completion
{ name = "omni" },
{ name = "emoji", insert = true }, -- emoji completion { name = "emoji", insert = true }, -- emoji completion
}, },
completion = { completion = {
@@ -61,6 +60,15 @@ cmp.setup {
}, },
} }
cmp.setup.filetype("tex", {
sources = {
{ name = "omni" },
{ name = "ultisnips" }, -- For ultisnips user.
{ name = "buffer", keyword_length = 2 }, -- for buffer word completion
{ name = "path" }, -- for path completion
},
})
-- see https://github.com/hrsh7th/nvim-cmp/wiki/Menu-Appearance#how-to-add-visual-studio-code-dark-theme-colors-to-the-menu -- see https://github.com/hrsh7th/nvim-cmp/wiki/Menu-Appearance#how-to-add-visual-studio-code-dark-theme-colors-to-the-menu
vim.cmd([[ vim.cmd([[
highlight! link CmpItemMenu Comment highlight! link CmpItemMenu Comment

View File

@@ -7,9 +7,6 @@ nvim_tree.setup {
hijack_cursor = false, hijack_cursor = false,
hijack_netrw = true, hijack_netrw = true,
hijack_unnamed_buffer_when_opening = false, hijack_unnamed_buffer_when_opening = false,
ignore_buffer_on_setup = false,
open_on_setup = false,
open_on_setup_file = false,
open_on_tab = false, open_on_tab = false,
sort_by = "name", sort_by = "name",
update_cwd = false, update_cwd = false,
@@ -21,12 +18,6 @@ nvim_tree.setup {
number = false, number = false,
relativenumber = false, relativenumber = false,
signcolumn = "yes", signcolumn = "yes",
mappings = {
custom_only = false,
list = {
-- user mappings go here
},
},
}, },
renderer = { renderer = {
indent_markers = { indent_markers = {
@@ -50,7 +41,6 @@ nvim_tree.setup {
update_cwd = false, update_cwd = false,
ignore_list = {}, ignore_list = {},
}, },
ignore_ft_on_setup = {},
system_open = { system_open = {
cmd = "", cmd = "",
args = {}, args = {},
@@ -89,7 +79,7 @@ nvim_tree.setup {
enable = true, enable = true,
chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890", chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890",
exclude = { exclude = {
filetype = { "notify", "packer", "qf", "diff", "fugitive", "fugitiveblame" }, filetype = { "notify", "qf", "diff", "fugitive", "fugitiveblame" },
buftype = { "nofile", "terminal", "help" }, buftype = { "nofile", "terminal", "help" },
}, },
}, },
@@ -113,6 +103,7 @@ nvim_tree.setup {
}, },
} }
keymap.set("n", "<space>s", function() keymap.set("n", "<space>s", require("nvim-tree.api").tree.toggle, {
return require("nvim-tree").toggle(false, true) silent = true,
end, { silent = true, desc = "toggle nvim-tree" }) desc = "toggle nvim-tree",
})

View File

@@ -8,11 +8,17 @@ local function spell()
return "" return ""
end end
--- show indicator for Chinese IME
local function ime_state() local function ime_state()
if vim.g.is_mac then if vim.g.is_mac then
-- ref: https://github.com/vim-airline/vim-airline/blob/master/autoload/airline/extensions/xkblayout.vim#L11 -- 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", "") local layout = fn.libcall(vim.g.XkbSwitchLib, "Xkb_Switch_getXkbLayout", "")
if layout == "0" then
-- We can use `xkbswitch -g` on the command line to get current mode.
-- mode for macOS builtin pinyin IME: com.apple.inputmethod.SCIM.ITABC
-- mode for Rime: im.rime.inputmethod.Squirrel.Rime
local res = fn.match(layout, [[\v(Squirrel\.Rime|SCIM.ITABC)]])
if res ~= -1 then
return "[CN]" return "[CN]"
end end
end end
@@ -87,7 +93,7 @@ local diff = function()
local add_num = git_status.added local add_num = git_status.added
local info = { added = add_num, modified = modify_num, removed = remove_num } local info = { added = add_num, modified = modify_num, removed = remove_num }
-- vim.pretty_print(info) -- vim.print(info)
return info return info
end end
@@ -121,6 +127,11 @@ require("lualine").setup {
spell, spell,
color = { fg = "black", bg = "#a7c080" }, color = { fg = "black", bg = "#a7c080" },
}, },
{
"diagnostics",
sources = { "nvim_diagnostic" },
symbols = {error = '🆇 ', warn = '⚠️ ', info = ' ', hint = ''},
},
}, },
lualine_x = { lualine_x = {
"encoding", "encoding",
@@ -134,13 +145,11 @@ require("lualine").setup {
}, },
"filetype", "filetype",
}, },
lualine_y = { "progress" }, lualine_y = {
lualine_z = {
"location", "location",
{ "progress",
"diagnostics", },
sources = { "nvim_diagnostic" }, lualine_z = {
},
{ {
trailing_space, trailing_space,
color = "WarningMsg", color = "WarningMsg",

View File

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

13
lua/config/yanky.lua Normal file
View File

@@ -0,0 +1,13 @@
require("yanky").setup({
ring = {
history_length = 50,
storage = "memory",
},
preserve_cursor_position = {
enabled = false,
},
})
-- cycle through the yank history, only work after paste
vim.keymap.set("n", "[y", "<Plug>(YankyCycleForward)")
vim.keymap.set("n", "]y", "<Plug>(YankyCycleBackward)")

View File

@@ -17,22 +17,30 @@ api.nvim_create_autocmd({ "BufRead" }, {
}) })
-- highlight yanked region, see `:h lua-highlight` -- highlight yanked region, see `:h lua-highlight`
local yank_group = api.nvim_create_augroup("highlight_yank", { clear = true })
api.nvim_create_autocmd({ "TextYankPost" }, { api.nvim_create_autocmd({ "TextYankPost" }, {
pattern = "*", pattern = "*",
group = api.nvim_create_augroup("highlight_yank", { clear = true }), group = yank_group,
callback = function() callback = function()
vim.highlight.on_yank { higroup = "YankColor", timeout = 300 } vim.highlight.on_yank { higroup = "YankColor", timeout = 300 }
end, end,
}) })
-- Auto-generate packer_compiled.lua file api.nvim_create_autocmd({ "CursorMoved" }, {
api.nvim_create_autocmd({ "BufWritePost" }, { pattern = "*",
pattern = "*/nvim/lua/plugins.lua", group = yank_group,
group = api.nvim_create_augroup("packer_auto_compile", { clear = true }), callback = function()
callback = function(ctx) vim.g.current_cursor_pos = vim.fn.getcurpos()
local cmd = "source " .. ctx.file end,
vim.cmd(cmd) })
vim.cmd("PackerCompile")
api.nvim_create_autocmd("TextYankPost", {
pattern = "*",
group = yank_group,
callback = function(ev)
if vim.v.event.operator == 'y' then
vim.fn.setpos('.', vim.g.current_cursor_pos)
end
end, end,
}) })

View File

@@ -5,7 +5,7 @@ local utils = require('utils')
-- Inspect something -- Inspect something
function _G.inspect(item) function _G.inspect(item)
vim.pretty_print(item) vim.print(item)
end end
------------------------------------------------------------------------ ------------------------------------------------------------------------
@@ -43,9 +43,7 @@ vim.g.mapleader = ','
vim.g.vimsyn_embed = 'l' vim.g.vimsyn_embed = 'l'
-- Use English as main language -- Use English as main language
if not vim.g.is_mac then vim.cmd [[language en_US.UTF-8]]
vim.cmd [[language en_US.utf-8]]
end
-- Disable loading certain plugins -- Disable loading certain plugins

View File

@@ -1,5 +1,6 @@
local keymap = vim.keymap local keymap = vim.keymap
local api = vim.api local api = vim.api
local uv = vim.loop
-- Save key strokes (now we do not need to press shift to enter command mode). -- Save key strokes (now we do not need to press shift to enter command mode).
keymap.set({ "n", "x" }, ";", ":") keymap.set({ "n", "x" }, ";", ":")
@@ -85,16 +86,15 @@ keymap.set("n", "<leader>ev", "<cmd>tabnew $MYVIMRC <bar> tcd %:h<cr>", {
desc = "open init.lua", desc = "open init.lua",
}) })
keymap.set("n", "<leader>sv", "", { keymap.set("n", "<leader>sv", function()
silent = true, vim.cmd([[
desc = "reload init.lua",
callback = function()
vim.cmd([[
update $MYVIMRC update $MYVIMRC
source $MYVIMRC source $MYVIMRC
]]) ]])
vim.notify("Nvim config successfully reloaded!", vim.log.levels.INFO, { title = "nvim-config" }) vim.notify("Nvim config successfully reloaded!", vim.log.levels.INFO, { title = "nvim-config" })
end, end, {
silent = true,
desc = "reload init.lua",
}) })
-- Reselect the text that has just been pasted, see also https://stackoverflow.com/a/4317090/6064933. -- Reselect the text that has just been pasted, see also https://stackoverflow.com/a/4317090/6064933.
@@ -173,25 +173,23 @@ keymap.set({ "x", "o" }, "iu", "<cmd>call text_obj#URL()<cr>", { desc = "URL tex
keymap.set({ "x", "o" }, "iB", "<cmd>call text_obj#Buffer()<cr>", { desc = "buffer text object" }) keymap.set({ "x", "o" }, "iB", "<cmd>call text_obj#Buffer()<cr>", { desc = "buffer text object" })
-- Do not move my cursor when joining lines. -- Do not move my cursor when joining lines.
keymap.set("n", "J", "", { keymap.set("n", "J", function()
desc = "join line", vim.cmd([[
callback = function()
vim.cmd([[
normal! mzJ`z normal! mzJ`z
delmarks z delmarks z
]]) ]])
end, end, {
desc = "join line",
}) })
keymap.set("n", "gJ", "mzgJ`z", { keymap.set("n", "gJ", function()
desc = "join visual lines", -- we must use `normal!`, otherwise it will trigger recursive mapping
callback = function() vim.cmd([[
-- we must use `normal!`, otherwise it will trigger recursive mapping
vim.cmd([[
normal! zmgJ`z normal! zmgJ`z
delmarks z delmarks z
]]) ]])
end, end, {
desc = "join visual lines",
}) })
-- Break inserted text into smaller undo units when we insert some punctuation chars. -- Break inserted text into smaller undo units when we insert some punctuation chars.
@@ -203,20 +201,6 @@ end
-- insert semicolon in the end -- insert semicolon in the end
keymap.set("i", "<A-;>", "<Esc>miA;<Esc>`ii") keymap.set("i", "<A-;>", "<Esc>miA;<Esc>`ii")
-- Keep cursor position after yanking
keymap.set("n", "y", "myy")
api.nvim_create_autocmd("TextYankPost", {
pattern = "*",
group = api.nvim_create_augroup("restore_after_yank", { clear = true }),
callback = function()
vim.cmd([[
silent! normal! `y
silent! delmarks y
]])
end,
})
-- Go to the beginning and end of current line in insert mode quickly -- Go to the beginning and end of current line in insert mode quickly
keymap.set("i", "<C-A>", "<HOME>") keymap.set("i", "<C-A>", "<HOME>")
keymap.set("i", "<C-E>", "<END>") keymap.set("i", "<C-E>", "<END>")
@@ -226,3 +210,22 @@ keymap.set("c", "<C-A>", "<HOME>")
-- Delete the character to the right of the cursor -- Delete the character to the right of the cursor
keymap.set("i", "<C-D>", "<DEL>") keymap.set("i", "<C-D>", "<DEL>")
keymap.set("n", "<leader>cb", function()
local cnt = 0
local blink_times = 7
local timer = uv.new_timer()
timer:start(0, 100, vim.schedule_wrap(function()
vim.cmd[[
set cursorcolumn!
set cursorline!
]]
if cnt == blink_times then
timer:close()
end
cnt = cnt + 1
end))
end)

View File

@@ -1,390 +1,503 @@
local utils = require("utils") local utils = require("utils")
local fn = vim.fn
-- The root dir to install all plugins. Plugins are under opt/ or start/ sub-directory. local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
vim.g.plugin_home = fn.stdpath("data") .. "/site/pack/packer"
-- Where to install packer.nvim -- the package manager (we make it opt) if not vim.loop.fs_stat(lazypath) then
local packer_dir = vim.g.plugin_home .. "/opt/packer.nvim" vim.fn.system {
"git",
-- Whether this is a fresh install, i.e., packer itself and plugins have not been installed. "clone",
local fresh_install = false "--filter=blob:none",
"https://github.com/folke/lazy.nvim.git",
-- Auto-install packer in case it hasn't been installed. "--branch=stable", -- latest stable release
if fn.glob(packer_dir) == "" then lazypath,
fresh_install = true }
-- Now we need to install packer.nvim first.
local packer_repo = "https://github.com/wbthomason/packer.nvim"
local install_cmd = string.format("!git clone --depth=1 %s %s", packer_repo, packer_dir)
vim.api.nvim_echo({ { "Installing packer.nvim", "Type" } }, true, {})
vim.cmd(install_cmd)
end end
vim.opt.rtp:prepend(lazypath)
-- Load packer.nvim
vim.cmd("packadd packer.nvim")
local packer = require("packer")
local packer_util = require("packer.util")
-- check if firenvim is active -- check if firenvim is active
local firenvim_not_active = function() local firenvim_not_active = function()
return not vim.g.started_by_firenvim return not vim.g.started_by_firenvim
end end
packer.startup { local plugin_specs = {
function(use) -- auto-completion engine
-- it is recommended to put impatient.nvim before any other plugins {
use { "lewis6991/impatient.nvim", config = [[require('impatient')]] } "hrsh7th/nvim-cmp",
-- event = 'InsertEnter',
use { "wbthomason/packer.nvim", opt = true } event = "VeryLazy",
dependencies = {
use { "onsails/lspkind-nvim", event = "VimEnter" } "hrsh7th/cmp-nvim-lsp",
-- auto-completion engine "onsails/lspkind-nvim",
use { "hrsh7th/nvim-cmp", after = "lspkind-nvim", config = [[require('config.nvim-cmp')]] } "hrsh7th/cmp-path",
"hrsh7th/cmp-buffer",
-- nvim-cmp completion sources "hrsh7th/cmp-omni",
use { "hrsh7th/cmp-nvim-lsp", after = "nvim-cmp" } "hrsh7th/cmp-emoji",
use { "hrsh7th/cmp-path", after = "nvim-cmp" } "quangnguyen30192/cmp-nvim-ultisnips",
use { "hrsh7th/cmp-buffer", after = "nvim-cmp" } },
use { "hrsh7th/cmp-omni", after = "nvim-cmp" } config = function()
use { "quangnguyen30192/cmp-nvim-ultisnips", after = { "nvim-cmp", "ultisnips" } } require("config.nvim-cmp")
if vim.g.is_mac then end,
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). "neovim/nvim-lspconfig",
use { "neovim/nvim-lspconfig", after = "cmp-nvim-lsp", config = [[require('config.lsp')]] } event = { "BufRead", "BufNewFile" },
config = function()
if vim.g.is_mac then require("config.lsp")
use { end,
"nvim-treesitter/nvim-treesitter", },
event = "BufEnter",
run = ":TSUpdate", {
config = [[require('config.treesitter')]], "nvim-treesitter/nvim-treesitter",
} enabled = function()
end if vim.g.is_mac then
return true
-- Python indent (follows the PEP8 style) end
use { "Vimjas/vim-python-pep8-indent", ft = { "python" } } return false
end,
-- Python-related text object event = "VeryLazy",
use { "jeetsukumaran/vim-pythonsense", ft = { "python" } } build = ":TSUpdate",
config = function()
use { "machakann/vim-swap", event = "VimEnter" } require("config.treesitter")
end,
-- IDE for Lisp },
if utils.executable("sbcl") then
-- use 'kovisoft/slimv' -- Python indent (follows the PEP8 style)
use { "vlime/vlime", rtp = "vim/", ft = { "lisp" } } { "Vimjas/vim-python-pep8-indent", ft = { "python" } },
end
-- Python-related text object
-- Super fast buffer jump { "jeetsukumaran/vim-pythonsense", ft = { "python" } },
use {
"phaazon/hop.nvim", { "machakann/vim-swap", event = "VeryLazy" },
event = "VimEnter",
config = function() -- IDE for Lisp
vim.defer_fn(function() -- 'kovisoft/slimv'
require("config.nvim_hop") {
end, 2000) "vlime/vlime",
end, enabled = function()
} if utils.executable("sbcl") then
return true
-- Show match number and index for searching end
use { return false
"kevinhwang91/nvim-hlslens", end,
branch = "main", config = function(plugin)
keys = { { "n", "*" }, { "n", "#" }, { "n", "n" }, { "n", "N" } }, vim.opt.rtp:append(plugin.dir .. "/vim")
config = [[require('config.hlslens')]], end,
} ft = { "lisp" },
},
-- Stay after pressing * and search selected text
use { "haya14busa/vim-asterisk", event = "VimEnter" } -- Super fast buffer jump
{
-- File search, tag search and more "phaazon/hop.nvim",
if vim.g.is_win then event = "VeryLazy",
use { "Yggdroot/LeaderF", cmd = "Leaderf" } config = function()
else vim.defer_fn(function()
use { "Yggdroot/LeaderF", cmd = "Leaderf", run = ":LeaderfInstallCExtension" } require("config.nvim_hop")
end end, 2000)
end,
use { },
"nvim-telescope/telescope.nvim",
cmd = "Telescope", -- Show match number and index for searching
requires = { { "nvim-lua/plenary.nvim" } }, {
} "kevinhwang91/nvim-hlslens",
-- search emoji and other symbols branch = "main",
use { "nvim-telescope/telescope-symbols.nvim", after = "telescope.nvim" } keys = { "*", "#", "n", "N" },
config = function()
-- A list of colorscheme plugin you may want to try. Find what suits you. require("config.hlslens")
use { "lifepillar/vim-gruvbox8", opt = true } end,
use { "navarasu/onedark.nvim", opt = true } },
use { "sainnhe/edge", opt = true } {
use { "sainnhe/sonokai", opt = true } "Yggdroot/LeaderF",
use { "sainnhe/gruvbox-material", opt = true } cmd = "Leaderf",
use { "shaunsingh/nord.nvim", opt = true } build = function()
use { "NTBBloodbath/doom-one.nvim", opt = true } if not vim.g.is_win then
use { "sainnhe/everforest", opt = true } vim.cmd(":LeaderfInstallCExtension")
use { "EdenEast/nightfox.nvim", opt = true } end
use { "rebelot/kanagawa.nvim", opt = true } end,
use { "catppuccin/nvim", as = "catppuccin", opt = true } },
"nvim-lua/plenary.nvim",
use { "kyazdani42/nvim-web-devicons", event = "VimEnter" } {
"nvim-telescope/telescope.nvim",
use { cmd = "Telescope",
"nvim-lualine/lualine.nvim", dependencies = {
event = "VimEnter", "nvim-telescope/telescope-symbols.nvim",
cond = firenvim_not_active, },
config = [[require('config.statusline')]], },
}
-- A list of colorscheme plugin you may want to try. Find what suits you.
use { "akinsho/bufferline.nvim", event = "VimEnter", { "navarasu/onedark.nvim", lazy = true },
cond = firenvim_not_active, { "sainnhe/edge", lazy = true },
config = [[require('config.bufferline')]] } { "sainnhe/sonokai", lazy = true },
{ "sainnhe/gruvbox-material", lazy = true },
-- fancy start screen { "shaunsingh/nord.nvim", lazy = true },
use { "glepnir/dashboard-nvim", event = "VimEnter", { "sainnhe/everforest", lazy = true },
cond = firenvim_not_active, { "EdenEast/nightfox.nvim", lazy = true },
config = [[require('config.dashboard-nvim')]] { "rebelot/kanagawa.nvim", lazy = true },
} { "catppuccin/nvim", name = "catppuccin", lazy = true },
{ "rose-pine/neovim", name = "rose-pine", lazy = true },
use { { "olimorris/onedarkpro.nvim", lazy = true },
"lukas-reineke/indent-blankline.nvim", { "tanvirtin/monokai.nvim", lazy = true },
event = "VimEnter", { "marko-cerovac/material.nvim", lazy = true },
config = [[require('config.indent-blankline')]],
} { "nvim-tree/nvim-web-devicons", event = "VeryLazy" },
-- Highlight URLs inside vim {
use { "itchyny/vim-highlighturl", event = "VimEnter" } "nvim-lualine/lualine.nvim",
event = "VeryLazy",
-- notification plugin cond = firenvim_not_active,
use { config = function()
"rcarriga/nvim-notify", require("config.statusline")
event = "BufEnter", end,
config = function() },
vim.defer_fn(function()
require("config.nvim-notify") {
end, 2000) "akinsho/bufferline.nvim",
end, event = { "BufEnter" },
} cond = firenvim_not_active,
config = function()
-- For Windows and Mac, we can open an URL in the browser. For Linux, it may require("config.bufferline")
-- not be possible since we maybe in a server which disables GUI. end,
if vim.g.is_win or vim.g.is_mac then },
-- open URL in browser
use { "tyru/open-browser.vim", event = "VimEnter" } -- fancy start screen
end {
"nvimdev/dashboard-nvim",
-- Only install these plugins if ctags are installed on the system cond = firenvim_not_active,
if utils.executable("ctags") then config = function()
-- show file tags in vim window require("config.dashboard-nvim")
use { "liuchengxu/vista.vim", cmd = "Vista" } end,
end },
-- Snippet engine and snippet template {
use { "SirVer/ultisnips", event = "InsertEnter" } "lukas-reineke/indent-blankline.nvim",
use { "honza/vim-snippets", after = "ultisnips" } event = "VeryLazy",
config = function()
-- Automatic insertion and deletion of a pair of characters require("config.indent-blankline")
use { "Raimondi/delimitMate", event = "InsertEnter" } end,
},
-- Comment plugin
use { "tpope/vim-commentary", event = "VimEnter" } -- Highlight URLs inside vim
{ "itchyny/vim-highlighturl", event = "VeryLazy" },
-- Multiple cursor plugin like Sublime Text?
-- use 'mg979/vim-visual-multi' -- notification plugin
{
-- Autosave files on certain events "rcarriga/nvim-notify",
use { "907th/vim-auto-save", event = "InsertEnter" } event = "VeryLazy",
config = function()
-- Show undo history visually vim.defer_fn(function()
use { "simnalamburt/vim-mundo", cmd = { "MundoToggle", "MundoShow" } } require("config.nvim-notify")
end, 2000)
-- Manage your yank history end,
if vim.g.is_win or vim.g.is_mac then },
use { "svermeulen/vim-yoink", event = "VimEnter" }
end -- For Windows and Mac, we can open an URL in the browser. For Linux, it may
-- not be possible since we maybe in a server which disables GUI.
-- Handy unix command inside Vim (Rename, Move etc.) {
use { "tpope/vim-eunuch", cmd = { "Rename", "Delete" } } "tyru/open-browser.vim",
enabled = function()
-- Repeat vim motions if vim.g.is_win or vim.g.is_mac then
use { "tpope/vim-repeat", event = "VimEnter" } return true
else
use { "nvim-zh/better-escape.vim", event = { "InsertEnter" } } return false
end
if vim.g.is_mac then end,
use { "lyokha/vim-xkbswitch", event = { "InsertEnter" } } event = "VeryLazy",
elseif vim.g.is_win then },
use { "Neur1n/neuims", event = { "InsertEnter" } }
end -- Only install these plugins if ctags are installed on the system
-- show file tags in vim window
-- Auto format tools {
use { "sbdchd/neoformat", cmd = { "Neoformat" } } "liuchengxu/vista.vim",
enabled = function()
-- Git command inside vim if utils.executable("ctags") then
use { "tpope/vim-fugitive", event = "User InGitRepo", config = [[require('config.fugitive')]] } return true
else
-- Better git log display return false
use { "rbong/vim-flog", requires = "tpope/vim-fugitive", cmd = { "Flog" } } end
end,
use { "christoomey/vim-conflicted", requires = "tpope/vim-fugitive", cmd = { "Conflicted" } } cmd = "Vista",
},
use {
"ruifm/gitlinker.nvim", -- Snippet engine and snippet template
requires = "nvim-lua/plenary.nvim", { "SirVer/ultisnips", dependencies = {
event = "User InGitRepo", "honza/vim-snippets",
config = [[require('config.git-linker')]], }, event = "InsertEnter" },
}
-- Automatic insertion and deletion of a pair of characters
-- Show git change (change, delete, add) signs in vim sign column { "Raimondi/delimitMate", event = "InsertEnter" },
use { "lewis6991/gitsigns.nvim", config = [[require('config.gitsigns')]] }
-- Comment plugin
-- Better git commit experience { "tpope/vim-commentary", event = "VeryLazy" },
use { "rhysd/committia.vim", opt = true, setup = [[vim.cmd('packadd committia.vim')]] }
-- Multiple cursor plugin like Sublime Text?
use { "kevinhwang91/nvim-bqf", ft = "qf", config = [[require('config.bqf')]] } -- 'mg979/vim-visual-multi'
-- Another markdown plugin -- Autosave files on certain events
use { "preservim/vim-markdown", ft = { "markdown" } } { "907th/vim-auto-save", event = "InsertEnter" },
-- Faster footnote generation -- Show undo history visually
use { "vim-pandoc/vim-markdownfootnotes", ft = { "markdown" } } { "simnalamburt/vim-mundo", cmd = { "MundoToggle", "MundoShow" } },
-- Vim tabular plugin for manipulate tabular, required by markdown plugins -- better UI for some nvim actions
use { "godlygeek/tabular", cmd = { "Tabularize" } } { "stevearc/dressing.nvim" },
-- Markdown JSON header highlight plugin -- Manage your yank history
use { "elzr/vim-json", ft = { "json", "markdown" } } {
"gbprod/yanky.nvim",
-- Markdown previewing (only for Mac and Windows) cmd = { "YankyRingHistory" },
if vim.g.is_win or vim.g.is_mac then config = function()
use { require("config.yanky")
"iamcco/markdown-preview.nvim", end,
run = "cd app && npm install", },
ft = { "markdown" },
} -- Handy unix command inside Vim (Rename, Move etc.)
end { "tpope/vim-eunuch", cmd = { "Rename", "Delete" } },
use { "folke/zen-mode.nvim", cmd = "ZenMode", config = [[require('config.zen-mode')]] } -- Repeat vim motions
{ "tpope/vim-repeat", event = "VeryLazy" },
if vim.g.is_mac then
use { "rhysd/vim-grammarous", ft = { "markdown" } } { "nvim-zh/better-escape.vim", event = { "InsertEnter" } },
end
{
use { "chrisbra/unicode.vim", event = "VimEnter" } "lyokha/vim-xkbswitch",
enabled = function()
-- Additional powerful text object for vim, this plugin should be studied if vim.g.is_mac and utils.executable("xkbswitch") then
-- carefully to use its full power return true
use { "wellle/targets.vim", event = "VimEnter" } end
return false
-- Plugin to manipulate character pairs quickly end,
use { "machakann/vim-sandwich", event = "VimEnter" } event = { "InsertEnter" },
},
-- Add indent object for vim (useful for languages like Python)
use { "michaeljsmith/vim-indent-object", event = "VimEnter" } {
"Neur1n/neuims",
-- Only use these plugin on Windows and Mac and when LaTeX is installed enabled = function()
if vim.g.is_win or vim.g.is_mac and utils.executable("latex") then if vim.g.is_win then
use { "lervag/vimtex", ft = { "tex" } } return true
end end
return false
-- Since tmux is only available on Linux and Mac, we only enable these plugins end,
-- for Linux and Mac event = { "InsertEnter" },
if utils.executable("tmux") then },
-- .tmux.conf syntax highlighting and setting check
use { "tmux-plugins/vim-tmux", ft = { "tmux" } } -- Auto format tools
end { "sbdchd/neoformat", cmd = { "Neoformat" } },
-- Modern matchit implementation -- Git command inside vim
use { "andymass/vim-matchup", event = "VimEnter" } {
"tpope/vim-fugitive",
-- Smoothie motions event = "User InGitRepo",
use { config = function()
"karb94/neoscroll.nvim", require("config.fugitive")
event = "VimEnter", end,
config = function() },
vim.defer_fn(function()
require("config.neoscroll") -- Better git log display
end, 2000) { "rbong/vim-flog", cmd = { "Flog" } },
end, { "christoomey/vim-conflicted", cmd = { "Conflicted" } },
} {
"ruifm/gitlinker.nvim",
use { "tpope/vim-scriptease", cmd = { "Scriptnames", "Message", "Verbose" } } event = "User InGitRepo",
config = function()
-- Asynchronous command execution require("config.git-linker")
use { "skywind3000/asyncrun.vim", opt = true, cmd = { "AsyncRun" } } end,
},
use { "cespare/vim-toml", ft = { "toml" }, branch = "main" }
-- Show git change (change, delete, add) signs in vim sign column
-- Edit text area in browser using nvim {
if vim.g.is_win or vim.g.is_mac then "lewis6991/gitsigns.nvim",
use { config = function()
"glacambre/firenvim", require("config.gitsigns")
run = function() end,
fn["firenvim#install"](0) },
end,
opt = true, -- Better git commit experience
setup = [[vim.cmd('packadd firenvim')]], { "rhysd/committia.vim", lazy = true },
} {
end "kevinhwang91/nvim-bqf",
ft = "qf",
-- Debugger plugin config = function()
if vim.g.is_win or vim.g.is_linux then require("config.bqf")
use { "sakhnik/nvim-gdb", run = { "bash install.sh" }, opt = true, setup = [[vim.cmd('packadd nvim-gdb')]] } end,
end },
-- Session management plugin -- Another markdown plugin
use { "tpope/vim-obsession", cmd = "Obsession" } { "preservim/vim-markdown", ft = { "markdown" } },
if vim.g.is_linux then -- Faster footnote generation
use { "ojroques/vim-oscyank", cmd = { "OSCYank", "OSCYankReg" } } { "vim-pandoc/vim-markdownfootnotes", ft = { "markdown" } },
end
-- Vim tabular plugin for manipulate tabular, required by markdown plugins
-- The missing auto-completion for cmdline! { "godlygeek/tabular", cmd = { "Tabularize" } },
use { "gelguy/wilder.nvim", opt = true, setup = [[vim.cmd('packadd wilder.nvim')]] }
-- Markdown previewing (only for Mac and Windows)
-- showing keybindings {
use { "iamcco/markdown-preview.nvim",
"folke/which-key.nvim", enabled = function()
event = "VimEnter", if vim.g.is_win or vim.g.is_mac then
config = function() return true
vim.defer_fn(function() end
require("config.which-key") return false
end, 2000) end,
end, build = "cd app && npm install",
} ft = { "markdown" },
},
-- show and trim trailing whitespaces
use { "jdhao/whitespace.nvim", event = "VimEnter" } {
"folke/zen-mode.nvim",
-- file explorer cmd = "ZenMode",
use { config = function()
"kyazdani42/nvim-tree.lua", require("config.zen-mode")
requires = { "kyazdani42/nvim-web-devicons" }, end,
config = [[require('config.nvim-tree')]], },
}
{
use { "ii14/emmylua-nvim", ft = "lua" } "rhysd/vim-grammarous",
enabled = function()
use { "j-hui/fidget.nvim", after = "nvim-lspconfig", config = [[require('config.fidget-nvim')]] } if vim.g.is_mac then
end, return true
config = { end
max_jobs = 16, return false
compile_path = packer_util.join_paths(fn.stdpath("data"), "site", "lua", "packer_compiled.lua"), end,
ft = { "markdown" },
},
{ "chrisbra/unicode.vim", event = "VeryLazy" },
-- Additional powerful text object for vim, this plugin should be studied
-- carefully to use its full power
{ "wellle/targets.vim", event = "VeryLazy" },
-- Plugin to manipulate character pairs quickly
{ "machakann/vim-sandwich", event = "VeryLazy" },
-- Add indent object for vim (useful for languages like Python)
{ "michaeljsmith/vim-indent-object", event = "VeryLazy" },
-- Only use these plugin on Windows and Mac and when LaTeX is installed
{
"lervag/vimtex",
enabled = function()
if utils.executable("latex") then
return true
end
return false
end,
ft = { "tex" },
},
-- Since tmux is only available on Linux and Mac, we only enable these plugins
-- for Linux and Mac
-- .tmux.conf syntax highlighting and setting check
{
"tmux-plugins/vim-tmux",
enabled = function()
if utils.executable("tmux") then
return true
end
return false
end,
ft = { "tmux" },
},
-- Modern matchit implementation
{ "andymass/vim-matchup", event = "BufRead" },
{ "tpope/vim-scriptease", cmd = { "Scriptnames", "Message", "Verbose" } },
-- Asynchronous command execution
{ "skywind3000/asyncrun.vim", lazy = true, cmd = { "AsyncRun" } },
{ "cespare/vim-toml", ft = { "toml" }, branch = "main" },
-- Edit text area in browser using nvim
{
"glacambre/firenvim",
enabled = function()
if vim.g.is_win or vim.g.is_mac then
return true
end
return false
end,
build = function()
vim.fn["firenvim#install"](0)
end,
lazy = true,
},
-- Debugger plugin
{
"sakhnik/nvim-gdb",
enabled = function()
if vim.g.is_win or vim.g.is_linux then
return true
end
return false
end,
build = { "bash install.sh" },
lazy = true,
},
-- Session management plugin
{ "tpope/vim-obsession", cmd = "Obsession" },
{
"ojroques/vim-oscyank",
enabled = function()
if vim.g.is_linux then
return true
end
return false
end,
cmd = { "OSCYank", "OSCYankReg" },
},
-- The missing auto-completion for cmdline!
{
"gelguy/wilder.nvim",
build = ":UpdateRemotePlugins",
},
-- showing keybindings
{
"folke/which-key.nvim",
event = "VeryLazy",
config = function()
vim.defer_fn(function()
require("config.which-key")
end, 2000)
end,
},
-- show and trim trailing whitespaces
{ "jdhao/whitespace.nvim", event = "VeryLazy" },
-- file explorer
{
"nvim-tree/nvim-tree.lua",
keys = { "<space>s" },
dependencies = { "nvim-tree/nvim-web-devicons" },
config = function()
require("config.nvim-tree")
end,
},
{ "ii14/emmylua-nvim", ft = "lua" },
{
"j-hui/fidget.nvim",
event = "VeryLazy",
tag = "legacy",
config = function()
require("config.fidget-nvim")
end,
}, },
} }
-- For fresh install, we need to install plugins. Otherwise, we just need to require `packer_compiled.lua`. -- configuration for lazy itself.
if fresh_install then local lazy_opts = {
-- We run packer.sync() here, because only after packer.startup, can we know which plugins to install. ui = {
-- So plugin installation should be done after the startup process. border = "rounded",
packer.sync() title = "Plugin Manager",
else title_pos = "center",
local status, _ = pcall(require, "packer_compiled") },
if not status then }
local msg = "File packer_compiled.lua not found: run PackerSync to fix!"
vim.notify(msg, vim.log.levels.ERROR, { title = "nvim-config" }) require("lazy").setup(plugin_specs, lazy_opts)
end
end

View File

@@ -31,13 +31,6 @@ function M.may_create_dir(dir)
end end
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
--- Generate random integers in the range [Low, High], inclusive, --- Generate random integers in the range [Low, High], inclusive,
--- adapted from https://stackoverflow.com/a/12739441/6064933 --- adapted from https://stackoverflow.com/a/12739441/6064933
--- @low: the lower value for this range --- @low: the lower value for this range

3
plugin/abbrev.vim Normal file
View File

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

View File

@@ -45,3 +45,6 @@ function! s:md_to_pdf() abort
echoerr "Error running command" echoerr "Error running command"
endif endif
endfunction endfunction
" json format
command! -range JSONFormat <line1>,<line2>!python -m json.tool

View File

@@ -194,7 +194,6 @@ wiki
backticks backticks
Reddit Reddit
LeaderF LeaderF
gruvbox8
tabpage tabpage
ccls ccls
cmake cmake
@@ -203,6 +202,8 @@ llvm
subsampling subsampling
refactor refactor
colorschemes colorschemes
gruvbox8
gruvbox
Gruvbox Gruvbox
monokai monokai
NeoSolarized NeoSolarized
@@ -440,3 +441,29 @@ Postgres
plpgsql plpgsql
postgres postgres
PySpark PySpark
winbar
cmdline
shada
async
localhost
JetBrains
localhost
MariaDB
SQLite
Pgadmin
Datagrip
mysql
cwd
pyright
stubgen
pylance
variadic
Vimium
Databricks
Jira
databricks
FastAPI
pylintrc
PYTHONPATH
Uvicorn
qpdf