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

62 Commits

Author SHA1 Message Date
jdhao
e23d4bb661 use black to format python file 2025-04-11 21:06:53 +02:00
jdhao
510a5501c5 update config for git-conflict.nvim (#401) 2025-04-11 21:06:23 +02:00
jdhao
e08b17f335 optimize nvim startup time with lazy.nvim (#400) 2025-04-08 19:35:47 +02:00
jdhao
adddbc0ba6 remove indent-blankline and use mini.indentscope 2025-04-08 19:13:01 +02:00
jdhao
aadfdae677 switch from nvim-web-devicons to mini.icons (#399) 2025-04-08 19:11:20 +02:00
jdhao
5826161160 move fzf-lua config to separate file 2025-04-04 18:17:24 +02:00
jdhao
ea2b4a728d remove plugin vim-markdown (#398)
use tree-sitter based markdown render instead.
2025-04-04 18:16:20 +02:00
jdhao
ad4a0e82dc Simplify condition check (#397) 2025-04-02 21:57:37 +02:00
jdhao
9e6be1f001 update type hints 2025-04-02 21:33:32 +02:00
jdhao
c4160b6f85 update handling of large files (#396) 2025-04-02 21:30:25 +02:00
jdhao
60852c0473 Switch from LeaderF to Fzf-lua as the default fuzzy finder (#395) 2025-04-02 18:20:01 +02:00
Ya Zhuang
7fa77fbfbf fix typo (#394) 2025-03-31 08:50:35 +02:00
jdhao
f76ef3dbb4 fix diagnostic issues 2025-03-30 21:01:02 +02:00
jdhao
d17289cd6b use builtin log level enum to specify log level (#393) 2025-03-30 21:00:21 +02:00
jdhao
bfc531656a Add option messagesopt config 2025-03-30 20:56:43 +02:00
jdhao
72e6480933 Use LspAttach to configure buffer behavior (#392) 2025-03-30 20:54:53 +02:00
jdhao
625a4ffa47 update config for lazydev and nvim-lightbulb (#391) 2025-03-30 20:21:35 +02:00
jdhao
265f171172 remove unused variable 2025-03-30 18:58:23 +02:00
jdhao
b82c1c112f update colorscheme (#390)
1. Remove catppuccin, it is too purple/blue for me
2. use another nightfox variant
2025-03-30 18:02:28 +02:00
jdhao
0816faee76 Separate diagnostic config from lsp ones (#389) 2025-03-30 17:58:09 +02:00
jdhao
12147bec86 Use glance.nvim for lsp references/implementations preview (#388) 2025-03-30 17:55:51 +02:00
jdhao
a8a1b92921 update floating window highlight (#387) 2025-03-28 20:29:39 +01:00
jdhao
5f662f143b update various config after nvim 0.11 release (#386) 2025-03-28 20:27:02 +01:00
jdhao
f005a8303d Nvim version bump (#385)
* update nvim version to 0.11.0

* replace deprecated nvim_err_write/nvim_err_writeln call

* replace deprecated func for diagnostic and lsp

* use vim.hl instead

* use new way to define diagnostic signs
2025-03-26 22:33:39 +01:00
Okarin
8cba1ba234 Install treesitter on all systems (#384)
For some reason treesitter gets only installed on mac os. This conflicts with treesitter-textobjects which gets installed for every system.
2025-03-21 14:42:33 +01:00
jdhao
a00e1fd92a Remove luarocks (#383)
remove luarocks.nvim as it is causing startup delays
2025-03-05 23:08:27 +01:00
jdhao
2383eb7075 switch back to nvim-cmp (#381) 2025-02-16 21:03:17 +01:00
jdhao
ab059bbb6d use treesitter-textobjects instead (#380)
Note that we should keep the branch of nvim-treesitter and nvim-treesitter-textobjects the same. `main` is targeted at nightly neovim and `master` is for stable neovim. See also https://github.com/nvim-treesitter/nvim-treesitter/issues/4767
2025-02-16 20:15:41 +01:00
jdhao
93166c65a5 update colorscheme config (#379) 2025-02-16 19:52:34 +01:00
jdhao
4b8c490abd fix gitsign word_diff flickering issue (#378)
I guess it is due to the reason that we are doing constant git fetch,
and somehow gitsigns word diff is affected.

Changing the gitsigns debounce or changing lualine refresh rate do not
seem to help. So gitsigns word diff is disabled.
2025-02-16 19:20:21 +01:00
jdhao
2242961925 Remove obsolete func (#377)
- remove function: SynGroup, HasColorscheme and
  GetGitBranch
- rewrite Inside_git_repo in lua instead
2025-02-16 19:13:24 +01:00
jdhao
ac421715d3 Lualine async git info (#376)
make everything async and non-blocking and also remove the branch name fetching. It is not needed if we use the @{upstream} notation.
2025-02-16 01:15:07 +01:00
jdhao
28bda349e8 Update lualine config (#375)
- components are re-ordered
- add new component to show git ahead/behind info
- remove some unused component
2025-02-15 18:58:15 +01:00
jdhao
ee4bce4671 enable mouse in normal mode 2025-02-15 14:36:24 +01:00
jdhao
7f53743255 remove automcd to go to last place
This conflicts with the fuzzy finder, if you grep for a word using fuzzy
finder and then press enter to go to the place, it does not work
anymore, it will go the line where you are last time.
2025-02-14 22:12:33 +01:00
jdhao
94497c0a73 snack config update 2025-02-13 00:41:35 +01:00
jdhao
70e9943aac update supported nvim version to latest stable
Update a few plugins
2025-02-12 23:32:21 +01:00
jdhao
9a6584bec3 add plugin colorzier 2025-01-29 00:21:10 +01:00
jdhao
c7fb090e4c update README 2024-12-22 14:04:56 +01:00
jdhao
a02f317a1d update supported nvim version to v0.10.3 2024-12-22 13:56:41 +01:00
jdhao
f95d4c09b4 disable mouse 2024-12-21 00:03:38 +01:00
jdhao
7e706515a8 silently format lua file using stylua
We need to disable the mapping set for LSP, otherwise the mapping set in
lua.vim will be overridden.
2024-12-19 23:45:15 +01:00
jdhao
1d66475cae make option showcmd shown in statusline instead
Related issues:

+ https://groups.google.com/g/vim_dev/c/YwFLUaduXTQ
+ https://github.com/neovim/neovim/pull/21202
+ https://github.com/nvim-lualine/lualine.nvim/issues/949
2024-12-19 23:39:14 +01:00
jdhao
5328c477a8 reformat with stylua 2024-12-19 22:16:23 +01:00
jdhao
917ab82ffb update dict 2024-12-19 22:13:53 +01:00
jdhao
54eb3ca811 install new plugins 2024-12-19 22:08:56 +01:00
jdhao
64b41fbd58 use native lua api instead of vim.cmd 2024-12-19 22:01:04 +01:00
jdhao
d941be482b update lualine config 2024-12-08 21:34:47 +01:00
jdhao
ab75189231 Fix command CopyPath issue
the string.gsub in lua is not flexible and use vim.fn.substitute()
instead.
2024-11-29 23:25:19 +01:00
jdhao
7645751dc1 Update readme 2024-11-27 00:05:38 +01:00
jdhao
8880268140 custom command update
1. Add new command `CopyPath`
2. Revise command `JSONFormat`: implemented using the nvim lua interface
   and fix a few issues. The previous implementation is removed.
2024-11-27 00:05:38 +01:00
jdhao
d86f599483 update the fold level allowed for statuscol.nvim 2024-11-08 22:57:33 +01:00
jdhao
8dfae271d0 use plaintext for pyright hover request
see my comment here for the details: https://www.reddit.com/r/neovim/comments/1gdv1rc/comment/lvt9nlm/
2024-11-07 21:53:32 +01:00
jdhao
1141a18c5f update config for pyright 2024-11-06 23:19:55 +01:00
jdhao
fe3d5e5922 remove plugin committia.vim 2024-11-05 22:16:54 +01:00
jdhao
9769c24633 Switch Python LSP for completion and add ruff
pyright servers type checking, completion, and ruff servers linting and
diagnostics (ruff can also format Python files, but it is slightly
different from black)
2024-11-05 22:09:33 +01:00
jdhao
97f72936ac Enable LSP format also for visual selection 2024-11-05 22:04:49 +01:00
jdhao
94cade03be enable inlayhint for lua_ls server
The client side inlayhint can be enabled by uncommentting the code in
this PR.
2024-11-05 22:01:23 +01:00
jdhao
590bd6c7e6 use stylua to format lua files 2024-11-05 21:56:18 +01:00
jdhao
4171f190f2 Add plugin nvim-lightbulb to hint code actions 2024-11-05 21:47:34 +01:00
jdhao
5426c88a90 update Leaderf setting
Only search file content and not file name when using Leaderf rg
2024-11-05 21:44:34 +01:00
jdhao
d715ce8f31 update supported nvim version to 0.10.2 2024-10-09 18:00:15 +02:00
35 changed files with 777 additions and 705 deletions

1
.gitignore vendored
View File

@@ -4,3 +4,4 @@ en.utf-8.add.spl
.netrwhist .netrwhist
*.log *.log
.DS_Store .DS_Store
lazy-lock.json

View File

@@ -9,21 +9,18 @@
<a> <a>
<img alt="Windows" src="https://img.shields.io/badge/Windows-%23.svg?style=flat-square&logo=windows&color=0078D6&logoColor=white" /> <img alt="Windows" src="https://img.shields.io/badge/Windows-%23.svg?style=flat-square&logo=windows&color=0078D6&logoColor=white" />
</a> </a>
<a href="https://github.com/neovim/neovim/releases/tag/stable">
<img src="https://img.shields.io/badge/Neovim-0.11.0-blueviolet.svg?style=flat-square&logo=Neovim&logoColor=green" alt="Neovim minimum version"/>
</a>
<a href="https://github.com/jdhao/nvim-config/releases/latest"> <a href="https://github.com/jdhao/nvim-config/releases/latest">
<img alt="Latest release" src="https://img.shields.io/github/v/release/jdhao/nvim-config" /> <img alt="Latest release" src="https://img.shields.io/github/v/release/jdhao/nvim-config" />
</a> </a>
<a href="https://github.com/neovim/neovim/releases/tag/stable">
<img src="https://img.shields.io/badge/Neovim-0.10.1-blueviolet.svg?style=flat-square&logo=Neovim&logoColor=green" alt="Neovim minimum version"/>
</a>
<a href="https://github.com/jdhao/nvim-config/search?l=vim-script"> <a href="https://github.com/jdhao/nvim-config/search?l=vim-script">
<img src="https://img.shields.io/github/languages/top/jdhao/nvim-config" alt="Top languages"/> <img src="https://img.shields.io/github/languages/top/jdhao/nvim-config" alt="Top languages"/>
</a> </a>
<a href="https://github.com/jdhao/nvim-config/graphs/commit-activity"> <a href="https://github.com/jdhao/nvim-config/graphs/commit-activity">
<img src="https://img.shields.io/github/commit-activity/m/jdhao/nvim-config?style=flat-square" /> <img src="https://img.shields.io/github/commit-activity/m/jdhao/nvim-config?style=flat-square" />
</a> </a>
<a href="https://github.com/jdhao/nvim-config/releases/tag/v0.10.0">
<img src="https://img.shields.io/github/commits-since/jdhao/nvim-config/v0.10.0?style=flat-square" />
</a>
<a href="https://github.com/jdhao/nvim-config/graphs/contributors"> <a href="https://github.com/jdhao/nvim-config/graphs/contributors">
<img src="https://img.shields.io/github/contributors/jdhao/nvim-config?style=flat-square" /> <img src="https://img.shields.io/github/contributors/jdhao/nvim-config?style=flat-square" />
</a> </a>
@@ -62,7 +59,7 @@ and how to set up on different platforms (Linux, macOS, and Windows).
+ Language server protocol (LSP) support via [nvim-lspconfig](https://github.com/neovim/nvim-lspconfig). + Language server protocol (LSP) support via [nvim-lspconfig](https://github.com/neovim/nvim-lspconfig).
+ Git integration via [vim-fugitive](https://github.com/tpope/vim-fugitive). + Git integration via [vim-fugitive](https://github.com/tpope/vim-fugitive).
+ Better escaping from insert mode via [better-escape.vim](https://github.com/nvim-zh/better-escape.vim). + Better escaping from insert mode via [better-escape.vim](https://github.com/nvim-zh/better-escape.vim).
+ Ultra-fast project-wide fuzzy searching via [LeaderF](https://github.com/Yggdroot/LeaderF). + Ultra-fast project-wide fuzzy searching via [fzf-lua](https://github.com/ibhagwan/fzf-lua).
+ Faster code commenting via [vim-commentary](https://github.com/tpope/vim-commentary). + Faster code commenting via [vim-commentary](https://github.com/tpope/vim-commentary).
+ Faster matching pair insertion and jump via [nvim-autopairs](https://github.com/windwp/nvim-autopairs). + Faster matching pair insertion and jump via [nvim-autopairs](https://github.com/windwp/nvim-autopairs).
+ Smarter and faster matching pair management (add, replace or delete) via [vim-sandwich](https://github.com/machakann/vim-sandwich). + Smarter and faster matching pair management (add, replace or delete) via [vim-sandwich](https://github.com/machakann/vim-sandwich).
@@ -82,7 +79,6 @@ and how to set up on different platforms (Linux, macOS, and Windows).
+ LaTeX editing and previewing via [vimtex](https://github.com/lervag/vimtex) + LaTeX editing and previewing via [vimtex](https://github.com/lervag/vimtex)
+ Animated GUI style notification via [nvim-notify](https://github.com/rcarriga/nvim-notify). + Animated GUI style notification via [nvim-notify](https://github.com/rcarriga/nvim-notify).
+ Tags navigation via [vista](https://github.com/liuchengxu/vista.vim). + Tags navigation via [vista](https://github.com/liuchengxu/vista.vim).
+ Code formatting via [Neoformat](https://github.com/sbdchd/neoformat).
+ Undo management via [vim-mundo](https://github.com/simnalamburt/vim-mundo) + Undo management via [vim-mundo](https://github.com/simnalamburt/vim-mundo)
+ Code folding with [nvim-ufo](https://github.com/kevinhwang91/nvim-ufo) and [statuscol.nvim](https://github.com/luukvbaal/statuscol.nvim) + Code folding with [nvim-ufo](https://github.com/kevinhwang91/nvim-ufo) and [statuscol.nvim](https://github.com/luukvbaal/statuscol.nvim)
+ ...... + ......
@@ -97,10 +93,10 @@ For more UI demos, check [here](https://github.com/jdhao/nvim-config/issues/15).
<img src="https://user-images.githubusercontent.com/16662357/183256752-fb23b215-a6b8-4646-beed-9999f52d53f1.png" width="800"> <img src="https://user-images.githubusercontent.com/16662357/183256752-fb23b215-a6b8-4646-beed-9999f52d53f1.png" width="800">
</p> </p>
## File fuzzy finding using LeaderF ## File fuzzy finding using fzf-lua
<p align="center"> <p align="center">
<img src="https://user-images.githubusercontent.com/16662357/183257017-2d9d7605-3c4b-4e1d-8955-30998f9b6f28.gif" width="800"> <img src="https://github.com/user-attachments/assets/3199e35d-121a-487b-bfd1-58eb69b0b48a" width="800">
</p> </p>
## Code autocompletion with nvim-cmp ## Code autocompletion with nvim-cmp
@@ -191,7 +187,6 @@ Some of the shortcuts I use frequently are listed here. In the following shortcu
| `Alt-j` | Normal | Linux/macOS/Win | Move current line or selected lines down | | `Alt-j` | Normal | Linux/macOS/Win | Move current line or selected lines down |
| `Alt-m` | Normal | macOS/Win | Markdown previewing in system browser | | `Alt-m` | Normal | macOS/Win | Markdown previewing in system browser |
| `Alt-Shift-m` | Normal | macOS/Win | Stopping 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-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 | | `ctrl-t` | Insert | Linux/macOS/Win | Turn word under cursor to title case |
| `jk` | Insert | Linux/macOS/Win | Return to Normal mode without lagging | | `jk` | Insert | Linux/macOS/Win | Return to Normal mode without lagging |
@@ -206,6 +201,7 @@ In addition to commands provided by various plugins, I have also created some cu
| `Edit` | edit multiple files at the same time, supports globing | `Edit *.vim` | | `Edit` | edit multiple files at the same time, supports globing | `Edit *.vim` |
| `Datetime` | print current date and time or convert Unix time stamp to date and time | `Datetime 12345` or `Datetime` | | `Datetime` | print current date and time or convert Unix time stamp to date and time | `Datetime 12345` or `Datetime` |
| `JSONFormat` | format a JSON file | `JSONFormat` | | `JSONFormat` | format a JSON file | `JSONFormat` |
| `CopyPath` | copy current file path to clipboard | `CopyPath relative` |
# Contributing # Contributing

View File

@@ -3,3 +3,5 @@ set formatoptions-=o
set formatoptions-=r set formatoptions-=r
nnoremap <buffer><silent> <F9> :luafile %<CR> nnoremap <buffer><silent> <F9> :luafile %<CR>
nnoremap <buffer><silent> <space>f <cmd>silent !stylua %<CR>

View File

@@ -12,3 +12,5 @@ set tabstop=4 " number of visual spaces per TAB
set softtabstop=4 " number of spaces in tab when editing set softtabstop=4 " number of spaces in tab when editing
set shiftwidth=4 " number of spaces to use for autoindent set shiftwidth=4 " number of spaces to use for autoindent
set expandtab " expand tab to spaces so that tabs are spaces set expandtab " expand tab to spaces so that tabs are spaces
nnoremap <buffer><silent> <space>f <cmd>silent !black %<CR>

View File

@@ -10,23 +10,6 @@ function! s:Single_quote(str) abort
return "'" . substitute(copy(a:str), "'", "''", 'g') . "'" return "'" . substitute(copy(a:str), "'", "''", 'g') . "'"
endfunction endfunction
" Check the syntax group in the current cursor position, see
" https://stackoverflow.com/q/9464844/6064933 and
" https://jordanelver.co.uk/blog/2015/05/27/working-with-vim-colorschemes/
function! utils#SynGroup() abort
if !exists('*synstack')
return
endif
echo map(synstack(line('.'), col('.')), 'synIDattr(v:val, "name")')
endfunction
" Check if a colorscheme exists in runtimepath.
" The following two functions are inspired by https://stackoverflow.com/a/5703164/6064933.
function! utils#HasColorscheme(name) abort
let l:pat = printf('colors/%s.vim', a:name)
return !empty(globpath(&runtimepath, l:pat))
endfunction
" Custom fold expr, adapted from https://vi.stackexchange.com/a/9094/15292 " Custom fold expr, adapted from https://vi.stackexchange.com/a/9094/15292
function! utils#VimFolds(lnum) abort function! utils#VimFolds(lnum) abort
" get content of current line and the line below " get content of current line and the line below
@@ -146,27 +129,6 @@ function! utils#iso_time(timestamp) abort
endfunction endfunction
" Check if we are inside a Git repo.
function! utils#Inside_git_repo() abort
let res = system('git rev-parse --is-inside-work-tree')
if match(res, 'true') == -1
return v:false
else
" Manually trigger a special user autocmd InGitRepo (used lazyloading.
doautocmd User InGitRepo
return v:true
endif
endfunction
function! utils#GetGitBranch()
let l:res = systemlist('git rev-parse --abbrev-ref HEAD')[0]
if match(l:res, 'fatal') != -1
return ''
else
return l:res
endif
endfunction
" Redirect command output to a register for later processing. " Redirect command output to a register for later processing.
" Ref: https://stackoverflow.com/q/2573021/6064933 and https://unix.stackexchange.com/q/8101/221410 . " Ref: https://stackoverflow.com/q/2573021/6064933 and https://unix.stackexchange.com/q/8101/221410 .
function! utils#CaptureCommandOutput(command) abort function! utils#CaptureCommandOutput(command) abort

View File

@@ -13,7 +13,7 @@ vim.loader.enable()
local utils = require("utils") local utils = require("utils")
local expected_version = "0.10.1" local expected_version = "0.11.0"
utils.is_compatible_version(expected_version) utils.is_compatible_version(expected_version)
local config_dir = vim.fn.stdpath("config") local config_dir = vim.fn.stdpath("config")
@@ -28,6 +28,13 @@ require("custom-autocmd")
-- all the user-defined mappings -- all the user-defined mappings
require("mappings") require("mappings")
-- all the plugins installed and their configurations -- all the plugins installed and their configurations
vim.cmd("source ".. vim.fs.joinpath(config_dir, "viml_conf/plugins.vim")) vim.cmd("source " .. vim.fs.joinpath(config_dir, "viml_conf/plugins.vim"))
-- diagnostic related config
require("diagnostic-conf")
-- colorscheme settings -- colorscheme settings
require("colorschemes") local color_scheme = require("colorschemes")
-- Load a random colorscheme
color_scheme.rand_colorscheme()

View File

@@ -1,5 +1,4 @@
--- This module will load a random colorscheme on nvim startup process. --- This module will load a random colorscheme on nvim startup process.
local utils = require("utils") local utils = require("utils")
local M = {} local M = {}
@@ -8,9 +7,14 @@ local M = {}
-- the same as the colorscheme name itself. -- the same as the colorscheme name itself.
M.colorscheme_conf = { M.colorscheme_conf = {
onedark = function() onedark = function()
vim.cmd([[colorscheme onedark]]) -- Lua
require("onedark").setup {
style = "darker",
}
require("onedark").load()
end, end,
edge = function() edge = function()
vim.g.edge_style = "default"
vim.g.edge_enable_italic = 1 vim.g.edge_enable_italic = 1
vim.g.edge_better_performance = 1 vim.g.edge_better_performance = 1
@@ -26,64 +30,45 @@ M.colorscheme_conf = {
-- foreground option can be material, mix, or original -- foreground option can be material, mix, or original
vim.g.gruvbox_material_foreground = "original" vim.g.gruvbox_material_foreground = "original"
--background option can be hard, medium, soft --background option can be hard, medium, soft
vim.g.gruvbox_material_background = "medium" vim.g.gruvbox_material_background = "hard"
vim.g.gruvbox_material_enable_italic = 1 vim.g.gruvbox_material_enable_italic = 1
vim.g.gruvbox_material_better_performance = 1 vim.g.gruvbox_material_better_performance = 1
vim.cmd([[colorscheme gruvbox-material]]) vim.cmd([[colorscheme gruvbox-material]])
end, end,
everforest = function() everforest = function()
vim.g.everforest_background = "hard"
vim.g.everforest_enable_italic = 1 vim.g.everforest_enable_italic = 1
vim.g.everforest_better_performance = 1 vim.g.everforest_better_performance = 1
vim.cmd([[colorscheme everforest]]) vim.cmd([[colorscheme everforest]])
end, end,
nightfox = function() nightfox = function()
vim.cmd([[colorscheme nordfox]]) vim.cmd([[colorscheme carbonfox]])
end,
catppuccin = function()
-- available option: latte, frappe, macchiato, mocha
vim.g.catppuccin_flavour = "frappe"
require("catppuccin").setup()
vim.cmd([[colorscheme catppuccin]])
end, end,
onedarkpro = function() onedarkpro = function()
-- set colorscheme after options -- set colorscheme after options
vim.cmd('colorscheme onedark_vivid') -- onedark_vivid does not enough contrast
vim.cmd("colorscheme onedark_dark")
end, end,
material = function() material = function()
vim.g.material_style = "oceanic" vim.g.material_style = "darker"
vim.cmd('colorscheme material') vim.cmd("colorscheme material")
end, end,
arctic = function () arctic = function()
vim.cmd("colorscheme arctic") vim.cmd("colorscheme arctic")
end, end,
kanagawa = function() kanagawa = function()
vim.cmd("colorscheme kanagawa-wave") vim.cmd("colorscheme kanagawa-wave")
end end,
} }
--- Use a random colorscheme from the pre-defined list of colorschemes. --- Use a random colorscheme from the pre-defined list of colorschemes.
M.rand_colorscheme = function() M.rand_colorscheme = function()
local colorscheme = utils.rand_element(vim.tbl_keys(M.colorscheme_conf)) local colorscheme = utils.rand_element(vim.tbl_keys(M.colorscheme_conf))
if not vim.tbl_contains(vim.tbl_keys(M.colorscheme_conf), colorscheme) then
local msg = "Invalid colorscheme: " .. colorscheme
vim.notify(msg, vim.log.levels.ERROR, { title = "nvim-config" })
return
end
-- Load the colorscheme and its settings -- Load the colorscheme and its settings
M.colorscheme_conf[colorscheme]() M.colorscheme_conf[colorscheme]()
if vim.g.logging_level == "debug" then
local msg = "Colorscheme: " .. colorscheme
vim.notify(msg, vim.log.levels.DEBUG, { title = "nvim-config" })
end
end end
-- Load a random colorscheme return M
M.rand_colorscheme()

View File

@@ -23,19 +23,19 @@ conf.center = {
{ {
icon = "󰈞 ", icon = "󰈞 ",
desc = "Find File ", desc = "Find File ",
action = "Leaderf file --popup", action = "FzfLua files",
key = "<Leader> f f", key = "<Leader> f f",
}, },
{ {
icon = "󰈢 ", icon = "󰈢 ",
desc = "Recently opened files ", desc = "Recently opened files ",
action = "Leaderf mru --popup", action = "FzfLua oldfiles",
key = "<Leader> f r", key = "<Leader> f r",
}, },
{ {
icon = "󰈬 ", icon = "󰈬 ",
desc = "Project grep ", desc = "Project grep ",
action = "Leaderf rg --popup", action = "FzfLua live_grep",
key = "<Leader> f g", key = "<Leader> f g",
}, },
{ {
@@ -59,17 +59,17 @@ conf.center = {
}, },
} }
dashboard.setup({ dashboard.setup {
theme = 'doom', theme = "doom",
shortcut_type = 'number', shortcut_type = "number",
config = conf config = conf,
}) }
api.nvim_create_autocmd("FileType", { api.nvim_create_autocmd("FileType", {
pattern = "dashboard", pattern = "dashboard",
group = api.nvim_create_augroup("dashboard_enter", { clear = true }), group = api.nvim_create_augroup("dashboard_enter", { clear = true }),
callback = function () callback = function()
keymap.set("n", "q", ":qa<CR>", { buffer = true, silent = true }) keymap.set("n", "q", ":qa<CR>", { buffer = true, silent = true })
keymap.set("n", "e", ":enew<CR>", { buffer = true, silent = true }) keymap.set("n", "e", ":enew<CR>", { buffer = true, silent = true })
end end,
}) })

18
lua/config/fzf-lua.lua Normal file
View File

@@ -0,0 +1,18 @@
require("fzf-lua").setup {
defaults = {
file_icons = "mini",
},
winopts = {
row = 0.5,
height = 0.7,
},
files = {
previewer = false,
},
}
vim.keymap.set("n", "<leader>ff", "<cmd>FzfLua files<cr>", { desc = "Fuzzy find files" })
vim.keymap.set("n", "<leader>fg", "<cmd>FzfLua live_grep<cr>", { desc = "Fuzzy grep files" })
vim.keymap.set("n", "<leader>fh", "<cmd>FzfLua helptags<cr>", { desc = "Fuzzy grep tags in help files" })
vim.keymap.set("n", "<leader>ft", "<cmd>FzfLua btags<cr>", { desc = "Fuzzy search buffer tags" })
vim.keymap.set("n", "<leader>fb", "<cmd>FzfLua buffers<cr>", { desc = "Fuzzy search opened buffers" })

View File

@@ -0,0 +1,12 @@
require("git-conflict").setup {}
vim.api.nvim_create_autocmd("User", {
pattern = "GitConflictResolved",
callback = function()
-- clear qf list
vim.fn.setqflist({}, "r")
-- reopen it?
vim.cmd([[GitConflictListQf]])
end,
})

View File

@@ -5,16 +5,26 @@ gitlinker.setup {
callbacks = { callbacks = {
["dev.azure.com"] = function(url_data) ["dev.azure.com"] = function(url_data)
vim.print(url_data) vim.print(url_data)
local url = require"gitlinker.hosts".get_base_https_url(url_data) local url = require("gitlinker.hosts").get_base_https_url(url_data)
if url_data.lstart then if url_data.lstart then
if url_data.lend == nil then if url_data.lend == nil then
url_data.lend = url_data.lstart url_data.lend = url_data.lstart
end end
url = url .. "?path=/" .. url_data.file .. "&version=GC" .. url_data.rev .. "&line=" .. url_data.lstart .. "&lineEnd=" .. url_data.lend .. "&lineStartColumn=1" .. "&lineEndColumn=120" url = url
.. "?path=/"
.. url_data.file
.. "&version=GC"
.. url_data.rev
.. "&line="
.. url_data.lstart
.. "&lineEnd="
.. url_data.lend
.. "&lineStartColumn=1"
.. "&lineEndColumn=120"
end end
return url return url
end end,
}, },
mappings = nil, mappings = nil,
} }
@@ -28,9 +38,9 @@ end, {
}) })
keymap.set("n", "<leader>gbr", function() keymap.set("n", "<leader>gbr", function()
gitlinker.get_repo_url({ gitlinker.get_repo_url {
action_callback = gitlinker.actions.open_in_browser action_callback = gitlinker.actions.open_in_browser,
}) }
end, { end, {
silent = true, silent = true,
desc = "Git: browse repo in browser", desc = "Git: browse repo in browser",

View File

@@ -8,7 +8,7 @@ gs.setup {
topdelete = { text = "" }, topdelete = { text = "" },
changedelete = { text = "" }, changedelete = { text = "" },
}, },
word_diff = true, word_diff = false,
on_attach = function(bufnr) on_attach = function(bufnr)
local function map(mode, l, r, opts) local function map(mode, l, r, opts)
opts = opts or {} opts = opts or {}
@@ -38,20 +38,20 @@ gs.setup {
end, { expr = true, desc = "previous hunk" }) end, { expr = true, desc = "previous hunk" })
-- Actions -- Actions
map("n", "<leader>hp", gs.preview_hunk) map("n", "<leader>hp", gs.preview_hunk, { desc = "preview hunk" })
map("n", "<leader>hb", function() map("n", "<leader>hb", function()
gs.blame_line { full = true } gs.blame_line { full = true }
end) end, { desc = "blame hunk" })
end, end,
} }
vim.api.nvim_create_autocmd('ColorScheme', { vim.api.nvim_create_autocmd("ColorScheme", {
pattern = "*", pattern = "*",
callback = function() callback = function()
vim.cmd [[ vim.cmd([[
hi GitSignsChangeInline gui=reverse hi GitSignsChangeInline gui=reverse
hi GitSignsAddInline gui=reverse hi GitSignsAddInline gui=reverse
hi GitSignsDeleteInline gui=reverse hi GitSignsDeleteInline gui=reverse
]] ]])
end end,
}) })

12
lua/config/glance.lua Normal file
View File

@@ -0,0 +1,12 @@
local glance = require("glance")
glance.setup {
height = 25,
border = {
enable = true,
},
}
vim.keymap.set("n", "<space>gd", "<cmd>Glance definitions<cr>")
vim.keymap.set("n", "<space>gr", "<cmd>Glance references<cr>")
vim.keymap.set("n", "<space>gi", "<cmd>Glance implementations<cr>")

View File

@@ -14,9 +14,9 @@ local activate_hlslens = function(direction)
-- Deal with the case that there is no such pattern in current buffer. -- Deal with the case that there is no such pattern in current buffer.
if not status then if not status then
local start_idx, _ = string.find(msg, 'E486', 1, true) local start_idx, _ = string.find(msg, "E486", 1, true)
local msg_part = string.sub(msg, start_idx) local msg_part = string.sub(msg, start_idx)
api.nvim_err_writeln(msg_part) api.nvim_echo({ { msg_part } }, true, { err = true })
return return
end end
@@ -40,7 +40,7 @@ local check_cursor_word = function()
local result = cursor_word == "" local result = cursor_word == ""
if result then if result then
local msg = "E348: No string under cursor" local msg = "E348: No string under cursor"
api.nvim_err_writeln(msg) api.nvim_echo({ { msg } }, true, { err = true })
end end
return result, cursor_word return result, cursor_word

View File

@@ -1,36 +0,0 @@
local api = vim.api
local exclude_ft = { "help", "git", "markdown", "snippets", "text", "gitconfig", "alpha", "dashboard" }
require("ibl").setup {
indent = {
-- -- U+2502 may also be a good choice, it will be on the middle of cursor.
-- -- U+250A is also a good choice
char = "",
},
scope = {
show_start = false,
show_end = false,
},
exclude = {
filetypes = exclude_ft,
buftypes = { "terminal" },
},
}
local gid = api.nvim_create_augroup("indent_blankline", { clear = true })
api.nvim_create_autocmd("InsertEnter", {
pattern = "*",
group = gid,
command = "IBLDisable",
})
api.nvim_create_autocmd("InsertLeave", {
pattern = "*",
group = gid,
callback = function()
if not vim.tbl_contains(exclude_ft, vim.bo.filetype) then
vim.cmd([[IBLEnable]])
end
end,
})

20
lua/config/lightbulb.lua Normal file
View File

@@ -0,0 +1,20 @@
---@diagnostic disable: missing-fields
require("nvim-lightbulb").setup {
autocmd = {
enabled = true,
updatetime = -1,
},
---@diagnostic disable-next-line: unused-local
filter = function(client_name, result)
-- Ruff always sends these two actions even if there are no action to take,
-- so it is better to just ignore this to avoid noise. See also discussion below:
-- https://github.com/astral-sh/ruff-lsp/issues/91
local ignored_kinds = { "source.fixAll.ruff", "source.organizeImports.ruff" }
if vim.tbl_contains(ignored_kinds, result.kind) then
return false
end
return true
end,
}

View File

@@ -1,196 +1,174 @@
local fn = vim.fn
local api = vim.api local api = vim.api
local keymap = vim.keymap local keymap = vim.keymap
local lsp = vim.lsp local lsp = vim.lsp
local diagnostic = vim.diagnostic local lspconfig = require("lspconfig")
local utils = require("utils") local utils = require("utils")
-- set quickfix list from diagnostics in a certain buffer, not the whole workspace vim.api.nvim_create_autocmd("LspAttach", {
local set_qflist = function(buf_num, severity) group = vim.api.nvim_create_augroup("buf_behavior_conf", { clear = true }),
local diagnostics = nil callback = function(event_context)
diagnostics = diagnostic.get(buf_num, { severity = severity }) local client = vim.lsp.get_client_by_id(event_context.data.client_id)
-- vim.print(client.name, client.server_capabilities)
local qf_items = diagnostic.toqflist(diagnostics) if not client then
vim.fn.setqflist({}, ' ', { title = 'Diagnostics', items = qf_items }) return
end
-- open quickfix by default local bufnr = event_context.buf
vim.cmd[[copen]]
end
local custom_attach = function(client, bufnr) -- Mappings.
-- Mappings. local map = function(mode, l, r, opts)
local map = function(mode, l, r, opts) opts = opts or {}
opts = opts or {} opts.silent = true
opts.silent = true opts.buffer = bufnr
opts.buffer = bufnr keymap.set(mode, l, r, opts)
keymap.set(mode, l, r, opts) end
end
map("n", "gd", vim.lsp.buf.definition, { desc = "go to definition" }) map("n", "gd", vim.lsp.buf.definition, { desc = "go to definition" })
map("n", "<C-]>", vim.lsp.buf.definition) map("n", "<C-]>", vim.lsp.buf.definition)
map("n", "K", vim.lsp.buf.hover) map("n", "K", function()
map("n", "<C-k>", vim.lsp.buf.signature_help) vim.lsp.buf.hover { border = "single", max_height = 25, max_width = 120 }
map("n", "<space>rn", vim.lsp.buf.rename, { desc = "varialbe rename" }) end)
map("n", "gr", vim.lsp.buf.references, { desc = "show references" }) map("n", "<C-k>", vim.lsp.buf.signature_help)
map("n", "[d", diagnostic.goto_prev, { desc = "previous diagnostic" }) map("n", "<space>rn", vim.lsp.buf.rename, { desc = "varialbe rename" })
map("n", "]d", diagnostic.goto_next, { desc = "next diagnostic" }) map("n", "<space>ca", vim.lsp.buf.code_action, { desc = "LSP code action" })
-- this puts diagnostics from opened files to quickfix map("n", "<space>wa", vim.lsp.buf.add_workspace_folder, { desc = "add workspace folder" })
map("n", "<space>qw", diagnostic.setqflist, { desc = "put window diagnostics to qf" }) map("n", "<space>wr", vim.lsp.buf.remove_workspace_folder, { desc = "remove workspace folder" })
-- this puts diagnostics from current buffer to quickfix map("n", "<space>wl", function()
map("n", "<space>qb", function() set_qflist(bufnr) end, { desc = "put buffer diagnostics to qf" }) vim.print(vim.lsp.buf.list_workspace_folders())
map("n", "<space>ca", vim.lsp.buf.code_action, { desc = "LSP code action" }) end, { desc = "list workspace folder" })
map("n", "<space>wa", vim.lsp.buf.add_workspace_folder, { desc = "add workspace folder" })
map("n", "<space>wr", vim.lsp.buf.remove_workspace_folder, { desc = "remove workspace folder" })
map("n", "<space>wl", function()
vim.print(vim.lsp.buf.list_workspace_folders())
end, { desc = "list workspace folder" })
-- Set some key bindings conditional on server capabilities -- Set some key bindings conditional on server capabilities
if client.server_capabilities.documentFormattingProvider then if client.server_capabilities.documentFormattingProvider and client.name ~= "lua_ls" then
map("n", "<space>f", vim.lsp.buf.format, { desc = "format code" }) map({ "n", "x" }, "<space>f", vim.lsp.buf.format, { desc = "format code" })
end end
api.nvim_create_autocmd("CursorHold", { -- Disable ruff hover feature in favor of Pyright
buffer = bufnr, if client.name == "ruff" then
callback = function() client.server_capabilities.hoverProvider = false
local float_opts = { end
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 -- Uncomment code below to enable inlay hint from language server, some LSP server supports inlay hint,
vim.b.diagnostics_pos = { nil, nil } -- but disable this feature by default, so you may need to enable inlay hint in the LSP server config.
end -- vim.lsp.inlay_hint.enable(true, {buffer=bufnr})
local cursor_pos = api.nvim_win_get_cursor(0) -- The blow command will highlight the current variable and its usages in the buffer.
if (cursor_pos[1] ~= vim.b.diagnostics_pos[1] or cursor_pos[2] ~= vim.b.diagnostics_pos[2]) if client.server_capabilities.documentHighlightProvider then
and #diagnostic.get() > 0 local gid = api.nvim_create_augroup("lsp_document_highlight", { clear = true })
then api.nvim_create_autocmd("CursorHold", {
diagnostic.open_float(nil, float_opts) group = gid,
end buffer = bufnr,
callback = function()
lsp.buf.document_highlight()
end,
})
vim.b.diagnostics_pos = cursor_pos api.nvim_create_autocmd("CursorMoved", {
end, group = gid,
}) buffer = bufnr,
callback = function()
lsp.buf.clear_references()
end,
})
end
end,
nested = true,
desc = "Configure buffer keymap and behavior based on LSP",
})
-- The blow command will highlight the current variable and its usages in the buffer. local capabilities = vim.lsp.protocol.make_client_capabilities()
if client.server_capabilities.documentHighlightProvider then
vim.cmd([[
hi! link LspReferenceRead Visual
hi! link LspReferenceText Visual
hi! link LspReferenceWrite Visual
]])
local gid = api.nvim_create_augroup("lsp_document_highlight", { clear = true })
api.nvim_create_autocmd("CursorHold" , {
group = gid,
buffer = bufnr,
callback = function ()
lsp.buf.document_highlight()
end
})
api.nvim_create_autocmd("CursorMoved" , {
group = gid,
buffer = bufnr,
callback = function ()
lsp.buf.clear_references()
end
})
end
if vim.g.logging_level == "debug" then
local msg = string.format("Language server %s started!", client.name)
vim.notify(msg, vim.log.levels.DEBUG, { title = "Nvim-config" })
end
end
local capabilities = require('cmp_nvim_lsp').default_capabilities()
-- required by nvim-ufo -- required by nvim-ufo
capabilities.textDocument.foldingRange = { capabilities.textDocument.foldingRange = {
dynamicRegistration = false, dynamicRegistration = false,
lineFoldingOnly = true lineFoldingOnly = true,
} }
local lspconfig = require("lspconfig") -- For what diagnostic is enabled in which type checking mode, check doc:
-- https://github.com/microsoft/pyright/blob/main/docs/configuration.md#diagnostic-settings-defaults
-- Currently, the pyright also has some issues displaying hover documentation:
-- https://www.reddit.com/r/neovim/comments/1gdv1rc/what_is_causeing_the_lsp_hover_docs_to_looks_like/
if utils.executable("pylsp") then if utils.executable("pyright") then
local venv_path = os.getenv('VIRTUAL_ENV') local new_capability = {
local py_path = nil -- this will remove some of the diagnostics that duplicates those from ruff, idea taken and adapted from
-- decide which python executable to use for mypy -- here: https://github.com/astral-sh/ruff-lsp/issues/384#issuecomment-1989619482
if venv_path ~= nil then textDocument = {
py_path = venv_path .. "/bin/python3" publishDiagnostics = {
else tagSupport = {
py_path = vim.g.python3_host_prog valueSet = { 2 },
end },
},
hover = {
contentFormat = { "plaintext" },
dynamicRegistration = true,
},
},
}
local merged_capability = vim.tbl_deep_extend("force", capabilities, new_capability)
lspconfig.pylsp.setup { lspconfig.pyright.setup {
on_attach = custom_attach, cmd = { "delance-langserver", "--stdio" },
capabilities = merged_capability,
settings = { settings = {
pylsp = { pyright = {
plugins = { -- disable import sorting and use Ruff for this
-- formatter options disableOrganizeImports = true,
black = { enabled = true }, disableTaggedHints = false,
autopep8 = { enabled = false }, },
yapf = { enabled = false }, python = {
-- linter options analysis = {
pylint = { enabled = true, executable = "pylint" }, autoSearchPaths = true,
ruff = { enabled = false }, diagnosticMode = "workspace",
pyflakes = { enabled = false }, typeCheckingMode = "standard",
pycodestyle = { enabled = false }, useLibraryCodeForTypes = true,
-- type checker -- we can this setting below to redefine some diagnostics
pylsp_mypy = { diagnosticSeverityOverrides = {
enabled = true, deprecateTypingAliases = false,
overrides = { "--python-executable", py_path, true }, },
report_progress = true, -- inlay hint settings are provided by pylance?
live_mode = false inlayHints = {
callArgumentNames = "partial",
functionReturnTypes = true,
pytestParameters = true,
variableTypes = true,
}, },
-- auto-completion options
jedi_completion = { fuzzy = true },
-- import sorting
isort = { enabled = true },
}, },
}, },
}, },
flags = {
debounce_text_changes = 200,
},
capabilities = capabilities,
} }
else else
vim.notify("pylsp not found!", vim.log.levels.WARN, { title = "Nvim-config" }) vim.notify("pyright not found!", vim.log.levels.WARN, { title = "Nvim-config" })
end end
-- if utils.executable('pyright') then if utils.executable("ruff") then
-- lspconfig.pyright.setup{ require("lspconfig").ruff.setup {
-- on_attach = custom_attach, capabilities = capabilities,
-- capabilities = capabilities init_options = {
-- } -- the settings can be found here: https://docs.astral.sh/ruff/editors/settings/
-- else settings = {
-- vim.notify("pyright not found!", vim.log.levels.WARN, {title = 'Nvim-config'}) organizeImports = true,
-- end },
},
}
end
if utils.executable("ltex-ls") then if utils.executable("ltex-ls") then
lspconfig.ltex.setup { lspconfig.ltex.setup {
on_attach = custom_attach,
cmd = { "ltex-ls" }, cmd = { "ltex-ls" },
filetypes = { "text", "plaintex", "tex", "markdown" }, filetypes = { "text", "plaintex", "tex", "markdown" },
settings = { settings = {
ltex = { ltex = {
language = "en" language = "en",
}, },
}, },
flags = { debounce_text_changes = 300 }, flags = { debounce_text_changes = 300 },
} }
end end
if utils.executable("clangd") then if utils.executable("clangd") then
lspconfig.clangd.setup { lspconfig.clangd.setup {
on_attach = custom_attach,
capabilities = capabilities, capabilities = capabilities,
filetypes = { "c", "cpp", "cc" }, filetypes = { "c", "cpp", "cc" },
flags = { flags = {
@@ -202,7 +180,6 @@ end
-- set up vim-language-server -- set up vim-language-server
if utils.executable("vim-language-server") then if utils.executable("vim-language-server") then
lspconfig.vimls.setup { lspconfig.vimls.setup {
on_attach = custom_attach,
flags = { flags = {
debounce_text_changes = 500, debounce_text_changes = 500,
}, },
@@ -215,49 +192,24 @@ end
-- set up bash-language-server -- set up bash-language-server
if utils.executable("bash-language-server") then if utils.executable("bash-language-server") then
lspconfig.bashls.setup { lspconfig.bashls.setup {
on_attach = custom_attach,
capabilities = capabilities, capabilities = capabilities,
} }
end end
-- settings for lua-language-server can be found on https://luals.github.io/wiki/settings/
if utils.executable("lua-language-server") then if utils.executable("lua-language-server") then
-- settings for lua-language-server can be found on https://github.com/LuaLS/lua-language-server/wiki/Settings .
lspconfig.lua_ls.setup { lspconfig.lua_ls.setup {
on_attach = custom_attach,
settings = { settings = {
Lua = { Lua = {
runtime = { runtime = {
-- Tell the language server which version of Lua you're using (most likely LuaJIT in the case of Neovim) -- Tell the language server which version of Lua you're using (most likely LuaJIT in the case of Neovim)
version = "LuaJIT", version = "LuaJIT",
}, },
hint = {
enable = true,
},
}, },
}, },
capabilities = capabilities, capabilities = capabilities,
} }
end end
-- Change diagnostic signs.
fn.sign_define("DiagnosticSignError", { text = '🆇', texthl = "DiagnosticSignError" })
fn.sign_define("DiagnosticSignWarn", { text = '⚠️', texthl = "DiagnosticSignWarn" })
fn.sign_define("DiagnosticSignInfo", { text = '', texthl = "DiagnosticSignInfo" })
fn.sign_define("DiagnosticSignHint", { text = '', texthl = "DiagnosticSignHint" })
-- global config for diagnostic
diagnostic.config {
underline = false,
virtual_text = false,
signs = true,
severity_sort = true,
}
-- lsp.handlers["textDocument/publishDiagnostics"] = lsp.with(lsp.diagnostic.on_publish_diagnostics, {
-- underline = false,
-- virtual_text = false,
-- signs = true,
-- update_in_insert = false,
-- })
-- Change border of documentation hover window, See https://github.com/neovim/neovim/pull/13998.
lsp.handlers["textDocument/hover"] = lsp.with(vim.lsp.handlers.hover, {
border = "rounded",
})

View File

@@ -1,5 +1,70 @@
local fn = vim.fn local fn = vim.fn
local git_status_cache = {}
local on_exit_fetch = function(result)
if result.code == 0 then
git_status_cache.fetch_success = true
end
end
local function handle_numeric_result(cache_key)
return function(result)
if result.code == 0 then
git_status_cache[cache_key] = tonumber(result.stdout:match("(%d+)")) or 0
end
end
end
local async_cmd = function(cmd_str, on_exit)
local cmd = vim.tbl_filter(function(element)
return element ~= ""
end, vim.split(cmd_str, " "))
vim.system(cmd, { text = true }, on_exit)
end
local async_git_status_update = function()
-- Fetch the latest changes from the remote repository (replace 'origin' if needed)
async_cmd("git fetch origin", on_exit_fetch)
if not git_status_cache.fetch_success then
return
end
-- Get the number of commits behind
-- the @{upstream} notation is inspired by post: https://www.reddit.com/r/neovim/comments/t48x5i/git_branch_aheadbehind_info_status_line_component/
-- note that here we should use double dots instead of triple dots
local behind_cmd_str = "git rev-list --count HEAD..@{upstream}"
async_cmd(behind_cmd_str, handle_numeric_result("behind_count"))
-- Get the number of commits ahead
local ahead_cmd_str = "git rev-list --count @{upstream}..HEAD"
async_cmd(ahead_cmd_str, handle_numeric_result("ahead_count"))
end
local function get_git_ahead_behind_info()
async_git_status_update()
local status = git_status_cache
if not status then
return ""
end
local msg = ""
if type(status.ahead_count) == "number" and status.ahead_count > 0 then
local ahead_str = string.format("↑[%d] ", status.ahead_count)
msg = msg .. ahead_str
end
if type(status.behind_count) == "number" and status.behind_count > 0 then
local behind_str = string.format("↓[%d] ", status.behind_count)
msg = msg .. behind_str
end
return msg
end
local function spell() local function spell()
if vim.o.spell then if vim.o.spell then
return string.format("[SPELL]") return string.format("[SPELL]")
@@ -119,7 +184,7 @@ local virtual_env = function()
end end
local get_active_lsp = function() local get_active_lsp = function()
local msg = "No Active Lsp" local msg = "🚫"
local buf_ft = vim.api.nvim_get_option_value("filetype", {}) local buf_ft = vim.api.nvim_get_option_value("filetype", {})
local clients = vim.lsp.get_clients { bufnr = 0 } local clients = vim.lsp.get_clients { bufnr = 0 }
if next(clients) == nil then if next(clients) == nil then
@@ -140,13 +205,23 @@ require("lualine").setup {
options = { options = {
icons_enabled = true, icons_enabled = true,
theme = "auto", theme = "auto",
component_separators = { left = "", right = "" },
section_separators = "", section_separators = "",
component_separators = "",
disabled_filetypes = {}, disabled_filetypes = {},
always_divide_middle = true, always_divide_middle = true,
refresh = {
statusline = 500,
},
}, },
sections = { sections = {
lualine_a = { "mode" }, lualine_a = {
{
"filename",
symbols = {
readonly = "[🔒]",
},
},
},
lualine_b = { lualine_b = {
{ {
"branch", "branch",
@@ -154,6 +229,15 @@ require("lualine").setup {
-- truncate branch name in case the name is too long -- truncate branch name in case the name is too long
return string.sub(name, 1, 20) return string.sub(name, 1, 20)
end, end,
color = { gui = "italic,bold" },
},
{
get_git_ahead_behind_info,
color = { fg = "#E0C479" },
},
{
"diff",
source = diff,
}, },
{ {
virtual_env, virtual_env,
@@ -162,18 +246,8 @@ require("lualine").setup {
}, },
lualine_c = { lualine_c = {
{ {
"filename", "%S",
symbols = { color = { gui = "bold", fg = "cyan" },
readonly = "[🔒]",
},
},
{
"diff",
source = diff,
},
{
ime_state,
color = { fg = "black", bg = "#f46868" },
}, },
{ {
spell, spell,
@@ -183,16 +257,27 @@ require("lualine").setup {
lualine_x = { lualine_x = {
{ {
get_active_lsp, get_active_lsp,
icon = " LSP:", icon = "📡",
}, },
{ {
"diagnostics", "diagnostics",
sources = { "nvim_diagnostic" }, sources = { "nvim_diagnostic" },
symbols = { error = "🆇 ", warn = "⚠️ ", info = " ", hint = "" }, symbols = { error = "🆇 ", warn = "⚠️ ", info = " ", hint = "" },
}, },
{
trailing_space,
color = "WarningMsg",
},
{
mixed_indent,
color = "WarningMsg",
},
}, },
lualine_y = { lualine_y = {
"encoding", {
"encoding",
fmt = string.upper,
},
{ {
"fileformat", "fileformat",
symbols = { symbols = {
@@ -202,17 +287,14 @@ require("lualine").setup {
}, },
}, },
"filetype", "filetype",
{
ime_state,
color = { fg = "black", bg = "#f46868" },
},
}, },
lualine_z = { lualine_z = {
{ "location",
trailing_space, "progress",
color = "WarningMsg",
},
{
mixed_indent,
color = "WarningMsg",
},
"progress"
}, },
}, },
inactive_sections = { inactive_sections = {

View File

@@ -1,6 +1,14 @@
-- Setup nvim-cmp. -- Setup nvim-cmp.
local cmp = require("cmp") local cmp = require("cmp")
local lspkind = require("lspkind")
-- The extentions needed by nvim-cmp should be loaded beforehand
require("cmp_nvim_lsp")
require("cmp_path")
require("cmp_buffer")
require("cmp_omni")
require("cmp_nvim_ultisnips")
local MiniIcons = require("mini.icons")
cmp.setup { cmp.setup {
snippet = { snippet = {
@@ -43,21 +51,14 @@ cmp.setup {
view = { view = {
entries = "custom", entries = "custom",
}, },
-- solution taken from https://github.com/echasnovski/mini.nvim/issues/1007#issuecomment-2258929830
formatting = { formatting = {
format = lspkind.cmp_format { format = function(_, vim_item)
mode = "symbol_text", local icon, hl = MiniIcons.get("lsp", vim_item.kind)
menu = { vim_item.kind = icon .. " " .. vim_item.kind
nvim_lsp = "[LSP]", vim_item.kind_hl_group = hl
ultisnips = "[US]", return vim_item
path = "[Path]", end,
buffer = "[Buffer]",
emoji = "[Emoji]",
omni = "[Omni]",
},
show_labelDetails = true,
maxwidth = 40,
ellipsis_char = "...",
},
}, },
} }

View File

@@ -3,7 +3,7 @@ local ffi = require("statuscol.ffidef")
local C = ffi.C local C = ffi.C
-- only show fold level up to this level -- only show fold level up to this level
local fold_level_limit = 2 local fold_level_limit = 3
local function foldfunc(args) local function foldfunc(args)
local foldinfo = C.fold_info(args.wp, args.lnum) local foldinfo = C.fold_info(args.wp, args.lnum)
if foldinfo.level > fold_level_limit then if foldinfo.level > fold_level_limit then

View File

@@ -4,7 +4,7 @@ hop.setup {
case_insensitive = true, case_insensitive = true,
char2_fallback_key = "<CR>", char2_fallback_key = "<CR>",
quit_key = "<Esc>", quit_key = "<Esc>",
match_mappings = { "zh_sc" } match_mappings = { "zh_sc" },
} }
keymap.set({ "n", "v", "o" }, "f", "", { keymap.set({ "n", "v", "o" }, "f", "", {
@@ -24,5 +24,5 @@ vim.api.nvim_create_autocmd("ColorScheme", {
hi HopNextKey1 cterm=bold ctermfg=176 gui=bold guibg=#ff00ff guifg=#ffffff hi HopNextKey1 cterm=bold ctermfg=176 gui=bold guibg=#ff00ff guifg=#ffffff
hi HopNextKey2 cterm=bold ctermfg=176 gui=bold guibg=#ff00ff guifg=#ffffff hi HopNextKey2 cterm=bold ctermfg=176 gui=bold guibg=#ff00ff guifg=#ffffff
]]) ]])
end end,
}) })

View File

@@ -0,0 +1,44 @@
require("nvim-treesitter.configs").setup {
textobjects = {
select = {
enable = true,
-- Automatically jump forward to textobj, similar to targets.vim
lookahead = true,
keymaps = {
-- You can use the capture groups defined in textobjects.scm
["af"] = "@function.outer",
["if"] = "@function.inner",
["ac"] = "@class.outer",
-- You can optionally set descriptions to the mappings (used in the desc parameter of
-- nvim_buf_set_keymap) which plugins like which-key display
["ic"] = { query = "@class.inner", desc = "Select inner part of a class region" },
},
-- You can choose the select mode (default is charwise 'v')
--
-- Can also be a function which gets passed a table with the keys
-- * query_string: eg '@function.inner'
-- * method: eg 'v' or 'o'
-- and should return the mode ('v', 'V', or '<c-v>') or a table
-- mapping query_strings to modes.
selection_modes = {
["@function.inner"] = "V", -- linewise
["@function.outer"] = "V", -- linewise
["@class.outer"] = "V", -- linewise
["@class.inner"] = "V", -- linewise
["@parameter.outer"] = "v", -- charwise
},
-- If you set this to `true` (default is `false`) then any textobject is
-- extended to include preceding or succeeding whitespace. Succeeding
-- whitespace has priority in order to act similarly to eg the built-in
-- `ap`.
--
-- Can also be a function which gets passed a table with the keys
-- * query_string: eg '@function.inner'
-- * selection_mode: eg 'v'
-- and should return true or false
include_surrounding_whitespace = false,
},
},
}

View File

@@ -3,6 +3,6 @@ require("nvim-treesitter.configs").setup {
ignore_install = {}, -- List of parsers to ignore installing ignore_install = {}, -- List of parsers to ignore installing
highlight = { highlight = {
enable = true, -- false will disable the whole extension enable = true, -- false will disable the whole extension
disable = { 'help' }, -- list of language that will be disabled disable = { "help" }, -- list of language that will be disabled
}, },
} }

View File

@@ -1,6 +1,6 @@
require("which-key").setup { require("which-key").setup {
preset = "modern", preset = "modern",
icons = { icons = {
mappings = false mappings = false,
} },
} }

View File

@@ -22,7 +22,7 @@ api.nvim_create_autocmd({ "TextYankPost" }, {
pattern = "*", pattern = "*",
group = yank_group, group = yank_group,
callback = function() callback = function()
vim.highlight.on_yank { higroup = "YankColor", timeout = 300 } vim.hl.on_yank { higroup = "YankColor", timeout = 300 }
end, end,
}) })
@@ -37,7 +37,8 @@ api.nvim_create_autocmd({ "CursorMoved" }, {
api.nvim_create_autocmd("TextYankPost", { api.nvim_create_autocmd("TextYankPost", {
pattern = "*", pattern = "*",
group = yank_group, group = yank_group,
callback = function(ev) ---@diagnostic disable-next-line: unused-local
callback = function(context)
if vim.v.event.operator == "y" then if vim.v.event.operator == "y" then
vim.fn.setpos(".", vim.g.current_cursor_pos) vim.fn.setpos(".", vim.g.current_cursor_pos)
end end
@@ -135,48 +136,6 @@ api.nvim_create_autocmd("TermOpen", {
end, end,
}) })
-- Return to last cursor position when opening a file, note that here we cannot use BufReadPost
-- as event. It seems that when BufReadPost is triggered, FileType event is still not run.
-- So the filetype for this buffer is empty string.
api.nvim_create_autocmd("FileType", {
group = api.nvim_create_augroup("resume_cursor_position", { clear = true }),
pattern = "*",
callback = function(ev)
local mark_pos = api.nvim_buf_get_mark(ev.buf, '"')
local last_cursor_line = mark_pos[1]
local max_line = vim.fn.line("$")
local buf_filetype = api.nvim_get_option_value("filetype", { buf = ev.buf })
local buftype = api.nvim_get_option_value("buftype", { buf = ev.buf })
-- only handle normal files
if buf_filetype == "" or buftype ~= "" then
return
end
-- Only resume last cursor position when there is no go-to-line command (something like '+23').
if vim.fn.match(vim.v.argv, [[\v^\+(\d){1,}$]]) ~= -1 then
return
end
if last_cursor_line > 1 and last_cursor_line <= max_line then
-- vim.print(string.format("mark_pos: %s", vim.inspect(mark_pos)))
-- it seems that without vim.schedule, the cursor position can not be set correctly
vim.schedule(function()
local status, result = pcall(api.nvim_win_set_cursor, 0, mark_pos)
if not status then
api.nvim_err_writeln(string.format("Failed to resume cursor position. Context %s, error: %s",
vim.inspect(ev), result))
end
end)
-- the following two ways also seem to work,
-- ref: https://www.reddit.com/r/neovim/comments/104lc26/how_can_i_press_escape_key_using_lua/
-- vim.api.nvim_feedkeys("g`\"", "n", true)
-- vim.fn.execute("normal! g`\"")
end
end,
})
local number_toggle_group = api.nvim_create_augroup("numbertoggle", { clear = true }) local number_toggle_group = api.nvim_create_augroup("numbertoggle", { clear = true })
api.nvim_create_autocmd({ "BufEnter", "FocusGained", "InsertLeave", "WinEnter" }, { api.nvim_create_autocmd({ "BufEnter", "FocusGained", "InsertLeave", "WinEnter" }, {
pattern = "*", pattern = "*",
@@ -204,20 +163,22 @@ api.nvim_create_autocmd("ColorScheme", {
pattern = "*", pattern = "*",
desc = "Define or overrride some highlight groups", desc = "Define or overrride some highlight groups",
callback = function() callback = function()
vim.cmd([[ -- For yank highlight
" For yank highlight vim.api.nvim_set_hl(0, "YankColor", { fg = "#34495E", bg = "#2ECC71", ctermfg = 59, ctermbg = 41 })
highlight YankColor ctermfg=59 ctermbg=41 guifg=#34495E guibg=#2ECC71
" For cursor colors -- For cursor colors
highlight Cursor cterm=bold gui=bold guibg=#00c918 guifg=black vim.api.nvim_set_hl(0, "Cursor", { fg = "black", bg = "#00c918", bold = true })
highlight Cursor2 guifg=red guibg=red vim.api.nvim_set_hl(0, "Cursor2", { fg = "red", bg = "red" })
" For floating windows border highlight -- For floating windows border highlight
highlight FloatBorder guifg=LightGreen guibg=NONE vim.api.nvim_set_hl(0, "FloatBorder", { fg = "LightGreen", bg = "None", bold = true })
" highlight for matching parentheses local hl = vim.api.nvim_get_hl(0, { name = "NormalFloat" })
highlight MatchParen cterm=bold,underline gui=bold,underline -- change the background color of floating window to None, so it blenders better
]]) vim.api.nvim_set_hl(0, "NormalFloat", { fg = hl.fg, bg = "None" })
-- highlight for matching parentheses
vim.api.nvim_set_hl(0, "MatchParen", { bold = true, underline = true })
end, end,
}) })
@@ -225,17 +186,18 @@ api.nvim_create_autocmd("BufEnter", {
pattern = "*", pattern = "*",
group = api.nvim_create_augroup("auto_close_win", { clear = true }), group = api.nvim_create_augroup("auto_close_win", { clear = true }),
desc = "Quit Nvim if we have only one window, and its filetype match our pattern", desc = "Quit Nvim if we have only one window, and its filetype match our pattern",
callback = function(ev) ---@diagnostic disable-next-line: unused-local
local quit_filetypes = {'qf', 'vista', 'NvimTree'} callback = function(context)
local quit_filetypes = { "qf", "vista", "NvimTree" }
local should_quit = true local should_quit = true
local tabwins = api.nvim_tabpage_list_wins(0) local tabwins = api.nvim_tabpage_list_wins(0)
for _, win in pairs(tabwins) do for _, win in pairs(tabwins) do
local buf = api.nvim_win_get_buf(win) local buf = api.nvim_win_get_buf(win)
local bf = fn.getbufvar(buf, '&filetype') local buf_type = vim.api.nvim_get_option_value("filetype", { buf = buf })
if fn.index(quit_filetypes, bf) == -1 then if not vim.tbl_contains(quit_filetypes, buf_type) then
should_quit = false should_quit = false
end end
end end
@@ -243,33 +205,40 @@ api.nvim_create_autocmd("BufEnter", {
if should_quit then if should_quit then
vim.cmd("qall") vim.cmd("qall")
end end
end end,
}) })
api.nvim_create_autocmd({"VimEnter", "DirChanged"}, { api.nvim_create_autocmd({ "VimEnter", "DirChanged" }, {
group = api.nvim_create_augroup("git_repo_check", { clear = true }), group = api.nvim_create_augroup("git_repo_check", { clear = true }),
pattern = "*", pattern = "*",
desc = "check if we are inside Git repo", desc = "check if we are inside Git repo",
command = "call utils#Inside_git_repo()" callback = function()
utils.inside_git_repo()
end,
}) })
-- ref: https://vi.stackexchange.com/a/169/15292 -- ref: https://vi.stackexchange.com/a/169/15292
api.nvim_create_autocmd("BufReadPre", { api.nvim_create_autocmd("BufReadPre", {
group = api.nvim_create_augroup("large_file", { clear = true }), group = api.nvim_create_augroup("large_file", { clear = true }),
pattern = "*", pattern = "*",
desc = "check if we are inside Git repo", desc = "optimize for large file",
callback = function (ev) callback = function(ev)
local file_size_limit =524288 -- 0.5MB local file_size_limit = 524288 -- 0.5MB
local f = ev.file local f = ev.file
if fn.getfsize(f) > file_size_limit or fn.getfsize(f) == -2 then if fn.getfsize(f) > file_size_limit or fn.getfsize(f) == -2 then
vim.o.eventignore = "all" vim.o.eventignore = "all"
-- show ruler
vim.o.ruler = true
-- turning off relative number helps a lot -- turning off relative number helps a lot
vim.wo.relativenumber = false vim.wo.relativenumber = false
vim.wo.number = false
vim.bo.swapfile = false vim.bo.swapfile = false
vim.bo.bufhidden = "unload" vim.bo.bufhidden = "unload"
vim.bo.undolevels = -1 vim.bo.undolevels = -1
end end
end end,
}) })

66
lua/diagnostic-conf.lua Normal file
View File

@@ -0,0 +1,66 @@
local diagnostic = vim.diagnostic
local api = vim.api
-- global config for diagnostic
diagnostic.config {
underline = false,
virtual_text = false,
virtual_lines = false,
signs = {
text = {
[diagnostic.severity.ERROR] = "🆇",
[diagnostic.severity.WARN] = "⚠️",
[diagnostic.severity.INFO] = "",
[diagnostic.severity.HINT] = "",
},
},
severity_sort = true,
float = {
source = true,
header = "Diagnostics:",
prefix = " ",
border = "single",
},
}
-- set quickfix list from diagnostics in a certain buffer, not the whole workspace
local set_qflist = function(buf_num, severity)
local diagnostics = nil
diagnostics = diagnostic.get(buf_num, { severity = severity })
local qf_items = diagnostic.toqflist(diagnostics)
vim.fn.setqflist({}, " ", { title = "Diagnostics", items = qf_items })
-- open quickfix by default
vim.cmd([[copen]])
end
-- this puts diagnostics from opened files to quickfix
vim.keymap.set("n", "<space>qw", diagnostic.setqflist, { desc = "put window diagnostics to qf" })
-- this puts diagnostics from current buffer to quickfix
vim.keymap.set("n", "<space>qb", function()
set_qflist(0)
end, { desc = "put buffer diagnostics to qf" })
-- automatically show diagnostic in float win for current line
api.nvim_create_autocmd("CursorHold", {
pattern = "*",
callback = function()
if #vim.diagnostic.get(0) == 0 then
return
end
if not vim.b.diagnostics_pos then
vim.b.diagnostics_pos = { nil, nil }
end
local cursor_pos = api.nvim_win_get_cursor(0)
if not vim.deep_equal(cursor_pos, vim.b.diagnostics_pos) then
diagnostic.open_float { width = 100 }
end
vim.b.diagnostics_pos = cursor_pos
end,
})

View File

@@ -1,49 +1,50 @@
local fn = vim.fn local fn = vim.fn
local api = vim.api local api = vim.api
local utils = require('utils') local utils = require("utils")
------------------------------------------------------------------------ ------------------------------------------------------------------------
-- custom variables -- -- custom variables --
------------------------------------------------------------------------ ------------------------------------------------------------------------
vim.g.is_win = (utils.has("win32") or utils.has("win64")) and true or false vim.g.is_win = (utils.has("win32") or utils.has("win64")) and true or false
vim.g.is_linux = (utils.has("unix") and (not utils.has("macunix"))) and true or false vim.g.is_linux = (utils.has("unix") and (not utils.has("macunix"))) and true or false
vim.g.is_mac = utils.has("macunix") and true or false vim.g.is_mac = utils.has("macunix") and true or false
vim.g.logging_level = "info" vim.g.logging_level = vim.log.levels.INFO
------------------------------------------------------------------------ ------------------------------------------------------------------------
-- builtin variables -- -- builtin variables --
------------------------------------------------------------------------ ------------------------------------------------------------------------
vim.g.loaded_perl_provider = 0 -- Disable perl provider vim.g.loaded_perl_provider = 0 -- Disable perl provider
vim.g.loaded_ruby_provider = 0 -- Disable ruby provider vim.g.loaded_ruby_provider = 0 -- Disable ruby provider
vim.g.loaded_node_provider = 0 -- Disable node provider vim.g.loaded_node_provider = 0 -- Disable node provider
vim.g.did_install_default_menus = 1 -- do not load menu vim.g.did_install_default_menus = 1 -- do not load menu
if utils.executable('python3') then if utils.executable("python3") then
if vim.g.is_win then if vim.g.is_win then
vim.g.python3_host_prog = fn.substitute(fn.exepath("python3"), ".exe$", '', 'g') vim.g.python3_host_prog = fn.substitute(fn.exepath("python3"), ".exe$", "", "g")
else else
vim.g.python3_host_prog = fn.exepath("python3") vim.g.python3_host_prog = fn.exepath("python3")
end end
else else
api.nvim_err_writeln("Python3 executable not found! You must install Python3 and set its PATH correctly!") local msg = "Python3 executable not found! You must install Python3 and set its PATH correctly!"
api.nvim_echo({ { msg } }, true, { err = true })
return return
end end
-- Custom mapping <leader> (see `:h mapleader` for more info) -- Custom mapping <leader> (see `:h mapleader` for more info)
vim.g.mapleader = ',' vim.g.mapleader = ","
-- Enable highlighting for lua HERE doc inside vim script -- Enable highlighting for lua HERE doc inside vim script
vim.g.vimsyn_embed = 'l' vim.g.vimsyn_embed = "l"
-- Use English as main language -- Use English as main language
vim.cmd [[language en_US.UTF-8]] vim.cmd([[language en_US.UTF-8]])
-- Disable loading certain plugins -- Disable loading certain plugins
-- Whether to load netrw by default, see https://github.com/bling/dotvim/issues/4 -- Whether to load netrw by default, see https://github.com/bling/dotvim/issues/4
vim.g.loaded_netrw = 1 vim.g.loaded_netrw = 1
vim.g.loaded_netrwPlugin = 1 vim.g.loaded_netrwPlugin = 1
vim.g.netrw_liststyle = 3 vim.g.netrw_liststyle = 3
if vim.g.is_win then if vim.g.is_win then
@@ -68,3 +69,6 @@ vim.g.loaded_matchparen = 1
-- Disable sql omni completion, it is broken. -- Disable sql omni completion, it is broken.
vim.g.loaded_sql_completion = 1 vim.g.loaded_sql_completion = 1
-- control how to show health check window
vim.g.health = { style = nil }

View File

@@ -23,19 +23,6 @@ keymap.set("n", "<leader>q", "<cmd>x<cr>", { silent = true, desc = "quit current
-- Quit all opened buffers -- Quit all opened buffers
keymap.set("n", "<leader>Q", "<cmd>qa!<cr>", { silent = true, desc = "quit nvim" }) keymap.set("n", "<leader>Q", "<cmd>qa!<cr>", { silent = true, desc = "quit nvim" })
-- Navigation in the location and quickfix list
keymap.set("n", "[l", "<cmd>lprevious<cr>zv", { silent = true, desc = "previous location item" })
keymap.set("n", "]l", "<cmd>lnext<cr>zv", { silent = true, desc = "next location item" })
keymap.set("n", "[L", "<cmd>lfirst<cr>zv", { silent = true, desc = "first location item" })
keymap.set("n", "]L", "<cmd>llast<cr>zv", { silent = true, desc = "last location item" })
keymap.set("n", "[q", "<cmd>cprevious<cr>zv", { silent = true, desc = "previous qf item" })
keymap.set("n", "]q", "<cmd>cnext<cr>zv", { silent = true, desc = "next qf item" })
keymap.set("n", "[Q", "<cmd>cfirst<cr>zv", { silent = true, desc = "first qf item" })
keymap.set("n", "]Q", "<cmd>clast<cr>zv", { silent = true, desc = "last qf item" })
-- Close location list or quickfix list if they are present, see https://superuser.com/q/355325/736190 -- Close location list or quickfix list if they are present, see https://superuser.com/q/355325/736190
keymap.set("n", [[\x]], "<cmd>windo lclose <bar> cclose <cr>", { keymap.set("n", [[\x]], "<cmd>windo lclose <bar> cclose <cr>", {
silent = true, silent = true,
@@ -143,9 +130,6 @@ keymap.set("x", "c", '"_c')
-- Remove trailing whitespace characters -- Remove trailing whitespace characters
keymap.set("n", "<leader><space>", "<cmd>StripTrailingWhitespace<cr>", { desc = "remove trailing space" }) keymap.set("n", "<leader><space>", "<cmd>StripTrailingWhitespace<cr>", { desc = "remove trailing space" })
-- check the syntax group of current cursor position
keymap.set("n", "<leader>st", "<cmd>call utils#SynGroup()<cr>", { desc = "check syntax group" })
-- Copy entire buffer. -- Copy entire buffer.
keymap.set("n", "<leader>y", "<cmd>%yank<cr>", { desc = "yank entire buffer" }) keymap.set("n", "<leader>y", "<cmd>%yank<cr>", { desc = "yank entire buffer" })

View File

@@ -22,19 +22,15 @@ end
local plugin_specs = { local plugin_specs = {
-- auto-completion engine -- auto-completion engine
{ "hrsh7th/cmp-nvim-lsp", lazy = true },
{ "hrsh7th/cmp-path", lazy = true },
{ "hrsh7th/cmp-buffer", lazy = true },
{ "hrsh7th/cmp-omni", lazy = true },
{ "quangnguyen30192/cmp-nvim-ultisnips", lazy = true },
{ {
"iguanacucumber/magazine.nvim", "hrsh7th/nvim-cmp",
name = "nvim-cmp", name = "nvim-cmp",
-- event = 'InsertEnter', event = "InsertEnter",
event = "VeryLazy",
dependencies = {
"hrsh7th/cmp-nvim-lsp",
"onsails/lspkind-nvim",
"hrsh7th/cmp-path",
"hrsh7th/cmp-buffer",
"hrsh7th/cmp-omni",
"quangnguyen30192/cmp-nvim-ultisnips",
},
config = function() config = function()
require("config.nvim-cmp") require("config.nvim-cmp")
end, end,
@@ -46,25 +42,29 @@ local plugin_specs = {
require("config.lsp") require("config.lsp")
end, end,
}, },
{ {
"nvim-treesitter/nvim-treesitter", "dnlhc/glance.nvim",
enabled = function() config = function()
if vim.g.is_mac then require("config.glance")
return true
end
return false
end, end,
event = "VeryLazy", event = "VeryLazy",
},
{
"nvim-treesitter/nvim-treesitter",
lazy = true,
build = ":TSUpdate", build = ":TSUpdate",
config = function() config = function()
require("config.treesitter") require("config.treesitter")
end, end,
}, },
{
-- Python-related text object "nvim-treesitter/nvim-treesitter-textobjects",
{ "jeetsukumaran/vim-pythonsense", ft = { "python" } }, event = "VeryLazy",
branch = "master",
config = function()
require("config.treesitter-textobjects")
end,
},
{ "machakann/vim-swap", event = "VeryLazy" }, { "machakann/vim-swap", event = "VeryLazy" },
-- IDE for Lisp -- IDE for Lisp
@@ -72,10 +72,7 @@ local plugin_specs = {
{ {
"vlime/vlime", "vlime/vlime",
enabled = function() enabled = function()
if utils.executable("sbcl") then return utils.executable("sbcl")
return true
end
return false
end, end,
config = function(plugin) config = function(plugin)
vim.opt.rtp:append(plugin.dir .. "/vim") vim.opt.rtp:append(plugin.dir .. "/vim")
@@ -86,7 +83,7 @@ local plugin_specs = {
-- Super fast buffer jump -- Super fast buffer jump
{ {
"smoka7/hop.nvim", "smoka7/hop.nvim",
event = "VeryLazy", keys = { "f" },
config = function() config = function()
require("config.nvim_hop") require("config.nvim_hop")
end, end,
@@ -101,20 +98,6 @@ local plugin_specs = {
require("config.hlslens") require("config.hlslens")
end, end,
}, },
{
"Yggdroot/LeaderF",
cmd = "Leaderf",
build = function()
local leaderf_path = plugin_dir .. "/LeaderF"
vim.opt.runtimepath:append(leaderf_path)
vim.cmd("runtime! plugin/leaderf.vim")
if not vim.g.is_win then
vim.cmd("LeaderfInstallCExtension")
end
end,
},
"nvim-lua/plenary.nvim",
{ {
"nvim-telescope/telescope.nvim", "nvim-telescope/telescope.nvim",
cmd = "Telescope", cmd = "Telescope",
@@ -124,18 +107,16 @@ local plugin_specs = {
}, },
{ {
"ibhagwan/fzf-lua", "ibhagwan/fzf-lua",
-- optional for icon support
dependencies = { "nvim-tree/nvim-web-devicons" },
config = function() config = function()
-- calling `setup` is optional for customization require("config.fzf-lua")
require("fzf-lua").setup {}
end, end,
event = "VeryLazy",
}, },
{ {
"MeanderingProgrammer/markdown.nvim", "MeanderingProgrammer/markdown.nvim",
main = "render-markdown", main = "render-markdown",
opts = {}, opts = {},
dependencies = { "nvim-treesitter/nvim-treesitter", "nvim-tree/nvim-web-devicons" }, ft = { "markdown" },
}, },
-- A list of colorscheme plugin you may want to try. Find what suits you. -- A list of colorscheme plugin you may want to try. Find what suits you.
{ "navarasu/onedark.nvim", lazy = true }, { "navarasu/onedark.nvim", lazy = true },
@@ -154,11 +135,22 @@ local plugin_specs = {
branch = "v2", branch = "v2",
}, },
{ "rebelot/kanagawa.nvim", lazy = true }, { "rebelot/kanagawa.nvim", lazy = true },
{ "nvim-tree/nvim-web-devicons", event = "VeryLazy" },
-- plugins to provide nerdfont icons
{
"echasnovski/mini.icons",
version = false,
config = function()
-- this is the compatibility fix for plugins that only support nvim-web-devicons
require("mini.icons").mock_nvim_web_devicons()
require("mini.icons").tweak_lsp_kind()
end,
lazy = true,
},
{ {
"nvim-lualine/lualine.nvim", "nvim-lualine/lualine.nvim",
event = "VeryLazy", event = "BufRead",
cond = firenvim_not_active, cond = firenvim_not_active,
config = function() config = function()
require("config.lualine") require("config.lualine")
@@ -184,11 +176,16 @@ local plugin_specs = {
}, },
{ {
"lukas-reineke/indent-blankline.nvim", "echasnovski/mini.indentscope",
event = "VeryLazy", version = false,
main = "ibl",
config = function() config = function()
require("config.indent-blankline") local mini_indent = require("mini.indentscope")
mini_indent.setup {
draw = {
animation = mini_indent.gen_animation.none(),
},
symbol = "",
}
end, end,
}, },
{ {
@@ -214,7 +211,7 @@ local plugin_specs = {
end, end,
}, },
-- Highlight URLs inside vim -- Highlight URLs inside vim
{ "itchyny/vim-highlighturl", event = "VeryLazy" }, { "itchyny/vim-highlighturl", event = "BufReadPost" },
-- notification plugin -- notification plugin
{ {
@@ -225,6 +222,8 @@ local plugin_specs = {
end, end,
}, },
{ "nvim-lua/plenary.nvim", lazy = true },
-- 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.
{ {
@@ -235,13 +234,8 @@ local plugin_specs = {
vim.g.netrw_nogx = 1 -- disable netrw gx vim.g.netrw_nogx = 1 -- disable netrw gx
end, end,
enabled = function() enabled = function()
if vim.g.is_win or vim.g.is_mac then return vim.g.is_win or vim.g.is_mac
return true
else
return false
end
end, end,
dependencies = { "nvim-lua/plenary.nvim" },
config = true, -- default settings config = true, -- default settings
submodules = false, -- not needed, submodules are required only for tests submodules = false, -- not needed, submodules are required only for tests
}, },
@@ -251,11 +245,7 @@ local plugin_specs = {
{ {
"liuchengxu/vista.vim", "liuchengxu/vista.vim",
enabled = function() enabled = function()
if utils.executable("ctags") then return utils.executable("ctags")
return true
else
return false
end
end, end,
cmd = "Vista", cmd = "Vista",
}, },
@@ -273,27 +263,24 @@ local plugin_specs = {
}, },
-- Comment plugin -- Comment plugin
{ "tpope/vim-commentary", event = "VeryLazy" }, { "tpope/vim-commentary", keys = {
{ "gc", mode = "n" },
{ "gc", mode = "v" },
} },
-- Multiple cursor plugin like Sublime Text? -- Multiple cursor plugin like Sublime Text?
-- 'mg979/vim-visual-multi' -- 'mg979/vim-visual-multi'
-- Autosave files on certain events
{ "907th/vim-auto-save", event = "InsertEnter" },
-- Show undo history visually -- Show undo history visually
{ "simnalamburt/vim-mundo", cmd = { "MundoToggle", "MundoShow" } }, { "simnalamburt/vim-mundo", cmd = { "MundoToggle", "MundoShow" } },
-- better UI for some nvim actions
{ "stevearc/dressing.nvim" },
-- Manage your yank history -- Manage your yank history
{ {
"gbprod/yanky.nvim", "gbprod/yanky.nvim",
config = function() config = function()
require("config.yanky") require("config.yanky")
end, end,
event = "VeryLazy", cmd = "YankyRingHistory",
}, },
-- Handy unix command inside Vim (Rename, Move etc.) -- Handy unix command inside Vim (Rename, Move etc.)
@@ -307,10 +294,7 @@ local plugin_specs = {
{ {
"lyokha/vim-xkbswitch", "lyokha/vim-xkbswitch",
enabled = function() enabled = function()
if vim.g.is_mac and utils.executable("xkbswitch") then return vim.g.is_mac and utils.executable("xkbswitch")
return true
end
return false
end, end,
event = { "InsertEnter" }, event = { "InsertEnter" },
}, },
@@ -318,10 +302,7 @@ local plugin_specs = {
{ {
"Neur1n/neuims", "Neur1n/neuims",
enabled = function() enabled = function()
if vim.g.is_win then return vim.g.is_win
return true
end
return false
end, end,
event = { "InsertEnter" }, event = { "InsertEnter" },
}, },
@@ -340,7 +321,14 @@ local plugin_specs = {
-- Better git log display -- Better git log display
{ "rbong/vim-flog", cmd = { "Flog" } }, { "rbong/vim-flog", cmd = { "Flog" } },
{ "akinsho/git-conflict.nvim", version = "*", config = true }, {
"akinsho/git-conflict.nvim",
version = "*",
event = "VeryLazy",
config = function()
require("config.git-conflict")
end,
},
{ {
"ruifm/gitlinker.nvim", "ruifm/gitlinker.nvim",
event = "User InGitRepo", event = "User InGitRepo",
@@ -355,13 +343,12 @@ local plugin_specs = {
config = function() config = function()
require("config.gitsigns") require("config.gitsigns")
end, end,
event = "BufRead",
}, },
-- Better git commit experience
{ "rhysd/committia.vim", lazy = true },
{ {
"sindrets/diffview.nvim", "sindrets/diffview.nvim",
cmd = { "DiffviewOpen" },
}, },
{ {
@@ -372,40 +359,31 @@ local plugin_specs = {
end, end,
}, },
-- Another markdown plugin
{ "preservim/vim-markdown", ft = { "markdown" } },
-- Faster footnote generation -- Faster footnote generation
{ "vim-pandoc/vim-markdownfootnotes", ft = { "markdown" } }, { "vim-pandoc/vim-markdownfootnotes", ft = { "markdown" } },
-- Vim tabular plugin for manipulate tabular, required by markdown plugins -- Vim tabular plugin for manipulate tabular, required by markdown plugins
{ "godlygeek/tabular", cmd = { "Tabularize" } }, { "godlygeek/tabular", ft = { "markdown" } },
-- Markdown previewing (only for Mac and Windows) -- Markdown previewing (only for Mac and Windows)
{ {
"iamcco/markdown-preview.nvim", "iamcco/markdown-preview.nvim",
enabled = function() enabled = function()
if vim.g.is_win or vim.g.is_mac then return vim.g.is_win or vim.g.is_mac
return true
end
return false
end, end,
build = "cd app && npm install", build = "cd app && npm install && git restore .",
ft = { "markdown" }, ft = { "markdown" },
}, },
{ {
"rhysd/vim-grammarous", "rhysd/vim-grammarous",
enabled = function() enabled = function()
if vim.g.is_mac then return vim.g.is_mac
return true
end
return false
end, end,
ft = { "markdown" }, ft = { "markdown" },
}, },
{ "chrisbra/unicode.vim", event = "VeryLazy" }, { "chrisbra/unicode.vim", keys = { "ga" }, cmd = { "UnicodeSearch" } },
-- Additional powerful text object for vim, this plugin should be studied -- Additional powerful text object for vim, this plugin should be studied
-- carefully to use its full power -- carefully to use its full power
@@ -414,17 +392,11 @@ local plugin_specs = {
-- Plugin to manipulate character pairs quickly -- Plugin to manipulate character pairs quickly
{ "machakann/vim-sandwich", event = "VeryLazy" }, { "machakann/vim-sandwich", event = "VeryLazy" },
-- Add indent object for vim (useful for languages like Python)
{ "michaeljsmith/vim-indent-object", event = "VeryLazy" },
-- Only use these plugin on Windows and Mac and when LaTeX is installed -- Only use these plugin on Windows and Mac and when LaTeX is installed
{ {
"lervag/vimtex", "lervag/vimtex",
enabled = function() enabled = function()
if utils.executable("latex") then return utils.executable("latex")
return true
end
return false
end, end,
ft = { "tex" }, ft = { "tex" },
}, },
@@ -435,10 +407,7 @@ local plugin_specs = {
{ {
"tmux-plugins/vim-tmux", "tmux-plugins/vim-tmux",
enabled = function() enabled = function()
if utils.executable("tmux") then return utils.executable("tmux")
return true
end
return false
end, end,
ft = { "tmux" }, ft = { "tmux" },
}, },
@@ -455,8 +424,7 @@ local plugin_specs = {
{ {
"glacambre/firenvim", "glacambre/firenvim",
enabled = function() enabled = function()
local result = vim.g.is_win or vim.g.is_mac return vim.g.is_win or vim.g.is_mac
return result
end, end,
-- it seems that we can only call the firenvim function directly. -- it seems that we can only call the firenvim function directly.
-- Using vim.fn or vim.cmd to call this function will fail. -- Using vim.fn or vim.cmd to call this function will fail.
@@ -479,10 +447,7 @@ local plugin_specs = {
{ {
"sakhnik/nvim-gdb", "sakhnik/nvim-gdb",
enabled = function() enabled = function()
if vim.g.is_win or vim.g.is_linux then return vim.g.is_win or vim.g.is_linux
return true
end
return false
end, end,
build = { "bash install.sh" }, build = { "bash install.sh" },
lazy = true, lazy = true,
@@ -494,10 +459,7 @@ local plugin_specs = {
{ {
"ojroques/vim-oscyank", "ojroques/vim-oscyank",
enabled = function() enabled = function()
if vim.g.is_linux then return vim.g.is_linux
return true
end
return false
end, end,
cmd = { "OSCYank", "OSCYankReg" }, cmd = { "OSCYank", "OSCYankReg" },
}, },
@@ -516,15 +478,30 @@ local plugin_specs = {
require("config.which-key") require("config.which-key")
end, end,
}, },
{
"folke/snacks.nvim",
priority = 1000,
lazy = false,
opts = {
-- more beautiful vim.ui.input
input = {
enabled = true,
win = {
relative = "cursor",
backdrop = true,
},
},
-- more beautiful vim.ui.select
picker = { enabled = true },
},
},
-- show and trim trailing whitespaces -- show and trim trailing whitespaces
{ "jdhao/whitespace.nvim", event = "VeryLazy" }, { "jdhao/whitespace.nvim", event = "VeryLazy" },
-- file explorer -- file explorer
{ {
"nvim-tree/nvim-tree.lua", "nvim-tree/nvim-tree.lua",
event = "VeryLazy", keys = { "<space>s" },
dependencies = { "nvim-tree/nvim-web-devicons" },
config = function() config = function()
require("config.nvim-tree") require("config.nvim-tree")
end, end,
@@ -532,8 +509,7 @@ local plugin_specs = {
{ {
"j-hui/fidget.nvim", "j-hui/fidget.nvim",
event = "VeryLazy", event = "BufRead",
tag = "legacy",
config = function() config = function()
require("config.fidget-nvim") require("config.fidget-nvim")
end, end,
@@ -541,20 +517,24 @@ local plugin_specs = {
{ {
"folke/lazydev.nvim", "folke/lazydev.nvim",
ft = "lua", -- only load on lua files ft = "lua", -- only load on lua files
opts = {}, opts = {
library = {
-- See the configuration section for more details
-- Load luvit types when the `vim.uv` word is found
{ path = "${3rd}/luv/library", words = { "vim%.uv" } },
},
},
}, },
{ {
"CopilotC-Nvim/CopilotChat.nvim", "CopilotC-Nvim/CopilotChat.nvim",
branch = "canary",
dependencies = { dependencies = {
{ "zbirenbaum/copilot.lua" }, -- or github/copilot.vim { "zbirenbaum/copilot.lua" }, -- or github/copilot.vim
{ "nvim-lua/plenary.nvim" }, -- for curl, log wrapper
}, },
opts = { opts = {
debug = true, -- Enable debugging debug = true, -- Enable debugging
-- See Configuration section for rest -- See Configuration section for rest
}, },
-- See Commands section for default commands if you want to lazy load on them cmd = { "CopilotChat" },
}, },
{ {
"zbirenbaum/copilot.lua", "zbirenbaum/copilot.lua",
@@ -571,10 +551,29 @@ local plugin_specs = {
config = function() config = function()
require("config.live-command") require("config.live-command")
end, end,
},
{
-- show hint for code actions, the user can also implement code actions themselves,
-- see discussion here: https://github.com/neovim/neovim/issues/14869
"kosayoda/nvim-lightbulb",
config = function()
require("config.lightbulb")
end,
event = "LspAttach",
},
{
"Bekaboo/dropbar.nvim",
event = "VeryLazy", event = "VeryLazy",
}, },
{
"catgoose/nvim-colorizer.lua",
event = "BufReadPre",
opts = { -- set to setup table
},
},
} }
---@diagnostic disable-next-line: missing-fields
require("lazy").setup { require("lazy").setup {
spec = plugin_specs, spec = plugin_specs,
ui = { ui = {
@@ -584,5 +583,6 @@ require("lazy").setup {
}, },
rocks = { rocks = {
enabled = false, enabled = false,
hererocks = false,
}, },
} }

View File

@@ -3,12 +3,11 @@ local version = vim.version
local M = {} local M = {}
--- Check if an executable exists
--- @param name string An executable name/path
--- @return boolean
function M.executable(name) function M.executable(name)
if fn.executable(name) > 0 then return fn.executable(name) > 0
return true
end
return false
end end
--- check whether a feature exists in Nvim --- check whether a feature exists in Nvim
@@ -61,7 +60,7 @@ function M.is_compatible_version(expected_version)
if expect_ver == nil then if expect_ver == nil then
local msg = string.format("Unsupported version string: %s", expected_version) local msg = string.format("Unsupported version string: %s", expected_version)
vim.api.nvim_err_writeln(msg) vim.api.nvim_echo({ { msg } }, true, { err = true })
return false return false
end end
@@ -73,10 +72,24 @@ function M.is_compatible_version(expected_version)
expected_version, expected_version,
_ver _ver
) )
vim.api.nvim_err_writeln(msg) vim.api.nvim_echo({ { msg } }, true, { err = true })
end end
return true return true
end end
--- check if we are inside a git repo
--- @return boolean
function M.inside_git_repo()
local result = vim.system({ "git", "rev-parse", "--is-inside-work-tree" }, { text = true }):wait()
if result.code ~= 0 then
return false
end
-- Manually trigger a special user autocmd InGitRepo (used lazyloading.
vim.cmd([[doautocmd User InGitRepo]])
return true
end
return M return M

59
plugin/command.lua Normal file
View File

@@ -0,0 +1,59 @@
-- Copy file path to clipboard
vim.api.nvim_create_user_command("CopyPath", function(context)
local full_path = vim.fn.glob("%:p")
local file_path = nil
if context["args"] == "nameonly" then
file_path = vim.fn.fnamemodify(full_path, ":t")
end
-- get the file path relative to project root
if context["args"] == "relative" then
local project_marker = { ".git", "pyproject.toml" }
local project_root = vim.fs.root(0, project_marker)
if project_root == nil then
vim.print("can not find project root")
return
end
file_path = vim.fn.substitute(full_path, project_root, "<project-root>", "g")
end
if context["args"] == "absolute" then
file_path = full_path
end
vim.fn.setreg("+", file_path)
vim.print("Filepath copied to clipboard!")
end, {
bang = false,
nargs = 1,
force = true,
desc = "Copy current file path to clipboard",
complete = function()
return { "nameonly", "relative", "absolute" }
end,
})
-- JSON format part of or the whole file
vim.api.nvim_create_user_command("JSONFormat", function(context)
local range = context["range"]
local line1 = context["line1"]
local line2 = context["line2"]
if range == 0 then
-- the command is invoked without range, then we assume whole buffer
local cmd_str = string.format("%s,%s!python -m json.tool", line1, line2)
vim.fn.execute(cmd_str)
elseif range == 2 then
-- the command is invoked with some range
local cmd_str = string.format("%s,%s!python -m json.tool", line1, line2)
vim.fn.execute(cmd_str)
else
local msg = string.format("unsupported range: %s", range)
vim.api.nvim_echo({ { msg } }, true, { err = true })
end
end, {
desc = "Format JSON string",
range = "%",
})

View File

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

View File

@@ -470,3 +470,9 @@ qpdf
Elasticsearch Elasticsearch
kibana kibana
submodule submodule
unix
GCP
Kubernetes
pubsub
Luarocks
luarocks

View File

@@ -72,7 +72,7 @@ set wildmode=list:longest
set scrolloff=3 set scrolloff=3
" Use mouse to select and resize windows, etc. " Use mouse to select and resize windows, etc.
set mouse=nic " Enable mouse in several mode set mouse=n
set mousemodel=popup " Set the behaviour of mouse set mousemodel=popup " Set the behaviour of mouse
set mousescroll=ver:1,hor:0 set mousescroll=ver:1,hor:0
@@ -115,6 +115,8 @@ set shortmess+=S
" Disable showing intro message (:intro) " Disable showing intro message (:intro)
set shortmess+=I set shortmess+=I
set messagesopt=hit-enter,history:500
" Completion behaviour " Completion behaviour
" set completeopt+=noinsert " Auto select the first completion entry " set completeopt+=noinsert " Auto select the first completion entry
set completeopt+=menuone " Show menu even if there is only one item set completeopt+=menuone " Show menu even if there is only one item
@@ -124,6 +126,7 @@ set pumheight=10 " Maximum number of items to show in popup menu
set pumblend=5 " pseudo transparency for completion menu set pumblend=5 " pseudo transparency for completion menu
set winblend=0 " pseudo transparency for floating window set winblend=0 " pseudo transparency for floating window
set winborder=none
" Insert mode key word completion setting " Insert mode key word completion setting
set complete+=kspell complete-=w complete-=b complete-=u complete-=t set complete+=kspell complete-=w complete-=b complete-=u complete-=t
@@ -179,3 +182,5 @@ set diffopt+=linematch:60
set nowrap " do no wrap set nowrap " do no wrap
set noruler set noruler
set showcmdloc=statusline

View File

@@ -34,85 +34,6 @@ let g:UltiSnipsSnippetDirectories=['UltiSnips', 'my_snippets']
"""""""""""""""""""""""""" vlime settings """""""""""""""""""""""""""""""" """""""""""""""""""""""""" vlime settings """"""""""""""""""""""""""""""""
command! -nargs=0 StartVlime call jobstart(printf("sbcl --load %s/vlime/lisp/start-vlime.lisp", g:package_home)) command! -nargs=0 StartVlime call jobstart(printf("sbcl --load %s/vlime/lisp/start-vlime.lisp", g:package_home))
"""""""""""""""""""""""""""""LeaderF settings"""""""""""""""""""""
" Do not use cache file
let g:Lf_UseCache = 0
" Refresh each time we call leaderf
let g:Lf_UseMemoryCache = 0
" Ignore certain files and directories when searching files
let g:Lf_WildIgnore = {
\ 'dir': ['.git', '__pycache__', '.DS_Store', '*_cache'],
\ 'file': ['*.exe', '*.dll', '*.so', '*.o', '*.pyc', '*.jpg', '*.png',
\ '*.gif', '*.svg', '*.ico', '*.db', '*.tgz', '*.tar.gz', '*.gz',
\ '*.zip', '*.bin', '*.pptx', '*.xlsx', '*.docx', '*.pdf', '*.tmp',
\ '*.wmv', '*.mkv', '*.mp4', '*.rmvb', '*.ttf', '*.ttc', '*.otf',
\ '*.mp3', '*.aac']
\}
" Do not show fancy icons for Linux server.
if g:is_linux
let g:Lf_ShowDevIcons = 0
endif
" Only fuzzy-search files names
let g:Lf_DefaultMode = 'FullPath'
" Do not use version control tool to list files under a directory since
" submodules are not searched by default.
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
let g:Lf_ShortcutF = ''
let g:Lf_ShortcutB = ''
" set up working directory for git repository
let g:Lf_WorkingDirectoryMode = 'a'
" Search files in popup window
nnoremap <silent> <leader>ff :<C-U>Leaderf file --popup<CR>
" Grep project files in popup window
nnoremap <silent> <leader>fg :<C-U>Leaderf rg --no-messages --popup<CR>
" Search vim help files
nnoremap <silent> <leader>fh :<C-U>Leaderf help --popup<CR>
" Search tags in current buffer
nnoremap <silent> <leader>ft :<C-U>Leaderf bufTag --popup<CR>
" Switch buffers
nnoremap <silent> <leader>fb :<C-U>Leaderf buffer --popup<CR>
" Search recent files
nnoremap <silent> <leader>fr :<C-U>Leaderf mru --popup --absolute-path<CR>
let g:Lf_PopupColorscheme = 'gruvbox_material'
" Change keybinding in LeaderF prompt mode, use ctrl-n and ctrl-p to navigate
" items.
let g:Lf_CommandMap = {'<C-J>': ['<C-N>'], '<C-K>': ['<C-P>']}
" do not preview results, it will add the file to buffer list
let g:Lf_PreviewResult = {
\ 'File': 0,
\ 'Buffer': 0,
\ 'Mru': 0,
\ 'Tag': 0,
\ 'BufTag': 1,
\ 'Function': 1,
\ 'Line': 0,
\ 'Colorscheme': 0,
\ 'Rg': 0,
\ 'Gtags': 0
\}
""""""""""""""""""""""""""" vista settings """""""""""""""""""""""""""""""""" """"""""""""""""""""""""""" vista settings """"""""""""""""""""""""""""""""""
let g:vista#renderer#icons = { let g:vista#renderer#icons = {
\ 'member': '', \ 'member': '',
@@ -151,25 +72,6 @@ let g:neoformat_c_clangformat = {
let g:neoformat_enabled_cpp = ['clangformat'] let g:neoformat_enabled_cpp = ['clangformat']
let g:neoformat_enabled_c = ['clangformat'] let g:neoformat_enabled_c = ['clangformat']
"""""""""""""""""""""""""vim-markdown settings"""""""""""""""""""
" Disable header folding
let g:vim_markdown_folding_disabled = 1
" Whether to use conceal feature in markdown
let g:vim_markdown_conceal = 1
" Disable math tex conceal and syntax highlight
let g:tex_conceal = ''
let g:vim_markdown_math = 0
" Support front matter of various format
let g:vim_markdown_frontmatter = 1 " for YAML format
let g:vim_markdown_toml_frontmatter = 1 " for TOML format
let g:vim_markdown_json_frontmatter = 1 " for JSON format
" Let the TOC window autofit so that it doesn't take too much space
let g:vim_markdown_toc_autofit = 1
"""""""""""""""""""""""""markdown-preview settings""""""""""""""""""" """""""""""""""""""""""""markdown-preview settings"""""""""""""""""""
" Only setting this for suitable platforms " Only setting this for suitable platforms
if g:is_win || g:is_mac if g:is_win || g:is_mac
@@ -384,6 +286,3 @@ function! s:wilder_init() abort
echohl Error |echomsg "Wilder.nvim missing"| echohl None echohl Error |echomsg "Wilder.nvim missing"| echohl None
endtry endtry
endfunction endfunction
""""""""""""""""""""""""""""""vim-auto-save settings""""""""""""""""""""""""""""""
let g:auto_save = 1 " enable AutoSave on Vim startup