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

51 Commits
v0.5.1 ... v0.6

Author SHA1 Message Date
jdhao
1d3552860b update nvim setup script for Linux, closes #31 2021-12-08 23:24:46 +08:00
jdhao
17a9488ba7 make impatient.nvim the first plugin 2021-12-06 21:23:59 +08:00
jdhao
683008dac0 update indent-blankline conf 2021-12-06 12:27:00 +08:00
jdhao
9ee4f46240 lazyload lua plugins 2021-12-06 12:26:44 +08:00
jdhao
7735a33a59 remove plugin gutentags
I rarely use it.
2021-12-06 11:40:45 +08:00
jdhao
aacbf56ee5 tweak lualine conf 2021-12-06 11:11:27 +08:00
jdhao
a7be6a58a4 update spell file 2021-12-05 19:51:36 +08:00
jdhao
3432dbbb63 update lualine conf 2021-12-05 16:54:29 +08:00
jdhao
c652796da1 add mixed indent detection for lualine 2021-12-05 16:18:10 +08:00
jdhao
8e46441a36 update lualine conf 2021-12-05 16:09:21 +08:00
jdhao
4d497ec8a7 update lualine conf 2021-12-05 14:59:08 +08:00
jdhao
752dbcbe2d remove mentioning of vim-airline 2021-12-05 14:33:59 +08:00
jdhao
0be331b28e replace vim-airline with lualine
Lualine is now feature-rich and faster than vim-airline.
2021-12-05 14:25:37 +08:00
jdhao
fcfd1e4437 update hop.nvim conf 2021-12-05 14:08:39 +08:00
jdhao
b9efd2b40f update fugitive conf 2021-12-05 11:21:57 +08:00
jdhao
dd61f1da8c more fugitive shortcut 2021-12-05 11:20:34 +08:00
jdhao
9e6a71c32d update cpp snippet 2021-12-04 23:47:50 +08:00
jdhao
50fafcffdb update default value of option 'wrap' 2021-12-04 23:41:56 +08:00
jdhao
b9f1d92564 use main branch of nvim-hlslens 2021-12-04 12:06:10 +08:00
jdhao
dcde6bb47f reduce startup time using impatient.nvim 2021-12-03 22:42:32 +08:00
jdhao
d04fce7bbc update Leaderf rg conf
Suppress permission denied error messages when grepping using ripgrep.
2021-12-02 22:57:41 +08:00
jdhao
39e5e1913f Add command :Datetime to show current time or translate a Unix timestamp 2021-12-02 22:06:40 +08:00
jdhao
80ceacbb02 fix vim.diagnostic.config() option name typo 2021-12-01 23:25:45 +08:00
jdhao
23e98aab6f [v0.6] update doc 2021-12-01 22:19:51 +08:00
jdhao
6069bd8922 [v0.6] update install script to use nvim v0.6 2021-12-01 22:19:03 +08:00
jdhao
402d4012d1 [v0.6] change LSP and diagnostic according to latest API 2021-12-01 22:10:24 +08:00
jdhao
22f16ee325 [v0.6] default value for option inccommand and joinspaces changed 2021-12-01 22:09:43 +08:00
jdhao
ac69b61c03 [v0.6] backupdir will be created by default
No need to create the backupdir manually.
2021-12-01 22:08:45 +08:00
jdhao
0ad051b394 [v0.6] Y is mapped to y$ by default 2021-12-01 22:07:51 +08:00
jdhao
103e051d96 use man for command :Man 2021-11-28 15:17:36 +08:00
jdhao
17995b95a4 refactor: renaming function 2021-11-23 22:55:10 +08:00
jdhao
19cf6cca3c refactor theme loading 2021-11-23 22:43:12 +08:00
jdhao
f996edf016 update LeaderF conf 2021-11-23 22:43:12 +08:00
jdhao
72d8cd07bc update nvim-notify conf 2021-11-23 22:43:12 +08:00
jdhao
1441601ddf remove plugin vim-searchlight
It can be replaced by nvim-hlslens
2021-11-23 22:43:12 +08:00
jdhao
7fe37ffd24 update linux setup script, closes #30 2021-11-23 22:42:17 +08:00
jdhao
e05c93aaeb use branch dev of nvim-hlslens
Master version has a bug where text is wrongly highlighted.
2021-11-22 23:16:25 +08:00
jdhao
5ed4e3610a update linux setup 2021-11-22 21:47:04 +08:00
jdhao
b96a3ce762 update snippets 2021-11-21 23:26:45 +08:00
jdhao
b46a1e7055 reword warning msg 2021-11-21 15:57:41 +08:00
jdhao
927a57452c update packer-related instructions 2021-11-21 15:45:34 +08:00
jdhao
af17364730 update hop.nvim conf 2021-11-17 23:19:36 +08:00
jdhao
46a465508a update snippets 2021-11-10 22:23:51 +08:00
jdhao
e0c406a344 add cpp snippets 2021-11-08 21:57:21 +08:00
jdhao
db3b0024a6 drop auto-remove trailing whitespaces
When working with legacy code which is not well formatted, it will cause
large undesirable diffs.
2021-11-07 13:32:06 +08:00
jdhao
c9535a0feb make alpah-nvim opt 2021-11-07 13:30:47 +08:00
jdhao
2a0a92f134 change location of packer_compiled.lua
Putting this file under ~/.config/nvim/plugin may cause problems since
script under plugin/ will be loaded automatically.
2021-11-07 00:26:18 +08:00
jdhao
62b6226520 fix indent-blankline activation bug
When InsertLeave is triggered, we should check if we need to start
indent-blankline before enabling it.
2021-11-06 23:10:24 +08:00
jdhao
bd92419bf9 remove lsp omnifunc conf
I never used it.
2021-11-06 20:05:54 +08:00
jdhao
6281322fce simplify lsp config 2021-11-06 20:03:21 +08:00
jdhao
538afe2fc6 update indent-blankline conf 2021-11-06 13:09:50 +08:00
21 changed files with 361 additions and 238 deletions

View File

