mirror of
https://github.com/jdhao/nvim-config.git
synced 2025-06-08 14:14:33 +02:00
Compare commits
23 Commits
v0.10.0
...
e6f95cedb1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e6f95cedb1 | ||
|
|
262ad6aa38 | ||
|
|
b30cc9ed78 | ||
|
|
b3a26e4226 | ||
|
|
794b098090 | ||
|
|
b728b39784 | ||
|
|
acc3ed7829 | ||
|
|
44e9e5a1ce | ||
|
|
5502d29f40 | ||
|
|
fe95658319 | ||
|
|
e165276763 | ||
|
|
933b887281 | ||
|
|
69643e143a | ||
|
|
7f4772fd31 | ||
|
|
bf49e90947 | ||
|
|
784b435f0e | ||
|
|
beec97c086 | ||
|
|
bbb8545403 | ||
|
|
9efadac8fb | ||
|
|
6e137fe9a3 | ||
|
|
719fbfc1ab | ||
|
|
e815de294f | ||
|
|
ca7430056c |
10
README.md
10
README.md
@@ -13,7 +13,7 @@
|
|||||||
<img alt="Latest release" src="https://img.shields.io/github/v/release/jdhao/nvim-config" />
|
<img alt="Latest release" src="https://img.shields.io/github/v/release/jdhao/nvim-config" />
|
||||||
</a>
|
</a>
|
||||||
<a href="https://github.com/neovim/neovim/releases/tag/stable">
|
<a href="https://github.com/neovim/neovim/releases/tag/stable">
|
||||||
<img src="https://img.shields.io/badge/Neovim-0.9.5-blueviolet.svg?style=flat-square&logo=Neovim&logoColor=green" alt="Neovim minimum version"/>
|
<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>
|
||||||
<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"/>
|
||||||
@@ -21,8 +21,8 @@
|
|||||||
<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.9.5">
|
<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.9.5?style=flat-square" />
|
<img src="https://img.shields.io/github/commits-since/jdhao/nvim-config/v0.10.0?style=flat-square" />
|
||||||
</a>
|
</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" />
|
||||||
@@ -169,8 +169,8 @@ Some of the shortcuts I use frequently are listed here. In the following shortcu
|
|||||||
| `<leader>gc` | Normal | Linux/macOS/Win | Run git commit |
|
| `<leader>gc` | Normal | Linux/macOS/Win | Run git commit |
|
||||||
| `<leader>gpl` | Normal | Linux/macOS/Win | Run git pull |
|
| `<leader>gpl` | Normal | Linux/macOS/Win | Run git pull |
|
||||||
| `<leader>gpu` | Normal | Linux/macOS/Win | Run git push |
|
| `<leader>gpu` | Normal | Linux/macOS/Win | Run git push |
|
||||||
| `<leader>gl` | Normal/Visual | Linux/macOS/Win | Get perm link for current/visually-select lines
|
| `<leader>gl` | Normal/Visual | Linux/macOS/Win | Get perm link for current/visually-select lines |
|
||||||
| `<leader>gb` | Normal | macOS | Browse current git repo in browser
|
| `<leader>gb` | Normal | macOS | Browse current git repo in browser |
|
||||||
| `<F9>` | Normal | Linux/macOS/Win | Compile&run current source file (for C++, LaTeX, Lua, Python) |
|
| `<F9>` | Normal | Linux/macOS/Win | Compile&run current source file (for C++, LaTeX, Lua, Python) |
|
||||||
| `<F11>` | Normal | Linux/macOS/Win | Toggle spell checking |
|
| `<F11>` | Normal | Linux/macOS/Win | Toggle spell checking |
|
||||||
| `<F12>` | Normal | Linux/macOS/Win | Toggle paste mode |
|
| `<F12>` | Normal | Linux/macOS/Win | Toggle paste mode |
|
||||||
|
|||||||
@@ -3,7 +3,3 @@ set formatoptions-=o
|
|||||||
set formatoptions-=r
|
set formatoptions-=r
|
||||||
|
|
||||||
nnoremap <buffer><silent> <F9> :luafile %<CR>
|
nnoremap <buffer><silent> <F9> :luafile %<CR>
|
||||||
|
|
||||||
" Use nvim-treesitter for folding
|
|
||||||
set foldmethod=expr
|
|
||||||
set foldexpr=nvim_treesitter#foldexpr()
|
|
||||||
|
|||||||
@@ -12,7 +12,3 @@ 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
|
||||||
|
|
||||||
" Use nvim-treesitter for folding
|
|
||||||
set foldmethod=expr
|
|
||||||
set foldexpr=nvim_treesitter#foldexpr()
|
|
||||||
|
|||||||
@@ -118,16 +118,16 @@ The version of Git on the Linux system may be too old so that plugins may break.
|
|||||||
Check [here](https://jdhao.github.io/2021/03/27/upgrade_git_on_linux/) on how to install and set up the latest version of Git.
|
Check [here](https://jdhao.github.io/2021/03/27/upgrade_git_on_linux/) on how to install and set up the latest version of Git.
|
||||||
For Windows, install [Git for Windows](https://git-scm.com/download/win) and make sure you can run `git` from command line.
|
For Windows, install [Git for Windows](https://git-scm.com/download/win) and make sure you can run `git` from command line.
|
||||||
|
|
||||||
### ctags
|
### universal-ctags
|
||||||
|
|
||||||
In order to use tags related plugins such as [vista.vim](https://github.com/liuchengxu/vista.vim), we need to install a ctags distribution.
|
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.
|
Universal-ctags is preferred.
|
||||||
|
|
||||||
To install it on Linux, we need to build it from source. See [here](https://askubuntu.com/a/836521/768311) for the details.
|
To install it on Linux, we need to build it from source. See [here](https://askubuntu.com/a/836521/768311) for the details.
|
||||||
To install ctags on macOS, use [Homebrew](https://github.com/universal-ctags/homebrew-universal-ctags):
|
To install ctags on macOS, use [Homebrew](https://formulae.brew.sh/formula/universal-ctags):
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
brew install ctags
|
brew install universal-ctags
|
||||||
```
|
```
|
||||||
|
|
||||||
To install it Windows, use [chocolatey](https://chocolatey.org/) or [scoop](https://scoop.sh/)
|
To install it Windows, use [chocolatey](https://chocolatey.org/) or [scoop](https://scoop.sh/)
|
||||||
@@ -166,35 +166,9 @@ Set their PATH properly and make sure you can run `pylint`, `flake8` and `vint`
|
|||||||
There are various ways to install Nvim depending on your system.
|
There are various ways to install Nvim depending on your system.
|
||||||
This config is only maintained for [the latest nvim stable release](https://github.com/neovim/neovim/releases/tag/stable).
|
This config is only maintained for [the latest nvim stable release](https://github.com/neovim/neovim/releases/tag/stable).
|
||||||
|
|
||||||
### Linux
|
Please check the official doc on how to install Neovim on different systems: https://github.com/neovim/neovim/blob/master/INSTALL.md
|
||||||
|
|
||||||
You can directly download the binary release from [here](https://github.com/neovim/neovim/releases/download/stable/nvim-linux64.tar.gz).
|
After installing Nvim, we need to set the PATH to nvim correctly.
|
||||||
You can also use the system package manager to install nvim,
|
|
||||||
but that is not reliable since the latest version may not be available.
|
|
||||||
|
|
||||||
### Windows
|
|
||||||
|
|
||||||
You may download from [nvim release](https://github.com/neovim/neovim/releases/download/stable/nvim-win64.zip) from GitHub and manually extract it.
|
|
||||||
|
|
||||||
Another way to install Nvim on Windows is via chocolatey or scoop:
|
|
||||||
|
|
||||||
```
|
|
||||||
choco install neovim
|
|
||||||
|
|
||||||
# via scoop
|
|
||||||
# scoop bucket add versions
|
|
||||||
# scoop install neovim
|
|
||||||
```
|
|
||||||
|
|
||||||
### macOS
|
|
||||||
|
|
||||||
It is recommended to install neovim via [Homebrew](https://brew.sh/) on macOS. Simply run the following command:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
brew install neovim
|
|
||||||
```
|
|
||||||
|
|
||||||
After installing Nvim, we need to set the path to nvim correctly.
|
|
||||||
**Make sure that you can run `nvim` from the command line after all these setups**.
|
**Make sure that you can run `nvim` from the command line after all these setups**.
|
||||||
|
|
||||||
## Setting up Nvim
|
## Setting up Nvim
|
||||||
|
|||||||
16
init.lua
16
init.lua
@@ -14,15 +14,21 @@ vim.loader.enable()
|
|||||||
local version = vim.version
|
local version = vim.version
|
||||||
|
|
||||||
-- check if we have the latest stable version of nvim
|
-- check if we have the latest stable version of nvim
|
||||||
local expected_ver = "0.10.0"
|
local expected_ver_str = "0.10.1"
|
||||||
local ev = version.parse(expected_ver)
|
local expect_ver = version.parse(expected_ver_str)
|
||||||
local actual_ver = version()
|
local actual_ver = vim.version()
|
||||||
|
|
||||||
local result = version.cmp(ev, {actual_ver.major, actual_ver.minor, actual_ver.patch})
|
if expect_ver == nil then
|
||||||
|
local msg = string.format("Unsupported version string: %s", expected_ver_str)
|
||||||
|
vim.api.nvim_err_writeln(msg)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local result = version.cmp(expect_ver, actual_ver)
|
||||||
|
|
||||||
if result ~= 0 then
|
if result ~= 0 then
|
||||||
local _ver = string.format("%s.%s.%s", actual_ver.major, actual_ver.minor, actual_ver.patch)
|
local _ver = string.format("%s.%s.%s", actual_ver.major, actual_ver.minor, actual_ver.patch)
|
||||||
local msg = string.format("Expect nvim %s, but got %s instead. Use at your own risk!", expected_ver, _ver)
|
local msg = string.format("Expect nvim %s, but got %s instead. Use at your own risk!", expected_ver_str, _ver)
|
||||||
vim.api.nvim_err_writeln(msg)
|
vim.api.nvim_err_writeln(msg)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -24,9 +24,9 @@ M.colorscheme_conf = {
|
|||||||
end,
|
end,
|
||||||
gruvbox_material = function()
|
gruvbox_material = function()
|
||||||
-- foreground option can be material, mix, or original
|
-- foreground option can be material, mix, or original
|
||||||
vim.g.gruvbox_material_foreground = "material"
|
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 = "soft"
|
vim.g.gruvbox_material_background = "medium"
|
||||||
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
|
||||||
|
|
||||||
@@ -56,6 +56,12 @@ M.colorscheme_conf = {
|
|||||||
vim.g.material_style = "oceanic"
|
vim.g.material_style = "oceanic"
|
||||||
vim.cmd('colorscheme material')
|
vim.cmd('colorscheme material')
|
||||||
end,
|
end,
|
||||||
|
arctic = function ()
|
||||||
|
vim.cmd("colorscheme arctic")
|
||||||
|
end,
|
||||||
|
kanagawa = function()
|
||||||
|
vim.cmd("colorscheme kanagawa-wave")
|
||||||
|
end
|
||||||
}
|
}
|
||||||
|
|
||||||
--- Use a random colorscheme from the pre-defined list of colorschemes.
|
--- Use a random colorscheme from the pre-defined list of colorschemes.
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ keymap.set("n", "<leader>gc", "<cmd>Git commit<cr>", { desc = "Git commit" })
|
|||||||
keymap.set("n", "<leader>gd", "<cmd>Gdiffsplit<cr>", { desc = "Git diff" })
|
keymap.set("n", "<leader>gd", "<cmd>Gdiffsplit<cr>", { desc = "Git diff" })
|
||||||
keymap.set("n", "<leader>gpl", "<cmd>Git pull<cr>", { desc = "Git pull" })
|
keymap.set("n", "<leader>gpl", "<cmd>Git pull<cr>", { desc = "Git pull" })
|
||||||
keymap.set("n", "<leader>gpu", "<cmd>15 split|term git push<cr>", { desc = "Git push" })
|
keymap.set("n", "<leader>gpu", "<cmd>15 split|term git push<cr>", { desc = "Git push" })
|
||||||
|
keymap.set("v", "<leader>gb", ":Git blame<cr>", { desc = "Git blame line" })
|
||||||
|
|
||||||
-- convert git to Git in command line mode
|
-- convert git to Git in command line mode
|
||||||
vim.fn['utils#Cabbrev']('git', 'Git')
|
vim.fn["utils#Cabbrev"]("git", "Git")
|
||||||
|
|||||||
@@ -35,14 +35,32 @@ keymap.set("n", "N", "", {
|
|||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
local no_word_under_cursor = function()
|
||||||
|
local cursor_word = vim.fn.expand("<cword>")
|
||||||
|
|
||||||
|
local result = cursor_word == ""
|
||||||
|
if result then
|
||||||
|
local msg = "E348: No string under cursor"
|
||||||
|
api.nvim_err_writeln(msg)
|
||||||
|
end
|
||||||
|
|
||||||
|
return result
|
||||||
|
end
|
||||||
|
|
||||||
keymap.set("n", "*", "", {
|
keymap.set("n", "*", "", {
|
||||||
callback = function()
|
callback = function()
|
||||||
|
if no_word_under_cursor() then
|
||||||
|
return
|
||||||
|
end
|
||||||
vim.fn.execute("normal! *N")
|
vim.fn.execute("normal! *N")
|
||||||
hlslens.start()
|
hlslens.start()
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
keymap.set("n", "#", "", {
|
keymap.set("n", "#", "", {
|
||||||
callback = function()
|
callback = function()
|
||||||
|
if no_word_under_cursor() then
|
||||||
|
return
|
||||||
|
end
|
||||||
vim.fn.execute("normal! #N")
|
vim.fn.execute("normal! #N")
|
||||||
hlslens.start()
|
hlslens.start()
|
||||||
end,
|
end,
|
||||||
|
|||||||
@@ -231,11 +231,12 @@ if utils.executable("lua-language-server") then
|
|||||||
},
|
},
|
||||||
workspace = {
|
workspace = {
|
||||||
-- Make the server aware of Neovim runtime files,
|
-- Make the server aware of Neovim runtime files,
|
||||||
-- see also https://github.com/LuaLS/lua-language-server/wiki/Libraries#link-to-workspace .
|
-- see also https://luals.github.io/wiki/settings/#workspacelibrary
|
||||||
-- Lua-dev.nvim also has similar settings for lua ls, https://github.com/folke/neodev.nvim/blob/main/lua/neodev/luals.lua .
|
|
||||||
library = {
|
library = {
|
||||||
vim.env.VIMRUNTIME,
|
vim.env.VIMRUNTIME,
|
||||||
fn.stdpath("config"),
|
fn.stdpath("config"),
|
||||||
|
-- make lua_ls aware of functions under vim.uv
|
||||||
|
"${3rd}/luv/library"
|
||||||
},
|
},
|
||||||
maxPreload = 2000,
|
maxPreload = 2000,
|
||||||
preloadFileSize = 50000,
|
preloadFileSize = 50000,
|
||||||
|
|||||||
45
lua/config/nvim_ufo.lua
Normal file
45
lua/config/nvim_ufo.lua
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
local handler = function(virtText, lnum, endLnum, width, truncate)
|
||||||
|
local newVirtText = {}
|
||||||
|
local foldedLines = endLnum - lnum
|
||||||
|
local suffix = (" %d"):format(foldedLines)
|
||||||
|
local sufWidth = vim.fn.strdisplaywidth(suffix)
|
||||||
|
local targetWidth = width - sufWidth
|
||||||
|
local curWidth = 0
|
||||||
|
|
||||||
|
for _, chunk in ipairs(virtText) do
|
||||||
|
local chunkText = chunk[1]
|
||||||
|
local chunkWidth = vim.fn.strdisplaywidth(chunkText)
|
||||||
|
if targetWidth > curWidth + chunkWidth then
|
||||||
|
table.insert(newVirtText, chunk)
|
||||||
|
else
|
||||||
|
chunkText = truncate(chunkText, targetWidth - curWidth)
|
||||||
|
local hlGroup = chunk[2]
|
||||||
|
table.insert(newVirtText, { chunkText, hlGroup })
|
||||||
|
chunkWidth = vim.fn.strdisplaywidth(chunkText)
|
||||||
|
-- str width returned from truncate() may less than 2nd argument, need padding
|
||||||
|
if curWidth + chunkWidth < targetWidth then
|
||||||
|
suffix = suffix .. (" "):rep(targetWidth - curWidth - chunkWidth)
|
||||||
|
end
|
||||||
|
break
|
||||||
|
end
|
||||||
|
curWidth = curWidth + chunkWidth
|
||||||
|
end
|
||||||
|
local rAlignAppndx = math.max(math.min(vim.opt.textwidth["_value"], width - 1) - curWidth - sufWidth, 0)
|
||||||
|
suffix = (" "):rep(rAlignAppndx) .. suffix
|
||||||
|
table.insert(newVirtText, { suffix, "MoreMsg" })
|
||||||
|
return newVirtText
|
||||||
|
end
|
||||||
|
|
||||||
|
local opts = {}
|
||||||
|
opts["fold_virt_text_handler"] = handler
|
||||||
|
|
||||||
|
require("ufo").setup(opts)
|
||||||
|
|
||||||
|
vim.keymap.set("n", "zR", require("ufo").openAllFolds)
|
||||||
|
vim.keymap.set("n", "zM", require("ufo").closeAllFolds)
|
||||||
|
vim.keymap.set("n", "zr", require("ufo").openFoldsExceptKinds)
|
||||||
|
vim.keymap.set("n", "<leader>K", function()
|
||||||
|
local _ = require("ufo").peekFoldedLinesUnderCursor()
|
||||||
|
end, {
|
||||||
|
desc = "Preview folded maps",
|
||||||
|
})
|
||||||
@@ -99,12 +99,12 @@ end
|
|||||||
|
|
||||||
local virtual_env = function()
|
local virtual_env = function()
|
||||||
-- only show virtual env for Python
|
-- only show virtual env for Python
|
||||||
if vim.bo.filetype ~= 'python' then
|
if vim.bo.filetype ~= "python" then
|
||||||
return ""
|
return ""
|
||||||
end
|
end
|
||||||
|
|
||||||
local conda_env = os.getenv('CONDA_DEFAULT_ENV')
|
local conda_env = os.getenv("CONDA_DEFAULT_ENV")
|
||||||
local venv_path = os.getenv('VIRTUAL_ENV')
|
local venv_path = os.getenv("VIRTUAL_ENV")
|
||||||
|
|
||||||
if venv_path == nil then
|
if venv_path == nil then
|
||||||
if conda_env == nil then
|
if conda_env == nil then
|
||||||
@@ -113,17 +113,33 @@ local virtual_env = function()
|
|||||||
return string.format(" %s (conda)", conda_env)
|
return string.format(" %s (conda)", conda_env)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
local venv_name = vim.fn.fnamemodify(venv_path, ':t')
|
local venv_name = vim.fn.fnamemodify(venv_path, ":t")
|
||||||
return string.format(" %s (venv)", venv_name)
|
return string.format(" %s (venv)", venv_name)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local get_active_lsp = function()
|
||||||
|
local msg = "No Active Lsp"
|
||||||
|
local buf_ft = vim.api.nvim_get_option_value("filetype", {})
|
||||||
|
local clients = vim.lsp.get_clients { bufnr = 0 }
|
||||||
|
if next(clients) == nil then
|
||||||
|
return msg
|
||||||
|
end
|
||||||
|
|
||||||
|
for _, client in ipairs(clients) do
|
||||||
|
---@diagnostic disable-next-line: undefined-field
|
||||||
|
local filetypes = client.config.filetypes
|
||||||
|
if filetypes and vim.fn.index(filetypes, buf_ft) ~= -1 then
|
||||||
|
return client.name
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return msg
|
||||||
|
end
|
||||||
|
|
||||||
require("lualine").setup {
|
require("lualine").setup {
|
||||||
options = {
|
options = {
|
||||||
icons_enabled = true,
|
icons_enabled = true,
|
||||||
theme = "auto",
|
theme = "auto",
|
||||||
-- component_separators = { left = "", right = "" },
|
|
||||||
-- section_separators = { left = "", right = "" },
|
|
||||||
section_separators = "",
|
section_separators = "",
|
||||||
component_separators = "",
|
component_separators = "",
|
||||||
disabled_filetypes = {},
|
disabled_filetypes = {},
|
||||||
@@ -132,18 +148,29 @@ require("lualine").setup {
|
|||||||
sections = {
|
sections = {
|
||||||
lualine_a = { "mode" },
|
lualine_a = { "mode" },
|
||||||
lualine_b = {
|
lualine_b = {
|
||||||
"branch",
|
{
|
||||||
|
"branch",
|
||||||
|
fmt = function(name, _)
|
||||||
|
-- truncate branch name in case the name is too long
|
||||||
|
return string.sub(name, 1, 20)
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
virtual_env,
|
||||||
|
color = { fg = "black", bg = "#F1CA81" },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
lualine_c = {
|
||||||
|
{
|
||||||
|
"filename",
|
||||||
|
symbols = {
|
||||||
|
readonly = "[🔒]",
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"diff",
|
"diff",
|
||||||
source = diff,
|
source = diff,
|
||||||
},
|
},
|
||||||
{
|
|
||||||
virtual_env,
|
|
||||||
color = { fg = 'black', bg = "#F1CA81" }
|
|
||||||
}
|
|
||||||
},
|
|
||||||
lualine_c = {
|
|
||||||
"filename",
|
|
||||||
{
|
{
|
||||||
ime_state,
|
ime_state,
|
||||||
color = { fg = "black", bg = "#f46868" },
|
color = { fg = "black", bg = "#f46868" },
|
||||||
@@ -152,13 +179,19 @@ require("lualine").setup {
|
|||||||
spell,
|
spell,
|
||||||
color = { fg = "black", bg = "#a7c080" },
|
color = { fg = "black", bg = "#a7c080" },
|
||||||
},
|
},
|
||||||
|
},
|
||||||
|
lualine_x = {
|
||||||
|
{
|
||||||
|
get_active_lsp,
|
||||||
|
icon = " LSP:",
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"diagnostics",
|
"diagnostics",
|
||||||
sources = { "nvim_diagnostic" },
|
sources = { "nvim_diagnostic" },
|
||||||
symbols = {error = '🆇 ', warn = '⚠️ ', info = 'ℹ️ ', hint = ' '},
|
symbols = { error = "🆇 ", warn = "⚠️ ", info = "ℹ️ ", hint = " " },
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
lualine_x = {
|
lualine_y = {
|
||||||
"encoding",
|
"encoding",
|
||||||
{
|
{
|
||||||
"fileformat",
|
"fileformat",
|
||||||
@@ -170,9 +203,6 @@ require("lualine").setup {
|
|||||||
},
|
},
|
||||||
"filetype",
|
"filetype",
|
||||||
},
|
},
|
||||||
lualine_y = {
|
|
||||||
"location",
|
|
||||||
},
|
|
||||||
lualine_z = {
|
lualine_z = {
|
||||||
{
|
{
|
||||||
trailing_space,
|
trailing_space,
|
||||||
@@ -182,6 +212,7 @@ require("lualine").setup {
|
|||||||
mixed_indent,
|
mixed_indent,
|
||||||
color = "WarningMsg",
|
color = "WarningMsg",
|
||||||
},
|
},
|
||||||
|
"progress"
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
inactive_sections = {
|
inactive_sections = {
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
local keymap = vim.keymap
|
local keymap = vim.keymap
|
||||||
local api = vim.api
|
|
||||||
local uv = vim.uv
|
local uv = vim.uv
|
||||||
|
|
||||||
-- Save key strokes (now we do not need to press shift to enter command mode).
|
-- Save key strokes (now we do not need to press shift to enter command mode).
|
||||||
@@ -215,6 +214,9 @@ keymap.set("n", "<leader>cb", function()
|
|||||||
local cnt = 0
|
local cnt = 0
|
||||||
local blink_times = 7
|
local blink_times = 7
|
||||||
local timer = uv.new_timer()
|
local timer = uv.new_timer()
|
||||||
|
if timer == nil then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
timer:start(0, 100, vim.schedule_wrap(function()
|
timer:start(0, 100, vim.schedule_wrap(function()
|
||||||
vim.cmd [[
|
vim.cmd [[
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
local utils = require("utils")
|
local utils = require("utils")
|
||||||
|
|
||||||
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
|
local plugin_dir = vim.fn.stdpath("data") .. "/lazy"
|
||||||
|
local lazypath = plugin_dir .. "/lazy.nvim"
|
||||||
|
|
||||||
if not vim.uv.fs_stat(lazypath) then
|
if not vim.uv.fs_stat(lazypath) then
|
||||||
vim.fn.system {
|
vim.fn.system {
|
||||||
@@ -108,8 +109,12 @@ local plugin_specs = {
|
|||||||
"Yggdroot/LeaderF",
|
"Yggdroot/LeaderF",
|
||||||
cmd = "Leaderf",
|
cmd = "Leaderf",
|
||||||
build = function()
|
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
|
if not vim.g.is_win then
|
||||||
vim.cmd(":LeaderfInstallCExtension")
|
vim.cmd("LeaderfInstallCExtension")
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
@@ -122,9 +127,10 @@ local plugin_specs = {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"lukas-reineke/headlines.nvim",
|
"MeanderingProgrammer/markdown.nvim",
|
||||||
dependencies = "nvim-treesitter/nvim-treesitter",
|
main = "render-markdown",
|
||||||
config = true, -- or `opts = {}`
|
opts = {},
|
||||||
|
dependencies = { "nvim-treesitter/nvim-treesitter", "nvim-tree/nvim-web-devicons" },
|
||||||
},
|
},
|
||||||
-- 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 },
|
||||||
@@ -136,7 +142,13 @@ local plugin_specs = {
|
|||||||
{ "catppuccin/nvim", name = "catppuccin", lazy = true },
|
{ "catppuccin/nvim", name = "catppuccin", lazy = true },
|
||||||
{ "olimorris/onedarkpro.nvim", lazy = true },
|
{ "olimorris/onedarkpro.nvim", lazy = true },
|
||||||
{ "marko-cerovac/material.nvim", lazy = true },
|
{ "marko-cerovac/material.nvim", lazy = true },
|
||||||
|
{
|
||||||
|
"rockyzhang24/arctic.nvim",
|
||||||
|
dependencies = { "rktjmp/lush.nvim" },
|
||||||
|
name = "arctic",
|
||||||
|
branch = "v2",
|
||||||
|
},
|
||||||
|
{ "rebelot/kanagawa.nvim", lazy = true },
|
||||||
{ "nvim-tree/nvim-web-devicons", event = "VeryLazy" },
|
{ "nvim-tree/nvim-web-devicons", event = "VeryLazy" },
|
||||||
|
|
||||||
{
|
{
|
||||||
@@ -169,12 +181,41 @@ local plugin_specs = {
|
|||||||
{
|
{
|
||||||
"lukas-reineke/indent-blankline.nvim",
|
"lukas-reineke/indent-blankline.nvim",
|
||||||
event = "VeryLazy",
|
event = "VeryLazy",
|
||||||
main = 'ibl',
|
main = "ibl",
|
||||||
config = function()
|
config = function()
|
||||||
require("config.indent-blankline")
|
require("config.indent-blankline")
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"luukvbaal/statuscol.nvim",
|
||||||
|
opts = {},
|
||||||
|
config = function()
|
||||||
|
local builtin = require("statuscol.builtin")
|
||||||
|
require("statuscol").setup {
|
||||||
|
relculright = true,
|
||||||
|
segments = {
|
||||||
|
{ text = { "%s" }, click = "v:lua.ScSa" },
|
||||||
|
{ text = { builtin.lnumfunc, " " }, click = "v:lua.ScLa" },
|
||||||
|
{ text = { builtin.foldfunc, " " }, condition = {true, builtin.not_empty}, click = "v:lua.ScFa" },
|
||||||
|
},
|
||||||
|
}
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"kevinhwang91/nvim-ufo",
|
||||||
|
dependencies = "kevinhwang91/promise-async",
|
||||||
|
event = "VeryLazy",
|
||||||
|
opts = {},
|
||||||
|
init = function()
|
||||||
|
vim.o.foldcolumn = "1" -- '0' is not bad
|
||||||
|
vim.o.foldlevel = 99 -- Using ufo provider need a large value, feel free to decrease the value
|
||||||
|
vim.o.foldlevelstart = 99
|
||||||
|
vim.o.foldenable = true
|
||||||
|
end,
|
||||||
|
config = function()
|
||||||
|
require("config.nvim_ufo")
|
||||||
|
end,
|
||||||
|
},
|
||||||
-- Highlight URLs inside vim
|
-- Highlight URLs inside vim
|
||||||
{ "itchyny/vim-highlighturl", event = "VeryLazy" },
|
{ "itchyny/vim-highlighturl", event = "VeryLazy" },
|
||||||
|
|
||||||
@@ -222,9 +263,9 @@ local plugin_specs = {
|
|||||||
|
|
||||||
-- Automatic insertion and deletion of a pair of characters
|
-- Automatic insertion and deletion of a pair of characters
|
||||||
{
|
{
|
||||||
'windwp/nvim-autopairs',
|
"windwp/nvim-autopairs",
|
||||||
event = "InsertEnter",
|
event = "InsertEnter",
|
||||||
config = true
|
config = true,
|
||||||
},
|
},
|
||||||
|
|
||||||
-- Comment plugin
|
-- Comment plugin
|
||||||
@@ -316,7 +357,7 @@ local plugin_specs = {
|
|||||||
{ "rhysd/committia.vim", lazy = true },
|
{ "rhysd/committia.vim", lazy = true },
|
||||||
|
|
||||||
{
|
{
|
||||||
"sindrets/diffview.nvim"
|
"sindrets/diffview.nvim",
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
@@ -418,17 +459,26 @@ local plugin_specs = {
|
|||||||
{
|
{
|
||||||
"glacambre/firenvim",
|
"glacambre/firenvim",
|
||||||
enabled = function()
|
enabled = function()
|
||||||
if vim.g.is_win or vim.g.is_mac then
|
local result = vim.g.is_win or vim.g.is_mac
|
||||||
return true
|
return result
|
||||||
end
|
|
||||||
return false
|
|
||||||
end,
|
end,
|
||||||
|
-- it seems that we can only call the firenvim function directly.
|
||||||
|
-- Using vim.fn or vim.cmd to call this function will fail.
|
||||||
build = function()
|
build = function()
|
||||||
vim.fn["firenvim#install"](0)
|
local firenvim_path = plugin_dir .. "/firenvim"
|
||||||
end,
|
vim.opt.runtimepath:append(firenvim_path)
|
||||||
lazy = true,
|
vim.cmd("runtime! firenvim.vim")
|
||||||
},
|
|
||||||
|
|
||||||
|
-- macOS will reset the PATH when firenvim starts a nvim process, causing the PATH variable to change unexpectedly.
|
||||||
|
-- Here we are trying to get the correct PATH and use it for firenvim.
|
||||||
|
-- See also https://github.com/glacambre/firenvim/blob/master/TROUBLESHOOTING.md#make-sure-firenvims-path-is-the-same-as-neovims
|
||||||
|
local path_env = vim.env.PATH
|
||||||
|
local prologue = string.format('export PATH="%s"', path_env)
|
||||||
|
-- local prologue = "echo"
|
||||||
|
local cmd_str = string.format(":call firenvim#install(0, '%s')", prologue)
|
||||||
|
vim.cmd(cmd_str)
|
||||||
|
end,
|
||||||
|
},
|
||||||
-- Debugger plugin
|
-- Debugger plugin
|
||||||
{
|
{
|
||||||
"sakhnik/nvim-gdb",
|
"sakhnik/nvim-gdb",
|
||||||
@@ -477,7 +527,7 @@ local plugin_specs = {
|
|||||||
-- file explorer
|
-- file explorer
|
||||||
{
|
{
|
||||||
"nvim-tree/nvim-tree.lua",
|
"nvim-tree/nvim-tree.lua",
|
||||||
keys = { "<space>s" },
|
event = "VeryLazy",
|
||||||
dependencies = { "nvim-tree/nvim-web-devicons" },
|
dependencies = { "nvim-tree/nvim-web-devicons" },
|
||||||
config = function()
|
config = function()
|
||||||
require("config.nvim-tree")
|
require("config.nvim-tree")
|
||||||
@@ -494,13 +544,14 @@ local plugin_specs = {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
-- configuration for lazy itself.
|
require("lazy").setup {
|
||||||
local lazy_opts = {
|
spec = plugin_specs,
|
||||||
ui = {
|
ui = {
|
||||||
border = "rounded",
|
border = "rounded",
|
||||||
title = "Plugin Manager",
|
title = "Plugin Manager",
|
||||||
title_pos = "center",
|
title_pos = "center",
|
||||||
},
|
},
|
||||||
|
rocks = {
|
||||||
|
enabled = false,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
require("lazy").setup(plugin_specs, lazy_opts)
|
|
||||||
|
|||||||
@@ -11,9 +11,8 @@ function M.executable(name)
|
|||||||
end
|
end
|
||||||
|
|
||||||
--- check whether a feature exists in Nvim
|
--- check whether a feature exists in Nvim
|
||||||
--- @feat: string
|
--- @param feat string the feature name, like `nvim-0.7` or `unix`.
|
||||||
--- the feature name, like `nvim-0.7` or `unix`.
|
--- @return boolean
|
||||||
--- return: bool
|
|
||||||
M.has = function(feat)
|
M.has = function(feat)
|
||||||
if fn.has(feat) == 1 then
|
if fn.has(feat) == 1 then
|
||||||
return true
|
return true
|
||||||
@@ -33,8 +32,9 @@ end
|
|||||||
|
|
||||||
--- Generate random integers in the range [Low, High], inclusive,
|
--- Generate random integers in the range [Low, High], inclusive,
|
||||||
--- adapted from https://stackoverflow.com/a/12739441/6064933
|
--- adapted from https://stackoverflow.com/a/12739441/6064933
|
||||||
--- @low: the lower value for this range
|
--- @param low integer the lower value for this range
|
||||||
--- @high: the upper value for this range
|
--- @param high integer the upper value for this range
|
||||||
|
--- @return integer
|
||||||
function M.rand_int(low, high)
|
function M.rand_int(low, high)
|
||||||
-- Use lua to generate random int, see also: https://stackoverflow.com/a/20157671/6064933
|
-- Use lua to generate random int, see also: https://stackoverflow.com/a/20157671/6064933
|
||||||
math.randomseed(os.time())
|
math.randomseed(os.time())
|
||||||
@@ -43,17 +43,11 @@ function M.rand_int(low, high)
|
|||||||
end
|
end
|
||||||
|
|
||||||
--- Select a random element from a sequence/list.
|
--- Select a random element from a sequence/list.
|
||||||
--- @seq: the sequence to choose an element
|
--- @param seq any[] the sequence to choose an element
|
||||||
function M.rand_element(seq)
|
function M.rand_element(seq)
|
||||||
local idx = M.rand_int(1, #seq)
|
local idx = M.rand_int(1, #seq)
|
||||||
|
|
||||||
return seq[idx]
|
return seq[idx]
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.add_pack(name)
|
|
||||||
local status, error = pcall(vim.cmd, "packadd " .. name)
|
|
||||||
|
|
||||||
return status
|
|
||||||
end
|
|
||||||
|
|
||||||
return M
|
return M
|
||||||
|
|||||||
@@ -467,3 +467,6 @@ pylintrc
|
|||||||
PYTHONPATH
|
PYTHONPATH
|
||||||
Uvicorn
|
Uvicorn
|
||||||
qpdf
|
qpdf
|
||||||
|
Elasticsearch
|
||||||
|
kibana
|
||||||
|
submodule
|
||||||
|
|||||||
@@ -1,11 +1,14 @@
|
|||||||
scriptencoding utf-8
|
scriptencoding utf-8
|
||||||
|
|
||||||
" change fillchars for folding, vertical split, end of buffer, and message separator
|
" change fillchars for folding, vertical split, end of buffer, and message separator
|
||||||
set fillchars=fold:\ ,vert:\│,eob:\ ,msgsep:‾,diff:╱
|
set fillchars=fold:\ ,foldsep:\ ,foldopen:,foldclose:,vert:\│,eob:\ ,msgsep:‾,diff:╱
|
||||||
|
|
||||||
" Split window below/right when creating horizontal/vertical windows
|
" Split window below/right when creating horizontal/vertical windows
|
||||||
set splitbelow splitright
|
set splitbelow splitright
|
||||||
|
|
||||||
|
" avoid the flickering when splitting window horizontal
|
||||||
|
set splitkeep=screen
|
||||||
|
|
||||||
" Time in milliseconds to wait for a mapped sequence to complete,
|
" Time in milliseconds to wait for a mapped sequence to complete,
|
||||||
" see https://unix.stackexchange.com/q/36882/221410 for more info
|
" see https://unix.stackexchange.com/q/36882/221410 for more info
|
||||||
set timeoutlen=500
|
set timeoutlen=500
|
||||||
|
|||||||
@@ -58,16 +58,6 @@ endif
|
|||||||
" Only fuzzy-search files names
|
" Only fuzzy-search files names
|
||||||
let g:Lf_DefaultMode = 'FullPath'
|
let g:Lf_DefaultMode = 'FullPath'
|
||||||
|
|
||||||
" Popup window settings
|
|
||||||
let w = float2nr(&columns * 0.8)
|
|
||||||
if w > 140
|
|
||||||
let g:Lf_PopupWidth = 140
|
|
||||||
else
|
|
||||||
let g:Lf_PopupWidth = w
|
|
||||||
endif
|
|
||||||
|
|
||||||
let g:Lf_PopupPosition = [0, float2nr((&columns - g:Lf_PopupWidth)/2)]
|
|
||||||
|
|
||||||
" Do not use version control tool to list files under a directory since
|
" Do not use version control tool to list files under a directory since
|
||||||
" submodules are not searched by default.
|
" submodules are not searched by default.
|
||||||
let g:Lf_UseVersionControlTool = 0
|
let g:Lf_UseVersionControlTool = 0
|
||||||
|
|||||||
Reference in New Issue
Block a user