mirror of
https://github.com/jdhao/nvim-config.git
synced 2025-06-08 14:14:33 +02:00
Compare commits
80 Commits
v0.7.0
...
497f93d6c7
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
497f93d6c7 | ||
|
|
cfe2e0611d | ||
|
|
9de08d0afe | ||
|
|
d5b7584e68 | ||
|
|
64a7a23309 | ||
|
|
c1efc0bad6 | ||
|
|
b3b69f21f4 | ||
|
|
f491e26676 | ||
|
|
e7e4892c22 | ||
|
|
a52a362b02 | ||
|
|
2880d7bce3 | ||
|
|
7e6dd23d37 | ||
|
|
fcbd7d3a0d | ||
|
|
97f302084f | ||
|
|
9d29544d72 | ||
|
|
cad9f5a214 | ||
|
|
ecde08941b | ||
|
|
ab88c112ff | ||
|
|
4c96243a4c | ||
|
|
fdc158272b | ||
|
|
b331cddc73 | ||
|
|
b11c57e36f | ||
|
|
84d73660fa | ||
|
|
a9cc10b2ef | ||
|
|
cad6112cc2 | ||
|
|
4d7fd6580a | ||
|
|
f492a94db6 | ||
|
|
0c92d9a018 | ||
|
|
369687b047 | ||
|
|
54908dfe9f | ||
|
|
2e5f5c5991 | ||
|
|
8291b15599 | ||
|
|
3de31f7d0a | ||
|
|
6b59c268f9 | ||
|
|
dd550dc3d0 | ||
|
|
3aae07df56 | ||
|
|
ed5ddf60cc | ||
|
|
bcdc8d3f66 | ||
|
|
5498a05bf7 | ||
|
|
644f8b6e2d | ||
|
|
3af7dd51b8 | ||
|
|
e0fc068f2e | ||
|
|
58ed71f870 | ||
|
|
aae9a7b7a7 | ||
|
|
33270f3257 | ||
|
|
99d5a0343b | ||
|
|
3678da1b3c | ||
|
|
a8fdbf3573 | ||
|
|
351ba5fc63 | ||
|
|
6dfaf2c521 | ||
|
|
ae759477c7 | ||
|
|
921fd17221 | ||
|
|
81696c9e13 | ||
|
|
32b1d3ac16 | ||
|
|
e3b15da059 | ||
|
|
934ef7fb13 | ||
|
|
3ee785506c | ||
|
|
428f612bb3 | ||
|
|
95b7ee5bc8 | ||
|
|
4899a82b35 | ||
|
|
424981683e | ||
|
|
c3253a5731 | ||
|
|
a9be0d0b20 | ||
|
|
13111596b8 | ||
|
|
6cea10fcc5 | ||
|
|
58102f182a | ||
|
|
9e284f58cb | ||
|
|
a5dc045acc | ||
|
|
dd3e9dd2f4 | ||
|
|
6784a87e26 | ||
|
|
99637c86f9 | ||
|
|
3817525441 | ||
|
|
4b4331d394 | ||
|
|
aaafaf58d6 | ||
|
|
1b9bd9ceef | ||
|
|
e043f07b71 | ||
|
|
b20b21b5dd | ||
|
|
c3ced68bea | ||
|
|
905efeb53f | ||
|
|
a3795cd043 |
2
.github/ISSUE_TEMPLATE/bug_report.md
vendored
2
.github/ISSUE_TEMPLATE/bug_report.md
vendored
@@ -8,7 +8,7 @@ assignees: ''
|
||||
|
||||
<!-- Before reporting: make sure that you have read the doc (https://github.com/jdhao/nvim-config/tree/master/docs) and searched existing issues. -->
|
||||
|
||||
- `nvim --version`:
|
||||
- `nvim --version`: <!--should be latest stable version: https://github.com/neovim/neovim/releases/tag/stable -->
|
||||
- terminal emulator and version:
|
||||
- Operating system/version:
|
||||
- Have you read and followed all steps in the [doc](https://github.com/jdhao/nvim-config/tree/master/docs):
|
||||
|
||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -2,6 +2,5 @@ tags
|
||||
en.utf-8.add.spl
|
||||
*.exe
|
||||
.netrwhist
|
||||
packer_compiled.lua
|
||||
*.log
|
||||
.DS_Store
|
||||
|
||||
6
.stylua.toml
Normal file
6
.stylua.toml
Normal file
@@ -0,0 +1,6 @@
|
||||
# config for stylua, ref: https://github.com/JohnnyMorganz/StyLua
|
||||
line_endings = "Unix"
|
||||
indent_type = "Spaces"
|
||||
indent_width = 2
|
||||
quote_style = "AutoPreferDouble"
|
||||
no_call_parentheses = true
|
||||
114
README.md
114
README.md
@@ -22,7 +22,7 @@
|
||||
<img alt="Latest release" src="https://img.shields.io/github/v/release/jdhao/nvim-config" />
|
||||
</a>
|
||||
<a href="https://github.com/neovim/neovim/releases/tag/stable">
|
||||
<img src="https://img.shields.io/badge/Neovim-0.7.0-blueviolet.svg?style=flat-square&logo=Neovim&logoColor=green" alt="Neovim minimum version"/>
|
||||
<img src="https://img.shields.io/badge/Neovim-0.7.2-blueviolet.svg?style=flat-square&logo=Neovim&logoColor=green" alt="Neovim minimum version"/>
|
||||
</a>
|
||||
<a href="https://github.com/jdhao/nvim-config/search?l=vim-script">
|
||||
<img src="https://img.shields.io/github/languages/top/jdhao/nvim-config" alt="Top languages"/>
|
||||
@@ -36,26 +36,27 @@
|
||||
# Introduction
|
||||
|
||||
This repo hosts my Nvim configuration for Linux, macOS, and Windows.
|
||||
`init.vim` is the config entry point for terminal Nvim,
|
||||
`init.lua` is the config entry point for terminal Nvim,
|
||||
and `ginit.vim` is the additional config file for [GUI client of Nvim](https://github.com/neovim/neovim/wiki/Related-projects#gui).
|
||||
|
||||
My configurations are heavily documented to make it as clear as possible.
|
||||
While you can download the whole repository and use it, it is not recommended though.
|
||||
While you can clone the whole repository and use it, it is not recommended though.
|
||||
Good configurations are personal. Everyone should have his or her unique config file.
|
||||
You are encouraged to copy from this repo the part you feel useful and add it to your own Nvim config.
|
||||
You are encouraged to copy from this repo the part you want and add it to your own config.
|
||||
|
||||
To reduce the possibility of breakage, **this config is only maintained for [the latest nvim stable release](https://github.com/neovim/neovim/releases/tag/stable).
|
||||
No effort is spent on maintaining backward compatibility.**
|
||||
|
||||
# Install and setup
|
||||
|
||||
See [doc here](docs/README.md) on how to install Nvim's dependencies, Nvim itself,
|
||||
and how to set up on different platforms (Linux, macOS, and Windows).
|
||||
|
||||
**This config is tested against [Nvim v0.7.0 release](https://github.com/neovim/neovim/releases/tag/stable).
|
||||
No backward compatibility is guaranteed.**
|
||||
|
||||
# Features #
|
||||
|
||||
+ Plugin management via [Packer.nvim](https://github.com/wbthomason/packer.nvim).
|
||||
+ Code auto-completion via [nvim-cmp](https://github.com/hrsh7th/nvim-cmp) and [nvim-lspconfig](https://github.com/neovim/nvim-lspconfig).
|
||||
+ Code, snippet, word auto-completion via [nvim-cmp](https://github.com/hrsh7th/nvim-cmp).
|
||||
+ Language server protocol (LSP) support via [nvim-lspconfig](https://github.com/neovim/nvim-lspconfig).
|
||||
+ Git integration via [vim-fugitive](https://github.com/tpope/vim-fugitive).
|
||||
+ Better escaping from insert mode via [better-escape.vim](https://github.com/jdhao/better-escape.vim).
|
||||
+ Ultra-fast project-wide fuzzy searching via [LeaderF](https://github.com/Yggdroot/LeaderF).
|
||||
@@ -63,40 +64,40 @@ No backward compatibility is guaranteed.**
|
||||
+ Faster matching pair insertion and jump via [delimitMate](https://github.com/Raimondi/delimitMate).
|
||||
+ Smarter and faster matching pair management (add, replace or delete) via [vim-sandwich](https://github.com/machakann/vim-sandwich).
|
||||
+ Fast buffer jump via [hop.nvim](https://github.com/phaazon/hop.nvim).
|
||||
+ Ultra fast snippet insertion via [Ultisnips](https://github.com/SirVer/ultisnips).
|
||||
+ Beautiful status line via [lualine.nvim](https://github.com/nvim-lualine/lualine.nvim).
|
||||
+ Powerful snippet insertion via [Ultisnips](https://github.com/SirVer/ultisnips).
|
||||
+ Beautiful statusline via [lualine.nvim](https://github.com/nvim-lualine/lualine.nvim).
|
||||
+ File tree explorer via [nvim-tree.lua](https://github.com/kyazdani42/nvim-tree.lua).
|
||||
+ Better quickfix list with [nvim-bqf](https://github.com/kevinhwang91/nvim-bqf).
|
||||
+ Show search index and count with [nvim-hlslens](https://github.com/kevinhwang91/nvim-hlslens).
|
||||
+ Command line auto-completion via [wilder.nvim](https://github.com/gelguy/wilder.nvim).
|
||||
+ Keymap display via [which-key.nvim](https://github.com/folke/which-key.nvim).
|
||||
+ User-defined mapping hint via [which-key.nvim](https://github.com/folke/which-key.nvim).
|
||||
+ Asynchronous code execution via [asyncrun.vim](https://github.com/skywind3000/asyncrun.vim).
|
||||
+ Code highlighting via [nvim-treesitter](https://github.com/nvim-treesitter/nvim-treesitter).
|
||||
+ Code editing using true nvim inside browser via [firenvim](https://github.com/glacambre/firenvim).
|
||||
+ Color theme via [vim-gruvbox8](https://github.com/lifepillar/vim-gruvbox8) and other beautiful themes.
|
||||
+ Markdown writing and previewing via [vim-markdown](https://github.com/plasticboy/vim-markdown) and [markdown-preview.nvim](https://github.com/iamcco/markdown-preview.nvim).
|
||||
+ LaTeX editing and previewing via [vimtex](https://github.com/lervag/vimtex) <sup id="a1">[1](#f1)</sup>.
|
||||
+ Animated GUI style notification via [nvim-notify](https://github.com/rcarriga/nvim-notify).
|
||||
+ Smooth scroll experience via [neoscroll](https://github.com/karb94/neoscroll.nvim).
|
||||
+ Tags navigation via [vista](https://github.com/liuchengxu/vista.vim).
|
||||
+ Code formatting via [Neoformat](https://github.com/sbdchd/neoformat).
|
||||
+ Undo management via [vim-mundo](https://github.com/simnalamburt/vim-mundo)
|
||||
+ LaTeX editing via [vimtex](https://github.com/lervag/vimtex) <sup id="a1">[1](#f1)</sup>.
|
||||
+ ......
|
||||
|
||||
# UI Demo
|
||||
|
||||
For more UI demos, see [here](https://github.com/jdhao/nvim-config/issues/15).
|
||||
For more UI demos, check [here](https://github.com/jdhao/nvim-config/issues/15).
|
||||
|
||||
## Start screen with alpha-nvim
|
||||
## Start screen with dashboard-nvim
|
||||
|
||||
<p align="center">
|
||||
<img src="https://user-images.githubusercontent.com/16662357/139459989-0537ded4-c119-4749-99bf-b551ca1ba118.jpg" width="800">
|
||||
<img src="https://user-images.githubusercontent.com/16662357/183256752-fb23b215-a6b8-4646-beed-9999f52d53f1.png" width="800">
|
||||
</p>
|
||||
|
||||
## fuzzy finding using LeaderF
|
||||
## File fuzzy finding using LeaderF
|
||||
|
||||
<p align="center">
|
||||
<img src="https://user-images.githubusercontent.com/16662357/139462025-7bce98c5-d2d5-413f-9659-20545865cdca.gif" width="800">
|
||||
<img src="https://user-images.githubusercontent.com/16662357/183257017-2d9d7605-3c4b-4e1d-8955-30998f9b6f28.gif" width="800">
|
||||
</p>
|
||||
|
||||
## Code autocompletion with nvim-cmp
|
||||
@@ -139,45 +140,48 @@ Go to a string starting with `se`
|
||||
|
||||
# Shortcuts
|
||||
|
||||
Some of the shortcuts I use frequently is listed here. In the following shortcuts, `<leader>` represents ASCII character `,`.
|
||||
Some of the shortcuts I use frequently are listed here. In the following shortcuts, `<leader>` represents ASCII character `,`.
|
||||
|
||||
| Shortcut | Mode | platform | Description |
|
||||
|-------------------|---------------|-----------------|------------------------------------------------------------------|
|
||||
| `<leader>ff` | Normal | Linux/macOS/Win | Fuzzy file searching in a floating window |
|
||||
| `<leader>fh` | Normal | Linux/macOS/Win | Fuzzy help file grepping in a floating window |
|
||||
| `<leader>fg` | Normal | Linux/macOS/Win | Fuzzy project-wide grepping in a floating window |
|
||||
| `<leader>ft` | Normal | Linux/macOS/Win | Fuzzy buffer tag searching in a floating window |
|
||||
| `<leader>fb` | Normal | Linux/macOS/Win | Fuzzy buffer switching in a floating window |
|
||||
| `<leader><Space>` | Normal | Linux/macOS/Win | Remove trailing white spaces |
|
||||
| `<leader>v` | Normal | Linux/macOS/Win | Reselect last pasted text |
|
||||
| `<leader>ev` | Normal | Linux/macOS/Win | Edit Nvim config in a new tabpage |
|
||||
| `<leader>sv` | Normal | Linux/macOS/Win | Reload Nvim config |
|
||||
| `<leader>st` | Normal | Linux/macOS/Win | Show highlight group for cursor text |
|
||||
| `<leader>q` | Normal | Linux/macOS/Win | Quit current window |
|
||||
| `<leader>Q` | Normal | Linux/macOS/Win | Quit all window and close Nvim |
|
||||
| `<leader>w` | Normal | Linux/macOS/Win | Save current buffer content |
|
||||
| `<leader>y` | Normal | Linux/macOS/Win | Copy the content of entire buffer to default register |
|
||||
| `<leader>cl` | Normal | Linux/macOS/Win | Toggle cursor column |
|
||||
| `<leader>cd` | Normal | Linux/macOS/Win | Change current working directory to to the dir of current buffer |
|
||||
| `<space>t` | Normal | Linux/macOS/Win | Toggle tag window (show project tags in the right window) |
|
||||
| `<leader>gs` | Normal | Linux/macOS/Win | Show Git status result |
|
||||
| `<leader>gw` | Normal | Linux/macOS/Win | Run Git add for current file |
|
||||
| `<leader>gd` | Normal | Linux/macOS/Win | Run git diff for current file |
|
||||
| `<leader>gc` | Normal | Linux/macOS/Win | Run git commit |
|
||||
| `<leader>gpl` | Normal | Linux/macOS/Win | Run git pull |
|
||||
| `<leader>gpu` | Normal | Linux/macOS/Win | Run git push |
|
||||
| `<F9>` | Normal | Linux/macOS/Win | Run current source file (for Python, C++) |
|
||||
| `<F11>` | Normal | Linux/macOS/Win | Toggle spell checking |
|
||||
| `<F12>` | Normal | Linux/macOS/Win | Toggle paste mode |
|
||||
| `\x` | Normal | Linux/macOS/Win | Close location or quickfix window |
|
||||
| `\d` | Normal | Linux/macOS/Win | Close current buffer and go to previous buffer |
|
||||
| `{count}gb` | Normal | Linux/macOS/Win | Go to buffer {count} or next buffer in the buffer list. |
|
||||
| `Alt-m` | Normal | macOS/Win | Markdown previewing in system browser |
|
||||
| `Alt-Shift-m` | Normal | macOS/Win | Stopping Markdown previewing in system browser |
|
||||
| `ob` | Normal/Visual | macOS/Win | Open link under cursor or search visual selection |
|
||||
| `ctrl-u` | Insert | Linux/macOS/Win | Turn word under cursor to upper case |
|
||||
| `ctrl-t` | Insert | Linux/macOS/Win | Turn word under cursor to title case |
|
||||
| `jk` | Insert | Linux/macOS/Win | Return to Normal mode without lagging |
|
||||
| Shortcut | Mode | platform | Description |
|
||||
|-------------------|---------------|-----------------|--------------------------------------------------------------------------|
|
||||
| `<leader>ff` | Normal | Linux/macOS/Win | Fuzzy file searching in a floating window |
|
||||
| `<leader>fh` | Normal | Linux/macOS/Win | Fuzzy help file grepping in a floating window |
|
||||
| `<leader>fg` | Normal | Linux/macOS/Win | Fuzzy project-wide grepping in a floating window |
|
||||
| `<leader>ft` | Normal | Linux/macOS/Win | Fuzzy buffer tag searching in a floating window |
|
||||
| `<leader>fb` | Normal | Linux/macOS/Win | Fuzzy buffer switching in a floating window |
|
||||
| `<leader><Space>` | Normal | Linux/macOS/Win | Remove trailing white spaces |
|
||||
| `<leader>v` | Normal | Linux/macOS/Win | Reselect last pasted text |
|
||||
| `<leader>ev` | Normal | Linux/macOS/Win | Edit Nvim config in a new tabpage |
|
||||
| `<leader>sv` | Normal | Linux/macOS/Win | Reload Nvim config |
|
||||
| `<leader>st` | Normal | Linux/macOS/Win | Show highlight group for cursor text |
|
||||
| `<leader>q` | Normal | Linux/macOS/Win | Quit current window |
|
||||
| `<leader>Q` | Normal | Linux/macOS/Win | Quit all window and close Nvim |
|
||||
| `<leader>w` | Normal | Linux/macOS/Win | Save current buffer content |
|
||||
| `<leader>y` | Normal | Linux/macOS/Win | Copy the content of entire buffer to default register |
|
||||
| `<leader>cl` | Normal | Linux/macOS/Win | Toggle cursor column |
|
||||
| `<leader>cd` | Normal | Linux/macOS/Win | Change current working directory to to the dir of current buffer |
|
||||
| `<space>t` | Normal | Linux/macOS/Win | Toggle tag window (show project tags in the right window) |
|
||||
| `<leader>gs` | Normal | Linux/macOS/Win | Show Git status result |
|
||||
| `<leader>gw` | Normal | Linux/macOS/Win | Run Git add for current file |
|
||||
| `<leader>gd` | Normal | Linux/macOS/Win | Run git diff for current file |
|
||||
| `<leader>gc` | Normal | Linux/macOS/Win | Run git commit |
|
||||
| `<leader>gpl` | Normal | Linux/macOS/Win | Run git pull |
|
||||
| `<leader>gpu` | Normal | Linux/macOS/Win | Run git push |
|
||||
| `<F9>` | Normal | Linux/macOS/Win | Compile&run current source file (for C++, LaTeX, Lua, Python) |
|
||||
| `<F11>` | Normal | Linux/macOS/Win | Toggle spell checking |
|
||||
| `<F12>` | Normal | Linux/macOS/Win | Toggle paste mode |
|
||||
| `\x` | Normal | Linux/macOS/Win | Close location or quickfix window |
|
||||
| `\d` | Normal | Linux/macOS/Win | Close current buffer and go to previous buffer |
|
||||
| `{count}gb` | Normal | Linux/macOS/Win | Go to buffer `{count}` or next buffer in the buffer list. |
|
||||
| `{operator}iB` | Normal | Linux/macOS/Win | Operate in the whole buffer, `{operator}` can be `v`, `y`, `c`, `d` etc. |
|
||||
| `Alt-k` | Normal | Linux/macOS/Win | Move current line or selected lines up |
|
||||
| `Alt-j` | Normal | Linux/macOS/Win | Move current line or selected lines down |
|
||||
| `Alt-m` | Normal | macOS/Win | Markdown previewing in system browser |
|
||||
| `Alt-Shift-m` | Normal | macOS/Win | Stopping Markdown previewing in system browser |
|
||||
| `ob` | Normal/Visual | macOS/Win | Open link under cursor or search visual selection |
|
||||
| `ctrl-u` | Insert | Linux/macOS/Win | Turn word under cursor to upper case |
|
||||
| `ctrl-t` | Insert | Linux/macOS/Win | Turn word under cursor to title case |
|
||||
| `jk` | Insert | Linux/macOS/Win | Return to Normal mode without lagging |
|
||||
|
||||
# Custom commands
|
||||
|
||||
|
||||
8
after/ftplugin/javascript.vim
Normal file
8
after/ftplugin/javascript.vim
Normal file
@@ -0,0 +1,8 @@
|
||||
" Disable inserting comment leader after hitting o or O or <Enter>
|
||||
set formatoptions-=o
|
||||
set formatoptions-=r
|
||||
|
||||
set tabstop=2 " number of visual spaces per TAB
|
||||
set softtabstop=2 " number of spaces in tab when editing
|
||||
set shiftwidth=2 " number of spaces to use for autoindent
|
||||
set expandtab " expand tab to spaces so that tabs are spaces
|
||||
@@ -6,3 +6,5 @@ set tabstop=2 " number of visual spaces per TAB
|
||||
set softtabstop=2 " number of spaces in tab when editing
|
||||
set shiftwidth=2 " number of spaces to use for autoindent
|
||||
set expandtab " expand tab to spaces so that tabs are spaces
|
||||
|
||||
nnoremap <silent> <F9> :luafile %<CR>
|
||||
|
||||
@@ -16,3 +16,5 @@ set tabstop=2 " number of visual spaces per TAB
|
||||
set softtabstop=2 " number of spaces in tab when editing
|
||||
set shiftwidth=2 " number of spaces to use for autoindent
|
||||
set expandtab " expand tab to spaces so that tabs are spaces
|
||||
|
||||
nnoremap <silent> <F9> :source %<CR>
|
||||
|
||||
@@ -131,9 +131,11 @@ function! utils#Get_titlestr() abort
|
||||
if g:is_linux
|
||||
let l:title_str = hostname() . ' '
|
||||
endif
|
||||
let l:title_str = l:title_str . expand('%:p:~') . ' '
|
||||
if &buflisted
|
||||
let l:title_str = l:title_str . strftime('%Y-%m-%d %H:%M',getftime(expand('%')))
|
||||
|
||||
let l:buf_path = expand('%:p:~')
|
||||
let l:title_str = l:title_str . l:buf_path . ' '
|
||||
if &buflisted && l:buf_path != ""
|
||||
let l:title_str = l:title_str . strftime('%Y-%m-%d %H:%M:%S%z', getftime(expand('%')))
|
||||
endif
|
||||
|
||||
return l:title_str
|
||||
|
||||
@@ -135,3 +135,23 @@ augroup auto_create_dir
|
||||
autocmd!
|
||||
autocmd BufWritePre * lua require('utils').may_create_dir()
|
||||
augroup END
|
||||
|
||||
" ref: https://vi.stackexchange.com/a/169/15292
|
||||
function! s:handle_large_file() abort
|
||||
let g:large_file = 10485760 " 10MB
|
||||
let f = expand("<afile>")
|
||||
|
||||
if getfsize(f) > g:large_file || getfsize(f) == -2
|
||||
set eventignore+=all
|
||||
" turning off relative number helps a lot
|
||||
set norelativenumber
|
||||
setlocal noswapfile bufhidden=unload buftype=nowrite undolevels=-1
|
||||
else
|
||||
set eventignore-=all relativenumber
|
||||
endif
|
||||
endfunction
|
||||
|
||||
augroup LargeFile
|
||||
autocmd!
|
||||
autocmd BufReadPre * call s:handle_large_file()
|
||||
augroup END
|
||||
|
||||
@@ -37,7 +37,9 @@ let g:mapleader = ','
|
||||
let g:vimsyn_embed = 'l'
|
||||
|
||||
" Use English as main language
|
||||
language en_US.utf-8
|
||||
if !g:is_mac
|
||||
language en_US.utf-8
|
||||
endif
|
||||
|
||||
" use filetype.lua instead of filetype.vim
|
||||
let g:do_filetype_lua = 1
|
||||
@@ -69,4 +71,7 @@ let g:loaded_tutor_mode_plugin = 1 " do not load the tutor plugin
|
||||
let g:loaded_matchit = 1
|
||||
let g:loaded_matchparen = 1
|
||||
"}}
|
||||
|
||||
" Disable sql omni completion, it is broken.
|
||||
let g:loaded_sql_completion = 1
|
||||
"}
|
||||
|
||||
@@ -87,7 +87,7 @@ xnoremap > >gv
|
||||
inoremap <expr> <tab> pumvisible() ? "\<c-n>" : "\<tab>"
|
||||
inoremap <expr> <s-tab> pumvisible() ? "\<c-p>" : "\<s-tab>"
|
||||
|
||||
" Edit and reload init.vim quickly
|
||||
" Edit and reload nvim config file quickly
|
||||
nnoremap <silent> <leader>ev :<C-U>tabnew $MYVIMRC <bar> tcd %:h<cr>
|
||||
nnoremap <silent> <leader>sv :<C-U>silent update $MYVIMRC <bar> source $MYVIMRC <bar>
|
||||
\ call v:lua.vim.notify("Nvim config successfully reloaded!", 'info', {'title': 'nvim-config'})<cr>
|
||||
@@ -95,13 +95,12 @@ nnoremap <silent> <leader>sv :<C-U>silent update $MYVIMRC <bar> source $MYVIMRC
|
||||
" Reselect the text that has just been pasted, see also https://stackoverflow.com/a/4317090/6064933.
|
||||
nnoremap <expr> <leader>v printf('`[%s`]', getregtype()[0])
|
||||
|
||||
" Always use very magic mode for searching
|
||||
nnoremap / /\v
|
||||
|
||||
" Search in selected region
|
||||
xnoremap / :<C-U>call feedkeys('/\%>'.(line("'<")-1).'l\%<'.(line("'>")+1)."l")<CR>
|
||||
|
||||
" Find and replace (like Sublime Text 3)
|
||||
nnoremap <C-H> :%s/
|
||||
xnoremap <C-H> :s/
|
||||
|
||||
" Change current working directory locally and print cwd after that,
|
||||
" see https://vim.fandom.com/wiki/Set_working_directory_to_the_current_file
|
||||
nnoremap <silent> <leader>cd :<C-U>lcd %:p:h<CR>:pwd<CR>
|
||||
@@ -168,6 +167,7 @@ onoremap <silent> iB :<C-U>call text_obj#Buffer()<CR>
|
||||
|
||||
" Do not move my cursor when joining lines.
|
||||
nnoremap J mzJ`z
|
||||
nnoremap gJ mzgJ`z
|
||||
|
||||
" Break inserted text into smaller undo units.
|
||||
for ch in [',', '.', '!', '?', ';', ':']
|
||||
@@ -190,3 +190,6 @@ function! s:restore_cursor() abort
|
||||
silent! normal `y
|
||||
silent! delmarks y
|
||||
endfunction
|
||||
|
||||
" for mappings defined in lua
|
||||
lua require('custom-map')
|
||||
|
||||
@@ -112,6 +112,9 @@ set shortmess+=c
|
||||
" choice, IMHO.
|
||||
set shortmess+=S
|
||||
|
||||
" Disable showing intro message (:intro)
|
||||
set shortmess+=I
|
||||
|
||||
" Completion behaviour
|
||||
" set completeopt+=noinsert " Auto select the first completion entry
|
||||
set completeopt+=menuone " Show menu even if there is only one item
|
||||
@@ -120,7 +123,7 @@ set completeopt-=preview " Disable the preview window
|
||||
set pumheight=10 " Maximum number of items to show in popup menu
|
||||
set pumblend=10 " pseudo transparency for completion menu
|
||||
|
||||
set winblend=5 " pseudo transparency for floating window
|
||||
set winblend=0 " pseudo transparency for floating window
|
||||
|
||||
" Insert mode key word completion setting
|
||||
set complete+=kspell complete-=w complete-=b complete-=u complete-=t
|
||||
|
||||
@@ -101,7 +101,7 @@ nnoremap <silent> <leader>ft :<C-U>Leaderf bufTag --popup<CR>
|
||||
nnoremap <silent> <leader>fb :<C-U>Leaderf buffer --popup<CR>
|
||||
|
||||
" Search recent files
|
||||
nnoremap <silent> <leader>fr :<C-U>Leaderf mru --popup<CR>
|
||||
nnoremap <silent> <leader>fr :<C-U>Leaderf mru --popup --absolute-path<CR>
|
||||
|
||||
let g:Lf_PopupColorscheme = 'gruvbox_material'
|
||||
|
||||
@@ -292,7 +292,6 @@ if ( g:is_win || g:is_mac ) && executable('latex')
|
||||
" Viewer settings for different platforms
|
||||
if g:is_win
|
||||
let g:vimtex_view_general_viewer = 'SumatraPDF'
|
||||
let g:vimtex_view_general_options_latexmk = '-reuse-instance'
|
||||
let g:vimtex_view_general_options = '-reuse-instance -forward-search @tex @line @pdf'
|
||||
endif
|
||||
|
||||
@@ -372,9 +371,16 @@ if exists('g:started_by_firenvim') && g:started_by_firenvim
|
||||
\ }
|
||||
\ }
|
||||
|
||||
function! s:setup_firenvim() abort
|
||||
set noruler noshowcmd
|
||||
set laststatus=0 showtabline=0
|
||||
endfunction
|
||||
|
||||
augroup firenvim
|
||||
autocmd!
|
||||
autocmd BufEnter *.txt setlocal filetype=markdown laststatus=0 nonumber noshowcmd noruler showtabline=1
|
||||
autocmd FileType text call s:setup_firenvim()
|
||||
autocmd BufNewFile github.com_*.txt set filetype=markdown
|
||||
autocmd BufNewFile stackoverflow.com_*.txt set filetype=markdown
|
||||
augroup END
|
||||
endif
|
||||
|
||||
@@ -426,3 +432,6 @@ function! s:wilder_init() abort
|
||||
echohl Error |echomsg "Wilder.nvim missing: run :PackerSync to fix."|echohl None
|
||||
endtry
|
||||
endfunction
|
||||
|
||||
""""""""""""""""""""""""""""""vim-auto-save settings""""""""""""""""""""""""""""""
|
||||
let g:auto_save = 1 " enable AutoSave on Vim startup
|
||||
|
||||
@@ -54,6 +54,13 @@ function! s:theme_setup_dict.kanagawa() dict abort
|
||||
colorscheme kanagawa
|
||||
endfunction
|
||||
|
||||
function! s:theme_setup_dict.catppuccin() dict abort
|
||||
let g:catppuccin_flavour = "frappe" " latte, frappe, macchiato, mocha
|
||||
|
||||
lua require("catppuccin").setup()
|
||||
colorscheme catppuccin
|
||||
endfunction
|
||||
|
||||
" Theme to directory name mapping, because theme repo name is not necessarily
|
||||
" the same as the theme name itself.
|
||||
let s:theme2dir = {
|
||||
@@ -67,6 +74,7 @@ let s:theme2dir = {
|
||||
\ 'everforest' :'everforest',
|
||||
\ 'nightfox': 'nightfox.nvim',
|
||||
\ 'kanagawa': 'kanagawa.nvim',
|
||||
\ 'catppuccin': 'catppuccin'
|
||||
\ }
|
||||
|
||||
let s:theme = utils#RandElement(keys(s:theme2dir))
|
||||
@@ -85,7 +93,7 @@ if !s:status
|
||||
endif
|
||||
|
||||
execute 'call ' . s:colorscheme_func
|
||||
if g:logging_level == 'info'
|
||||
if g:logging_level == 'debug'
|
||||
let s:msg1 = "Colorscheme: " . s:theme
|
||||
call v:lua.vim.notify(s:msg1, 'info', {'title': 'nvim-config'})
|
||||
endif
|
||||
|
||||
108
docs/README.md
108
docs/README.md
@@ -2,9 +2,44 @@ This doc summarizes how to install and use this configuration in detail.
|
||||
|
||||
# Pre-requisite
|
||||
|
||||
## Terminal emulators
|
||||
|
||||
Which [terminal emulator](https://en.wikipedia.org/wiki/Terminal_emulator) we choose to use greatly affects the appearance and features of Nvim.
|
||||
Since Nvim supports true colors, terminals that support true colors are preferred.
|
||||
For a list of terminals that support true colors, see [here](https://github.com/termstandard/colors).
|
||||
|
||||
For macOS, we can use [kitty](https://sw.kovidgoyal.net/kitty/), [iterm2](https://www.iterm2.com/), [wezterm](https://wezfurlong.org/wezterm/) or [Alacritty](https://github.com/jwilm/alacritty).
|
||||
|
||||
If you ssh to Linux server on Windows, I recommend [wsltty](https://github.com/mintty/wsltty) and [Cygwin](https://www.cygwin.com/),
|
||||
both of them use [mintty](https://github.com/mintty/mintty) as the terminal emulator.
|
||||
For the latest version of Windows 10, you can also try [Windows Terminal](https://github.com/microsoft/terminal).
|
||||
|
||||
## Patched Fonts
|
||||
|
||||
Since statusline or file explorer plugins often use Unicode symbols not available in normal font,
|
||||
we need to install a patched font from the [nerd-fonts](https://github.com/ryanoasis/nerd-fonts) project.
|
||||
|
||||
# Automatic installation
|
||||
|
||||
## Automatic Installation for Linux
|
||||
|
||||
To set up a workable Nvim environment on Linux,
|
||||
I use [a bash script](nvim_setup_linux.sh) to automatically install necessary dependencies, Nvim itself and configs.
|
||||
|
||||
Note that the variable `PYTHON_INSTALLED`, `SYSTEM_PYTHON` and `ADD_TO_SYSTEM_PATH` in the script
|
||||
should be set properly based on your environment.
|
||||
|
||||
## Automatic installation for Windows
|
||||
|
||||
Run script [nvim_setup_windows.ps1](nvim_setup_windows.ps1) under PowerShell.
|
||||
|
||||
# Manual install
|
||||
|
||||
There are a few dependencies if we want to use Nvim for efficient editing and development work.
|
||||
|
||||
## Python
|
||||
## Dependencies
|
||||
|
||||
### Python
|
||||
|
||||
A lot of Nvim plugins are mainly written in Python, so we must install Python 3.
|
||||
The easiest way to install is via [Anaconda](https://docs.anaconda.com/anaconda/install/index.html) or [Miniconda](https://docs.conda.io/en/latest/miniconda.html).
|
||||
@@ -12,7 +47,7 @@ The easiest way to install is via [Anaconda](https://docs.anaconda.com/anaconda/
|
||||
After installation, make sure that you can run `python --version`,
|
||||
and that the output should be Python 3.x.
|
||||
|
||||
## Pynvim
|
||||
### Pynvim
|
||||
|
||||
Nvim relies on [pynvim](https://github.com/neovim/pynvim) to communicate with plugins that utilize its Python binding.
|
||||
Pynvim is required by plugins such as [wilder.nvim](https://github.com/gelguy/wilder.nvim).
|
||||
@@ -21,7 +56,7 @@ Pynvim is required by plugins such as [wilder.nvim](https://github.com/gelguy/wi
|
||||
pip install -U pynvim
|
||||
```
|
||||
|
||||
## python-lsp-server
|
||||
### python-lsp-server
|
||||
|
||||
[python-lsp-server (pylsp)](https://github.com/python-lsp/python-lsp-server) is a Python [Language Server](https://microsoft.github.io/language-server-protocol/) for completion, linting, go to definition, etc.
|
||||
|
||||
@@ -33,7 +68,7 @@ Note the executable for pylsp is also named `pylsp`. You need to set its PATH co
|
||||
If you use pip from Anaconda, the executable path may be something like `$CONDA_ROOT/bin/pylsp`.
|
||||
For native python, the path for pylsp may be like `$HOME/.local/bin/pylsp`
|
||||
|
||||
## Node
|
||||
### Node
|
||||
|
||||
We need to install node.js from [here](https://nodejs.org/en/download/).
|
||||
For Linux, you can use the following script:
|
||||
@@ -60,7 +95,7 @@ source ~/.bash_profile
|
||||
# source ~/.zshrc
|
||||
```
|
||||
|
||||
## vim-language-server
|
||||
### vim-language-server
|
||||
|
||||
[vim-language-server](https://github.com/iamcco/vim-language-server) provides completion for vim script. We can install vim-language-server globally:
|
||||
|
||||
@@ -70,7 +105,7 @@ npm install -g vim-language-server
|
||||
|
||||
vim-language-server is installed in the same directory as the node executable.
|
||||
|
||||
## Git
|
||||
### Git
|
||||
|
||||
Git is required by plugin manager [packer.nvim](https://github.com/wbthomason/packer.nvim) and other git-related plugins.
|
||||
|
||||
@@ -79,7 +114,7 @@ The version of Git on the Linux system may be too old so that plugins may break.
|
||||
Check [here](https://jdhao.github.io/2021/03/27/upgrade_git_on_linux/) on how to install and set up the latest version of Git.
|
||||
For Windows, install [Git for Windows](https://git-scm.com/download/win) and make sure you can run `git` from command line.
|
||||
|
||||
## ctags
|
||||
### ctags
|
||||
|
||||
In order to use tags related plugins such as [vista.vim](https://github.com/liuchengxu/vista.vim), we need to install a ctags distribution.
|
||||
Universal-ctags is preferred.
|
||||
@@ -102,7 +137,7 @@ choco install universal-ctags
|
||||
|
||||
Set its PATH properly and make sure you can run `ctags` from command line.
|
||||
|
||||
## Ripgrep
|
||||
### Ripgrep
|
||||
|
||||
[Ripgrep](https://github.com/BurntSushi/ripgrep), aka, `rg`, is a fast grepping tool available for both Linux, Windows and macOS.
|
||||
It is used by several searching plugins.
|
||||
@@ -112,7 +147,7 @@ For Linux, we can download the [binary release](https://github.com/BurntSushi/ri
|
||||
|
||||
Set its PATH properly and make sure you can run `rg` from command line.
|
||||
|
||||
## Linters
|
||||
### Linters
|
||||
|
||||
A linter is a tool to check the source code for possible style and syntax issues.
|
||||
Based on the programming languages we use, we may need to install various linters.
|
||||
@@ -122,35 +157,18 @@ Based on the programming languages we use, we may need to install various linter
|
||||
|
||||
Set their PATH properly and make sure you can run `pylint`, `flake8` and `vint` from command line.
|
||||
|
||||
## Terminal emulators
|
||||
|
||||
Which [terminal emulator](https://en.wikipedia.org/wiki/Terminal_emulator) we choose to use greatly affects the appearance and features of Nvim.
|
||||
Since Nvim supports true colors, terminals that support true colors are preferred.
|
||||
For a list of terminals that support true colors, see [here](https://github.com/termstandard/colors).
|
||||
|
||||
For macOS, we can use [kitty](https://sw.kovidgoyal.net/kitty/), [iterm2](https://www.iterm2.com/), [wezterm](https://wezfurlong.org/wezterm/) or [Alacritty](https://github.com/jwilm/alacritty).
|
||||
|
||||
If you ssh to Linux server on Windows, I recommend [wsltty](https://github.com/mintty/wsltty) and [Cygwin](https://www.cygwin.com/),
|
||||
both of them use [mintty](https://github.com/mintty/mintty) as the terminal emulator.
|
||||
For the latest version of Windows 10, you can also try [Windows Terminal](https://github.com/microsoft/terminal).
|
||||
|
||||
## Patched Fonts
|
||||
|
||||
Since statusline or file explorer plugins often use Unicode symbols not available in normal font,
|
||||
we need to install a patched font from the [nerd-fonts](https://github.com/ryanoasis/nerd-fonts) project.
|
||||
|
||||
# Install Nvim
|
||||
## Install Nvim
|
||||
|
||||
There are various ways to install Nvim depending on your system.
|
||||
Current configuration is tested against nvim v0.7.0.
|
||||
This config is only maintained for [the latest nvim stable release](https://github.com/neovim/neovim/releases/tag/stable).
|
||||
|
||||
## Linux
|
||||
### Linux
|
||||
|
||||
We can directly download the binary release from [here](https://github.com/neovim/neovim/releases/download/stable/nvim-linux64.tar.gz).
|
||||
You can directly download the binary release from [here](https://github.com/neovim/neovim/releases/download/stable/nvim-linux64.tar.gz).
|
||||
You can also use the system package manager to install nvim,
|
||||
but that is not reliable since latest version may not be available.
|
||||
but that is not reliable since the latest version may not be available.
|
||||
|
||||
## Windows
|
||||
### Windows
|
||||
|
||||
You may download from [nvim release](https://github.com/neovim/neovim/releases/download/stable/nvim-win64.zip) from GitHub and manually extract it.
|
||||
|
||||
@@ -164,7 +182,7 @@ choco install neovim
|
||||
# scoop install neovim
|
||||
```
|
||||
|
||||
## macOS
|
||||
### macOS
|
||||
|
||||
It is recommended to install neovim via [Homebrew](https://brew.sh/) on macOS. Simply run the following command:
|
||||
|
||||
@@ -173,11 +191,13 @@ brew install neovim
|
||||
```
|
||||
|
||||
After installing Nvim, we need to set the path to nvim correctly.
|
||||
Make sure that you can run `nvim` from the command line after all these setups.
|
||||
**Make sure that you can run `nvim` from the command line after all these setups**.
|
||||
|
||||
# Setting up Nvim
|
||||
## Setting up Nvim
|
||||
|
||||
## Install plugin manager packer.nvim
|
||||
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.
|
||||
|
||||
@@ -193,7 +213,7 @@ For macOS and Linux, run the following command:
|
||||
git clone --depth=1 https://github.com/wbthomason/packer.nvim ~/.local/share/nvim/site/pack/packer/opt/packer.nvim
|
||||
```
|
||||
|
||||
## How to install this configuration
|
||||
### How to install this configuration
|
||||
|
||||
On Linux and macOS, the directory is `~/.config/nvim`.
|
||||
On Windows, the config directory is `$HOME/AppData/Local/nvim`[^1].
|
||||
@@ -207,18 +227,4 @@ 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.
|
||||
Since I use quite a lot of plugins (more than 60), it may take some time to install all of them.
|
||||
|
||||
# Automatic installation
|
||||
|
||||
## Automatic Installation for Linux #
|
||||
|
||||
To set up a workable Nvim environment on Linux,
|
||||
I use [a bash script](nvim_setup_linux.sh) to automatically install necessary dependencies, Nvim itself and configs.
|
||||
|
||||
Note that the variable `PYTHON_INSTALLED`, `SYSTEM_PYTHON` and `ADD_TO_SYSTEM_PATH` in the script
|
||||
should be set properly based on your environment.
|
||||
|
||||
## Automatic installation for Windows
|
||||
|
||||
Run script [nvim_setup_windows.ps1](nvim_setup_windows.ps1) under PowerShell.
|
||||
|
||||
[^1]: Use `echo %userprofile%` to see where your `$HOME` is.
|
||||
|
||||
@@ -9,8 +9,9 @@ if [[ ! -d "$HOME/tools/" ]]; then
|
||||
fi
|
||||
|
||||
# Delete existing nvim installation.
|
||||
if [[ -d "$HOME/tools/nvim-osx64" ]]; then
|
||||
rm -rf "$HOME/tools/nvim-osx64"
|
||||
# For newer release, the directory name is nvim-macos
|
||||
if [[ -d "$HOME/tools/nvim-macos" ]]; then
|
||||
rm -rf "$HOME/tools/nvim-macos"
|
||||
fi
|
||||
|
||||
# Extract the tar ball
|
||||
|
||||
@@ -120,6 +120,35 @@ fi
|
||||
# Install bash-language-server
|
||||
"$NODE_DIR/bin/npm" install -g bash-language-server
|
||||
|
||||
#######################################################################
|
||||
# lua-language-server #
|
||||
#######################################################################
|
||||
SUMNEKO_LUA_DIR=$HOME/tools/lua-language-server
|
||||
SUMNEKO_LUA_SRC_NAME=$HOME/packages/lua-language-server.tar.gz
|
||||
SUMNEKO_LUA_LINK="https://github.com/sumneko/lua-language-server/releases/download/3.5.3/lua-language-server-3.5.3-linux-x64.tar.gz"
|
||||
|
||||
if [[ -z "$(command -v lua-language-server)" ]] && [[ ! -f "$SUMNEKO_LUA_DIR/bin/lua-language-server" ]]; then
|
||||
echo 'Install lua-language-server'
|
||||
if [[ ! -f $SUMNEKO_LUA_SRC_NAME ]]; then
|
||||
echo "Downloading lua-language-server and renaming"
|
||||
wget $SUMNEKO_LUA_LINK -O "$SUMNEKO_LUA_SRC_NAME"
|
||||
fi
|
||||
|
||||
if [[ ! -d "$SUMNEKO_LUA_DIR" ]]; then
|
||||
echo "Creating lua-language-server directory under tools directory"
|
||||
mkdir -p "$SUMNEKO_LUA_DIR"
|
||||
echo "Extracting to directory $SUMNEKO_LUA_DIR"
|
||||
|
||||
tar zxvf "$SUMNEKO_LUA_SRC_NAME" -C "$SUMNEKO_LUA_DIR"
|
||||
fi
|
||||
|
||||
if [[ "$ADD_TO_SYSTEM_PATH" = true ]] && [[ "$USE_BASH_SHELL" = true ]]; then
|
||||
echo "export PATH=\"$SUMNEKO_LUA_DIR/bin:\$PATH\"" >> "$HOME/.bash_profile"
|
||||
fi
|
||||
else
|
||||
echo "lua-language-server is already installed. Skip installing it."
|
||||
fi
|
||||
|
||||
#######################################################################
|
||||
# Ripgrep part #
|
||||
#######################################################################
|
||||
@@ -145,8 +174,8 @@ if [[ -z "$(command -v rg)" ]] && [[ ! -f "$RIPGREP_DIR/rg" ]]; then
|
||||
fi
|
||||
|
||||
# set up manpath and zsh completion for ripgrep
|
||||
mkdir -p $HOME/tools/ripgrep/doc/man/man1
|
||||
mv $HOME/tools/ripgrep/doc/rg.1 $HOME/tools/ripgrep/doc/man/man1
|
||||
mkdir -p "$HOME/tools/ripgrep/doc/man/man1"
|
||||
mv "$HOME/tools/ripgrep/doc/rg.1" "$HOME/tools/ripgrep/doc/man/man1"
|
||||
|
||||
if [[ "$USE_BASH_SHELL" = true ]]; then
|
||||
echo 'export MANPATH=$HOME/tools/ripgrep/doc/man:$MANPATH' >> "$HOME/.bash_profile"
|
||||
@@ -222,8 +251,10 @@ fi
|
||||
git clone --depth=1 https://github.com/jdhao/nvim-config.git "$NVIM_CONFIG_DIR"
|
||||
|
||||
echo "Installing packer.nvim"
|
||||
git clone --depth=1 https://github.com/wbthomason/packer.nvim \
|
||||
~/.local/share/nvim/site/pack/packer/opt/packer.nvim
|
||||
if [[ ! -d ~/.local/share/nvim/site/pack/packer/opt/packer.nvim ]]; then
|
||||
git clone --depth=1 https://github.com/wbthomason/packer.nvim \
|
||||
~/.local/share/nvim/site/pack/packer/opt/packer.nvim
|
||||
fi
|
||||
|
||||
echo "Installing nvim plugins, please wait"
|
||||
"$NVIM_DIR/bin/nvim" -c "autocmd User PackerComplete quitall" -c "PackerSync"
|
||||
|
||||
37
init.lua
Normal file
37
init.lua
Normal file
@@ -0,0 +1,37 @@
|
||||
-- This is my personal Nvim configuration supporting Mac, Linux and Windows, with various plugins configured.
|
||||
-- This configuration evolves as I learn more about Nvim and become more proficient in using Nvim.
|
||||
-- Since it is very long (more than 1000 lines!), you should read it carefully and take only the settings that suit you.
|
||||
-- I would not recommend cloning this repo and replace your own config. Good configurations are personal,
|
||||
-- built over time with a lot of polish.
|
||||
--
|
||||
-- Author: Jie-dong Hao
|
||||
-- Email: jdhao@hotmail.com
|
||||
-- Blog: https://jdhao.github.io/
|
||||
|
||||
-- check if we have the latest stable version of nvim
|
||||
local expected_ver = "0.7.2"
|
||||
|
||||
local utils = require "utils"
|
||||
local nvim_ver = utils.get_nvim_version()
|
||||
|
||||
if nvim_ver ~= expected_ver then
|
||||
local msg = string.format("Unsupported nvim version: expect %s, but got %s instead!", expected_ver, nvim_ver)
|
||||
vim.api.nvim_echo({ { msg, "ErrorMsg" } }, false, {})
|
||||
return
|
||||
end
|
||||
|
||||
local core_conf_files = {
|
||||
"globals.vim",
|
||||
"options.vim",
|
||||
"autocommands.vim",
|
||||
"mappings.vim",
|
||||
"plugins.vim",
|
||||
"themes.vim",
|
||||
}
|
||||
|
||||
-- source all the core config files
|
||||
for _, name in ipairs(core_conf_files) do
|
||||
local path = string.format("%s/core/%s", vim.fn.stdpath('config'), name)
|
||||
local source_cmd = "source " .. path
|
||||
vim.cmd(source_cmd)
|
||||
end
|
||||
22
init.vim
22
init.vim
@@ -1,22 +0,0 @@
|
||||
" This is my personal Nvim configuration supporting Mac, Linux and Windows, with various plugins configured.
|
||||
" This configuration evolves as I learn more about Nvim and become more proficient in using Nvim.
|
||||
" Since it is very long (more than 1000 lines!), you should read it carefully and take only the settings that suit you.
|
||||
" I would not recommend cloning this repo and replace your own config. Good configurations are personal,
|
||||
" built over time with a lot of polish.
|
||||
"
|
||||
" Author: Jie-dong Hao
|
||||
" Email: jdhao@hotmail.com
|
||||
" Blog: https://jdhao.github.io/
|
||||
|
||||
let s:core_conf_files = [
|
||||
\ 'globals.vim',
|
||||
\ 'options.vim',
|
||||
\ 'autocommands.vim',
|
||||
\ 'mappings.vim',
|
||||
\ 'plugins.vim',
|
||||
\ 'themes.vim'
|
||||
\ ]
|
||||
|
||||
for s:fname in s:core_conf_files
|
||||
execute printf('source %s/core/%s', stdpath('config'), s:fname)
|
||||
endfor
|
||||
@@ -1,32 +0,0 @@
|
||||
local alpha = require("alpha")
|
||||
local dashboard = require("alpha.themes.dashboard")
|
||||
|
||||
-- Set header
|
||||
dashboard.section.header.val = {
|
||||
" ",
|
||||
" ███╗ ██╗███████╗ ██████╗ ██╗ ██╗██╗███╗ ███╗ ",
|
||||
" ████╗ ██║██╔════╝██╔═══██╗██║ ██║██║████╗ ████║ ",
|
||||
" ██╔██╗ ██║█████╗ ██║ ██║██║ ██║██║██╔████╔██║ ",
|
||||
" ██║╚██╗██║██╔══╝ ██║ ██║╚██╗ ██╔╝██║██║╚██╔╝██║ ",
|
||||
" ██║ ╚████║███████╗╚██████╔╝ ╚████╔╝ ██║██║ ╚═╝ ██║ ",
|
||||
" ╚═╝ ╚═══╝╚══════╝ ╚═════╝ ╚═══╝ ╚═╝╚═╝ ╚═╝ ",
|
||||
" ",
|
||||
}
|
||||
|
||||
-- Set menu
|
||||
dashboard.section.buttons.val = {
|
||||
dashboard.button( "Leader f f", " > Find file", ":Leaderf file --popup<CR>"),
|
||||
dashboard.button( "Leader f r", " > Recent files" , ":Leaderf mru --popup<CR>"),
|
||||
dashboard.button( "Leader f g", " > Project grep" , ":Leaderf rg --popup<CR>"),
|
||||
dashboard.button( "u", " > Update plugins" , ":PackerSync<CR>"),
|
||||
dashboard.button( "e", " > New file" , ":enew <CR>"),
|
||||
dashboard.button( "q", " > Quit NVIM", ":qa<CR>"),
|
||||
}
|
||||
|
||||
local fortune = require("alpha.fortune")
|
||||
dashboard.section.footer.val = fortune()
|
||||
|
||||
alpha.setup(dashboard.opts)
|
||||
|
||||
-- Send config to alpha
|
||||
alpha.setup(dashboard.opts)
|
||||
@@ -1,15 +0,0 @@
|
||||
require("autosave").setup({
|
||||
enabled = true,
|
||||
execution_message = "Autosaved at " .. vim.fn.strftime("%H:%M:%S"),
|
||||
events = { "InsertLeave", "TextChanged" },
|
||||
conditions = {
|
||||
exists = true,
|
||||
filename_is_not = {"plugins.lua"},
|
||||
filetype_is_not = {},
|
||||
modifiable = true,
|
||||
},
|
||||
write_all_buffers = false,
|
||||
on_off_commands = true,
|
||||
clean_command_line_interval = 1000,
|
||||
debounce_delay = 135,
|
||||
})
|
||||
65
lua/config/dashboard-nvim.lua
Normal file
65
lua/config/dashboard-nvim.lua
Normal file
@@ -0,0 +1,65 @@
|
||||
local dashboard = require("dashboard")
|
||||
|
||||
dashboard.custom_header = {
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ███╗ ██╗ ███████╗ ██████╗ ██╗ ██╗ ██╗ ███╗ ███╗",
|
||||
" ████╗ ██║ ██╔════╝██╔═══██╗ ██║ ██║ ██║ ████╗ ████║",
|
||||
" ██╔██╗ ██║ █████╗ ██║ ██║ ██║ ██║ ██║ ██╔████╔██║",
|
||||
" ██║╚██╗██║ ██╔══╝ ██║ ██║ ╚██╗ ██╔╝ ██║ ██║╚██╔╝██║",
|
||||
" ██║ ╚████║ ███████╗╚██████╔╝ ╚████╔╝ ██║ ██║ ╚═╝ ██║",
|
||||
" ╚═╝ ╚═══╝ ╚══════╝ ╚═════╝ ╚═══╝ ╚═╝ ╚═╝ ╚═╝",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
}
|
||||
|
||||
dashboard.custom_center = {
|
||||
{
|
||||
icon = " ",
|
||||
desc = "Find File ",
|
||||
action = "Leaderf file --popup",
|
||||
shortcut = "<Leader> f f",
|
||||
},
|
||||
{
|
||||
icon = " ",
|
||||
desc = "Recently opened files ",
|
||||
action = "Leaderf mru --popup",
|
||||
shortcut = "<Leader> f r",
|
||||
},
|
||||
{
|
||||
icon = " ",
|
||||
desc = "Project grep ",
|
||||
action = "Leaderf rg --popup",
|
||||
shortcut = "<Leader> f g",
|
||||
},
|
||||
{
|
||||
icon = " ",
|
||||
desc = "Open Nvim config ",
|
||||
action = "tabnew $MYVIMRC | tcd %:p:h",
|
||||
shortcut = "<Leader> e v",
|
||||
},
|
||||
{
|
||||
icon = " ",
|
||||
desc = "New file ",
|
||||
action = "enew",
|
||||
shortcut = "e ",
|
||||
},
|
||||
{
|
||||
icon = " ",
|
||||
desc = "Quit Nvim ",
|
||||
-- desc = "Quit Nvim ",
|
||||
action = "qa",
|
||||
shortcut = "q "
|
||||
}
|
||||
}
|
||||
|
||||
vim.cmd([[
|
||||
augroup dashboard_enter
|
||||
au!
|
||||
autocmd FileType dashboard nnoremap <buffer> q :qa<CR>
|
||||
autocmd FileType dashboard nnoremap <buffer> e :enew<CR>
|
||||
augroup END
|
||||
]])
|
||||
1
lua/config/fidget-nvim.lua
Normal file
1
lua/config/fidget-nvim.lua
Normal file
@@ -0,0 +1 @@
|
||||
require"fidget".setup{}
|
||||
@@ -3,19 +3,32 @@ require('hlslens').setup({
|
||||
nearest_only = true,
|
||||
})
|
||||
|
||||
vim.api.nvim_set_keymap(
|
||||
"n",
|
||||
"n",
|
||||
"<Cmd>execute('normal! ' . v:count1 . 'nzzzv')<CR><Cmd>lua require('hlslens').start()<CR>",
|
||||
{ noremap = true, silent = true }
|
||||
)
|
||||
local activate_hlslens = function(direction)
|
||||
local cmd = string.format("normal! %s%szzzv", vim.v.count1, direction)
|
||||
local status, msg = pcall(vim.fn.execute, cmd)
|
||||
-- 13 is the index where real error message starts
|
||||
msg = msg:sub(13)
|
||||
|
||||
vim.api.nvim_set_keymap(
|
||||
"n",
|
||||
"N",
|
||||
"<Cmd>execute('normal! ' . v:count1 . 'Nzzzv')<CR><Cmd>lua require('hlslens').start()<CR>",
|
||||
{ noremap = true, silent = true }
|
||||
)
|
||||
if not status then
|
||||
vim.api.nvim_echo({{msg, "ErrorMsg"}}, false, {})
|
||||
return
|
||||
end
|
||||
require('hlslens').start()
|
||||
end
|
||||
|
||||
vim.api.nvim_set_keymap("n", "*", "<Plug>(asterisk-z*)<Cmd>lua require('hlslens').start()<CR>", { silent = true })
|
||||
vim.api.nvim_set_keymap("n", "#", "<Plug>(asterisk-z#)<Cmd>lua require('hlslens').start()<CR>", { silent = true })
|
||||
vim.keymap.set('n', 'n', '',
|
||||
{
|
||||
noremap = true,
|
||||
silent = true,
|
||||
callback = function() activate_hlslens('n') end
|
||||
})
|
||||
|
||||
vim.keymap.set('n', 'N', '',
|
||||
{
|
||||
noremap = true,
|
||||
silent = true,
|
||||
callback = function() activate_hlslens('N') end
|
||||
})
|
||||
|
||||
vim.keymap.set('n', '*', "<Plug>(asterisk-z*)<Cmd>lua require('hlslens').start()<CR>", { silent = true })
|
||||
vim.keymap.set('n', '#', "<Plug>(asterisk-z#)<Cmd>lua require('hlslens').start()<CR>", { silent = true })
|
||||
|
||||
@@ -1,21 +1,9 @@
|
||||
local fn = vim.fn
|
||||
local api = vim.api
|
||||
local lsp = vim.lsp
|
||||
|
||||
local utils = require("utils")
|
||||
|
||||
local M = {}
|
||||
|
||||
function M.show_line_diagnostics()
|
||||
local opts = {
|
||||
focusable = false,
|
||||
close_events = { "BufLeave", "CursorMoved", "InsertEnter", "FocusLost" },
|
||||
border = 'rounded',
|
||||
source = 'always', -- show source in diagnostic popup window
|
||||
prefix = ' '
|
||||
}
|
||||
vim.diagnostic.open_float(nil, opts)
|
||||
end
|
||||
|
||||
local custom_attach = function(client, bufnr)
|
||||
-- Mappings.
|
||||
local opts = { silent = true, buffer = bufnr }
|
||||
@@ -25,7 +13,7 @@ local custom_attach = function(client, bufnr)
|
||||
vim.keymap.set("n", "<C-k>", vim.lsp.buf.signature_help, opts)
|
||||
vim.keymap.set("n", "<space>wa", vim.lsp.buf.add_workspace_folder, opts)
|
||||
vim.keymap.set("n", "<space>wr", vim.lsp.buf.remove_workspace_folder, opts)
|
||||
vim.keymap.set("n", "<space>wl", function() print(vim.inspect(vim.lsp.buf.list_workspace_folders())) end, opts)
|
||||
vim.keymap.set("n", "<space>wl", function() inspect(vim.lsp.buf.list_workspace_folders()) end, opts)
|
||||
vim.keymap.set("n", "<space>rn", vim.lsp.buf.rename, opts)
|
||||
vim.keymap.set("n", "gr", vim.lsp.buf.references, opts)
|
||||
vim.keymap.set("n", "[d", vim.diagnostic.goto_prev, opts)
|
||||
@@ -33,9 +21,31 @@ local custom_attach = function(client, bufnr)
|
||||
vim.keymap.set("n", "<space>q", function() vim.diagnostic.setqflist({open = true}) end, opts)
|
||||
vim.keymap.set("n", "<space>ca", vim.lsp.buf.code_action, opts)
|
||||
|
||||
vim.cmd([[
|
||||
autocmd CursorHold <buffer> lua require('config.lsp').show_line_diagnostics()
|
||||
]])
|
||||
api.nvim_create_autocmd("CursorHold", {
|
||||
buffer=bufnr,
|
||||
callback = function()
|
||||
local float_opts = {
|
||||
focusable = false,
|
||||
close_events = { "BufLeave", "CursorMoved", "InsertEnter", "FocusLost" },
|
||||
border = 'rounded',
|
||||
source = 'always', -- show source in diagnostic popup window
|
||||
prefix = ' '
|
||||
}
|
||||
|
||||
if not vim.b.diagnostics_pos then
|
||||
vim.b.diagnostics_pos = { nil, nil }
|
||||
end
|
||||
|
||||
local cursor_pos = api.nvim_win_get_cursor(0)
|
||||
if (cursor_pos[1] ~= vim.b.diagnostics_pos[1] or cursor_pos[2] ~= vim.b.diagnostics_pos[2]) and
|
||||
#vim.diagnostic.get() > 0
|
||||
then
|
||||
vim.diagnostic.open_float(nil, float_opts)
|
||||
end
|
||||
|
||||
vim.b.diagnostics_pos = cursor_pos
|
||||
end
|
||||
})
|
||||
|
||||
-- Set some key bindings conditional on server capabilities
|
||||
if client.resolved_capabilities.document_formatting then
|
||||
@@ -138,36 +148,30 @@ if utils.executable('bash-language-server') then
|
||||
})
|
||||
end
|
||||
|
||||
local sumneko_binary_path = vim.fn.exepath("lua-language-server")
|
||||
if vim.g.is_mac or vim.g.is_linux and sumneko_binary_path ~= "" then
|
||||
local sumneko_root_path = vim.fn.fnamemodify(sumneko_binary_path, ":h:h:h")
|
||||
|
||||
local runtime_path = vim.split(package.path, ";")
|
||||
table.insert(runtime_path, "lua/?.lua")
|
||||
table.insert(runtime_path, "lua/?/init.lua")
|
||||
|
||||
if utils.executable("lua-language-server") then
|
||||
-- settings for lua-language-server can be found on https://github.com/sumneko/lua-language-server/wiki/Settings .
|
||||
lspconfig.sumneko_lua.setup({
|
||||
on_attach = custom_attach,
|
||||
cmd = { sumneko_binary_path, "-E", sumneko_root_path .. "/main.lua" },
|
||||
settings = {
|
||||
Lua = {
|
||||
runtime = {
|
||||
-- Tell the language server which version of Lua you're using (most likely LuaJIT in the case of Neovim)
|
||||
version = "LuaJIT",
|
||||
-- Setup your lua path
|
||||
path = runtime_path,
|
||||
},
|
||||
diagnostics = {
|
||||
-- Get the language server to recognize the `vim` global
|
||||
globals = { "vim" },
|
||||
},
|
||||
workspace = {
|
||||
-- Make the server aware of Neovim runtime files
|
||||
library = api.nvim_get_runtime_file("", true),
|
||||
},
|
||||
-- Do not send telemetry data containing a randomized but unique identifier
|
||||
telemetry = {
|
||||
enable = false,
|
||||
-- Make the server aware of Neovim runtime files,
|
||||
-- see also https://github.com/sumneko/lua-language-server/wiki/Libraries#link-to-workspace .
|
||||
-- Lua-dev.nvim also has similar settings for sumneko lua, https://github.com/folke/lua-dev.nvim/blob/main/lua/lua-dev/sumneko.lua .
|
||||
library = {
|
||||
fn.stdpath('data') .. "/site/pack/packer/opt/emmylua-nvim",
|
||||
fn.stdpath('config'),
|
||||
},
|
||||
maxPreload = 2000,
|
||||
preloadFileSize = 50000,
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -176,10 +180,10 @@ if vim.g.is_mac or vim.g.is_linux and sumneko_binary_path ~= "" then
|
||||
end
|
||||
|
||||
-- Change diagnostic signs.
|
||||
vim.fn.sign_define("DiagnosticSignError", { text = "✗", texthl = "DiagnosticSignError" })
|
||||
vim.fn.sign_define("DiagnosticSignWarn", { text = "!", texthl = "DiagnosticSignWarn" })
|
||||
vim.fn.sign_define("DiagnosticSignInformation", { text = "", texthl = "DiagnosticSignInfo" })
|
||||
vim.fn.sign_define("DiagnosticSignHint", { text = "", texthl = "DiagnosticSignHint" })
|
||||
fn.sign_define("DiagnosticSignError", { text = "✗", texthl = "DiagnosticSignError" })
|
||||
fn.sign_define("DiagnosticSignWarn", { text = "!", texthl = "DiagnosticSignWarn" })
|
||||
fn.sign_define("DiagnosticSignInformation", { text = "", texthl = "DiagnosticSignInfo" })
|
||||
fn.sign_define("DiagnosticSignHint", { text = "", texthl = "DiagnosticSignHint" })
|
||||
|
||||
-- global config for diagnostic
|
||||
vim.diagnostic.config({
|
||||
@@ -200,5 +204,3 @@ vim.diagnostic.config({
|
||||
lsp.handlers["textDocument/hover"] = lsp.with(vim.lsp.handlers.hover, {
|
||||
border = "rounded",
|
||||
})
|
||||
|
||||
return M
|
||||
|
||||
@@ -33,7 +33,6 @@ cmp.setup({
|
||||
sources = {
|
||||
{ name = 'nvim_lsp' }, -- For nvim-lsp
|
||||
{ name = 'ultisnips' }, -- For ultisnips user.
|
||||
{ name = 'nvim_lua' }, -- for nvim lua function
|
||||
{ name = 'path' }, -- for path completion
|
||||
{ name = 'buffer', keyword_length = 4 }, -- for buffer word completion
|
||||
{ name = 'omni' },
|
||||
|
||||
@@ -1,62 +1,119 @@
|
||||
local nvim_tree = require("nvim-tree")
|
||||
|
||||
nvim_tree.setup({
|
||||
disable_netrw = true,
|
||||
hijack_netrw = true,
|
||||
open_on_setup = false,
|
||||
ignore_ft_on_setup = {},
|
||||
open_on_tab = false,
|
||||
hijack_cursor = false,
|
||||
update_cwd = false,
|
||||
update_to_buf_dir = {
|
||||
enable = true,
|
||||
auto_open = true,
|
||||
},
|
||||
diagnostics = {
|
||||
enable = false,
|
||||
icons = {
|
||||
hint = "",
|
||||
info = "",
|
||||
warning = "",
|
||||
error = "",
|
||||
},
|
||||
},
|
||||
update_focused_file = {
|
||||
enable = false,
|
||||
update_cwd = false,
|
||||
ignore_list = {},
|
||||
},
|
||||
system_open = {
|
||||
cmd = nil,
|
||||
args = {},
|
||||
},
|
||||
filters = {
|
||||
dotfiles = false,
|
||||
custom = {},
|
||||
},
|
||||
git = {
|
||||
enable = true,
|
||||
ignore = true,
|
||||
timeout = 500,
|
||||
},
|
||||
view = {
|
||||
width = 35,
|
||||
height = 30,
|
||||
hide_root_folder = false,
|
||||
side = "left",
|
||||
auto_resize = true,
|
||||
mappings = {
|
||||
custom_only = false,
|
||||
list = {},
|
||||
},
|
||||
number = false,
|
||||
relativenumber = false,
|
||||
signcolumn = "yes",
|
||||
},
|
||||
trash = {
|
||||
cmd = "trash",
|
||||
require_confirm = true,
|
||||
},
|
||||
auto_reload_on_write = true,
|
||||
disable_netrw = false,
|
||||
hijack_cursor = false,
|
||||
hijack_netrw = true,
|
||||
hijack_unnamed_buffer_when_opening = false,
|
||||
ignore_buffer_on_setup = false,
|
||||
open_on_setup = false,
|
||||
open_on_setup_file = false,
|
||||
open_on_tab = false,
|
||||
sort_by = "name",
|
||||
update_cwd = false,
|
||||
view = {
|
||||
width = 30,
|
||||
height = 30,
|
||||
hide_root_folder = false,
|
||||
side = "left",
|
||||
preserve_window_proportions = false,
|
||||
number = false,
|
||||
relativenumber = false,
|
||||
signcolumn = "yes",
|
||||
mappings = {
|
||||
custom_only = false,
|
||||
list = {
|
||||
-- user mappings go here
|
||||
},
|
||||
},
|
||||
},
|
||||
renderer = {
|
||||
indent_markers = {
|
||||
enable = false,
|
||||
icons = {
|
||||
corner = "└ ",
|
||||
edge = "│ ",
|
||||
none = " ",
|
||||
},
|
||||
},
|
||||
icons = {
|
||||
webdev_colors = true,
|
||||
},
|
||||
},
|
||||
hijack_directories = {
|
||||
enable = true,
|
||||
auto_open = true,
|
||||
},
|
||||
update_focused_file = {
|
||||
enable = false,
|
||||
update_cwd = false,
|
||||
ignore_list = {},
|
||||
},
|
||||
ignore_ft_on_setup = {},
|
||||
system_open = {
|
||||
cmd = "",
|
||||
args = {},
|
||||
},
|
||||
diagnostics = {
|
||||
enable = false,
|
||||
show_on_dirs = false,
|
||||
icons = {
|
||||
hint = "",
|
||||
info = "",
|
||||
warning = "",
|
||||
error = "",
|
||||
},
|
||||
},
|
||||
filters = {
|
||||
dotfiles = false,
|
||||
custom = {},
|
||||
exclude = {},
|
||||
},
|
||||
git = {
|
||||
enable = true,
|
||||
ignore = true,
|
||||
timeout = 400,
|
||||
},
|
||||
actions = {
|
||||
use_system_clipboard = true,
|
||||
change_dir = {
|
||||
enable = true,
|
||||
global = false,
|
||||
restrict_above_cwd = false,
|
||||
},
|
||||
open_file = {
|
||||
quit_on_open = false,
|
||||
resize_window = false,
|
||||
window_picker = {
|
||||
enable = true,
|
||||
chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890",
|
||||
exclude = {
|
||||
filetype = { "notify", "packer", "qf", "diff", "fugitive", "fugitiveblame" },
|
||||
buftype = { "nofile", "terminal", "help" },
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
trash = {
|
||||
cmd = "trash",
|
||||
require_confirm = true,
|
||||
},
|
||||
log = {
|
||||
enable = false,
|
||||
truncate = false,
|
||||
types = {
|
||||
all = false,
|
||||
config = false,
|
||||
copy_paste = false,
|
||||
diagnostics = false,
|
||||
git = false,
|
||||
profile = false,
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
vim.api.nvim_set_keymap("n", "<space>s", "<cmd>lua require'nvim-tree'.toggle(false, true)<CR>", { noremap = true, silent = true })
|
||||
vim.keymap.set('n', '<space>s', function()
|
||||
return require('nvim-tree').toggle(false, true)
|
||||
end,
|
||||
{ noremap = true, silent = true, desc = "toggle nvim-tree"})
|
||||
|
||||
@@ -8,4 +8,7 @@ require('hop').setup({
|
||||
quit_key='<Esc>',
|
||||
})
|
||||
|
||||
vim.api.nvim_set_keymap('n', 'f', "<cmd>lua require'hop'.hint_char2()<cr>", {noremap = true})
|
||||
vim.keymap.set('n', 'f', function()
|
||||
return require('hop').hint_char2()
|
||||
end,
|
||||
{ silent = true, noremap = true, desc = "nvim-hop char2" })
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
local fn = vim.fn
|
||||
|
||||
local function spell()
|
||||
if vim.o.spell then
|
||||
return string.format("[SPELL]")
|
||||
@@ -9,7 +11,7 @@ end
|
||||
local function ime_state()
|
||||
if vim.g.is_mac then
|
||||
-- ref: https://github.com/vim-airline/vim-airline/blob/master/autoload/airline/extensions/xkblayout.vim#L11
|
||||
local layout = vim.fn.libcall(vim.g.XkbSwitchLib, 'Xkb_Switch_getXkbLayout', '')
|
||||
local layout = fn.libcall(vim.g.XkbSwitchLib, 'Xkb_Switch_getXkbLayout', '')
|
||||
if layout == '0' then
|
||||
return '[CN]'
|
||||
end
|
||||
@@ -19,36 +21,52 @@ local function ime_state()
|
||||
end
|
||||
|
||||
local function trailing_space()
|
||||
-- Get the positions of trailing whitespaces from plugin 'jdhao/whitespace.nvim'.
|
||||
local trailing_space_pos = vim.b.trailing_whitespace_pos
|
||||
if not vim.o.modifiable then
|
||||
return ""
|
||||
end
|
||||
|
||||
local line_num = nil
|
||||
|
||||
for i=1, fn.line('$') do
|
||||
local linetext = fn.getline(i)
|
||||
-- To prevent invalid escape error, we wrap the regex string with `[[]]`.
|
||||
local idx = fn.match(linetext, [[\v\s+$]])
|
||||
|
||||
if idx ~= -1 then
|
||||
line_num = i
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
local msg = ""
|
||||
if #trailing_space_pos > 0 then
|
||||
-- Note that lua index is 1-based, not zero based!!!
|
||||
local line = trailing_space_pos[1][1]
|
||||
msg = string.format("[%d]trailing", line)
|
||||
if line_num ~= nil then
|
||||
msg = string.format("[%d]trailing", line_num)
|
||||
end
|
||||
|
||||
return msg
|
||||
end
|
||||
|
||||
local function mixed_indent()
|
||||
if not vim.o.modifiable then
|
||||
return ""
|
||||
end
|
||||
|
||||
local space_pat = [[\v^ +]]
|
||||
local tab_pat = [[\v^\t+]]
|
||||
local space_indent = vim.fn.search(space_pat, 'nwc')
|
||||
local tab_indent = vim.fn.search(tab_pat, 'nwc')
|
||||
local space_indent = fn.search(space_pat, 'nwc')
|
||||
local tab_indent = fn.search(tab_pat, 'nwc')
|
||||
local mixed = (space_indent > 0 and tab_indent > 0)
|
||||
local mixed_same_line
|
||||
if not mixed then
|
||||
mixed_same_line = vim.fn.search([[\v^(\t+ | +\t)]], 'nwc')
|
||||
mixed_same_line = fn.search([[\v^(\t+ | +\t)]], 'nwc')
|
||||
mixed = mixed_same_line > 0
|
||||
end
|
||||
if not mixed then return '' end
|
||||
if mixed_same_line ~= nil and mixed_same_line > 0 then
|
||||
return 'MI:'..mixed_same_line
|
||||
end
|
||||
local space_indent_cnt = vim.fn.searchcount({pattern=space_pat, max_count=1e3}).total
|
||||
local tab_indent_cnt = vim.fn.searchcount({pattern=tab_pat, max_count=1e3}).total
|
||||
local space_indent_cnt = fn.searchcount({pattern=space_pat, max_count=1e3}).total
|
||||
local tab_indent_cnt = fn.searchcount({pattern=tab_pat, max_count=1e3}).total
|
||||
if space_indent_cnt > tab_indent_cnt then
|
||||
return 'MI:'..tab_indent
|
||||
else
|
||||
|
||||
11
lua/custom-map.lua
Normal file
11
lua/custom-map.lua
Normal file
@@ -0,0 +1,11 @@
|
||||
local keymap = vim.keymap
|
||||
|
||||
-- Go to the beginning and end of current line in insert mode quickly
|
||||
keymap.set('i', '<C-A>', '<HOME>')
|
||||
keymap.set('i', '<C-E>', '<END>')
|
||||
|
||||
-- Go to beginning of command in command-line mode
|
||||
keymap.set('c', '<C-A>', '<HOME>')
|
||||
|
||||
-- Delete the character to the right of the cursor
|
||||
keymap.set('i', '<C-D>', '<DEL>')
|
||||
@@ -1,23 +1,34 @@
|
||||
local utils = require("utils")
|
||||
local fn = vim.fn
|
||||
|
||||
vim.g.package_home = fn.stdpath("data") .. "/site/pack/packer/"
|
||||
local packer_install_dir = vim.g.package_home .. "/opt/packer.nvim"
|
||||
-- The root dir to install all plugins. Plugins are under opt/ or start/ sub-directory.
|
||||
vim.g.plugin_home = fn.stdpath("data") .. "/site/pack/packer"
|
||||
|
||||
local packer_repo = "https://github.com/wbthomason/packer.nvim"
|
||||
local install_cmd = string.format("10split |term git clone --depth=1 %s %s", packer_repo, packer_install_dir)
|
||||
-- Where to install packer.nvim -- the package manager (we make it opt)
|
||||
local packer_dir = vim.g.plugin_home .. "/opt/packer.nvim"
|
||||
|
||||
-- Whether this is a fresh install, i.e., packer itself and plugins have not been installed.
|
||||
local fresh_install = false
|
||||
|
||||
-- Auto-install packer in case it hasn't been installed.
|
||||
if fn.glob(packer_install_dir) == "" then
|
||||
if fn.glob(packer_dir) == "" then
|
||||
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
|
||||
|
||||
-- Load packer.nvim
|
||||
vim.cmd("packadd packer.nvim")
|
||||
local util = require('packer.util')
|
||||
|
||||
require("packer").startup({
|
||||
local packer = require("packer")
|
||||
local packer_util = require('packer.util')
|
||||
|
||||
packer.startup({
|
||||
function(use)
|
||||
-- it is recommened to put impatient.nvim before any other plugins
|
||||
use {'lewis6991/impatient.nvim', config = [[require('impatient')]]}
|
||||
@@ -30,7 +41,7 @@ require("packer").startup({
|
||||
|
||||
-- nvim-cmp completion sources
|
||||
use {"hrsh7th/cmp-nvim-lsp", after = "nvim-cmp"}
|
||||
use {"hrsh7th/cmp-nvim-lua", after = "nvim-cmp"}
|
||||
-- use {"hrsh7th/cmp-nvim-lua", after = "nvim-cmp"}
|
||||
use {"hrsh7th/cmp-path", after = "nvim-cmp"}
|
||||
use {"hrsh7th/cmp-buffer", after = "nvim-cmp"}
|
||||
use { "hrsh7th/cmp-omni", after = "nvim-cmp" }
|
||||
@@ -119,6 +130,7 @@ require("packer").startup({
|
||||
use({"sainnhe/everforest", opt = true})
|
||||
use({"EdenEast/nightfox.nvim", opt = true})
|
||||
use({"rebelot/kanagawa.nvim", opt = true})
|
||||
use({"catppuccin/nvim", as = "catppuccin", opt = true})
|
||||
|
||||
-- Show git change (change, delete, add) signs in vim sign column
|
||||
use({"mhinz/vim-signify", event = 'BufEnter'})
|
||||
@@ -136,7 +148,7 @@ require("packer").startup({
|
||||
use({ "akinsho/bufferline.nvim", event = "VimEnter", config = [[require('config.bufferline')]] })
|
||||
|
||||
-- fancy start screen
|
||||
use { 'goolord/alpha-nvim', event = 'VimEnter', config = [[require('config.alpha-nvim')]] }
|
||||
use { 'glepnir/dashboard-nvim', event = "VimEnter", config = [[require('config.dashboard-nvim')]] }
|
||||
|
||||
use({
|
||||
"lukas-reineke/indent-blankline.nvim",
|
||||
@@ -183,13 +195,7 @@ require("packer").startup({
|
||||
-- use 'mg979/vim-visual-multi'
|
||||
|
||||
-- Autosave files on certain events
|
||||
use({
|
||||
"Pocco81/AutoSave.nvim",
|
||||
event = "VimEnter",
|
||||
config = function()
|
||||
vim.defer_fn(function() require('config.autosave') end, 1500)
|
||||
end
|
||||
})
|
||||
use({"907th/vim-auto-save", event = "InsertEnter"})
|
||||
|
||||
-- Show undo history visually
|
||||
use({"simnalamburt/vim-mundo", cmd = {"MundoToggle", "MundoShow"}})
|
||||
@@ -356,14 +362,25 @@ require("packer").startup({
|
||||
requires = { 'kyazdani42/nvim-web-devicons' },
|
||||
config = [[require('config.nvim-tree')]]
|
||||
}
|
||||
|
||||
use { 'ii14/emmylua-nvim', ft = 'lua' }
|
||||
|
||||
use { 'j-hui/fidget.nvim', after = 'nvim-lspconfig', config = [[require('config.fidget-nvim')]]}
|
||||
end,
|
||||
config = {
|
||||
max_jobs = 16,
|
||||
compile_path = util.join_paths(vim.fn.stdpath('config'), 'lua', 'packer_compiled.lua'),
|
||||
compile_path = packer_util.join_paths(fn.stdpath('data'), 'site', 'lua', 'packer_compiled.lua'),
|
||||
},
|
||||
})
|
||||
|
||||
local status, _ = pcall(require, 'packer_compiled')
|
||||
if not status then
|
||||
-- For fresh install, we need to install plugins. Otherwise, we just need to require `packer_compiled.lua`.
|
||||
if fresh_install then
|
||||
-- We can command `PackerSync` here, because only after packer.startup, we can know what plugins to install.
|
||||
-- So plugin install should be done after the startup process.
|
||||
vim.cmd("PackerSync")
|
||||
else
|
||||
local status, _ = pcall(require, 'packer_compiled')
|
||||
if not status then
|
||||
vim.notify("Error requiring packer_compiled.lua: run PackerSync to fix!")
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
local fn = vim.fn
|
||||
|
||||
-- inspect something
|
||||
-- Taken from https://github.com/jamestthompson3/vimConfig/blob/eeef4a8eeb5a24938f8a0969a35f69c78643fb66/lua/tt/nvim_utils.lua#L106
|
||||
function inspect(item)
|
||||
print(vim.inspect(item))
|
||||
function _G.inspect(item)
|
||||
vim.pretty_print(item)
|
||||
end
|
||||
|
||||
local M = {}
|
||||
|
||||
function M.executable(name)
|
||||
if vim.fn.executable(name) > 0 then
|
||||
if fn.executable(name) > 0 then
|
||||
return true
|
||||
end
|
||||
|
||||
@@ -15,13 +16,20 @@ function M.executable(name)
|
||||
end
|
||||
|
||||
function M.may_create_dir()
|
||||
local fpath = vim.fn.expand('<afile>')
|
||||
local parent_dir = vim.fn.fnamemodify(fpath, ":p:h")
|
||||
local res = vim.fn.isdirectory(parent_dir)
|
||||
local fpath = fn.expand('<afile>')
|
||||
local parent_dir = fn.fnamemodify(fpath, ":p:h")
|
||||
local res = fn.isdirectory(parent_dir)
|
||||
|
||||
if res == 0 then
|
||||
vim.fn.mkdir(parent_dir, 'p')
|
||||
fn.mkdir(parent_dir, 'p')
|
||||
end
|
||||
end
|
||||
|
||||
function M.get_nvim_version()
|
||||
local actual_ver = vim.version()
|
||||
|
||||
local nvim_ver_str = string.format("%d.%d.%d", actual_ver.major, actual_ver.minor, actual_ver.patch)
|
||||
return nvim_ver_str
|
||||
end
|
||||
|
||||
return M
|
||||
|
||||
@@ -24,3 +24,7 @@ def main():
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
endsnippet
|
||||
|
||||
snippet sol "solution" b
|
||||
solution = Solution()
|
||||
endsnippet
|
||||
|
||||
@@ -8,3 +8,40 @@ call utils#Cabbrev('man', 'Man')
|
||||
|
||||
" show current date and time in human readable format
|
||||
command! -nargs=? Datetime echo utils#iso_time(<q-args>)
|
||||
|
||||
" Convert Markdown file to PDF
|
||||
command! ToPDF call s:md_to_pdf()
|
||||
|
||||
function! s:md_to_pdf() abort
|
||||
" check if pandoc is installed
|
||||
if executable('pandoc') != 1
|
||||
echoerr "pandoc not found"
|
||||
return
|
||||
endif
|
||||
|
||||
let l:md_path = expand("%:p")
|
||||
let l:pdf_path = fnamemodify(l:md_path, ":r") .. ".pdf"
|
||||
|
||||
let l:header_path = stdpath('config') . '/resources/head.tex'
|
||||
|
||||
let l:cmd = "pandoc --pdf-engine=xelatex --highlight-style=zenburn --table-of-content " .
|
||||
\ "--include-in-header=" . l:header_path . " -V fontsize=10pt -V colorlinks -V toccolor=NavyBlue " .
|
||||
\ "-V linkcolor=red -V urlcolor=teal -V filecolor=magenta -s " .
|
||||
\ l:md_path . " -o " . l:pdf_path
|
||||
|
||||
if g:is_mac
|
||||
let l:cmd = l:cmd . '&& open ' . l:pdf_path
|
||||
endif
|
||||
|
||||
if g:is_win
|
||||
let l:cmd = l:cmd . '&& start ' . l:pdf_path
|
||||
endif
|
||||
|
||||
" echomsg l:cmd
|
||||
|
||||
let l:id = jobstart(l:cmd)
|
||||
|
||||
if l:id == 0 || l:id == -1
|
||||
echoerr "Error running command"
|
||||
endif
|
||||
endfunction
|
||||
|
||||
78
resources/head.tex
Normal file
78
resources/head.tex
Normal file
@@ -0,0 +1,78 @@
|
||||
\usepackage{fancyvrb,newverbs}
|
||||
\usepackage[top=2cm, bottom=1.5cm, left=2cm, right=2cm]{geometry}
|
||||
|
||||
\PassOptionsToPackage{dvipsnames,svgnames,x11names}{xcolor}
|
||||
\usepackage{hyperref}
|
||||
|
||||
% begin a new page for each section (first level header),
|
||||
% we need to combine this with `-V subparagraph` when invoking pandc
|
||||
% \usepackage{titlesec}
|
||||
% \newcommand{\sectionbreak}{\clearpage}
|
||||
|
||||
% change background color for inline code in markdown files.
|
||||
% The following code does not work well for long text, because the text will exceed the page boundary.
|
||||
\definecolor{bgcolor}{HTML}{DADADA}
|
||||
\let\oldtexttt\texttt
|
||||
|
||||
\renewcommand{\texttt}[1]{
|
||||
\colorbox{bgcolor}{\oldtexttt{#1}}
|
||||
}
|
||||
|
||||
% change style of quote, see also https://tex.stackexchange.com/a/436253/114857
|
||||
\usepackage[most]{tcolorbox}
|
||||
|
||||
\definecolor{linequote}{RGB}{224,215,188}
|
||||
\definecolor{backquote}{RGB}{249,245,233}
|
||||
\definecolor{bordercolor}{RGB}{221,221,221}
|
||||
|
||||
% change left border: https://tex.stackexchange.com/a/475716/114857
|
||||
% change left margin: https://tex.stackexchange.com/a/457936/114857
|
||||
\newtcolorbox{myquote}[1][]{%
|
||||
enhanced,
|
||||
breakable,
|
||||
size=minimal,
|
||||
left=10pt,
|
||||
top=5pt,
|
||||
bottom=5pt,
|
||||
frame hidden,
|
||||
boxrule=0pt,
|
||||
sharp corners=all,
|
||||
colback=backquote,
|
||||
borderline west={2pt}{0pt}{bordercolor},
|
||||
#1
|
||||
}
|
||||
|
||||
% redefine quote environment to use the myquote environment, see https://tex.stackexchange.com/a/337587/114857
|
||||
\renewenvironment{quote}{\begin{myquote}}{\end{myquote}}
|
||||
|
||||
% start a new page after toc, we need to save the old command before defining
|
||||
% new one to avoid recursive command calls,
|
||||
% see https://tex.stackexchange.com/questions/47351/can-i-redefine-a-command-to-contain-itself
|
||||
\let\oldtoc\tableofcontents
|
||||
\renewcommand{\tableofcontents}{\oldtoc\newpage}
|
||||
|
||||
% fix header level issue
|
||||
\usepackage{enumitem}
|
||||
\setlistdepth{9}
|
||||
|
||||
\setlist[itemize,1]{label=$\bullet$}
|
||||
\setlist[itemize,2]{label=$\bullet$}
|
||||
\setlist[itemize,3]{label=$\bullet$}
|
||||
\setlist[itemize,4]{label=$\bullet$}
|
||||
\setlist[itemize,5]{label=$\bullet$}
|
||||
\setlist[itemize,6]{label=$\bullet$}
|
||||
\setlist[itemize,7]{label=$\bullet$}
|
||||
\setlist[itemize,8]{label=$\bullet$}
|
||||
\setlist[itemize,9]{label=$\bullet$}
|
||||
\renewlist{itemize}{itemize}{9}
|
||||
|
||||
\setlist[enumerate,1]{label=$\arabic*.$}
|
||||
\setlist[enumerate,2]{label=$\alph*.$}
|
||||
\setlist[enumerate,3]{label=$\roman*.$}
|
||||
\setlist[enumerate,4]{label=$\arabic*.$}
|
||||
\setlist[enumerate,5]{label=$\alpha*$}
|
||||
\setlist[enumerate,6]{label=$\roman*.$}
|
||||
\setlist[enumerate,7]{label=$\arabic*.$}
|
||||
\setlist[enumerate,8]{label=$\alph*.$}
|
||||
\setlist[enumerate,9]{label=$\roman*.$}
|
||||
\renewlist{enumerate}{enumerate}{9}
|
||||
@@ -415,3 +415,18 @@ src
|
||||
RGBA
|
||||
yapf
|
||||
Vimming
|
||||
overfitting
|
||||
PCA
|
||||
SVM
|
||||
KNN
|
||||
leetcode
|
||||
Logitech
|
||||
WTF
|
||||
tensorboard
|
||||
Nvidia
|
||||
GPG
|
||||
manpage
|
||||
metatable
|
||||
open3d
|
||||
pyntcloud
|
||||
param
|
||||
|
||||
Reference in New Issue
Block a user