@@ -22,7 +22,7 @@ add it to your own Nvim config.
See [doc here](docs/README.md) on how to install Nvim's dependencies, Nvim 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). itself, and how to set up on different platforms (Linux, macOS and Windows).
**This config is tested against Nvim 0.5.1 release. No backward compatibility **This config is tested against [Nvim 0.6.0 release](https://github.com/neovim/neovim/releases/tag/v0.6.0). No backward compatibility
is guaranteed.** is guaranteed.**
# Features # # Features #
@@ -37,7 +37,7 @@ is guaranteed.**
+ Smarter and faster matching pair management (add, replace or delete) via [vim-sandwich](https://github.com/machakann/vim-sandwich). + Smarter and faster matching pair management (add, replace or delete) via [vim-sandwich](https://github.com/machakann/vim-sandwich).
+ Fast buffer jump via [hop.nvim](https://github.com/phaazon/hop.nvim). + Fast buffer jump via [hop.nvim](https://github.com/phaazon/hop.nvim).
+ Ultra fast snippet insertion via [Ultisnips](https://github.com/SirVer/ultisnips). + Ultra fast snippet insertion via [Ultisnips](https://github.com/SirVer/ultisnips).
+ Beautiful status line via [vim-airline](https://github.com/vim-airline/vim-airline). + Beautiful status line via [lualine.nvim](https://github.com/nvim-lualine/lualine.nvim).
+ 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).
@@ -130,6 +130,8 @@ represents ASCII character `,`.
| `<leader>cd` | Normal | Linux/macOS/Win | Change current working directory to to the dir of current buffer | | `<leader>cd` | Normal | Linux/macOS/Win | Change current working directory to to the dir of current buffer |
| `<space>t` | Normal | Linux/macOS/Win | Toggle tag window (show project tags in the right window) | | `<space>t` | Normal | Linux/macOS/Win | Toggle tag window (show project tags in the right window) |
| `<leader>gs` | Normal | Linux/macOS/Win | Show Git status result | | `<leader>gs` | Normal | Linux/macOS/Win | Show Git status result |
| `<leader>gw` | Normal | Linux/macOS/Win | Run Git add for current file |
| `<leader>gd` | Normal | Linux/macOS/Win | Run git diff for current file |
| `<leader>gc` | Normal | Linux/macOS/Win | Run git commit | | `<leader>gc` | Normal | Linux/macOS/Win | Run git commit |
| `<F9>` | Normal | Linux/macOS/Win | Run current source file (for Python, C++) | | `<F9>` | Normal | Linux/macOS/Win | Run current source file (for Python, C++) |
| `<F11>` | Normal | Linux/macOS/Win | Toggle spell checking | | `<F11>` | Normal | Linux/macOS/Win | Toggle spell checking |

View File

@@ -1,6 +1,8 @@
set concealcursor=c set concealcursor=c
set synmaxcol=3000 " For long Chinese paragraphs set synmaxcol=3000 " For long Chinese paragraphs
set wrap
" Fix minor issue with footnote, see https://github.com/vim-pandoc/vim-markdownfootnotes/issues/22 " Fix minor issue with footnote, see https://github.com/vim-pandoc/vim-markdownfootnotes/issues/22
if exists(':FootnoteNumber') if exists(':FootnoteNumber')
nnoremap <buffer><silent> ^^ :<C-U>call markdownfootnotes#VimFootnotes('i')<CR> nnoremap <buffer><silent> ^^ :<C-U>call markdownfootnotes#VimFootnotes('i')<CR>

View File

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

View File

@@ -27,12 +27,6 @@ function! utils#HasColorscheme(name) abort
return !empty(globpath(&runtimepath, l:pat)) return !empty(globpath(&runtimepath, l:pat))
endfunction endfunction
" Check if an Airline theme exists in runtimepath.
function! utils#HasAirlinetheme(name) abort
let l:pat = printf('autoload/airline/themes/%s.vim', a:name)
return !empty(globpath(&runtimepath, l:pat))
endfunction
" Generate random integers in the range [Low, High] in pure vim script, " Generate random integers in the range [Low, High] in pure vim script,
" adapted from https://stackoverflow.com/a/12739441/6064933 " adapted from https://stackoverflow.com/a/12739441/6064933
function! utils#RandInt(Low, High) abort function! utils#RandInt(Low, High) abort
@@ -145,8 +139,12 @@ function! utils#Get_titlestr() abort
return l:title_str return l:title_str
endfunction endfunction
" Output current time in ISO format. " Output current time or unix timestamp in human-readable format.
function! utils#iso_time() abort function! utils#iso_time(timestamp) abort
if a:timestamp
return strftime('%Y-%m-%d %H:%M:%S%z', a:timestamp)
endif
return strftime('%Y-%m-%d %H:%M:%S%z') return strftime('%Y-%m-%d %H:%M:%S%z')
endfunction endfunction
@@ -193,3 +191,14 @@ function! utils#MultiEdit(patterns) abort
endfor endfor
endfor endfor
endfunction endfunction
function! utils#add_pack(name) abort
let l:success = v:true
try
execute printf("packadd! %s", a:name)
catch /^Vim\%((\a\+)\)\=:E919/
let l:success = v:false
endtry
return l:success
endfunction

View File

@@ -103,9 +103,3 @@ augroup packer_auto_compile
autocmd! autocmd!
autocmd BufWritePost */nvim/lua/plugins.lua source <afile> | PackerCompile autocmd BufWritePost */nvim/lua/plugins.lua source <afile> | PackerCompile
augroup END augroup END
" Remove trailing whitespaces
augroup strip_trailing_space
autocmd!
autocmd BufWritePre,TextChanged * StripTrailingWhitespace
augroup END

View File

@@ -53,10 +53,6 @@ nnoremap <expr> <Space>O printf('m`%sO<ESC>``', v:count1)
" Insert a space after current character " Insert a space after current character
nnoremap <Space><Space> a<Space><ESC>h nnoremap <Space><Space> a<Space><ESC>h
" Yank from current cursor position to the end of the line (make it
" consistent with the behavior of D, C)
nnoremap Y y$
" Move the cursor based on physical lines, not the actual lines. " Move the cursor based on physical lines, not the actual lines.
nnoremap <expr> j (v:count == 0 ? 'gj' : 'j') nnoremap <expr> j (v:count == 0 ? 'gj' : 'j')
nnoremap <expr> k (v:count == 0 ? 'gk' : 'k') nnoremap <expr> k (v:count == 0 ? 'gk' : 'k')

View File

@@ -35,10 +35,7 @@ set wildignore+=*.aux,*.bbl,*.blg,*.brf,*.fls,*.fdb_latexmk,*.synctex.gz,*.xdv
set wildignorecase " ignore file and dir name cases in cmd-completion set wildignorecase " ignore file and dir name cases in cmd-completion
" Set up backup directory " Set up backup directory
let g:backupdir=expand(stdpath('data') . '/backup') let g:backupdir=expand(stdpath('data') . '/backup//')
if !isdirectory(g:backupdir)
call mkdir(g:backupdir, 'p')
endif
let &backupdir=g:backupdir let &backupdir=g:backupdir
" Skip backup for patterns in option wildignore " Skip backup for patterns in option wildignore
@@ -79,13 +76,11 @@ set scrolloff=3
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
" Do not show mode on command line since vim-airline can show it " Disable showing current mode on command line since statusline plugins can show it.
set noshowmode set noshowmode
set fileformats=unix,dos " Fileformats to use for new files set fileformats=unix,dos " Fileformats to use for new files
set inccommand=nosplit " Show the result of substitution in real time for preview
" Ask for confirmation when handling unsaved or read-only files " Ask for confirmation when handling unsaved or read-only files
set confirm set confirm
@@ -146,10 +141,6 @@ 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
" Do not add two spaces after a period when joining lines or formatting texts,
" see https://stackoverflow.com/q/4760428/6064933
set nojoinspaces
set synmaxcol=200 " Text after this column number is not highlighted set synmaxcol=200 " Text after this column number is not highlighted
set nostartofline set nostartofline
@@ -181,3 +172,5 @@ 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 nowrap " do no wrap

View File

@@ -84,6 +84,12 @@ let g:Lf_PopupPosition = [0, float2nr((&columns - g:Lf_PopupWidth)/2)]
" submodules are not searched by default. " submodules are not searched by default.
let g:Lf_UseVersionControlTool = 0 let g:Lf_UseVersionControlTool = 0
" Use rg as the default search tool
let g:Lf_DefaultExternalTool = "rg"
" show dot files
let g:Lf_ShowHidden = 1
" Disable default mapping " Disable default mapping
let g:Lf_ShortcutF = '' let g:Lf_ShortcutF = ''
let g:Lf_ShortcutB = '' let g:Lf_ShortcutB = ''
@@ -95,7 +101,7 @@ let g:Lf_WorkingDirectoryMode = 'a'
nnoremap <silent> <leader>ff :<C-U>Leaderf file --popup<CR> nnoremap <silent> <leader>ff :<C-U>Leaderf file --popup<CR>
" Grep project files in popup window " Grep project files in popup window
nnoremap <silent> <leader>fg :<C-U>Leaderf rg --popup<CR> nnoremap <silent> <leader>fg :<C-U>Leaderf rg --no-messages --popup<CR>
" Search vim help files " Search vim help files
nnoremap <silent> <leader>fh :<C-U>Leaderf help --popup<CR> nnoremap <silent> <leader>fh :<C-U>Leaderf help --popup<CR>
@@ -127,14 +133,6 @@ if g:is_win || g:is_mac
xmap ob <Plug>(openbrowser-smart-search) xmap ob <Plug>(openbrowser-smart-search)
endif endif
""""""""""""""""""""""""""" gutentags settings """"""""""""""""""""""""""""""
" The path to store tags files, instead of in the project root.
let g:gutentags_cache_dir = stdpath('cache') . '/ctags'
let g:gutentags_ctags_extra_args = ['--fields=+niazS', '--extra=+q']
let g:gutentags_ctags_extra_args += ['--c++-kinds=+px']
let g:gutentags_ctags_extra_args += ['--c-kinds=+px']
let g:gutentags_ctags_exclude = ['*.md', '*.html', '*.json', '*.toml', '*.css', '*.js',]
""""""""""""""""""""""""""" vista settings """""""""""""""""""""""""""""""""" """"""""""""""""""""""""""" vista settings """"""""""""""""""""""""""""""""""
let g:vista#renderer#icons = { let g:vista#renderer#icons = {
\ 'member': '', \ 'member': '',
@@ -209,9 +207,10 @@ let g:signify_sign_change = '~'
nnoremap <silent> <leader>gs :Git<CR> nnoremap <silent> <leader>gs :Git<CR>
nnoremap <silent> <leader>gw :Gwrite<CR> nnoremap <silent> <leader>gw :Gwrite<CR>
nnoremap <silent> <leader>gc :Git commit<CR> nnoremap <silent> <leader>gc :Git commit<CR>
nnoremap <silent> <leader>gd :Gdiffsplit<CR>
nnoremap <silent> <leader>gpl :Git pull<CR> nnoremap <silent> <leader>gpl :Git pull<CR>
" Note that to use bar literally, we need backslash it, see also `:h :bar`. " Note that to use bar literally, we need backslash it, see also `:h :bar`.
nnoremap <silent> <leader>gpu :15split \| term git push nnoremap <silent> <leader>gpu :15split \| term git push<CR>
"""""""""""""""""""""""""plasticboy/vim-markdown settings""""""""""""""""""" """""""""""""""""""""""""plasticboy/vim-markdown settings"""""""""""""""""""
" Disable header folding " Disable header folding
@@ -336,58 +335,6 @@ if ( g:is_win || g:is_mac ) && executable('latex')
endif endif
endif endif
"""""""""""""""""""""""""""vim-airline setting""""""""""""""""""""""""""""""
" Set airline theme to a random one if it exists
let s:candidate_airlinetheme = ['ayu_mirage', 'lucius', 'ayu_dark', 'base16_bright',
\ 'base16_adwaita', 'raven', 'term', 'deus', 'onedark']
let g:airline_theme = utils#RandElement(s:candidate_airlinetheme)
" Whether to show function or other tags on status line
let g:airline#extensions#vista#enabled = 0
let g:airline#extensions#gutentags#enabled = 1
" Do not show search index in statusline since it is shown on command line
let g:airline#extensions#anzu#enabled = 0
" Enable vim-airline extension for nvim-lsp
let g:airline#extensions#nvimlsp#enabled = 1
let g:airline#extensions#searchcount#enabled = 0
" Skip empty sections if there are nothing to show,
" extracted from https://vi.stackexchange.com/a/9637/15292
let g:airline_skip_empty_sections = 1
" Whether to use powerline symbols, see https://vi.stackexchange.com/q/3359/15292
let g:airline_powerline_fonts = 0
if !exists('g:airline_symbols')
let g:airline_symbols = {}
endif
let g:airline_symbols.paste = 'ρ'
let g:airline_symbols.linenr = " L:"
let g:airline_symbols.colnr = " C:"
if !g:is_linux
let g:airline_symbols.branch = ''
let g:airline_symbols.spell = 'Ꞩ'
endif
" Custom branch name
let g:airline#extensions#branch#custom_head = 'utils#GetGitBranch'
" Only show git hunks which are non-zero
let g:airline#extensions#hunks#non_zero_only = 1
" Speed up airline
let g:airline_highlighting_cache = 1
" The keys in the following shortcode are the layout when we use a specific
" input method mode. On my macOS, 0 means that we are trying to input Chinese,
" and 1 means we are using English mode.
" See also https://github.com/vim-airline/vim-airline/blob/master/autoload/airline/extensions/xkblayout.vim#L11
let g:airline#extensions#xkblayout#short_codes = {'0': 'CN', '1': 'US'}
""""""""""""""""""""""""""""vim-startify settings"""""""""""""""""""""""""""" """"""""""""""""""""""""""""vim-startify settings""""""""""""""""""""""""""""
" Do not change working directory when opening files. " Do not change working directory when opening files.
let g:startify_change_to_dir = 0 let g:startify_change_to_dir = 0
@@ -493,6 +440,6 @@ 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 :PackerInstall to install all plugins."|echohl None echohl Error |echomsg "Wilder.nvim missing: run :PackerSync to fix."|echohl None
endtry endtry
endfunction endfunction

View File

@@ -1,8 +1,6 @@
let s:my_theme_dict = {} let s:theme_setup_dict = {}
function! s:my_theme_dict.gruvbox8() dict abort
packadd! vim-gruvbox8
function! s:theme_setup_dict.gruvbox8() dict abort
" Italic options should be put before colorscheme setting, " Italic options should be put before colorscheme setting,
" see https://github.com/morhetz/gruvbox/wiki/Terminal-specific#1-italics-is-disabled " see https://github.com/morhetz/gruvbox/wiki/Terminal-specific#1-italics-is-disabled
let g:gruvbox_italics=1 let g:gruvbox_italics=1
@@ -12,83 +10,77 @@ function! s:my_theme_dict.gruvbox8() dict abort
colorscheme gruvbox8_hard colorscheme gruvbox8_hard
endfunction endfunction
function! s:my_theme_dict.onedark() dict abort function! s:theme_setup_dict.onedark() dict abort
packadd! onedark.nvim
colorscheme onedark colorscheme onedark
endfunction endfunction
function! s:my_theme_dict.edge() dict abort function! s:theme_setup_dict.edge() dict abort
packadd! edge
let g:edge_enable_italic = 1 let g:edge_enable_italic = 1
let g:edge_better_performance = 1 let g:edge_better_performance = 1
colorscheme edge colorscheme edge
endfunction endfunction
function! s:my_theme_dict.sonokai() dict abort function! s:theme_setup_dict.sonokai() dict abort
packadd! sonokai
let g:sonokai_enable_italic = 1 let g:sonokai_enable_italic = 1
let g:sonokai_better_performance = 1 let g:sonokai_better_performance = 1
colorscheme sonokai colorscheme sonokai
endfunction endfunction
function! s:my_theme_dict.gruvbox_material() dict abort function! s:theme_setup_dict.gruvbox_material() dict abort
packadd! gruvbox-material
let g:gruvbox_material_enable_italic = 1 let g:gruvbox_material_enable_italic = 1
let g:gruvbox_material_better_performance = 1 let g:gruvbox_material_better_performance = 1
colorscheme gruvbox-material colorscheme gruvbox-material
endfunction endfunction
function! s:my_theme_dict.nord() dict abort function! s:theme_setup_dict.nord() dict abort
packadd! nord.nvim
colorscheme nord colorscheme nord
endfunction endfunction
function! s:my_theme_dict.doom_one() dict abort function! s:theme_setup_dict.doom_one() dict abort
packadd! doom-one.nvim
colorscheme doom-one colorscheme doom-one
endfunction endfunction
function! s:my_theme_dict.everforest() dict abort function! s:theme_setup_dict.everforest() dict abort
packadd! everforest
let g:everforest_enable_italic = 1 let g:everforest_enable_italic = 1
let g:everforest_better_performance = 1 let g:everforest_better_performance = 1
colorscheme everforest colorscheme everforest
endfunction endfunction
function! s:my_theme_dict.nightfox() dict abort function! s:theme_setup_dict.nightfox() dict abort
packadd! nightfox.nvim
colorscheme nordfox colorscheme nordfox
endfunction endfunction
let s:candidate_theme = [ " Theme to directory name mapping, because theme repo name is not necessarily
\ 'gruvbox8', " the same as the theme name itself.
\ 'onedark', let s:theme2dir = {
\ 'edge', \ 'gruvbox8' : 'vim-gruvbox8',
\ 'sonokai', \ 'onedark': 'onedark.nvim',
\ 'gruvbox_material', \ 'edge' : 'edge',
\ 'nord', \ 'sonokai': 'sonokai',
\ 'doom_one', \ 'gruvbox_material': 'gruvbox-material',
\ 'everforest', \ 'nord': 'nord.nvim',
\ 'nightfox' \ 'doom_one': 'doom-one.nvim',
\ ] \ 'everforest' :'everforest',
\ 'nightfox': 'nightfox.nvim'
\ }
let s:theme = utils#RandElement(s:candidate_theme) let s:theme = utils#RandElement(keys(s:theme2dir))
let s:colorscheme_func = printf('s:my_theme_dict.%s()', s:theme) let s:colorscheme_func = printf('s:theme_setup_dict.%s()', s:theme)
if has_key(s:my_theme_dict, s:theme) if !has_key(s:theme_setup_dict, s:theme)
execute 'call ' . s:colorscheme_func
if g:logging_level == 'debug'
let s:msg1 = "Currently loaded theme: " . s:theme
call v:lua.vim.notify(s:msg1, 'info', {'title': 'nvim-config'})
endif
else
let s:msg = "Invalid colorscheme function: " . s:colorscheme_func let s:msg = "Invalid colorscheme function: " . s:colorscheme_func
call v:lua.vim.notify(s:msg, 'error', {'title': 'nvim-config'}) call v:lua.vim.notify(s:msg, 'error', {'title': 'nvim-config'})
finish
endif
let s:res = utils#add_pack(s:theme2dir[s:theme])
if !s:res
echomsg printf("Theme %s not installed. Run PackerSync to install.", s:theme)
finish
endif
execute 'call ' . s:colorscheme_func
if g:logging_level == 'debug'
let s:msg1 = "Currently loaded theme: " . s:theme
call v:lua.vim.notify(s:msg1, 'info', {'title': 'nvim-config'})
endif endif

View File

@@ -78,7 +78,7 @@ and make sure you can call `git` from the command line.
## ctags ## ctags
In order to use tags related plugins such as [vista.vim](https://github.com/liuchengxu/vista.vim) and [gutentags](https://github.com/ludovicchabant/vim-gutentags), we need to 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. install a ctags distribution. Universal-ctags is preferred.
To install ctags on macOS, use [Homebrew](https://github.com/universal-ctags/homebrew-universal-ctags): To install ctags on macOS, use [Homebrew](https://github.com/universal-ctags/homebrew-universal-ctags):
@@ -136,19 +136,17 @@ Terminal](https://github.com/microsoft/terminal).
## Font ## Font
Since [Vim-airline](https://github.com/vim-airline/vim-airline) uses several Since statusline or file explorer plugins often use Unicode symbols not
Unicode symbols not available in normal font, we need to install [fonts available in normal font, we need to install a patched font from the [nerd-fonts](https://github.com/ryanoasis/nerd-fonts) project.
here](https://github.com/powerline/fonts) to make vim-airline look pretty. I am using [Hack](https://github.com/powerline/fonts/tree/master/Hack), and it looks
great. Another great resource for programming font is the [nerd-font](https://github.com/ryanoasis/nerd-fonts) project.
# Install Nvim # Install Nvim
There are various ways to install Nvim depending on your system. Current There are various ways to install Nvim depending on your system. Current
configuration is tested against nvim 0.5. configuration is tested against nvim v0.6.0.
## Linux ## Linux
We can directly download the binary release from [here](https://github.com/neovim/neovim/releases/download/v0.5.1/nvim-linux64.tar.gz). We can directly download the binary release from [here](https://github.com/neovim/neovim/releases/download/v0.6.0/nvim-linux64.tar.gz).
## Windows ## Windows
@@ -158,7 +156,7 @@ The easiest way to install Nvim on Windows is via chocolatey:
choco install neovim choco install neovim
``` ```
You may download from [nvim release](https://github.com/neovim/neovim/releases/download/v0.5.1/nvim-win64.zip) from GitHub and manually extract it. You may download from [nvim release](https://github.com/neovim/neovim/releases/download/v0.6.0/nvim-win64.zip) from GitHub and manually extract it.
## macOS ## macOS
@@ -205,9 +203,10 @@ directory, and run the following command to install this configuration:
git clone --depth=1 https://github.com/jdhao/nvim-config.git . git clone --depth=1 https://github.com/jdhao/nvim-config.git .
``` ```
After that, when we first open nvim, run command `:PackerInstall` to install After that, when we first open nvim, run command `:PackerSync` to install all
all the plugins. Since I use quite a lot of plugins (more than 60), it may take the plugins and generate `packer_compiled.lua`. Since I use quite a lot of
some time to install all of them, depending on your network condition. plugins (more than 60), it may take some time to install all of them, depending
on your network condition.
# Automatic installation # Automatic installation

View File

@@ -2,7 +2,7 @@
#!/bin/bash #!/bin/bash
set -eux set -eux
wget https://hub.fastgit.org/neovim/neovim/releases/download/nightly/nvim-macos.tar.gz wget https://github.com/neovim/neovim/releases/download/v0.6.0/nvim-macos.tar.gz
if [[ ! -d "$HOME/tools/" ]]; then if [[ ! -d "$HOME/tools/" ]]; then
mkdir -p "$HOME/tools" mkdir -p "$HOME/tools"

View File

@@ -140,6 +140,17 @@ if [[ -z "$(command -v rg)" ]] && [[ ! -f "$RIPGREP_DIR/rg" ]]; then
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=\"$RIPGREP_DIR:\$PATH\"" >> "$HOME/.bash_profile" echo "export PATH=\"$RIPGREP_DIR:\$PATH\"" >> "$HOME/.bash_profile"
fi 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
if [[ "$USE_BASH_SHELL" = true ]]; then
echo 'export MANPATH=$HOME/tools/ripgrep/doc/man:$MANPATH' >> "$HOME/.bash_profile"
else
echo 'export MANPATH=$HOME/tools/ripgrep/doc/man:$MANPATH' >> "$HOME/.zshrc"
echo 'export FPATH=$HOME/tools/ripgrep/complete:$FPATH' >> "$HOME/.zshrc"
fi
else else
echo "ripgrep is already installed. Skip installing it." echo "ripgrep is already installed. Skip installing it."
fi fi
@@ -177,7 +188,7 @@ fi
NVIM_DIR=$HOME/tools/nvim NVIM_DIR=$HOME/tools/nvim
NVIM_SRC_NAME=$HOME/packages/nvim-linux64.tar.gz NVIM_SRC_NAME=$HOME/packages/nvim-linux64.tar.gz
NVIM_CONFIG_DIR=$HOME/.config/nvim NVIM_CONFIG_DIR=$HOME/.config/nvim
NVIM_LINK="https://hub.fastgit.org/neovim/neovim/releases/download/nightly/nvim-linux64.tar.gz" NVIM_LINK="https://github.com/neovim/neovim/releases/download/v0.6.0/nvim-linux64.tar.gz"
if [[ ! -f "$NVIM_DIR/bin/nvim" ]]; then if [[ ! -f "$NVIM_DIR/bin/nvim" ]]; then
echo "Installing Nvim" echo "Installing Nvim"
echo "Creating nvim directory under tools directory" echo "Creating nvim directory under tools directory"
@@ -209,9 +220,9 @@ git clone --depth=1 https://hub.fastgit.org/jdhao/nvim-config.git "$NVIM_CONFIG_
echo "Installing packer.nvim" echo "Installing packer.nvim"
git clone --depth=1 https://hub.fastgit.org/wbthomason/packer.nvim \ git clone --depth=1 https://hub.fastgit.org/wbthomason/packer.nvim \
~/.local/share/nvim/site/pack/packer/start/packer.nvim ~/.local/share/nvim/site/pack/packer/opt/packer.nvim
echo "Installing plugins" echo "Installing nvim plugins, please wait"
"$NVIM_DIR/bin/nvim" +PackerInstall +qall "$NVIM_DIR/bin/nvim" -c "autocmd User PackerComplete quitall" -c "PackerSync"
echo "Finished installing Nvim and its dependencies!" echo "Finished installing Nvim and its dependencies!"

View File

@@ -1,16 +1,23 @@
require("indent_blankline").setup { require("indent_blankline").setup({
-- U+2502 may also be a good choice, it will be on the middle of cursor. -- U+2502 may also be a good choice, it will be on the middle of cursor.
-- U+250A is also a good choice
char = "", char = "",
show_end_of_line = false, show_end_of_line = false,
disable_with_nolist = true, disable_with_nolist = true,
buftype_exclude = {"terminal"}, buftype_exclude = { "terminal" },
filetype_exclude = { "help", "git", "markdown", "snippets", "text" }, filetype_exclude = { "help", "git", "markdown", "snippets", "text", "gitconfig", "alpha" },
} })
vim.cmd([[
function! Should_activate_indentblankline() abort
if index(g:indent_blankline_filetype_exclude, &filetype) == -1
IndentBlanklineEnable
endif
endfunction
vim.cmd[[
augroup indent_blankline augroup indent_blankline
autocmd! autocmd!
autocmd InsertEnter * IndentBlanklineDisable autocmd InsertEnter * IndentBlanklineDisable
autocmd InsertLeave * IndentBlanklineEnable autocmd InsertLeave * call Should_activate_indentblankline()
augroup END augroup END
]] ]])

View File

@@ -1,23 +1,23 @@
local api = vim.api
local lsp = vim.lsp
local M = {} local M = {}
function M.show_line_diagnostics() function M.show_line_diagnostics()
local opts = { local opts = {
focusable = false, focusable = false,
close_events = { "BufLeave", "CursorMoved", "InsertEnter", "FocusLost" }, close_events = { "BufLeave", "CursorMoved", "InsertEnter", "FocusLost" },
border = 'single' border = 'rounded',
source = 'always', -- show source in diagnostic popup window
prefix = ' '
} }
vim.lsp.diagnostic.show_line_diagnostics(opts) vim.diagnostic.open_float(nil, opts)
end end
local custom_attach = function(client, bufnr) local custom_attach = function(client, bufnr)
local function buf_set_keymap(...) local function buf_set_keymap(...)
vim.api.nvim_buf_set_keymap(bufnr, ...) api.nvim_buf_set_keymap(bufnr, ...)
end end
local function buf_set_option(...)
vim.api.nvim_buf_set_option(bufnr, ...)
end
buf_set_option("omnifunc", "v:lua.vim.lsp.omnifunc")
-- Mappings. -- Mappings.
local opts = { noremap = true, silent = true } local opts = { noremap = true, silent = true }
@@ -30,9 +30,9 @@ local custom_attach = function(client, bufnr)
buf_set_keymap("n", "<space>wl", "<cmd>lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<CR>", opts) buf_set_keymap("n", "<space>wl", "<cmd>lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<CR>", opts)
buf_set_keymap("n", "<space>rn", "<cmd>lua vim.lsp.buf.rename()<CR>", opts) buf_set_keymap("n", "<space>rn", "<cmd>lua vim.lsp.buf.rename()<CR>", opts)
buf_set_keymap("n", "gr", "<cmd>lua vim.lsp.buf.references()<CR>", opts) buf_set_keymap("n", "gr", "<cmd>lua vim.lsp.buf.references()<CR>", opts)
buf_set_keymap("n", "[d", "<cmd>lua vim.lsp.diagnostic.goto_prev()<CR>", opts) buf_set_keymap("n", "[d", "<cmd>lua vim.diagnostic.goto_prev()<CR>", opts)
buf_set_keymap("n", "]d", "<cmd>lua vim.lsp.diagnostic.goto_next()<CR>", opts) buf_set_keymap("n", "]d", "<cmd>lua vim.diagnostic.goto_next()<CR>", opts)
buf_set_keymap("n", "<space>q", "<cmd>lua vim.lsp.diagnostic.set_loclist()<CR>", opts) buf_set_keymap("n", "<space>q", "<cmd>lua vim.diagnostic.setqflist({open = true})<CR>", opts)
buf_set_keymap("n", "<space>ca", "<cmd>lua vim.lsp.buf.code_action()<CR>", opts) buf_set_keymap("n", "<space>ca", "<cmd>lua vim.lsp.buf.code_action()<CR>", opts)
vim.cmd([[ vim.cmd([[
@@ -41,7 +41,7 @@ local custom_attach = function(client, bufnr)
-- Set some key bindings conditional on server capabilities -- Set some key bindings conditional on server capabilities
if client.resolved_capabilities.document_formatting then if client.resolved_capabilities.document_formatting then
buf_set_keymap("n", "<space>f", "<cmd>lua vim.lsp.buf.formatting()<CR>", opts) buf_set_keymap("n", "<space>f", "<cmd>lua vim.lsp.buf.formatting_sync()<CR>", opts)
end end
if client.resolved_capabilities.document_range_formatting then if client.resolved_capabilities.document_range_formatting then
buf_set_keymap("x", "<space>f", "<cmd>lua vim.lsp.buf.range_formatting()<CR><ESC>", opts) buf_set_keymap("x", "<space>f", "<cmd>lua vim.lsp.buf.range_formatting()<CR><ESC>", opts)
@@ -67,7 +67,7 @@ local custom_attach = function(client, bufnr)
end end
end end
local capabilities = require('cmp_nvim_lsp').update_capabilities(vim.lsp.protocol.make_client_capabilities()) local capabilities = require('cmp_nvim_lsp').update_capabilities(lsp.protocol.make_client_capabilities())
capabilities.textDocument.completion.completionItem.snippetSupport = true capabilities.textDocument.completion.completionItem.snippetSupport = true
local lspconfig = require("lspconfig") local lspconfig = require("lspconfig")
@@ -140,7 +140,7 @@ if vim.g.is_mac or vim.g.is_linux and sumneko_binary_path ~= "" then
}, },
workspace = { workspace = {
-- Make the server aware of Neovim runtime files -- Make the server aware of Neovim runtime files
library = vim.api.nvim_get_runtime_file("", true), library = api.nvim_get_runtime_file("", true),
}, },
-- Do not send telemetry data containing a randomized but unique identifier -- Do not send telemetry data containing a randomized but unique identifier
telemetry = { telemetry = {
@@ -153,53 +153,28 @@ if vim.g.is_mac or vim.g.is_linux and sumneko_binary_path ~= "" then
end end
-- Change diagnostic signs. -- Change diagnostic signs.
vim.fn.sign_define("LspDiagnosticsSignError", { text = "", texthl = "LspDiagnosticsDefaultError" }) vim.fn.sign_define("DiagnosticSignError", { text = "", texthl = "DiagnosticSignError" })
vim.fn.sign_define("LspDiagnosticsSignWarning", { text = "!", texthl = "LspDiagnosticsDefaultWarning" }) vim.fn.sign_define("DiagnosticSignWarn", { text = "!", texthl = "DiagnosticSignWarn" })
vim.fn.sign_define("LspDiagnosticsSignInformation", { text = "", texthl = "LspDiagnosticsDefaultInformation" }) vim.fn.sign_define("DiagnosticSignInformation", { text = "", texthl = "DiagnosticSignInfo" })
vim.fn.sign_define("LspDiagnosticsSignHint", { text = "", texthl = "LspDiagnosticsDefaultHint" }) vim.fn.sign_define("DiagnosticSignHint", { text = "", texthl = "DiagnosticSignHint" })
vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with(vim.lsp.diagnostic.on_publish_diagnostics, { -- global config for diagnostic
vim.diagnostic.config({
underline = false, underline = false,
virtual_text = false, virtual_text = false,
signs = true, signs = true,
update_in_insert = false, severity_sort = true,
}) })
-- Refs: https://github.com/neovim/nvim-lspconfig/wiki/UI-customization#show-source-in-diagnostics -- lsp.handlers["textDocument/publishDiagnostics"] = lsp.with(lsp.diagnostic.on_publish_diagnostics, {
vim.lsp.handlers["textDocument/publishDiagnostics"] = function(_, result, context, _) -- underline = false,
-- result contains diagnostics and uri -- virtual_text = false,
-- context contains client_id and method, but not always buf_nr -- signs = true,
local client_id = context.client_id -- update_in_insert = false,
local diagnostics = result.diagnostics -- })
local uri = result.uri
local bufnr = vim.uri_to_bufnr(uri) -- Change border of documentation hover window, See https://github.com/neovim/neovim/pull/13998.
if not bufnr then lsp.handlers["textDocument/hover"] = lsp.with(vim.lsp.handlers.hover, {
return
end
if not vim.api.nvim_buf_is_loaded(bufnr) then
return
end
-- change diagnostics format
for i, v in ipairs(diagnostics) do
diagnostics[i].message = string.format("%s: %s", v.source, v.message)
end
vim.lsp.diagnostic.save(diagnostics, bufnr, client_id)
local config = {
underline = false,
virtual_text = false,
signs = true,
update_in_insert = false,
}
vim.lsp.diagnostic.display(diagnostics, bufnr, client_id, config)
end
-- The following settings works with the bleeding edge neovim.
-- See https://github.com/neovim/neovim/pull/13998.
vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, {
border = "rounded", border = "rounded",
}) })

View File

@@ -4,6 +4,7 @@ nvim_notify.setup({
stages = "fade_in_slide_out", stages = "fade_in_slide_out",
-- Default timeout for notifications -- Default timeout for notifications
timeout = 1500, timeout = 1500,
background_colour = "#2E3440",
}) })
vim.notify = nvim_notify vim.notify = nvim_notify

View File

@@ -1,6 +1,10 @@
vim.cmd[[ hi HopNextKey cterm=bold ctermfg=176 gui=bold guibg=#ff00ff guifg=#ffffff ]] vim.cmd[[ hi HopNextKey cterm=bold ctermfg=176 gui=bold guibg=#ff00ff guifg=#ffffff ]]
vim.cmd[[ hi HopNextKey1 cterm=bold ctermfg=176 gui=bold guibg=#ff00ff guifg=#ffffff ]]
vim.cmd[[ hi HopNextKey2 cterm=bold ctermfg=176 gui=bold guibg=#ff00ff guifg=#ffffff ]]
require('hop').setup({ require('hop').setup({
case_insensitive = true, case_insensitive = true,
char2_fallback_key = '<CR>',
}) })
vim.api.nvim_set_keymap('n', 'f', "<cmd>lua require'hop'.hint_char2()<cr>", {noremap = true}) vim.api.nvim_set_keymap('n', 'f', "<cmd>lua require'hop'.hint_char2()<cr>", {noremap = true})

108
lua/config/statusline.lua Normal file
View File

@@ -0,0 +1,108 @@
local function spell()
if vim.o.spell then
return string.format("[SPELL]")
end
return ""
end
local function trailing_space()
-- Get the positions of trailing whitespaces from plugin 'jdhao/whitespace.nvim'.
local trailing_space_pos = vim.b.trailing_whitespace_pos
local msg = ""
if #trailing_space_pos > 0 then
-- Note that lua index is 1-based, not zero based!!!
local line = trailing_space_pos[1][1]
msg = string.format("[%d]trailing", line)
end
return msg
end
local function mixed_indent()
local space_pat = [[\v^ +]]
local tab_pat = [[\v^\t+]]
local space_indent = vim.fn.search(space_pat, 'nwc')
local tab_indent = vim.fn.search(tab_pat, 'nwc')
local mixed = (space_indent > 0 and tab_indent > 0)
local mixed_same_line
if not mixed then
mixed_same_line = vim.fn.search([[\v^(\t+ | +\t)]], 'nwc')
mixed = mixed_same_line > 0
end
if not mixed then return '' end
if mixed_same_line ~= nil and mixed_same_line > 0 then
return 'MI:'..mixed_same_line
end
local space_indent_cnt = vim.fn.searchcount({pattern=space_pat, max_count=1e3}).total
local tab_indent_cnt = vim.fn.searchcount({pattern=tab_pat, max_count=1e3}).total
if space_indent_cnt > tab_indent_cnt then
return 'MI:'..tab_indent
else
return 'MI:'..space_indent
end
end
require("lualine").setup({
options = {
icons_enabled = true,
theme = "auto",
-- component_separators = { left = "", right = "" },
-- section_separators = { left = "", right = "" },
section_separators = "",
component_separators = "",
disabled_filetypes = {},
always_divide_middle = true,
},
sections = {
lualine_a = { "mode" },
lualine_b = { "branch", "diff" },
lualine_c = {
{
spell,
color = {fg = 'black', bg = '#a7c080'}
},
"filename"
},
lualine_x = {
"encoding",
{
"fileformat",
symbols = {
unix = "unix",
dos = "win",
mac = "mac",
},
},
"filetype",
},
lualine_y = { "progress" },
lualine_z = {
"location",
{
"diagnostics",
sources = { "nvim_lsp" }
},
{
trailing_space,
color = "WarningMsg"
},
{
mixed_indent,
color = "WarningMsg"
},
},
},
inactive_sections = {
lualine_a = {},
lualine_b = {},
lualine_c = { "filename" },
lualine_x = { "location" },
lualine_y = {},
lualine_z = {},
},
tabline = {},
extensions = {'quickfix', 'fugitive'},
})

View File

@@ -22,9 +22,13 @@ end
-- Load packer.nvim -- Load packer.nvim
vim.cmd("packadd packer.nvim") vim.cmd("packadd packer.nvim")
local util = require('packer.util')
require("packer").startup({ require("packer").startup({
function(use) function(use)
-- it is recommened to put impatient.nvim before any other plugins
use {'lewis6991/impatient.nvim', config = [[require('impatient')]]}
use({"wbthomason/packer.nvim", opt = true}) use({"wbthomason/packer.nvim", opt = true})
use {"onsails/lspkind-nvim", event = "BufEnter"} use {"onsails/lspkind-nvim", event = "BufEnter"}
@@ -70,16 +74,19 @@ require("packer").startup({
end end
-- Super fast buffer jump -- Super fast buffer jump
use { 'phaazon/hop.nvim', event = "VimEnter", config = [[require('config.nvim_hop')]] } use {
'phaazon/hop.nvim',
event = "VimEnter",
config = function()
vim.defer_fn(function() require('config.nvim_hop') end, 2000)
end
}
-- Clear highlight search automatically for you -- Clear highlight search automatically for you
use({"romainl/vim-cool", event = "VimEnter"}) use({"romainl/vim-cool", event = "VimEnter"})
-- Show current search term in different color
use({"PeterRincker/vim-searchlight", event = "VimEnter"})
-- Show match number for search -- Show match number for search
use({"kevinhwang91/nvim-hlslens", event = 'VimEnter'}) use {'kevinhwang91/nvim-hlslens', branch = 'main', event = "VimEnter"}
-- Stay after pressing * and search selected text -- Stay after pressing * and search selected text
use({"haya14busa/vim-asterisk", event = 'VimEnter'}) use({"haya14busa/vim-asterisk", event = 'VimEnter'})
@@ -92,11 +99,11 @@ require("packer").startup({
end end
use { use {
'nvim-telescope/telescope.nvim', 'nvim-telescope/telescope.nvim', cmd = 'Telescope',
requires = { {'nvim-lua/plenary.nvim'} } requires = { {'nvim-lua/plenary.nvim'} }
} }
-- search emoji and other symbols -- search emoji and other symbols
use 'nvim-telescope/telescope-symbols.nvim' use {'nvim-telescope/telescope-symbols.nvim', after = 'telescope.nvim'}
-- Another similar plugin is command-t -- Another similar plugin is command-t
-- use 'wincent/command-t' -- use 'wincent/command-t'
@@ -123,21 +130,33 @@ require("packer").startup({
-- Another similar plugin -- Another similar plugin
-- use 'airblade/vim-gitgutter' -- use 'airblade/vim-gitgutter'
-- colorful status line and theme use {
use({"vim-airline/vim-airline-themes", after = 'vim-signify',}) 'nvim-lualine/lualine.nvim', event = 'VimEnter',
use({"vim-airline/vim-airline", after = 'vim-airline-themes',}) requires = {'kyazdani42/nvim-web-devicons', opt = true},
config = [[require('config.statusline')]]
}
use({ "akinsho/bufferline.nvim", event = "VimEnter", config = [[require('config.bufferline')]] }) use({ "akinsho/bufferline.nvim", event = "VimEnter", config = [[require('config.bufferline')]] })
use { 'goolord/alpha-nvim', config = [[require('config.alpha-nvim')]] }
-- fancy start screen -- fancy start screen
use({ "lukas-reineke/indent-blankline.nvim", event = "VimEnter", config = [[require('config.indent-blankline')]] }) use { 'goolord/alpha-nvim', event = 'VimEnter', config = [[require('config.alpha-nvim')]] }
use({
"lukas-reineke/indent-blankline.nvim",
config = [[require('config.indent-blankline')]]
})
-- Highlight URLs inside vim -- Highlight URLs inside vim
use({"itchyny/vim-highlighturl", event = "VimEnter"}) use({"itchyny/vim-highlighturl", event = "VimEnter"})
-- notification plugin -- notification plugin
use({ "rcarriga/nvim-notify", event = "BufEnter", config = [[require('config.nvim-notify')]] }) use({
"rcarriga/nvim-notify",
event = "BufEnter",
config = function()
vim.defer_fn(function() require('config.nvim-notify') end, 2000)
end
})
-- For Windows and Mac, we can open an URL in the browser. For Linux, it may -- 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. -- not be possible since we maybe in a server which disables GUI.
@@ -148,8 +167,6 @@ require("packer").startup({
-- Only install these plugins if ctags are installed on the system -- Only install these plugins if ctags are installed on the system
if utils.executable("ctags") then if utils.executable("ctags") then
-- plugin to manage your tags
use({"ludovicchabant/vim-gutentags", event = "VimEnter"})
-- show file tags in vim window -- show file tags in vim window
use({"liuchengxu/vista.vim", cmd = "Vista"}) use({"liuchengxu/vista.vim", cmd = "Vista"})
end end
@@ -168,7 +185,13 @@ require("packer").startup({
-- use 'mg979/vim-visual-multi' -- use 'mg979/vim-visual-multi'
-- Autosave files on certain events -- Autosave files on certain events
use({"Pocco81/AutoSave.nvim", event = "VimEnter", config = [[require('config.autosave')]]}) use({
"Pocco81/AutoSave.nvim",
event = "VimEnter",
config = function()
vim.defer_fn(function() require('config.autosave') end, 1500)
end
})
-- Show undo history visually -- Show undo history visually
use({"simnalamburt/vim-mundo", cmd = {"MundoToggle", "MundoShow"}}) use({"simnalamburt/vim-mundo", cmd = {"MundoToggle", "MundoShow"}})
@@ -274,7 +297,13 @@ require("packer").startup({
-- Smoothie motions -- Smoothie motions
-- use 'psliwka/vim-smoothie' -- use 'psliwka/vim-smoothie'
use({ "karb94/neoscroll.nvim", event = "VimEnter", config = [[require('config.neoscroll')]] }) use({
"karb94/neoscroll.nvim",
event = "VimEnter",
config = function()
vim.defer_fn(function() require('config.neoscroll') end, 2000)
end
})
use({"tpope/vim-scriptease", cmd = {"Scriptnames", "Message", "Verbose"}}) use({"tpope/vim-scriptease", cmd = {"Scriptnames", "Message", "Verbose"}})
@@ -311,15 +340,26 @@ require("packer").startup({
use({"gelguy/wilder.nvim", opt = true, setup = [[vim.cmd('packadd wilder.nvim')]]}) use({"gelguy/wilder.nvim", opt = true, setup = [[vim.cmd('packadd wilder.nvim')]]})
-- showing keybindings -- showing keybindings
use {"folke/which-key.nvim", event = "VimEnter", config = [[require('config.which-key')]]} use {"folke/which-key.nvim",
event = "VimEnter",
config = function()
vim.defer_fn(function() require('config.which-key') end, 2000)
end
}
-- show and trim trailing whitespaces -- show and trim trailing whitespaces
use {'jdhao/whitespace.nvim', event = 'VimEnter'} use {'jdhao/whitespace.nvim', event = 'VimEnter'}
end, end,
config = { config = {
max_jobs = 16, max_jobs = 16,
compile_path = util.join_paths(vim.fn.stdpath('config'), 'lua', 'packer_compiled.lua'),
git = { git = {
default_url_format = plug_url_format, default_url_format = plug_url_format,
}, },
}, },
}) })
local status, _ = pcall(require, 'packer_compiled')
if not status then
vim.notify("Error requiring packer_compiled.lua: run PackerSync to fix!")
end

View File

@@ -23,6 +23,7 @@ using std::pair;
using std::make_pair; using std::make_pair;
int main() int main()
{ {
@@ -41,8 +42,9 @@ void printList(const T& arr, const string& desc){
std::cout << desc << ": ["; std::cout << desc << ": [";
for (auto it = arr.begin(); it != arr.end(); it++){ for (auto it = arr.begin(); it != arr.end(); it++){
std::cout << *it << ((std::next(it) != arr.end()) ? ", " : "]\n"); std::cout << *it << ((std::next(it) != arr.end()) ? ", " : "");
} }
std::cout << "]\n";
} }
endsnippet endsnippet
@@ -53,13 +55,25 @@ void printMat(const vector<vector<T>>& mat, const string& desc){
for (auto it1 = mat.begin(); it1 != mat.end(); it1++){ for (auto it1 = mat.begin(); it1 != mat.end(); it1++){
auto cur_vec = *it1; auto cur_vec = *it1;
cout << "[";
for (auto it2 = cur_vec.begin(); it2 != cur_vec.end(); it2++){ for (auto it2 = cur_vec.begin(); it2 != cur_vec.end(); it2++){
cout << *it2 << ((std::next(it2) != cur_vec.end()) ? ", " : "\n"); cout << *it2 << ((std::next(it2) != cur_vec.end()) ? ", " : "]\n");
} }
} }
} }
endsnippet endsnippet
snippet pqueue "print queue"
template <class T>
void printQueue(T q){
while(!q.empty()){
std::cout << q.top() << " ";
q.pop();
}
std::cout << '\n';
}
endsnippet
snippet cout "print a variable" w snippet cout "print a variable" w
cout << "$1: " << $2 << endl; cout << "$1: " << $2 << endl;
endsnippet endsnippet

View File

@@ -3,3 +3,8 @@ command! -nargs=1 -complete=command Redir call utils#CaptureCommandOutput(<q-arg
command! -bar -bang -nargs=+ -complete=file Edit call utils#MultiEdit([<f-args>]) command! -bar -bang -nargs=+ -complete=file Edit call utils#MultiEdit([<f-args>])
call utils#Cabbrev('edit', 'Edit') call utils#Cabbrev('edit', 'Edit')
call utils#Cabbrev('man', 'Man')
" show current date and time in human readable format
command! -nargs=? Datetime echo utils#iso_time(<q-args>)

View File

@@ -323,3 +323,25 @@ zshrc
pdftoppm pdftoppm
pdf2image pdf2image
pdffonts pdffonts
myers
difftool
vimdiff
softmax
lib64
toolset
sym
ffmpeg
PyAV
mp4
vint
npm
js
sudo
ps1
tpm
hacky
PCRE
teardown
github
fastgit
EOL