From cb8c9208e160837fd9c4c3b88e99a2fddf20dadf Mon Sep 17 00:00:00 2001
From: jdhao
Date: Wed, 24 Jul 2024 21:59:41 +0200
Subject: [PATCH 001/247] update which-key conf and some mappings
---
lua/config/which-key.lua | 60 ++--------------------------------------
lua/mappings.lua | 8 ++++--
2 files changed, 8 insertions(+), 60 deletions(-)
diff --git a/lua/config/which-key.lua b/lua/config/which-key.lua
index 10c0c413..13b736c9 100644
--- a/lua/config/which-key.lua
+++ b/lua/config/which-key.lua
@@ -1,60 +1,6 @@
require("which-key").setup {
- plugins = {
- marks = true, -- shows a list of your marks on ' and `
- registers = true, -- shows your registers on " in NORMAL or in INSERT mode
- spelling = {
- enabled = true, -- enabling this will show WhichKey when pressing z= to select spelling suggestions
- suggestions = 9, -- how many suggestions should be shown in the list?
- },
- -- the presets plugin, adds help for a bunch of default keybindings in Neovim
- -- No actual key bindings are created
- presets = {
- operators = true, -- adds help for operators like d, y, ... and registers them for motion / text object completion
- motions = true, -- adds help for motions
- text_objects = true, -- help for text objects triggered after entering an operator
- windows = true, -- default bindings on
- nav = true, -- misc bindings to work with windows
- z = true, -- bindings for folds, spelling and others prefixed with z
- g = true, -- bindings for prefixed with g
- },
- },
- -- add operators that will trigger motion and text object completion
- -- to enable all native operators, set the preset / operators plugin above
- operators = { gc = "Comments" },
- key_labels = {
- -- override the label used to display some keys. It doesn't effect WK in any other way.
- -- For example:
- -- [""] = "SPC",
- -- [""] = "RET",
- -- [""] = "TAB",
- },
+ preset = "modern",
icons = {
- breadcrumb = "»", -- symbol used in the command line area that shows your active key combo
- separator = "➜", -- symbol used between a key and it's label
- group = "+", -- symbol prepended to a group
- },
- window = {
- border = "none", -- none, single, double, shadow
- position = "bottom", -- bottom, top
- margin = { 0, 0, 0, 0 }, -- extra window margin [top, right, bottom, left]
- padding = { 1, 0, 1, 0 }, -- extra window padding [top, right, bottom, left]
- },
- layout = {
- height = { min = 1, max = 25 }, -- min and max height of the columns
- width = { min = 20, max = 50 }, -- min and max width of the columns
- spacing = 1, -- spacing between columns
- align = "center", -- align columns left, center or right
- },
- ignore_missing = false, -- enable this to hide mappings for which you didn't specify a label
- hidden = { "", "", "", "", "call", "lua", "^:", "^ " }, -- hide mapping boilerplate
- show_help = true, -- show help message on the command line when the popup is visible
- triggers = "auto", -- automatically setup triggers
- -- triggers = {""} -- or specify a list manually
-
- triggers_blacklist = {
- -- list of mode / prefixes that should never be hooked by WhichKey
- -- this is mostly relevant for key maps that start with a native binding
- -- most people should not need to change this
- n = { "o", "O" },
- },
+ mappings = false
+ }
}
diff --git a/lua/mappings.lua b/lua/mappings.lua
index fb7091e2..96a07cc7 100644
--- a/lua/mappings.lua
+++ b/lua/mappings.lua
@@ -217,7 +217,7 @@ keymap.set("n", "cb", function()
local timer = uv.new_timer()
timer:start(0, 100, vim.schedule_wrap(function()
- vim.cmd[[
+ vim.cmd [[
set cursorcolumn!
set cursorline!
]]
@@ -227,5 +227,7 @@ keymap.set("n", "cb", function()
end
cnt = cnt + 1
- end))
-end)
+ end)
+ )
+end,
+ { desc = "show cursor" })
From ca7430056c6c6cfe68b98178bcfde6a85b9023f7 Mon Sep 17 00:00:00 2001
From: jdhao
Date: Thu, 25 Jul 2024 21:31:53 +0200
Subject: [PATCH 002/247] update to neovim version 0.10.1
---
README.md | 6 +++---
init.lua | 6 +++---
2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/README.md b/README.md
index 7116a590..c29e7f3e 100644
--- a/README.md
+++ b/README.md
@@ -13,7 +13,7 @@
-
+
@@ -21,8 +21,8 @@
-
-
+
+
diff --git a/init.lua b/init.lua
index baa4ae65..ee66d272 100644
--- a/init.lua
+++ b/init.lua
@@ -14,11 +14,11 @@ vim.loader.enable()
local version = vim.version
-- check if we have the latest stable version of nvim
-local expected_ver = "0.10.0"
-local ev = version.parse(expected_ver)
+local expected_ver = "0.10.1"
+local expect_ver = version.parse(expected_ver)
local actual_ver = version()
-local result = version.cmp(ev, {actual_ver.major, actual_ver.minor, actual_ver.patch})
+local result = version.cmp(expect_ver, actual_ver)
if result ~= 0 then
local _ver = string.format("%s.%s.%s", actual_ver.major, actual_ver.minor, actual_ver.patch)
From e815de294ff124ed36e95ee8540472a28755088c Mon Sep 17 00:00:00 2001
From: jdhao
Date: Fri, 26 Jul 2024 21:24:51 +0200
Subject: [PATCH 003/247] update plugin for markdown preview
---
README.md | 4 ++--
lua/plugin_specs.lua | 7 ++++---
2 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/README.md b/README.md
index c29e7f3e..176e43fa 100644
--- a/README.md
+++ b/README.md
@@ -169,8 +169,8 @@ Some of the shortcuts I use frequently are listed here. In the following shortcu
| `gc` | Normal | Linux/macOS/Win | Run git commit |
| `gpl` | Normal | Linux/macOS/Win | Run git pull |
| `gpu` | Normal | Linux/macOS/Win | Run git push |
-| `gl` | Normal/Visual | Linux/macOS/Win | Get perm link for current/visually-select lines
-| `gb` | Normal | macOS | Browse current git repo in browser
+| `gl` | Normal/Visual | Linux/macOS/Win | Get perm link for current/visually-select lines |
+| `gb` | Normal | macOS | Browse current git repo in browser |
| `` | Normal | Linux/macOS/Win | Compile&run current source file (for C++, LaTeX, Lua, Python) |
| `` | Normal | Linux/macOS/Win | Toggle spell checking |
| `` | Normal | Linux/macOS/Win | Toggle paste mode |
diff --git a/lua/plugin_specs.lua b/lua/plugin_specs.lua
index f18dda42..68d07d4c 100644
--- a/lua/plugin_specs.lua
+++ b/lua/plugin_specs.lua
@@ -122,9 +122,10 @@ local plugin_specs = {
},
},
{
- "lukas-reineke/headlines.nvim",
- dependencies = "nvim-treesitter/nvim-treesitter",
- config = true, -- or `opts = {}`
+ 'MeanderingProgrammer/markdown.nvim',
+ main = "render-markdown",
+ 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.
{ "navarasu/onedark.nvim", lazy = true },
From 719fbfc1ab6fe0ef4bd5ca0a1ad322ed08eb4c31 Mon Sep 17 00:00:00 2001
From: jdhao
Date: Tue, 30 Jul 2024 23:34:53 +0200
Subject: [PATCH 004/247] update lua_ls settings
---
lua/config/lsp.lua | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/lua/config/lsp.lua b/lua/config/lsp.lua
index aac7a90c..f43aa583 100644
--- a/lua/config/lsp.lua
+++ b/lua/config/lsp.lua
@@ -231,11 +231,12 @@ if utils.executable("lua-language-server") then
},
workspace = {
-- Make the server aware of Neovim runtime files,
- -- see also https://github.com/LuaLS/lua-language-server/wiki/Libraries#link-to-workspace .
- -- Lua-dev.nvim also has similar settings for lua ls, https://github.com/folke/neodev.nvim/blob/main/lua/neodev/luals.lua .
+ -- see also https://luals.github.io/wiki/settings/#workspacelibrary
library = {
vim.env.VIMRUNTIME,
fn.stdpath("config"),
+ -- make lua_ls aware of functions under vim.uv
+ "${3rd}/luv/library"
},
maxPreload = 2000,
preloadFileSize = 50000,
From 6e137fe9a3ee215f82a46a05e77be51ac17151f7 Mon Sep 17 00:00:00 2001
From: jdhao
Date: Wed, 31 Jul 2024 01:08:50 +0200
Subject: [PATCH 005/247] make firenvim work again
1. fix build issue
2. fix PATH env issue
---
lua/plugin_specs.lua | 20 +++++++++++---------
1 file changed, 11 insertions(+), 9 deletions(-)
diff --git a/lua/plugin_specs.lua b/lua/plugin_specs.lua
index 68d07d4c..17de0510 100644
--- a/lua/plugin_specs.lua
+++ b/lua/plugin_specs.lua
@@ -15,6 +15,12 @@ end
vim.opt.rtp:prepend(lazypath)
-- check if firenvim is active
+-- 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 firenvim_not_active = function()
return not vim.g.started_by_firenvim
end
@@ -419,17 +425,13 @@ local plugin_specs = {
{
"glacambre/firenvim",
enabled = function()
- if vim.g.is_win or vim.g.is_mac then
- return true
- end
- return false
+ local result = vim.g.is_win or vim.g.is_mac
+ return result
end,
- build = function()
- vim.fn["firenvim#install"](0)
- end,
- lazy = true,
+ -- it seems that we can only call the firenvim function directly.
+ -- Using vim.fn or vim.cmd to call this function will fail.
+ build = string.format(":call firenvim#install(0, '%s')", prologue)
},
-
-- Debugger plugin
{
"sakhnik/nvim-gdb",
From 9efadac8fb8506f31f0d48deb90e3ce543fe5120 Mon Sep 17 00:00:00 2001
From: jdhao
Date: Wed, 31 Jul 2024 22:13:07 +0200
Subject: [PATCH 006/247] update lazy.nvim config
---
lua/plugin_specs.lua | 29 +++++++++++++++--------------
1 file changed, 15 insertions(+), 14 deletions(-)
diff --git a/lua/plugin_specs.lua b/lua/plugin_specs.lua
index 17de0510..8c55f8bc 100644
--- a/lua/plugin_specs.lua
+++ b/lua/plugin_specs.lua
@@ -128,10 +128,10 @@ local plugin_specs = {
},
},
{
- 'MeanderingProgrammer/markdown.nvim',
- main = "render-markdown",
- opts = {},
- dependencies = { 'nvim-treesitter/nvim-treesitter', 'nvim-tree/nvim-web-devicons' },
+ "MeanderingProgrammer/markdown.nvim",
+ main = "render-markdown",
+ 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.
{ "navarasu/onedark.nvim", lazy = true },
@@ -176,7 +176,7 @@ local plugin_specs = {
{
"lukas-reineke/indent-blankline.nvim",
event = "VeryLazy",
- main = 'ibl',
+ main = "ibl",
config = function()
require("config.indent-blankline")
end,
@@ -229,9 +229,9 @@ local plugin_specs = {
-- Automatic insertion and deletion of a pair of characters
{
- 'windwp/nvim-autopairs',
- event = "InsertEnter",
- config = true
+ "windwp/nvim-autopairs",
+ event = "InsertEnter",
+ config = true,
},
-- Comment plugin
@@ -323,7 +323,7 @@ local plugin_specs = {
{ "rhysd/committia.vim", lazy = true },
{
- "sindrets/diffview.nvim"
+ "sindrets/diffview.nvim",
},
{
@@ -430,7 +430,7 @@ local plugin_specs = {
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 = string.format(":call firenvim#install(0, '%s')", prologue)
+ build = string.format(":call firenvim#install(0, '%s')", prologue),
},
-- Debugger plugin
{
@@ -497,13 +497,14 @@ local plugin_specs = {
},
}
--- configuration for lazy itself.
-local lazy_opts = {
+require("lazy").setup {
+ spec = plugin_specs,
ui = {
border = "rounded",
title = "Plugin Manager",
title_pos = "center",
},
+ rocks = {
+ enabled = false
+ },
}
-
-require("lazy").setup(plugin_specs, lazy_opts)
From bbb8545403d276fa6bc56e956906fb14f871553f Mon Sep 17 00:00:00 2001
From: jdhao
Date: Fri, 2 Aug 2024 00:22:04 +0200
Subject: [PATCH 007/247] update lualine config
- rearrange a few components
- add and remove a few components
---
lua/config/statusline.lua | 64 ++++++++++++++++++++++++++++-----------
1 file changed, 47 insertions(+), 17 deletions(-)
diff --git a/lua/config/statusline.lua b/lua/config/statusline.lua
index 0563ba64..466edf6c 100644
--- a/lua/config/statusline.lua
+++ b/lua/config/statusline.lua
@@ -99,12 +99,12 @@ end
local virtual_env = function()
-- only show virtual env for Python
- if vim.bo.filetype ~= 'python' then
+ if vim.bo.filetype ~= "python" then
return ""
end
- local conda_env = os.getenv('CONDA_DEFAULT_ENV')
- local venv_path = os.getenv('VIRTUAL_ENV')
+ local conda_env = os.getenv("CONDA_DEFAULT_ENV")
+ local venv_path = os.getenv("VIRTUAL_ENV")
if venv_path == nil then
if conda_env == nil then
@@ -113,17 +113,32 @@ local virtual_env = function()
return string.format(" %s (conda)", conda_env)
end
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)
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
+ 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 {
options = {
icons_enabled = true,
theme = "auto",
- -- component_separators = { left = "", right = "" },
- -- section_separators = { left = "", right = "" },
section_separators = "",
component_separators = "",
disabled_filetypes = {},
@@ -132,18 +147,29 @@ require("lualine").setup {
sections = {
lualine_a = { "mode" },
lualine_b = {
- "branch",
{
- "diff",
- source = diff,
+ "branch",
+ fmt = function(name, context)
+ -- truncate branch name in case the name is too long
+ return string.sub(name, 1, 20)
+ end,
},
{
virtual_env,
- color = { fg = 'black', bg = "#F1CA81" }
- }
+ color = { fg = "black", bg = "#F1CA81" },
+ },
},
lualine_c = {
- "filename",
+ {
+ "filename",
+ symbols = {
+ readonly = "[🔒]",
+ },
+ },
+ {
+ "diff",
+ source = diff,
+ },
{
ime_state,
color = { fg = "black", bg = "#f46868" },
@@ -152,13 +178,19 @@ require("lualine").setup {
spell,
color = { fg = "black", bg = "#a7c080" },
},
+ },
+ lualine_x = {
+ {
+ get_active_lsp,
+ icon = " LSP:",
+ },
{
"diagnostics",
sources = { "nvim_diagnostic" },
- symbols = {error = '🆇 ', warn = '⚠️ ', info = 'ℹ️ ', hint = ' '},
+ symbols = { error = "🆇 ", warn = "⚠️ ", info = "ℹ️ ", hint = " " },
},
},
- lualine_x = {
+ lualine_y = {
"encoding",
{
"fileformat",
@@ -170,9 +202,6 @@ require("lualine").setup {
},
"filetype",
},
- lualine_y = {
- "location",
- },
lualine_z = {
{
trailing_space,
@@ -182,6 +211,7 @@ require("lualine").setup {
mixed_indent,
color = "WarningMsg",
},
+ "progress"
},
},
inactive_sections = {
From beec97c0865795e91c8734f0c7048d453c2bd6ab Mon Sep 17 00:00:00 2001
From: jdhao
Date: Fri, 2 Aug 2024 17:28:28 +0200
Subject: [PATCH 008/247] Fix firenvim and LeaderF build issues
In lazy.nvim, the `build` parameter accept value in different format.
If the value is
1. a string and starts with `:`, it will be treated as vim command
2. a string and starts without `:`, it will be treated as shell command
3. a function. Lazy.nvim will run this function
I compared closely between case 1 and case 3. In case 1, when lazy.nvim
runs the viml command, the runtimepath is already populated with the
current plugin we are trying to build.
However in case 3, the runtimepath is not populated with the plugin
path, which means that any command you run by this plugin is not
available.
So I did it in a hacky way to add the plugin path to runtimepath
manually, and source it manually using `:runtime` command. The `:
runtime` command is needed because in the init process, adding the
plugin path to runtimepath does not ensure that the script under this
plugin is sourced immediately. So if we want to use the command/function
immediately, we need to source it manually, see also https://github.com/neovim/neovim/issues/29957.
---
lua/plugin_specs.lua | 30 +++++++++++++++++++++---------
1 file changed, 21 insertions(+), 9 deletions(-)
diff --git a/lua/plugin_specs.lua b/lua/plugin_specs.lua
index 8c55f8bc..7b58b85b 100644
--- a/lua/plugin_specs.lua
+++ b/lua/plugin_specs.lua
@@ -1,6 +1,7 @@
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
vim.fn.system {
@@ -15,12 +16,6 @@ end
vim.opt.rtp:prepend(lazypath)
-- check if firenvim is active
--- 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 firenvim_not_active = function()
return not vim.g.started_by_firenvim
end
@@ -114,8 +109,12 @@ local plugin_specs = {
"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")
+ vim.cmd("LeaderfInstallCExtension")
end
end,
},
@@ -430,7 +429,20 @@ local plugin_specs = {
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 = string.format(":call firenvim#install(0, '%s')", prologue),
+ build = function()
+ local firenvim_path = plugin_dir .. "/firenvim"
+ vim.opt.runtimepath:append(firenvim_path)
+ 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
{
From 784b435f0e637e496e4bb541bb3d2331c2eeb47f Mon Sep 17 00:00:00 2001
From: jdhao
Date: Fri, 2 Aug 2024 17:41:05 +0200
Subject: [PATCH 009/247] update LeaderF settings
---
viml_conf/plugins.vim | 10 ----------
1 file changed, 10 deletions(-)
diff --git a/viml_conf/plugins.vim b/viml_conf/plugins.vim
index 83b6a527..da3252ec 100644
--- a/viml_conf/plugins.vim
+++ b/viml_conf/plugins.vim
@@ -58,16 +58,6 @@ endif
" Only fuzzy-search files names
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
" submodules are not searched by default.
let g:Lf_UseVersionControlTool = 0
From bf49e9094752f4d27d2856d0c08f71366efae57d Mon Sep 17 00:00:00 2001
From: jdhao
Date: Sun, 4 Aug 2024 23:02:16 +0200
Subject: [PATCH 010/247] change value for option 'splitkeep'
---
viml_conf/options.vim | 3 +++
1 file changed, 3 insertions(+)
diff --git a/viml_conf/options.vim b/viml_conf/options.vim
index 98fb3a6c..f3b9af45 100644
--- a/viml_conf/options.vim
+++ b/viml_conf/options.vim
@@ -6,6 +6,9 @@ set fillchars=fold:\ ,vert:\│,eob:\ ,msgsep:‾,diff:╱
" Split window below/right when creating horizontal/vertical windows
set splitbelow splitright
+" avoid the flickering when splitting window horizontal
+set splitkeep=screen
+
" Time in milliseconds to wait for a mapped sequence to complete,
" see https://unix.stackexchange.com/q/36882/221410 for more info
set timeoutlen=500
From 7f4772fd31d020c234b780f0f33376d8e92c422d Mon Sep 17 00:00:00 2001
From: jdhao
Date: Sun, 4 Aug 2024 23:03:56 +0200
Subject: [PATCH 011/247] update setting for colorscheme gruvbox-material
---
lua/colorschemes.lua | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/lua/colorschemes.lua b/lua/colorschemes.lua
index 9618b4d5..387b6ec5 100644
--- a/lua/colorschemes.lua
+++ b/lua/colorschemes.lua
@@ -24,9 +24,9 @@ M.colorscheme_conf = {
end,
gruvbox_material = function()
-- 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
- vim.g.gruvbox_material_background = "soft"
+ vim.g.gruvbox_material_background = "medium"
vim.g.gruvbox_material_enable_italic = 1
vim.g.gruvbox_material_better_performance = 1
From 69643e143a72f7e98015f61faba2f2a428d9c79a Mon Sep 17 00:00:00 2001
From: jdhao
Date: Sun, 4 Aug 2024 23:25:17 +0200
Subject: [PATCH 012/247] use plugin nvim-ufo for better folding
The settings are copied from https://github.com/kevinhwang91/nvim-ufo/issues/4#issuecomment-1514537245,
with some modification.
---
lua/config/nvim_ufo.lua | 48 +++++++++++++++++++++++++++++++++++++++++
lua/plugin_specs.lua | 35 +++++++++++++++++++++++++++---
viml_conf/options.vim | 2 +-
3 files changed, 81 insertions(+), 4 deletions(-)
create mode 100644 lua/config/nvim_ufo.lua
diff --git a/lua/config/nvim_ufo.lua b/lua/config/nvim_ufo.lua
new file mode 100644
index 00000000..8d0ffc04
--- /dev/null
+++ b/lua/config/nvim_ufo.lua
@@ -0,0 +1,48 @@
+local handler = function(virtText, lnum, endLnum, width, truncate)
+ local newVirtText = {}
+ local totalLines = vim.api.nvim_buf_line_count(0)
+ 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", "K", function()
+ local winid = require("ufo").peekFoldedLinesUnderCursor()
+ if not winid then
+ -- vim.lsp.buf.hover()
+ vim.cmd([[ Lspsaga hover_doc ]])
+ end
+end)
diff --git a/lua/plugin_specs.lua b/lua/plugin_specs.lua
index 7b58b85b..551dc855 100644
--- a/lua/plugin_specs.lua
+++ b/lua/plugin_specs.lua
@@ -180,7 +180,36 @@ local plugin_specs = {
require("config.indent-blankline")
end,
},
-
+ {
+ "luukvbaal/statuscol.nvim",
+ opts = {},
+ config = function()
+ local builtin = require("statuscol.builtin")
+ require("statuscol").setup {
+ relculright = true,
+ segments = {
+ { text = { builtin.foldfunc }, click = "v:lua.ScFa" },
+ { text = { "%s" }, click = "v:lua.ScSa" },
+ { text = { builtin.lnumfunc, " " }, click = "v:lua.ScLa" },
+ },
+ }
+ 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
{ "itchyny/vim-highlighturl", event = "VeryLazy" },
@@ -442,7 +471,7 @@ local plugin_specs = {
-- local prologue = "echo"
local cmd_str = string.format(":call firenvim#install(0, '%s')", prologue)
vim.cmd(cmd_str)
- end
+ end,
},
-- Debugger plugin
{
@@ -517,6 +546,6 @@ require("lazy").setup {
title_pos = "center",
},
rocks = {
- enabled = false
+ enabled = false,
},
}
diff --git a/viml_conf/options.vim b/viml_conf/options.vim
index f3b9af45..68e0059f 100644
--- a/viml_conf/options.vim
+++ b/viml_conf/options.vim
@@ -1,7 +1,7 @@
scriptencoding utf-8
" 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
set splitbelow splitright
From 933b887281eaefec6f8c64c7ea627de8308caddf Mon Sep 17 00:00:00 2001
From: jdhao
Date: Sun, 4 Aug 2024 23:47:08 +0200
Subject: [PATCH 013/247] update config for nvim-ufo
---
lua/config/nvim_ufo.lua | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/lua/config/nvim_ufo.lua b/lua/config/nvim_ufo.lua
index 8d0ffc04..2430932d 100644
--- a/lua/config/nvim_ufo.lua
+++ b/lua/config/nvim_ufo.lua
@@ -40,9 +40,7 @@ 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", "K", function()
- local winid = require("ufo").peekFoldedLinesUnderCursor()
- if not winid then
- -- vim.lsp.buf.hover()
- vim.cmd([[ Lspsaga hover_doc ]])
- end
-end)
+ local _ = require("ufo").peekFoldedLinesUnderCursor()
+end, {
+ desc = "Preview folded maps",
+})
From e165276763f52bc1f8a30d892651b1725aef7017 Mon Sep 17 00:00:00 2001
From: jdhao
Date: Mon, 5 Aug 2024 00:22:29 +0200
Subject: [PATCH 014/247] fix error when there is no cursor word
---
lua/config/hlslens.lua | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/lua/config/hlslens.lua b/lua/config/hlslens.lua
index 430bd230..36323470 100644
--- a/lua/config/hlslens.lua
+++ b/lua/config/hlslens.lua
@@ -35,14 +35,28 @@ keymap.set("n", "N", "", {
end,
})
+local no_word_under_cursor = function()
+ local word_under_cursor = vim.fn.expand("")
+
+ local msg = "E348: No string under cursor"
+ api.nvim_err_writeln(msg)
+ return word_under_cursor == ""
+end
+
keymap.set("n", "*", "", {
callback = function()
+ if no_word_under_cursor() then
+ return
+ end
vim.fn.execute("normal! *N")
hlslens.start()
end,
})
keymap.set("n", "#", "", {
callback = function()
+ if no_word_under_cursor() then
+ return
+ end
vim.fn.execute("normal! #N")
hlslens.start()
end,
From fe9565831929d047f623e68c72173fb2f9624ecc Mon Sep 17 00:00:00 2001
From: jdhao
Date: Mon, 5 Aug 2024 00:24:48 +0200
Subject: [PATCH 015/247] Add colorscheme arctic.nvim
---
lua/colorschemes.lua | 3 +++
lua/plugin_specs.lua | 6 ++++++
2 files changed, 9 insertions(+)
diff --git a/lua/colorschemes.lua b/lua/colorschemes.lua
index 387b6ec5..f956ad0e 100644
--- a/lua/colorschemes.lua
+++ b/lua/colorschemes.lua
@@ -56,6 +56,9 @@ M.colorscheme_conf = {
vim.g.material_style = "oceanic"
vim.cmd('colorscheme material')
end,
+ arctic = function ()
+ vim.cmd("colorscheme arctic")
+ end
}
--- Use a random colorscheme from the pre-defined list of colorschemes.
diff --git a/lua/plugin_specs.lua b/lua/plugin_specs.lua
index 551dc855..f040f23a 100644
--- a/lua/plugin_specs.lua
+++ b/lua/plugin_specs.lua
@@ -142,6 +142,12 @@ local plugin_specs = {
{ "catppuccin/nvim", name = "catppuccin", lazy = true },
{ "olimorris/onedarkpro.nvim", lazy = true },
{ "marko-cerovac/material.nvim", lazy = true },
+ {
+ "rockyzhang24/arctic.nvim",
+ dependencies = { "rktjmp/lush.nvim" },
+ name = "arctic",
+ branch = "v2",
+ },
{ "nvim-tree/nvim-web-devicons", event = "VeryLazy" },
From 5502d29f408509838afab2b0e6e5ef6b1614f543 Mon Sep 17 00:00:00 2001
From: jdhao
Date: Mon, 5 Aug 2024 23:14:24 +0200
Subject: [PATCH 016/247] update config related to folding
1. For python and lua, rely on LSP for folding
2. show fold signs on the right of the number column
---
after/ftplugin/lua.vim | 4 ----
after/ftplugin/python.vim | 4 ----
lua/plugin_specs.lua | 2 +-
3 files changed, 1 insertion(+), 9 deletions(-)
diff --git a/after/ftplugin/lua.vim b/after/ftplugin/lua.vim
index 910c31da..914dd843 100644
--- a/after/ftplugin/lua.vim
+++ b/after/ftplugin/lua.vim
@@ -3,7 +3,3 @@ set formatoptions-=o
set formatoptions-=r
nnoremap :luafile %
-
-" Use nvim-treesitter for folding
-set foldmethod=expr
-set foldexpr=nvim_treesitter#foldexpr()
diff --git a/after/ftplugin/python.vim b/after/ftplugin/python.vim
index a9f625c4..7e8b33ba 100644
--- a/after/ftplugin/python.vim
+++ b/after/ftplugin/python.vim
@@ -12,7 +12,3 @@ set tabstop=4 " number of visual spaces per TAB
set softtabstop=4 " number of spaces in tab when editing
set shiftwidth=4 " number of spaces to use for autoindent
set expandtab " expand tab to spaces so that tabs are spaces
-
-" Use nvim-treesitter for folding
-set foldmethod=expr
-set foldexpr=nvim_treesitter#foldexpr()
diff --git a/lua/plugin_specs.lua b/lua/plugin_specs.lua
index f040f23a..008c11f6 100644
--- a/lua/plugin_specs.lua
+++ b/lua/plugin_specs.lua
@@ -194,9 +194,9 @@ local plugin_specs = {
require("statuscol").setup {
relculright = true,
segments = {
- { text = { builtin.foldfunc }, click = "v:lua.ScFa" },
{ 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,
From 44e9e5a1ce766d31770329257f52f97a27bdb7ae Mon Sep 17 00:00:00 2001
From: jdhao
Date: Mon, 5 Aug 2024 23:23:44 +0200
Subject: [PATCH 017/247] Fix lua_ls diagnostic warnings
---
init.lua | 14 ++++++++++----
lua/config/nvim_ufo.lua | 1 -
lua/config/statusline.lua | 3 ++-
lua/mappings.lua | 4 +++-
4 files changed, 15 insertions(+), 7 deletions(-)
diff --git a/init.lua b/init.lua
index ee66d272..9fda2f9a 100644
--- a/init.lua
+++ b/init.lua
@@ -14,15 +14,21 @@ vim.loader.enable()
local version = vim.version
-- check if we have the latest stable version of nvim
-local expected_ver = "0.10.1"
-local expect_ver = version.parse(expected_ver)
-local actual_ver = version()
+local expected_ver_str = "0.10.1"
+local expect_ver = version.parse(expected_ver_str)
+local actual_ver = vim.version()
+
+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
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)
end
diff --git a/lua/config/nvim_ufo.lua b/lua/config/nvim_ufo.lua
index 2430932d..96d7bc11 100644
--- a/lua/config/nvim_ufo.lua
+++ b/lua/config/nvim_ufo.lua
@@ -1,6 +1,5 @@
local handler = function(virtText, lnum, endLnum, width, truncate)
local newVirtText = {}
- local totalLines = vim.api.nvim_buf_line_count(0)
local foldedLines = endLnum - lnum
local suffix = (" %d"):format(foldedLines)
local sufWidth = vim.fn.strdisplaywidth(suffix)
diff --git a/lua/config/statusline.lua b/lua/config/statusline.lua
index 466edf6c..08ead79a 100644
--- a/lua/config/statusline.lua
+++ b/lua/config/statusline.lua
@@ -127,6 +127,7 @@ local get_active_lsp = function()
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
@@ -149,7 +150,7 @@ require("lualine").setup {
lualine_b = {
{
"branch",
- fmt = function(name, context)
+ fmt = function(name, _)
-- truncate branch name in case the name is too long
return string.sub(name, 1, 20)
end,
diff --git a/lua/mappings.lua b/lua/mappings.lua
index 96a07cc7..f2976953 100644
--- a/lua/mappings.lua
+++ b/lua/mappings.lua
@@ -1,5 +1,4 @@
local keymap = vim.keymap
-local api = vim.api
local uv = vim.uv
-- Save key strokes (now we do not need to press shift to enter command mode).
@@ -215,6 +214,9 @@ keymap.set("n", "cb", function()
local cnt = 0
local blink_times = 7
local timer = uv.new_timer()
+ if timer == nil then
+ return
+ end
timer:start(0, 100, vim.schedule_wrap(function()
vim.cmd [[
From acc3ed7829882a55e2e3ce29163cb9b2b907a5e5 Mon Sep 17 00:00:00 2001
From: jdhao
Date: Mon, 5 Aug 2024 23:32:03 +0200
Subject: [PATCH 018/247] show error message only when no word is under cursor
---
lua/config/hlslens.lua | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/lua/config/hlslens.lua b/lua/config/hlslens.lua
index 36323470..c682d5c0 100644
--- a/lua/config/hlslens.lua
+++ b/lua/config/hlslens.lua
@@ -36,11 +36,15 @@ keymap.set("n", "N", "", {
})
local no_word_under_cursor = function()
- local word_under_cursor = vim.fn.expand("")
+ local cursor_word = vim.fn.expand("")
- local msg = "E348: No string under cursor"
- api.nvim_err_writeln(msg)
- return word_under_cursor == ""
+ 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", "*", "", {
From b728b3978421048e8a0336ea7a09cfcc0507f92f Mon Sep 17 00:00:00 2001
From: jdhao
Date: Mon, 5 Aug 2024 23:34:19 +0200
Subject: [PATCH 019/247] update type hint for functions
---
lua/utils.lua | 18 ++++++------------
1 file changed, 6 insertions(+), 12 deletions(-)
diff --git a/lua/utils.lua b/lua/utils.lua
index fef41782..6b279d62 100644
--- a/lua/utils.lua
+++ b/lua/utils.lua
@@ -11,9 +11,8 @@ function M.executable(name)
end
--- check whether a feature exists in Nvim
---- @feat: string
---- the feature name, like `nvim-0.7` or `unix`.
---- return: bool
+--- @param feat string the feature name, like `nvim-0.7` or `unix`.
+--- @return boolean
M.has = function(feat)
if fn.has(feat) == 1 then
return true
@@ -33,8 +32,9 @@ end
--- Generate random integers in the range [Low, High], inclusive,
--- adapted from https://stackoverflow.com/a/12739441/6064933
---- @low: the lower value for this range
---- @high: the upper value for this range
+--- @param low integer the lower value for this range
+--- @param high integer the upper value for this range
+--- @return integer
function M.rand_int(low, high)
-- Use lua to generate random int, see also: https://stackoverflow.com/a/20157671/6064933
math.randomseed(os.time())
@@ -43,17 +43,11 @@ function M.rand_int(low, high)
end
--- 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)
local idx = M.rand_int(1, #seq)
return seq[idx]
end
-function M.add_pack(name)
- local status, error = pcall(vim.cmd, "packadd " .. name)
-
- return status
-end
-
return M
From 794b09809030e19ed45fa4752597fd6df9436cbf Mon Sep 17 00:00:00 2001
From: jdhao
Date: Mon, 5 Aug 2024 23:58:20 +0200
Subject: [PATCH 020/247] Add git blame mapping
---
lua/config/fugitive.lua | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/lua/config/fugitive.lua b/lua/config/fugitive.lua
index b9c45e2a..9aaab97d 100644
--- a/lua/config/fugitive.lua
+++ b/lua/config/fugitive.lua
@@ -6,6 +6,7 @@ keymap.set("n", "gc", "Git commit", { desc = "Git commit" })
keymap.set("n", "gd", "Gdiffsplit", { desc = "Git diff" })
keymap.set("n", "gpl", "Git pull", { desc = "Git pull" })
keymap.set("n", "gpu", "15 split|term git push", { desc = "Git push" })
+keymap.set("v", "gb", ":Git blame", { desc = "Git blame line" })
-- convert git to Git in command line mode
-vim.fn['utils#Cabbrev']('git', 'Git')
+vim.fn["utils#Cabbrev"]("git", "Git")
From b3a26e42269846041ddcfb0cf8d8a1d6ae238589 Mon Sep 17 00:00:00 2001
From: jdhao
Date: Tue, 6 Aug 2024 00:01:17 +0200
Subject: [PATCH 021/247] update load condtion for nvim-tree
---
lua/plugin_specs.lua | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lua/plugin_specs.lua b/lua/plugin_specs.lua
index 008c11f6..20bf4eb7 100644
--- a/lua/plugin_specs.lua
+++ b/lua/plugin_specs.lua
@@ -527,7 +527,7 @@ local plugin_specs = {
-- file explorer
{
"nvim-tree/nvim-tree.lua",
- keys = { "s" },
+ event = "VeryLazy",
dependencies = { "nvim-tree/nvim-web-devicons" },
config = function()
require("config.nvim-tree")
From b30cc9ed782a1d93154907e692078725e74ff31d Mon Sep 17 00:00:00 2001
From: jdhao
Date: Tue, 6 Aug 2024 00:04:48 +0200
Subject: [PATCH 022/247] update user dictionary
---
spell/en.utf-8.add | 3 +++
1 file changed, 3 insertions(+)
diff --git a/spell/en.utf-8.add b/spell/en.utf-8.add
index 9767d50e..42e271e3 100644
--- a/spell/en.utf-8.add
+++ b/spell/en.utf-8.add
@@ -467,3 +467,6 @@ pylintrc
PYTHONPATH
Uvicorn
qpdf
+Elasticsearch
+kibana
+submodule
From 262ad6aa381ee7f6b6c35f87b1616bd173c31d4c Mon Sep 17 00:00:00 2001
From: jdhao
Date: Tue, 6 Aug 2024 00:15:31 +0200
Subject: [PATCH 023/247] Add new colorscheme kanagawa
---
lua/colorschemes.lua | 3 +++
lua/plugin_specs.lua | 2 +-
2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/lua/colorschemes.lua b/lua/colorschemes.lua
index f956ad0e..132e3c28 100644
--- a/lua/colorschemes.lua
+++ b/lua/colorschemes.lua
@@ -58,6 +58,9 @@ M.colorscheme_conf = {
end,
arctic = function ()
vim.cmd("colorscheme arctic")
+ end,
+ kanagawa = function()
+ vim.cmd("colorscheme kanagawa-wave")
end
}
diff --git a/lua/plugin_specs.lua b/lua/plugin_specs.lua
index 20bf4eb7..ed5a1c3d 100644
--- a/lua/plugin_specs.lua
+++ b/lua/plugin_specs.lua
@@ -148,7 +148,7 @@ local plugin_specs = {
name = "arctic",
branch = "v2",
},
-
+ { "rebelot/kanagawa.nvim", lazy = true },
{ "nvim-tree/nvim-web-devicons", event = "VeryLazy" },
{
From e6f95cedb15eb9cc6f7ded15017fd4e4fb60e8af Mon Sep 17 00:00:00 2001
From: jdhao
Date: Tue, 6 Aug 2024 00:50:47 +0200
Subject: [PATCH 024/247] Update installation doc
---
docs/README.md | 36 +++++-------------------------------
1 file changed, 5 insertions(+), 31 deletions(-)
diff --git a/docs/README.md b/docs/README.md
index 774d9196..d041655f 100644
--- a/docs/README.md
+++ b/docs/README.md
@@ -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.
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.
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 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
-brew install ctags
+brew install universal-ctags
```
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.
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).
-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.
+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**.
## Setting up Nvim
From 4c697d89f30ae619d82749a6f0f89f2a4a6e51d7 Mon Sep 17 00:00:00 2001
From: jdhao
Date: Tue, 6 Aug 2024 17:00:18 +0200
Subject: [PATCH 025/247] change name of lualine config
---
lua/config/lualine.lua | 228 +++++++++++++++++++++++++++++++++++++++++
lua/plugin_specs.lua | 2 +-
2 files changed, 229 insertions(+), 1 deletion(-)
create mode 100644 lua/config/lualine.lua
diff --git a/lua/config/lualine.lua b/lua/config/lualine.lua
new file mode 100644
index 00000000..08ead79a
--- /dev/null
+++ b/lua/config/lualine.lua
@@ -0,0 +1,228 @@
+local fn = vim.fn
+
+local function spell()
+ if vim.o.spell then
+ return string.format("[SPELL]")
+ end
+
+ return ""
+end
+
+--- show indicator for Chinese IME
+local function ime_state()
+ if vim.g.is_mac then
+ -- ref: https://github.com/vim-airline/vim-airline/blob/master/autoload/airline/extensions/xkblayout.vim#L11
+ local layout = fn.libcall(vim.g.XkbSwitchLib, "Xkb_Switch_getXkbLayout", "")
+
+ -- We can use `xkbswitch -g` on the command line to get current mode.
+ -- mode for macOS builtin pinyin IME: com.apple.inputmethod.SCIM.ITABC
+ -- mode for Rime: im.rime.inputmethod.Squirrel.Rime
+ local res = fn.match(layout, [[\v(Squirrel\.Rime|SCIM.ITABC)]])
+ if res ~= -1 then
+ return "[CN]"
+ end
+ end
+
+ return ""
+end
+
+local function trailing_space()
+ if not vim.o.modifiable then
+ return ""
+ end
+
+ local line_num = nil
+
+ for i = 1, fn.line("$") do
+ local linetext = fn.getline(i)
+ -- To prevent invalid escape error, we wrap the regex string with `[[]]`.
+ local idx = fn.match(linetext, [[\v\s+$]])
+
+ if idx ~= -1 then
+ line_num = i
+ break
+ end
+ end
+
+ local msg = ""
+ if line_num ~= nil then
+ msg = string.format("[%d]trailing", line_num)
+ end
+
+ return msg
+end
+
+local function mixed_indent()
+ if not vim.o.modifiable then
+ return ""
+ end
+
+ local space_pat = [[\v^ +]]
+ local tab_pat = [[\v^\t+]]
+ local space_indent = fn.search(space_pat, "nwc")
+ local tab_indent = fn.search(tab_pat, "nwc")
+ local mixed = (space_indent > 0 and tab_indent > 0)
+ local mixed_same_line
+ if not mixed then
+ mixed_same_line = fn.search([[\v^(\t+ | +\t)]], "nwc")
+ mixed = mixed_same_line > 0
+ end
+ if not mixed then
+ return ""
+ end
+ if mixed_same_line ~= nil and mixed_same_line > 0 then
+ return "MI:" .. mixed_same_line
+ end
+ local space_indent_cnt = fn.searchcount({ pattern = space_pat, max_count = 1e3 }).total
+ local tab_indent_cnt = fn.searchcount({ pattern = tab_pat, max_count = 1e3 }).total
+ if space_indent_cnt > tab_indent_cnt then
+ return "MI:" .. tab_indent
+ else
+ return "MI:" .. space_indent
+ end
+end
+
+local diff = function()
+ local git_status = vim.b.gitsigns_status_dict
+ if git_status == nil then
+ return
+ end
+
+ local modify_num = git_status.changed
+ local remove_num = git_status.removed
+ local add_num = git_status.added
+
+ local info = { added = add_num, modified = modify_num, removed = remove_num }
+ -- vim.print(info)
+ return info
+end
+
+local virtual_env = function()
+ -- only show virtual env for Python
+ if vim.bo.filetype ~= "python" then
+ return ""
+ end
+
+ local conda_env = os.getenv("CONDA_DEFAULT_ENV")
+ local venv_path = os.getenv("VIRTUAL_ENV")
+
+ if venv_path == nil then
+ if conda_env == nil then
+ return ""
+ else
+ return string.format(" %s (conda)", conda_env)
+ end
+ else
+ local venv_name = vim.fn.fnamemodify(venv_path, ":t")
+ return string.format(" %s (venv)", venv_name)
+ 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 {
+ options = {
+ icons_enabled = true,
+ theme = "auto",
+ section_separators = "",
+ component_separators = "",
+ disabled_filetypes = {},
+ always_divide_middle = true,
+ },
+ sections = {
+ lualine_a = { "mode" },
+ lualine_b = {
+ {
+ "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",
+ source = diff,
+ },
+ {
+ ime_state,
+ color = { fg = "black", bg = "#f46868" },
+ },
+ {
+ spell,
+ color = { fg = "black", bg = "#a7c080" },
+ },
+ },
+ lualine_x = {
+ {
+ get_active_lsp,
+ icon = " LSP:",
+ },
+ {
+ "diagnostics",
+ sources = { "nvim_diagnostic" },
+ symbols = { error = "🆇 ", warn = "⚠️ ", info = "ℹ️ ", hint = " " },
+ },
+ },
+ lualine_y = {
+ "encoding",
+ {
+ "fileformat",
+ symbols = {
+ unix = "unix",
+ dos = "win",
+ mac = "mac",
+ },
+ },
+ "filetype",
+ },
+ lualine_z = {
+ {
+ trailing_space,
+ color = "WarningMsg",
+ },
+ {
+ mixed_indent,
+ color = "WarningMsg",
+ },
+ "progress"
+ },
+ },
+ inactive_sections = {
+ lualine_a = {},
+ lualine_b = {},
+ lualine_c = { "filename" },
+ lualine_x = { "location" },
+ lualine_y = {},
+ lualine_z = {},
+ },
+ tabline = {},
+ extensions = { "quickfix", "fugitive", "nvim-tree" },
+}
diff --git a/lua/plugin_specs.lua b/lua/plugin_specs.lua
index ed5a1c3d..c57fd25f 100644
--- a/lua/plugin_specs.lua
+++ b/lua/plugin_specs.lua
@@ -156,7 +156,7 @@ local plugin_specs = {
event = "VeryLazy",
cond = firenvim_not_active,
config = function()
- require("config.statusline")
+ require("config.lualine")
end,
},
From 8af8ebd72a3632c96968a686e2d2fdeaa61de092 Mon Sep 17 00:00:00 2001
From: jdhao
Date: Tue, 6 Aug 2024 17:25:33 +0200
Subject: [PATCH 026/247] remove statusline.lua
---
lua/config/statusline.lua | 228 --------------------------------------
1 file changed, 228 deletions(-)
delete mode 100644 lua/config/statusline.lua
diff --git a/lua/config/statusline.lua b/lua/config/statusline.lua
deleted file mode 100644
index 08ead79a..00000000
--- a/lua/config/statusline.lua
+++ /dev/null
@@ -1,228 +0,0 @@
-local fn = vim.fn
-
-local function spell()
- if vim.o.spell then
- return string.format("[SPELL]")
- end
-
- return ""
-end
-
---- show indicator for Chinese IME
-local function ime_state()
- if vim.g.is_mac then
- -- ref: https://github.com/vim-airline/vim-airline/blob/master/autoload/airline/extensions/xkblayout.vim#L11
- local layout = fn.libcall(vim.g.XkbSwitchLib, "Xkb_Switch_getXkbLayout", "")
-
- -- We can use `xkbswitch -g` on the command line to get current mode.
- -- mode for macOS builtin pinyin IME: com.apple.inputmethod.SCIM.ITABC
- -- mode for Rime: im.rime.inputmethod.Squirrel.Rime
- local res = fn.match(layout, [[\v(Squirrel\.Rime|SCIM.ITABC)]])
- if res ~= -1 then
- return "[CN]"
- end
- end
-
- return ""
-end
-
-local function trailing_space()
- if not vim.o.modifiable then
- return ""
- end
-
- local line_num = nil
-
- for i = 1, fn.line("$") do
- local linetext = fn.getline(i)
- -- To prevent invalid escape error, we wrap the regex string with `[[]]`.
- local idx = fn.match(linetext, [[\v\s+$]])
-
- if idx ~= -1 then
- line_num = i
- break
- end
- end
-
- local msg = ""
- if line_num ~= nil then
- msg = string.format("[%d]trailing", line_num)
- end
-
- return msg
-end
-
-local function mixed_indent()
- if not vim.o.modifiable then
- return ""
- end
-
- local space_pat = [[\v^ +]]
- local tab_pat = [[\v^\t+]]
- local space_indent = fn.search(space_pat, "nwc")
- local tab_indent = fn.search(tab_pat, "nwc")
- local mixed = (space_indent > 0 and tab_indent > 0)
- local mixed_same_line
- if not mixed then
- mixed_same_line = fn.search([[\v^(\t+ | +\t)]], "nwc")
- mixed = mixed_same_line > 0
- end
- if not mixed then
- return ""
- end
- if mixed_same_line ~= nil and mixed_same_line > 0 then
- return "MI:" .. mixed_same_line
- end
- local space_indent_cnt = fn.searchcount({ pattern = space_pat, max_count = 1e3 }).total
- local tab_indent_cnt = fn.searchcount({ pattern = tab_pat, max_count = 1e3 }).total
- if space_indent_cnt > tab_indent_cnt then
- return "MI:" .. tab_indent
- else
- return "MI:" .. space_indent
- end
-end
-
-local diff = function()
- local git_status = vim.b.gitsigns_status_dict
- if git_status == nil then
- return
- end
-
- local modify_num = git_status.changed
- local remove_num = git_status.removed
- local add_num = git_status.added
-
- local info = { added = add_num, modified = modify_num, removed = remove_num }
- -- vim.print(info)
- return info
-end
-
-local virtual_env = function()
- -- only show virtual env for Python
- if vim.bo.filetype ~= "python" then
- return ""
- end
-
- local conda_env = os.getenv("CONDA_DEFAULT_ENV")
- local venv_path = os.getenv("VIRTUAL_ENV")
-
- if venv_path == nil then
- if conda_env == nil then
- return ""
- else
- return string.format(" %s (conda)", conda_env)
- end
- else
- local venv_name = vim.fn.fnamemodify(venv_path, ":t")
- return string.format(" %s (venv)", venv_name)
- 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 {
- options = {
- icons_enabled = true,
- theme = "auto",
- section_separators = "",
- component_separators = "",
- disabled_filetypes = {},
- always_divide_middle = true,
- },
- sections = {
- lualine_a = { "mode" },
- lualine_b = {
- {
- "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",
- source = diff,
- },
- {
- ime_state,
- color = { fg = "black", bg = "#f46868" },
- },
- {
- spell,
- color = { fg = "black", bg = "#a7c080" },
- },
- },
- lualine_x = {
- {
- get_active_lsp,
- icon = " LSP:",
- },
- {
- "diagnostics",
- sources = { "nvim_diagnostic" },
- symbols = { error = "🆇 ", warn = "⚠️ ", info = "ℹ️ ", hint = " " },
- },
- },
- lualine_y = {
- "encoding",
- {
- "fileformat",
- symbols = {
- unix = "unix",
- dos = "win",
- mac = "mac",
- },
- },
- "filetype",
- },
- lualine_z = {
- {
- trailing_space,
- color = "WarningMsg",
- },
- {
- mixed_indent,
- color = "WarningMsg",
- },
- "progress"
- },
- },
- inactive_sections = {
- lualine_a = {},
- lualine_b = {},
- lualine_c = { "filename" },
- lualine_x = { "location" },
- lualine_y = {},
- lualine_z = {},
- },
- tabline = {},
- extensions = { "quickfix", "fugitive", "nvim-tree" },
-}
From fd6df981cd0b888d3a51666af2bb1fc5b8db8dd7 Mon Sep 17 00:00:00 2001
From: jdhao
Date: Tue, 6 Aug 2024 17:58:05 +0200
Subject: [PATCH 027/247] Update nvim-ufo settings
---
lua/config/lsp.lua | 5 +++++
lua/config/nvim_ufo.lua | 7 +++----
2 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/lua/config/lsp.lua b/lua/config/lsp.lua
index f43aa583..da7d93c6 100644
--- a/lua/config/lsp.lua
+++ b/lua/config/lsp.lua
@@ -110,6 +110,11 @@ local custom_attach = function(client, bufnr)
end
local capabilities = require('cmp_nvim_lsp').default_capabilities()
+-- required by nvim-ufo
+capabilities.textDocument.foldingRange = {
+ dynamicRegistration = false,
+ lineFoldingOnly = true
+}
local lspconfig = require("lspconfig")
diff --git a/lua/config/nvim_ufo.lua b/lua/config/nvim_ufo.lua
index 96d7bc11..b8704ee7 100644
--- a/lua/config/nvim_ufo.lua
+++ b/lua/config/nvim_ufo.lua
@@ -30,10 +30,9 @@ local handler = function(virtText, lnum, endLnum, width, truncate)
return newVirtText
end
-local opts = {}
-opts["fold_virt_text_handler"] = handler
-
-require("ufo").setup(opts)
+require("ufo").setup {
+ fold_virt_text_handler = handler,
+}
vim.keymap.set("n", "zR", require("ufo").openAllFolds)
vim.keymap.set("n", "zM", require("ufo").closeAllFolds)
From f1062a3d8f0002e8fd3ddf45580397e013c0aa8b Mon Sep 17 00:00:00 2001
From: jdhao
Date: Tue, 6 Aug 2024 18:00:41 +0200
Subject: [PATCH 028/247] filter fold level sign for statuscol.nvim
Only show fold signs for fold level below a certain level to avoid
clutter the left side columns with a lot of folding signs
---
lua/config/nvim-statuscol.lua | 23 +++++++++++++++++++++++
lua/plugin_specs.lua | 10 +---------
2 files changed, 24 insertions(+), 9 deletions(-)
create mode 100644 lua/config/nvim-statuscol.lua
diff --git a/lua/config/nvim-statuscol.lua b/lua/config/nvim-statuscol.lua
new file mode 100644
index 00000000..a0998de6
--- /dev/null
+++ b/lua/config/nvim-statuscol.lua
@@ -0,0 +1,23 @@
+local builtin = require("statuscol.builtin")
+local ffi = require("statuscol.ffidef")
+local C = ffi.C
+
+-- only show fold level up to this level
+local fold_level_limit = 2
+local function foldfunc(args)
+ local foldinfo = C.fold_info(args.wp, args.lnum)
+ if foldinfo.level > fold_level_limit then
+ return " "
+ end
+
+ return builtin.foldfunc(args)
+end
+
+require("statuscol").setup {
+ relculright = false,
+ segments = {
+ { text = { "%s" }, click = "v:lua.ScSa" },
+ { text = { builtin.lnumfunc, " " }, click = "v:lua.ScLa" },
+ { text = { foldfunc, " " }, condition = { true, builtin.not_empty }, click = "v:lua.ScFa" },
+ },
+}
diff --git a/lua/plugin_specs.lua b/lua/plugin_specs.lua
index c57fd25f..ee87c053 100644
--- a/lua/plugin_specs.lua
+++ b/lua/plugin_specs.lua
@@ -190,15 +190,7 @@ local plugin_specs = {
"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" },
- },
- }
+ require("config.nvim-statuscol")
end,
},
{
From cfc0089bb5f923084f5e8df4933cf7033364aa4d Mon Sep 17 00:00:00 2001
From: jdhao
Date: Tue, 6 Aug 2024 18:47:50 +0200
Subject: [PATCH 029/247] add plugin lazydev.nvim
---
lua/plugin_specs.lua | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/lua/plugin_specs.lua b/lua/plugin_specs.lua
index ee87c053..96200245 100644
--- a/lua/plugin_specs.lua
+++ b/lua/plugin_specs.lua
@@ -534,6 +534,11 @@ local plugin_specs = {
require("config.fidget-nvim")
end,
},
+ {
+ "folke/lazydev.nvim",
+ ft = "lua", -- only load on lua files
+ opts = {},
+ },
}
require("lazy").setup {
From 85232b82a856481c2a8ffeaa4968a0092e274089 Mon Sep 17 00:00:00 2001
From: jdhao
Date: Fri, 9 Aug 2024 22:03:02 +0200
Subject: [PATCH 030/247] Update mapping of plugin open-browser.vim
---
viml_conf/plugins.vim | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/viml_conf/plugins.vim b/viml_conf/plugins.vim
index da3252ec..f7c202ba 100644
--- a/viml_conf/plugins.vim
+++ b/viml_conf/plugins.vim
@@ -119,8 +119,9 @@ if g:is_win || g:is_mac
let g:netrw_nogx = 1
" Use another mapping for the open URL method
- nmap ob (openbrowser-smart-search)
- xmap ob (openbrowser-smart-search)
+ nmap ob (openbrowser-smart-search)
+ xmap ob (openbrowser-smart-search)
+ nmap ob echoerr "Use ob instead!"
endif
""""""""""""""""""""""""""" vista settings """"""""""""""""""""""""""""""""""
From 9ff76931e366634f0e73d0ef3ca600bb79c5272a Mon Sep 17 00:00:00 2001
From: jdhao
Date: Fri, 9 Aug 2024 22:18:39 +0200
Subject: [PATCH 031/247] update git related mappings
---
lua/config/fugitive.lua | 29 ++++++++++++++++++++++-------
lua/config/git-linker.lua | 6 +++---
2 files changed, 25 insertions(+), 10 deletions(-)
diff --git a/lua/config/fugitive.lua b/lua/config/fugitive.lua
index 9aaab97d..8d37cf3f 100644
--- a/lua/config/fugitive.lua
+++ b/lua/config/fugitive.lua
@@ -1,12 +1,27 @@
local keymap = vim.keymap
-keymap.set("n", "gs", "Git", { desc = "Git status" })
-keymap.set("n", "gw", "Gwrite", { desc = "Git add" })
-keymap.set("n", "gc", "Git commit", { desc = "Git commit" })
-keymap.set("n", "gd", "Gdiffsplit", { desc = "Git diff" })
-keymap.set("n", "gpl", "Git pull", { desc = "Git pull" })
-keymap.set("n", "gpu", "15 split|term git push", { desc = "Git push" })
-keymap.set("v", "gb", ":Git blame", { desc = "Git blame line" })
+keymap.set("n", "gs", "Git", { desc = "Git: show status" })
+keymap.set("n", "gw", "Gwrite", { desc = "Git: add file" })
+keymap.set("n", "gc", "Git commit", { desc = "Git: commit changes" })
+keymap.set("n", "gpl", "Git pull", { desc = "Git: pull changes" })
+keymap.set("n", "gpu", "15 split|term git push", { desc = "Git: push changes" })
+keymap.set("v", "gb", ":Git blame", { desc = "Git: blame selected line" })
-- convert git to Git in command line mode
vim.fn["utils#Cabbrev"]("git", "Git")
+
+keymap.set("n", "gnb", function()
+ vim.ui.input({ prompt = "Enter the new branch nmae" }, function(user_input)
+ if user_input == nil or user_input == "" then
+ return
+ end
+
+ local cmd_str = string.format("G checkout -b %s", user_input)
+ vim.cmd(cmd_str)
+ end)
+end, {
+ desc = "Git: create new branch",
+})
+
+keymap.set("n", "gf", "Git fetch", { desc = "Git: prune branches" })
+keymap.set("n", "gbd", ":Git branch -D ", { desc = "Git: delete branch" })
diff --git a/lua/config/git-linker.lua b/lua/config/git-linker.lua
index 39f5ba21..e3fb3e67 100644
--- a/lua/config/git-linker.lua
+++ b/lua/config/git-linker.lua
@@ -24,14 +24,14 @@ keymap.set({ "n", "v" }, "gl", function()
gitlinker.get_buf_range_url(mode)
end, {
silent = true,
- desc = "get git permlink",
+ desc = "Git: get permlink",
})
-keymap.set("n", "gb", function()
+keymap.set("n", "gbr", function()
gitlinker.get_repo_url({
action_callback = gitlinker.actions.open_in_browser
})
end, {
silent = true,
- desc = "browse repo in browser",
+ desc = "Git: browse repo in browser",
})
From a602d9881982ec209218299bad200c98f53b2259 Mon Sep 17 00:00:00 2001
From: jdhao
Date: Fri, 9 Aug 2024 22:22:01 +0200
Subject: [PATCH 032/247] fix git mapping issue
` `mapping must end with ``
---
lua/config/fugitive.lua | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lua/config/fugitive.lua b/lua/config/fugitive.lua
index 8d37cf3f..b92415a9 100644
--- a/lua/config/fugitive.lua
+++ b/lua/config/fugitive.lua
@@ -23,5 +23,5 @@ end, {
desc = "Git: create new branch",
})
-keymap.set("n", "gf", "Git fetch", { desc = "Git: prune branches" })
+keymap.set("n", "gf", ":Git fetch ", { desc = "Git: prune branches" })
keymap.set("n", "gbd", ":Git branch -D ", { desc = "Git: delete branch" })
From 659f410b9ea400277a444813f10ce7b747a025d1 Mon Sep 17 00:00:00 2001
From: jdhao
Date: Thu, 15 Aug 2024 23:37:35 +0200
Subject: [PATCH 033/247] move version check into function
---
init.lua | 22 +++-------------------
lua/utils.lua | 29 +++++++++++++++++++++++++++++
2 files changed, 32 insertions(+), 19 deletions(-)
diff --git a/init.lua b/init.lua
index 9fda2f9a..5199cd72 100644
--- a/init.lua
+++ b/init.lua
@@ -11,26 +11,10 @@
-- StackOverflow: https://stackoverflow.com/users/6064933/jdhao
vim.loader.enable()
-local version = vim.version
+local utils = require("utils")
--- check if we have the latest stable version of nvim
-local expected_ver_str = "0.10.1"
-local expect_ver = version.parse(expected_ver_str)
-local actual_ver = vim.version()
-
-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
- 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_str, _ver)
- vim.api.nvim_err_writeln(msg)
-end
+local expected_version = "0.10.1"
+utils.is_compatible_version(expected_version)
local core_conf_files = {
"globals.lua", -- some global settings
diff --git a/lua/utils.lua b/lua/utils.lua
index 6b279d62..86a97d08 100644
--- a/lua/utils.lua
+++ b/lua/utils.lua
@@ -1,4 +1,5 @@
local fn = vim.fn
+local version = vim.version
local M = {}
@@ -50,4 +51,32 @@ function M.rand_element(seq)
return seq[idx]
end
+--- check if the current nvim version is compatible with the allowed version
+--- @param expected_version string
+--- @return boolean
+function M.is_compatible_version(expected_version)
+ -- check if we have the latest stable version of nvim
+ local expect_ver = version.parse(expected_version)
+ local actual_ver = vim.version()
+
+ if expect_ver == nil then
+ local msg = string.format("Unsupported version string: %s", expected_version)
+ vim.api.nvim_err_writeln(msg)
+ return false
+ end
+
+ local result = version.cmp(expect_ver, actual_ver)
+ if result ~= 0 then
+ local _ver = string.format("%s.%s.%s", actual_ver.major, actual_ver.minor, actual_ver.patch)
+ local msg = string.format(
+ "Expect nvim version %s, but your current nvim version is %s. Use at your own risk!",
+ expected_version,
+ _ver
+ )
+ vim.api.nvim_err_writeln(msg)
+ end
+
+ return true
+end
+
return M
From d90273df8eacdb33557258118df89806f7bbc295 Mon Sep 17 00:00:00 2001
From: jdhao
Date: Thu, 15 Aug 2024 23:43:41 +0200
Subject: [PATCH 034/247] remove lua_ls conf in favor of lazydev.nvim
The removed settings are already set by lazydev.nvim.
---
lua/config/lsp.lua | 16 ----------------
1 file changed, 16 deletions(-)
diff --git a/lua/config/lsp.lua b/lua/config/lsp.lua
index da7d93c6..2b385a18 100644
--- a/lua/config/lsp.lua
+++ b/lua/config/lsp.lua
@@ -230,22 +230,6 @@ if utils.executable("lua-language-server") then
-- Tell the language server which version of Lua you're using (most likely LuaJIT in the case of Neovim)
version = "LuaJIT",
},
- diagnostics = {
- -- Get the language server to recognize the `vim` global
- globals = { "vim" },
- },
- workspace = {
- -- Make the server aware of Neovim runtime files,
- -- see also https://luals.github.io/wiki/settings/#workspacelibrary
- library = {
- vim.env.VIMRUNTIME,
- fn.stdpath("config"),
- -- make lua_ls aware of functions under vim.uv
- "${3rd}/luv/library"
- },
- maxPreload = 2000,
- preloadFileSize = 50000,
- },
},
},
capabilities = capabilities,
From 6e60475f3f956ee4b7a2a2deea47f44d9676ed9a Mon Sep 17 00:00:00 2001
From: jdhao
Date: Fri, 16 Aug 2024 00:02:24 +0200
Subject: [PATCH 035/247] Use gx.nvim for browsing in Browser
---
lua/plugin_specs.lua | 11 +++++++++--
viml_conf/plugins.vim | 11 -----------
2 files changed, 9 insertions(+), 13 deletions(-)
diff --git a/lua/plugin_specs.lua b/lua/plugin_specs.lua
index 96200245..8230e063 100644
--- a/lua/plugin_specs.lua
+++ b/lua/plugin_specs.lua
@@ -223,7 +223,12 @@ local plugin_specs = {
-- 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.
{
- "tyru/open-browser.vim",
+ "chrishrb/gx.nvim",
+ keys = { { "gx", "Browse", mode = { "n", "x" } } },
+ cmd = { "Browse" },
+ init = function()
+ vim.g.netrw_nogx = 1 -- disable netrw gx
+ end,
enabled = function()
if vim.g.is_win or vim.g.is_mac then
return true
@@ -231,7 +236,9 @@ local plugin_specs = {
return false
end
end,
- event = "VeryLazy",
+ dependencies = { "nvim-lua/plenary.nvim" },
+ config = true, -- default settings
+ submodules = false, -- not needed, submodules are required only for tests
},
-- Only install these plugins if ctags are installed on the system
diff --git a/viml_conf/plugins.vim b/viml_conf/plugins.vim
index f7c202ba..9b223a6d 100644
--- a/viml_conf/plugins.vim
+++ b/viml_conf/plugins.vim
@@ -113,17 +113,6 @@ let g:Lf_PreviewResult = {
\ 'Gtags': 0
\}
-""""""""""""""""""""""""""""open-browser.vim settings"""""""""""""""""""
-if g:is_win || g:is_mac
- " Disable netrw's gx mapping.
- let g:netrw_nogx = 1
-
- " Use another mapping for the open URL method
- nmap ob (openbrowser-smart-search)
- xmap ob (openbrowser-smart-search)
- nmap ob echoerr "Use ob instead!"
-endif
-
""""""""""""""""""""""""""" vista settings """"""""""""""""""""""""""""""""""
let g:vista#renderer#icons = {
\ 'member': '',
From eff98d036d93034cc9809ecb942c084ff06818f9 Mon Sep 17 00:00:00 2001
From: jdhao
Date: Sat, 17 Aug 2024 15:10:09 +0200
Subject: [PATCH 036/247] update README
---
README.md | 24 +++++++++++++++++-------
1 file changed, 17 insertions(+), 7 deletions(-)
diff --git a/README.md b/README.md
index 176e43fa..76f3de5c 100644
--- a/README.md
+++ b/README.md
@@ -84,6 +84,7 @@ and how to set up on different platforms (Linux, macOS, and Windows).
+ 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)
++ Code folding with [nvim-ufo](https://github.com/kevinhwang91/nvim-ufo) and [statuscol.nvim](https://github.com/luukvbaal/statuscol.nvim)
+ ......
# UI Demo
@@ -140,6 +141,12 @@ Go to a string starting with `se`
+## code folding with nvim-ufo and statuscol.nvim
+
+
+
+
+
# Shortcuts
Some of the shortcuts I use frequently are listed here. In the following shortcuts, `` represents ASCII character `,`.
@@ -165,12 +172,14 @@ Some of the shortcuts I use frequently are listed here. In the following shortcu
| `t` | Normal | Linux/macOS/Win | Toggle tag window (show project tags in the right window) |
| `gs` | Normal | Linux/macOS/Win | Show Git status result |
| `gw` | Normal | Linux/macOS/Win | Run Git add for current file |
-| `gd` | Normal | Linux/macOS/Win | Run git diff for current file |
| `gc` | Normal | Linux/macOS/Win | Run git commit |
| `gpl` | Normal | Linux/macOS/Win | Run git pull |
| `gpu` | Normal | Linux/macOS/Win | Run git push |
+| `gbd` | Normal | Linux/macOS/Win | Delete a branch |
+| `gbn` | Normal | Linux/macOS/Win | Create a new branch |
| `gl` | Normal/Visual | Linux/macOS/Win | Get perm link for current/visually-select lines |
-| `gb` | Normal | macOS | Browse current git repo in browser |
+| `gbr` | Normal | macOS | Browse current git repo in browser |
+| `gb` | Visual | macOS | Blame current line |
| `` | Normal | Linux/macOS/Win | Compile&run current source file (for C++, LaTeX, Lua, Python) |
| `` | Normal | Linux/macOS/Win | Toggle spell checking |
| `` | Normal | Linux/macOS/Win | Toggle paste mode |
@@ -191,11 +200,12 @@ Some of the shortcuts I use frequently are listed here. In the following shortcu
In addition to commands provided by various plugins, I have also created some custom commands for personal use.
-| command | description | example |
-|------------|-------------------------------------------------------------------------|--------------------------------|
-| `Redir` | capture command output to a tabpage for easier inspection. | `Redir hi` |
-| `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` |
+| command | description | example |
+|--------------|-------------------------------------------------------------------------|--------------------------------|
+| `Redir` | capture command output to a tabpage for easier inspection. | `Redir hi` |
+| `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` |
+| `JSONFormat` | format a JSON file | `JSONFormat` |
# Contributing
From 256c37a946aeb00382c17778a917c7af2805d733 Mon Sep 17 00:00:00 2001
From: jdhao
Date: Sat, 17 Aug 2024 15:15:30 +0200
Subject: [PATCH 037/247] update vim-fugitive mapping
---
lua/config/fugitive.lua | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/lua/config/fugitive.lua b/lua/config/fugitive.lua
index b92415a9..306d71ba 100644
--- a/lua/config/fugitive.lua
+++ b/lua/config/fugitive.lua
@@ -10,8 +10,8 @@ keymap.set("v", "gb", ":Git blame", { desc = "Git: blame selected li
-- convert git to Git in command line mode
vim.fn["utils#Cabbrev"]("git", "Git")
-keymap.set("n", "gnb", function()
- vim.ui.input({ prompt = "Enter the new branch nmae" }, function(user_input)
+keymap.set("n", "gbn", function()
+ vim.ui.input({ prompt = "Enter a new branch name" }, function(user_input)
if user_input == nil or user_input == "" then
return
end
From f9780c2dff238f83863a9bd9030484cb85b9d577 Mon Sep 17 00:00:00 2001
From: jdhao
Date: Sat, 17 Aug 2024 17:28:09 +0200
Subject: [PATCH 038/247] update config for bufferline.nvim
Do not show buffer number and use a mapping to pick buffer instead.
---
lua/config/bufferline.lua | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/lua/config/bufferline.lua b/lua/config/bufferline.lua
index 6fa27cee..747fe185 100644
--- a/lua/config/bufferline.lua
+++ b/lua/config/bufferline.lua
@@ -1,6 +1,6 @@
require("bufferline").setup {
options = {
- numbers = "buffer_id",
+ numbers = "none",
close_command = "bdelete! %d",
right_mouse_command = nil,
left_mouse_command = "buffer %d",
@@ -44,3 +44,7 @@ require("bufferline").setup {
sort_by = "id",
},
}
+
+vim.keymap.set("n", "bp", "BufferLinePick", {
+ desc = "pick a buffer",
+})
From c3d8dc3e1d23f74f02f7972d9d40bfe3dddd394f Mon Sep 17 00:00:00 2001
From: jdhao
Date: Sat, 17 Aug 2024 17:32:24 +0200
Subject: [PATCH 039/247] Add mapping to delete other buffers
---
lua/mappings.lua | 38 +++++++++++++++++++++++++++-----------
1 file changed, 27 insertions(+), 11 deletions(-)
diff --git a/lua/mappings.lua b/lua/mappings.lua
index f2976953..7b4980ea 100644
--- a/lua/mappings.lua
+++ b/lua/mappings.lua
@@ -45,7 +45,21 @@ keymap.set("n", [[\x]], "windo lclose cclose ", {
-- Delete a buffer, without closing the window, see https://stackoverflow.com/q/4465095/6064933
keymap.set("n", [[\d]], "bprevious bdelete #", {
silent = true,
- desc = "delete buffer",
+ desc = "delete current buffer",
+})
+
+keymap.set("n", [[\D]], function()
+ local buf_ids = vim.api.nvim_list_bufs()
+ local cur_buf = vim.api.nvim_win_get_buf(0)
+
+ for _, buf_id in pairs(buf_ids) do
+ -- do not Delete unlisted buffers, which may lead to unexpected errors
+ if vim.api.nvim_get_option_value("buflisted", { buf = buf_id }) and buf_id ~= cur_buf then
+ vim.api.nvim_buf_delete(buf_id, { force = true })
+ end
+ end
+end, {
+ desc = "delete other buffers",
})
-- Insert a blank line below or above current line (do not move the cursor),
@@ -218,18 +232,20 @@ keymap.set("n", "cb", function()
return
end
- timer:start(0, 100, vim.schedule_wrap(function()
- vim.cmd [[
+ timer:start(
+ 0,
+ 100,
+ vim.schedule_wrap(function()
+ vim.cmd([[
set cursorcolumn!
set cursorline!
- ]]
+ ]])
- if cnt == blink_times then
- timer:close()
- end
+ if cnt == blink_times then
+ timer:close()
+ end
- cnt = cnt + 1
- end)
+ cnt = cnt + 1
+ end)
)
-end,
- { desc = "show cursor" })
+end, { desc = "show cursor" })
From 95d3b2f2d86c0f452f9d615eb1c7113eb644c48e Mon Sep 17 00:00:00 2001
From: jdhao
Date: Mon, 19 Aug 2024 22:36:26 +0200
Subject: [PATCH 040/247] remove setting for JSON file
---
after/ftplugin/json.vim | 6 ------
1 file changed, 6 deletions(-)
delete mode 100644 after/ftplugin/json.vim
diff --git a/after/ftplugin/json.vim b/after/ftplugin/json.vim
deleted file mode 100644
index 90db3ec7..00000000
--- a/after/ftplugin/json.vim
+++ /dev/null
@@ -1,6 +0,0 @@
-" let the initial folding state be that all folds are closed.
-set foldlevel=0
-
-" Use nvim-treesitter for folding
-set foldmethod=expr
-set foldexpr=nvim_treesitter#foldexpr()
From 3904cd4ccf801674249569dd83ba52d3d42a4690 Mon Sep 17 00:00:00 2001
From: jdhao
Date: Mon, 19 Aug 2024 23:33:29 +0200
Subject: [PATCH 041/247] Update config for handling large files
---
viml_conf/autocommands.vim | 12 +++++-------
1 file changed, 5 insertions(+), 7 deletions(-)
diff --git a/viml_conf/autocommands.vim b/viml_conf/autocommands.vim
index 0fad8423..3b4ec103 100644
--- a/viml_conf/autocommands.vim
+++ b/viml_conf/autocommands.vim
@@ -101,16 +101,14 @@ augroup END
" ref: https://vi.stackexchange.com/a/169/15292
function! s:handle_large_file() abort
- let g:large_file = 10485760 " 10MB
+ let g:file_size_limit = 524288 " 0.5MB
let f = expand("")
- if getfsize(f) > g:large_file || getfsize(f) == -2
- set eventignore+=all
+ if getfsize(f) > g:file_size_limit || getfsize(f) == -2
+ setlocal eventignore=all
" turning off relative number helps a lot
- set norelativenumber
- setlocal noswapfile bufhidden=unload buftype=nowrite undolevels=-1
- else
- set eventignore-=all relativenumber
+ setlocal norelativenumber
+ setlocal noswapfile bufhidden=unload undolevels=-1
endif
endfunction
From d150f39afc7031ff201bd35e0c02c71f8848fd4e Mon Sep 17 00:00:00 2001
From: jdhao
Date: Mon, 19 Aug 2024 23:37:31 +0200
Subject: [PATCH 042/247] Add new plugins
---
lua/plugin_specs.lua | 29 +++++++++++++++++++++++++++++
1 file changed, 29 insertions(+)
diff --git a/lua/plugin_specs.lua b/lua/plugin_specs.lua
index 8230e063..7e1eee0f 100644
--- a/lua/plugin_specs.lua
+++ b/lua/plugin_specs.lua
@@ -126,6 +126,15 @@ local plugin_specs = {
"nvim-telescope/telescope-symbols.nvim",
},
},
+ {
+ "ibhagwan/fzf-lua",
+ -- optional for icon support
+ dependencies = { "nvim-tree/nvim-web-devicons" },
+ config = function()
+ -- calling `setup` is optional for customization
+ require("fzf-lua").setup {}
+ end,
+ },
{
"MeanderingProgrammer/markdown.nvim",
main = "render-markdown",
@@ -546,6 +555,26 @@ local plugin_specs = {
ft = "lua", -- only load on lua files
opts = {},
},
+ {
+ "CopilotC-Nvim/CopilotChat.nvim",
+ branch = "canary",
+ dependencies = {
+ { "zbirenbaum/copilot.lua" }, -- or github/copilot.vim
+ { "nvim-lua/plenary.nvim" }, -- for curl, log wrapper
+ },
+ opts = {
+ debug = true, -- Enable debugging
+ -- See Configuration section for rest
+ },
+ -- See Commands section for default commands if you want to lazy load on them
+ },
+ {
+ "zbirenbaum/copilot.lua",
+ cmd = "Copilot",
+ config = function()
+ require("copilot").setup {}
+ end,
+ },
}
require("lazy").setup {
From a3c8b3d5b59526f247bffa56ad9fba723d61feaf Mon Sep 17 00:00:00 2001
From: jdhao
Date: Tue, 20 Aug 2024 01:01:04 +0200
Subject: [PATCH 043/247] Update configuration for nvim-cmp
1. restrict max width of the completion menu. Here I am using
lspkind.nvim to achieve this. There are other native ways to do this,
see also https://github.com/hrsh7th/nvim-cmp/discussions/609 and
https://github.com/hrsh7th/nvim-cmp/issues/980
2. remove cmp-emoji as it is rarely used and interfere when I write
Python
3. lower the transparency for popup menu
---
lua/config/nvim-cmp.lua | 5 +++--
lua/plugin_specs.lua | 1 -
viml_conf/options.vim | 2 +-
3 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/lua/config/nvim-cmp.lua b/lua/config/nvim-cmp.lua
index a402f1c7..100c77f0 100644
--- a/lua/config/nvim-cmp.lua
+++ b/lua/config/nvim-cmp.lua
@@ -35,7 +35,6 @@ cmp.setup {
{ name = "ultisnips" }, -- For ultisnips user.
{ name = "path" }, -- for path completion
{ name = "buffer", keyword_length = 2 }, -- for buffer word completion
- { name = "emoji", insert = true }, -- emoji completion
},
completion = {
keyword_length = 1,
@@ -50,12 +49,14 @@ cmp.setup {
menu = {
nvim_lsp = "[LSP]",
ultisnips = "[US]",
- nvim_lua = "[Lua]",
path = "[Path]",
buffer = "[Buffer]",
emoji = "[Emoji]",
omni = "[Omni]",
},
+ show_labelDetails = true,
+ maxwidth = 40,
+ ellipsis_char = "...",
},
},
}
diff --git a/lua/plugin_specs.lua b/lua/plugin_specs.lua
index 7e1eee0f..3e9127d5 100644
--- a/lua/plugin_specs.lua
+++ b/lua/plugin_specs.lua
@@ -32,7 +32,6 @@ local plugin_specs = {
"hrsh7th/cmp-path",
"hrsh7th/cmp-buffer",
"hrsh7th/cmp-omni",
- "hrsh7th/cmp-emoji",
"quangnguyen30192/cmp-nvim-ultisnips",
},
config = function()
diff --git a/viml_conf/options.vim b/viml_conf/options.vim
index 68e0059f..ca0d66ad 100644
--- a/viml_conf/options.vim
+++ b/viml_conf/options.vim
@@ -121,7 +121,7 @@ set completeopt+=menuone " Show menu even if there is only one item
set completeopt-=preview " Disable the preview window
set pumheight=10 " Maximum number of items to show in popup menu
-set pumblend=10 " pseudo transparency for completion menu
+set pumblend=5 " pseudo transparency for completion menu
set winblend=0 " pseudo transparency for floating window
From 21522bd1948f648659061a46002a2b1fc4b0f392 Mon Sep 17 00:00:00 2001
From: jdhao
Date: Sun, 25 Aug 2024 23:33:34 +0200
Subject: [PATCH 044/247] update config for yanky
---
lua/config/yanky.lua | 20 ++++++++++++--------
lua/plugin_specs.lua | 2 +-
2 files changed, 13 insertions(+), 9 deletions(-)
diff --git a/lua/config/yanky.lua b/lua/config/yanky.lua
index 0f8eceba..2c7b134e 100644
--- a/lua/config/yanky.lua
+++ b/lua/config/yanky.lua
@@ -1,13 +1,17 @@
-require("yanky").setup({
- ring = {
- history_length = 50,
- storage = "memory",
- },
+require("yanky").setup {
preserve_cursor_position = {
enabled = false,
},
-})
+ highlight = {
+ on_put = true,
+ on_yank = false,
+ timer = 300,
+ },
+}
+
+vim.keymap.set({ "n", "x" }, "p", "(YankyPutAfter)")
+vim.keymap.set({ "n", "x" }, "P", "(YankyPutBefore)")
-- cycle through the yank history, only work after paste
-vim.keymap.set("n", "[y", "(YankyCycleForward)")
-vim.keymap.set("n", "]y", "(YankyCycleBackward)")
+vim.keymap.set("n", "[y", "(YankyPreviousEntry)")
+vim.keymap.set("n", "]y", "(YankyNextEntry)")
diff --git a/lua/plugin_specs.lua b/lua/plugin_specs.lua
index 3e9127d5..5e1e9b4b 100644
--- a/lua/plugin_specs.lua
+++ b/lua/plugin_specs.lua
@@ -293,10 +293,10 @@ local plugin_specs = {
-- Manage your yank history
{
"gbprod/yanky.nvim",
- cmd = { "YankyRingHistory" },
config = function()
require("config.yanky")
end,
+ event = "VeryLazy",
},
-- Handy unix command inside Vim (Rename, Move etc.)
From e3930e8aa705cf6dfe66470b000ce637cab034e3 Mon Sep 17 00:00:00 2001
From: jdhao
Date: Sun, 25 Aug 2024 23:35:53 +0200
Subject: [PATCH 045/247] remove unused plugins
---
lua/config/zen-mode.lua | 15 ---------------
lua/plugin_specs.lua | 13 +------------
2 files changed, 1 insertion(+), 27 deletions(-)
delete mode 100644 lua/config/zen-mode.lua
diff --git a/lua/config/zen-mode.lua b/lua/config/zen-mode.lua
deleted file mode 100644
index b6d52ce6..00000000
--- a/lua/config/zen-mode.lua
+++ /dev/null
@@ -1,15 +0,0 @@
-require("zen-mode").setup {
- window = {
- backdrop = 0.8, -- shade the backdrop of the Zen window. Set to 1 to keep the same as Normal
- width = 120,
- options = {
- -- signcolumn = "no", -- disable signcolumn
- -- number = false, -- disable number column
- -- relativenumber = false, -- disable relative numbers
- cursorline = false, -- disable cursorline
- cursorcolumn = false, -- disable cursor column
- foldcolumn = "0", -- disable fold column
- list = false, -- disable whitespace characters
- },
- },
-}
diff --git a/lua/plugin_specs.lua b/lua/plugin_specs.lua
index 5e1e9b4b..35d75aa1 100644
--- a/lua/plugin_specs.lua
+++ b/lua/plugin_specs.lua
@@ -62,9 +62,6 @@ local plugin_specs = {
end,
},
- -- Python indent (follows the PEP8 style)
- { "Vimjas/vim-python-pep8-indent", ft = { "python" } },
-
-- Python-related text object
{ "jeetsukumaran/vim-pythonsense", ft = { "python" } },
@@ -397,14 +394,6 @@ local plugin_specs = {
ft = { "markdown" },
},
- {
- "folke/zen-mode.nvim",
- cmd = "ZenMode",
- config = function()
- require("config.zen-mode")
- end,
- },
-
{
"rhysd/vim-grammarous",
enabled = function()
@@ -456,7 +445,7 @@ local plugin_specs = {
-- Modern matchit implementation
{ "andymass/vim-matchup", event = "BufRead" },
- { "tpope/vim-scriptease", cmd = { "Scriptnames", "Message", "Verbose" } },
+ { "tpope/vim-scriptease", cmd = { "Scriptnames", "Messages", "Verbose" } },
-- Asynchronous command execution
{ "skywind3000/asyncrun.vim", lazy = true, cmd = { "AsyncRun" } },
From 12b0ff02b67bc42e961c2223088887397976dd6b Mon Sep 17 00:00:00 2001
From: jdhao
Date: Tue, 27 Aug 2024 23:11:53 +0200
Subject: [PATCH 046/247] Move autocmd in viml to Lua
---
init.lua | 2 +-
lua/custom-autocmd.lua | 168 ++++++++++++++++++++++++++++++++++++-
viml_conf/autocommands.vim | 121 --------------------------
3 files changed, 166 insertions(+), 125 deletions(-)
delete mode 100644 viml_conf/autocommands.vim
diff --git a/init.lua b/init.lua
index 5199cd72..083054a2 100644
--- a/init.lua
+++ b/init.lua
@@ -19,7 +19,7 @@ utils.is_compatible_version(expected_version)
local core_conf_files = {
"globals.lua", -- some global settings
"options.vim", -- setting options in nvim
- "autocommands.vim", -- various autocommands
+ "custom-autocmd.lua", -- various autocommands
"mappings.lua", -- all the user-defined mappings
"plugins.vim", -- all the plugins installed and their configurations
"colorschemes.lua", -- colorscheme settings
diff --git a/lua/custom-autocmd.lua b/lua/custom-autocmd.lua
index 21fa15ca..3da4b408 100644
--- a/lua/custom-autocmd.lua
+++ b/lua/custom-autocmd.lua
@@ -38,8 +38,8 @@ api.nvim_create_autocmd("TextYankPost", {
pattern = "*",
group = yank_group,
callback = function(ev)
- if vim.v.event.operator == 'y' then
- vim.fn.setpos('.', vim.g.current_cursor_pos)
+ if vim.v.event.operator == "y" then
+ vim.fn.setpos(".", vim.g.current_cursor_pos)
end
end,
})
@@ -102,4 +102,166 @@ local function open_nvim_tree(data)
require("nvim-tree.api").tree.open()
end
-vim.api.nvim_create_autocmd({ "VimEnter" }, { callback = open_nvim_tree })
+api.nvim_create_autocmd({ "VimEnter" }, { callback = open_nvim_tree })
+
+-- Do not use smart case in command line mode, extracted from https://vi.stackexchange.com/a/16511/15292.
+api.nvim_create_augroup("dynamic_smartcase", { clear = true })
+api.nvim_create_autocmd("CmdLineEnter", {
+ group = "dynamic_smartcase",
+ pattern = ":",
+ callback = function()
+ vim.o.smartcase = false
+ end,
+})
+
+api.nvim_create_autocmd("CmdLineLeave", {
+ group = "dynamic_smartcase",
+ pattern = ":",
+ callback = function()
+ vim.o.smartcase = true
+ end,
+})
+
+api.nvim_create_autocmd("TermOpen", {
+ group = api.nvim_create_augroup("term_start", { clear = true }),
+ pattern = "*",
+ callback = function()
+ -- Do not use number and relative number for terminal inside nvim
+ vim.wo.relativenumber = false
+ vim.wo.number = false
+
+ -- Go to insert mode by default to start typing command
+ vim.cmd("startinsert")
+ 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()
+ api.nvim_win_set_cursor(0, mark_pos)
+ end)
+ end
+ end,
+})
+
+local number_toggle_group = api.nvim_create_augroup("numbertoggle", { clear = true })
+api.nvim_create_autocmd({ "BufEnter", "FocusGained", "InsertLeave", "WinEnter" }, {
+ pattern = "*",
+ group = number_toggle_group,
+ desc = "togger line number",
+ callback = function()
+ if vim.wo.number then
+ vim.wo.relativenumber = true
+ end
+ end,
+})
+
+api.nvim_create_autocmd({ "BufLeave", "FocusLost", "InsertEnter", "WinLeave" }, {
+ group = number_toggle_group,
+ desc = "togger line number",
+ callback = function()
+ if vim.wo.number then
+ vim.wo.relativenumber = false
+ end
+ end,
+})
+
+api.nvim_create_autocmd("ColorScheme", {
+ group = api.nvim_create_augroup("custom_highlight", { clear = true }),
+ pattern = "*",
+ desc = "Define or overrride some highlight groups",
+ callback = function()
+ vim.cmd([[
+ " For yank highlight
+ highlight YankColor ctermfg=59 ctermbg=41 guifg=#34495E guibg=#2ECC71
+
+ " For cursor colors
+ highlight Cursor cterm=bold gui=bold guibg=#00c918 guifg=black
+ highlight Cursor2 guifg=red guibg=red
+
+ " For floating windows border highlight
+ highlight FloatBorder guifg=LightGreen guibg=NONE
+
+ " highlight for matching parentheses
+ highlight MatchParen cterm=bold,underline gui=bold,underline
+ ]])
+ end,
+})
+
+api.nvim_create_autocmd("BufEnter", {
+ pattern = "*",
+ 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",
+ callback = function(ev)
+ local quit_filetypes = {'qf', 'vista', 'NvimTree'}
+
+ local should_quit = true
+ local tabwins = api.nvim_tabpage_list_wins(0)
+
+ for _, win in pairs(tabwins) do
+ local buf = api.nvim_win_get_buf(win)
+ local bf = fn.getbufvar(buf, '&filetype')
+
+ if fn.index(quit_filetypes, bf) == -1 then
+ should_quit = false
+ end
+ end
+
+ if should_quit then
+ vim.cmd("qall")
+ end
+ end
+})
+
+api.nvim_create_autocmd({"VimEnter", "DirChanged"}, {
+ group = api.nvim_create_augroup("git_repo_check", { clear = true }),
+ pattern = "*",
+ desc = "check if we are inside Git repo",
+ command = "call utils#Inside_git_repo()"
+})
+
+-- ref: https://vi.stackexchange.com/a/169/15292
+api.nvim_create_autocmd("BufReadPre", {
+ group = api.nvim_create_augroup("large_file", { clear = true }),
+ pattern = "*",
+ desc = "check if we are inside Git repo",
+ callback = function (ev)
+ local file_size_limit =524288 -- 0.5MB
+ local f = ev.file
+
+ if fn.getfsize(f) > file_size_limit or fn.getfsize(f) == -2 then
+ vim.o.eventignore = "all"
+ -- turning off relative number helps a lot
+ vim.bo.relativenumber = false
+
+ vim.bo.swapfile = false
+ vim.bo.bufhidden = "unload"
+ vim.bo.undolevels = -1
+ end
+ end
+})
diff --git a/viml_conf/autocommands.vim b/viml_conf/autocommands.vim
deleted file mode 100644
index 3b4ec103..00000000
--- a/viml_conf/autocommands.vim
+++ /dev/null
@@ -1,121 +0,0 @@
-" Do not use smart case in command line mode, extracted from https://vi.stackexchange.com/a/16511/15292.
-augroup dynamic_smartcase
- autocmd!
- autocmd CmdLineEnter : set nosmartcase
- autocmd CmdLineLeave : set smartcase
-augroup END
-
-augroup term_settings
- autocmd!
- " Do not use number and relative number for terminal inside nvim
- autocmd TermOpen * setlocal norelativenumber nonumber
- " Go to insert mode by default to start typing command
- autocmd TermOpen * startinsert
-augroup END
-
-" More accurate syntax highlighting? (see `:h syn-sync`)
-augroup accurate_syn_highlight
- autocmd!
- autocmd BufEnter * :syntax sync fromstart
-augroup END
-
-" Return to last cursor position when opening a file
-augroup resume_cursor_position
- autocmd!
- autocmd BufReadPost * call s:resume_cursor_position()
-augroup END
-
-" Only resume last cursor position when there is no go-to-line command (something like '+23').
-function s:resume_cursor_position() abort
- if line("'\"") > 1 && line("'\"") <= line("$") && &ft !~# 'commit'
- let l:args = v:argv " command line arguments
- for l:cur_arg in l:args
- " Check if a go-to-line command is given.
- let idx = match(l:cur_arg, '\v^\+(\d){1,}$')
- if idx != -1
- return
- endif
- endfor
-
- execute "normal! g`\"zvzz"
- endif
-endfunction
-
-augroup numbertoggle
- autocmd!
- autocmd BufEnter,FocusGained,InsertLeave,WinEnter * if &nu | set rnu | endif
- autocmd BufLeave,FocusLost,InsertEnter,WinLeave * if &nu | set nornu | endif
-augroup END
-
-" Define or override some highlight groups
-augroup custom_highlight
- autocmd!
- autocmd ColorScheme * call s:custom_highlight()
-augroup END
-
-function! s:custom_highlight() abort
- " For yank highlight
- highlight YankColor ctermfg=59 ctermbg=41 guifg=#34495E guibg=#2ECC71
-
- " For cursor colors
- highlight Cursor cterm=bold gui=bold guibg=#00c918 guifg=black
- highlight Cursor2 guifg=red guibg=red
-
- " For floating windows border highlight
- highlight FloatBorder guifg=LightGreen guibg=NONE
-
- " highlight for matching parentheses
- highlight MatchParen cterm=bold,underline gui=bold,underline
-endfunction
-
-augroup auto_close_win
- autocmd!
- autocmd BufEnter * call s:quit_current_win()
-augroup END
-
-" Quit Nvim if we have only one window, and its filetype match our pattern.
-function! s:quit_current_win() abort
- let l:quit_filetypes = ['qf', 'vista', 'NvimTree']
-
- let l:should_quit = v:true
-
- let l:tabwins = nvim_tabpage_list_wins(0)
- for w in l:tabwins
- let l:buf = nvim_win_get_buf(w)
- let l:bf = getbufvar(l:buf, '&filetype')
-
- if index(l:quit_filetypes, l:bf) == -1
- let l:should_quit = v:false
- endif
- endfor
-
- if l:should_quit
- qall
- endif
-endfunction
-
-augroup git_repo_check
- autocmd!
- autocmd VimEnter,DirChanged * call utils#Inside_git_repo()
-augroup END
-
-" ref: https://vi.stackexchange.com/a/169/15292
-function! s:handle_large_file() abort
- let g:file_size_limit = 524288 " 0.5MB
- let f = expand("")
-
- if getfsize(f) > g:file_size_limit || getfsize(f) == -2
- setlocal eventignore=all
- " turning off relative number helps a lot
- setlocal norelativenumber
- setlocal noswapfile bufhidden=unload undolevels=-1
- endif
-endfunction
-
-augroup LargeFile
- autocmd!
- autocmd BufReadPre * call s:handle_large_file()
-augroup END
-
-" Load auto-command defined in Lua
-lua require("custom-autocmd")
From 4b4ff5f549736f2ad1a189564d885268a0da75c2 Mon Sep 17 00:00:00 2001
From: jdhao
Date: Thu, 29 Aug 2024 21:40:06 +0200
Subject: [PATCH 047/247] Add error handling for resuming the cursor
This will close issue #328.
---
lua/custom-autocmd.lua | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/lua/custom-autocmd.lua b/lua/custom-autocmd.lua
index 3da4b408..6a149f9a 100644
--- a/lua/custom-autocmd.lua
+++ b/lua/custom-autocmd.lua
@@ -163,7 +163,11 @@ api.nvim_create_autocmd("FileType", {
-- 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()
- api.nvim_win_set_cursor(0, mark_pos)
+ 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)
end
end,
From fa79647a63c9faf48a09367095092f91b76fa6f4 Mon Sep 17 00:00:00 2001
From: jdhao
Date: Thu, 29 Aug 2024 21:43:56 +0200
Subject: [PATCH 048/247] Fix type for option relativenumber
"relativenumber" should be window local option, not buffer local option.
---
lua/custom-autocmd.lua | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lua/custom-autocmd.lua b/lua/custom-autocmd.lua
index 6a149f9a..98566879 100644
--- a/lua/custom-autocmd.lua
+++ b/lua/custom-autocmd.lua
@@ -261,7 +261,7 @@ api.nvim_create_autocmd("BufReadPre", {
if fn.getfsize(f) > file_size_limit or fn.getfsize(f) == -2 then
vim.o.eventignore = "all"
-- turning off relative number helps a lot
- vim.bo.relativenumber = false
+ vim.wo.relativenumber = false
vim.bo.swapfile = false
vim.bo.bufhidden = "unload"
From 9071e045ebae642135b89865ac58e26f8cdb5590 Mon Sep 17 00:00:00 2001
From: jdhao
Date: Fri, 30 Aug 2024 00:57:51 +0200
Subject: [PATCH 049/247] Make * and # search case aware
By default, when you press `*` to search word under the cursor, the
option `smartcase` is ignored. This means that if you press `*` when
your cursor is on `The`, the lower case one `the` is also searched.
In this commit, we translate star and # search into normal search so that
'smartcase' option is respected.
---
lua/config/hlslens.lua | 29 ++++++++++++++++++++++-------
1 file changed, 22 insertions(+), 7 deletions(-)
diff --git a/lua/config/hlslens.lua b/lua/config/hlslens.lua
index c682d5c0..cbf540ad 100644
--- a/lua/config/hlslens.lua
+++ b/lua/config/hlslens.lua
@@ -35,33 +35,48 @@ keymap.set("n", "N", "", {
end,
})
-local no_word_under_cursor = function()
+local check_cursor_word = function()
local cursor_word = vim.fn.expand("")
-
local result = cursor_word == ""
if result then
local msg = "E348: No string under cursor"
api.nvim_err_writeln(msg)
end
- return result
+ return result, cursor_word
end
keymap.set("n", "*", "", {
callback = function()
- if no_word_under_cursor() then
+ local cursor_word_empty, cursor_word = check_cursor_word()
+ if cursor_word_empty then
return
end
- vim.fn.execute("normal! *N")
+
+ local cmd = string.format([[normal! /\v<%s>]], cursor_word)
+
+ -- In order to say that we are pressing Enter key, instead of typing literally the character,
+ -- we need to replace special notation with their internal representation.
+ local escaped_enter = vim.api.nvim_replace_termcodes("", true, false, true)
+
+ -- character `N` is used to keep the cursor when pressing `*`
+ local full_cmd = cmd .. escaped_enter .. "N"
+ vim.fn.execute(full_cmd)
hlslens.start()
end,
})
keymap.set("n", "#", "", {
callback = function()
- if no_word_under_cursor() then
+ local cursor_word_empty, cursor_word = check_cursor_word()
+ if cursor_word_empty then
return
end
- vim.fn.execute("normal! #N")
+
+ local cmd = string.format([[normal! ?\v<%s>]], cursor_word)
+ local escaped_enter = vim.api.nvim_replace_termcodes("", true, false, true)
+
+ local full_cmd = cmd .. escaped_enter .. "N"
+ vim.fn.execute(full_cmd)
hlslens.start()
end,
})
From a9fc298063a2fccf049dc1ec3295c16722a27d5c Mon Sep 17 00:00:00 2001
From: jdhao
Date: Fri, 30 Aug 2024 01:02:29 +0200
Subject: [PATCH 050/247] update documentation for resuming cursor position
---
lua/custom-autocmd.lua | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/lua/custom-autocmd.lua b/lua/custom-autocmd.lua
index 98566879..51a648ab 100644
--- a/lua/custom-autocmd.lua
+++ b/lua/custom-autocmd.lua
@@ -169,6 +169,10 @@ api.nvim_create_autocmd("FileType", {
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,
})
From 51f81093dad801ff48178d9fc96ed8ccc9767ed9 Mon Sep 17 00:00:00 2001
From: jdhao
Date: Sat, 31 Aug 2024 21:24:54 +0200
Subject: [PATCH 051/247] restructure init.lua
---
init.lua | 34 ++++++++++++----------------------
1 file changed, 12 insertions(+), 22 deletions(-)
diff --git a/init.lua b/init.lua
index 083054a2..377d9fb3 100644
--- a/init.lua
+++ b/init.lua
@@ -16,25 +16,15 @@ local utils = require("utils")
local expected_version = "0.10.1"
utils.is_compatible_version(expected_version)
-local core_conf_files = {
- "globals.lua", -- some global settings
- "options.vim", -- setting options in nvim
- "custom-autocmd.lua", -- various autocommands
- "mappings.lua", -- all the user-defined mappings
- "plugins.vim", -- all the plugins installed and their configurations
- "colorschemes.lua", -- colorscheme settings
-}
-
-local viml_conf_dir = vim.fn.stdpath("config") .. "/viml_conf"
--- source all the core config files
-for _, file_name in ipairs(core_conf_files) do
- if vim.endswith(file_name, 'vim') then
- local path = string.format("%s/%s", viml_conf_dir, file_name)
- local source_cmd = "source " .. path
- vim.cmd(source_cmd)
- else
- local module_name, _ = string.gsub(file_name, "%.lua", "")
- package.loaded[module_name] = nil
- require(module_name)
- end
-end
+-- some global settings
+require("globals")
+-- setting options in nvim
+vim.cmd("source viml_conf/options.vim")
+-- various autocommands
+require("custom-autocmd")
+-- all the user-defined mappings
+require("mappings")
+-- all the plugins installed and their configurations
+vim.cmd("source viml_conf/plugins.vim")
+-- colorscheme settings
+require("colorschemes")
From db380ca7a7df1f563d25dbdc3f292a61d795ed93 Mon Sep 17 00:00:00 2001
From: jdhao
Date: Sun, 1 Sep 2024 21:46:22 +0200
Subject: [PATCH 052/247] remove inspect() from lua _G table
Nvim nows provides `vim.inspect()` and `vim.print()`.
---
lua/config/lsp.lua | 2 +-
lua/globals.lua | 5 -----
2 files changed, 1 insertion(+), 6 deletions(-)
diff --git a/lua/config/lsp.lua b/lua/config/lsp.lua
index 2b385a18..69c7b7d5 100644
--- a/lua/config/lsp.lua
+++ b/lua/config/lsp.lua
@@ -43,7 +43,7 @@ local custom_attach = function(client, bufnr)
map("n", "wa", vim.lsp.buf.add_workspace_folder, { desc = "add workspace folder" })
map("n", "wr", vim.lsp.buf.remove_workspace_folder, { desc = "remove workspace folder" })
map("n", "wl", function()
- inspect(vim.lsp.buf.list_workspace_folders())
+ vim.print(vim.lsp.buf.list_workspace_folders())
end, { desc = "list workspace folder" })
-- Set some key bindings conditional on server capabilities
diff --git a/lua/globals.lua b/lua/globals.lua
index b0af26ea..ee964273 100644
--- a/lua/globals.lua
+++ b/lua/globals.lua
@@ -3,11 +3,6 @@ local api = vim.api
local utils = require('utils')
--- Inspect something
-function _G.inspect(item)
- vim.print(item)
-end
-
------------------------------------------------------------------------
-- custom variables --
------------------------------------------------------------------------
From 81f64ed32eb229ffe22cec030ab0126b981ab9aa Mon Sep 17 00:00:00 2001
From: jdhao
Date: Mon, 2 Sep 2024 22:18:18 +0200
Subject: [PATCH 053/247] Use absolute path for viml config
Full path should be used to load viml config, otherwise, when we open
nvim in other directories, we see errors that the viml config can not be
found.
---
init.lua | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/init.lua b/init.lua
index 377d9fb3..77e5c42d 100644
--- a/init.lua
+++ b/init.lua
@@ -16,15 +16,18 @@ local utils = require("utils")
local expected_version = "0.10.1"
utils.is_compatible_version(expected_version)
+local config_dir = vim.fn.stdpath("config")
+---@cast config_dir string
+
-- some global settings
require("globals")
-- setting options in nvim
-vim.cmd("source viml_conf/options.vim")
+vim.cmd("source " .. vim.fs.joinpath(config_dir, "viml_conf/options.vim"))
-- various autocommands
require("custom-autocmd")
-- all the user-defined mappings
require("mappings")
-- all the plugins installed and their configurations
-vim.cmd("source viml_conf/plugins.vim")
+vim.cmd("source ".. vim.fs.joinpath(config_dir, "viml_conf/plugins.vim"))
-- colorscheme settings
require("colorschemes")
From 154cde3d715b6d5c05392f24fc6c00e0a322be5b Mon Sep 17 00:00:00 2001
From: jdhao
Date: Thu, 19 Sep 2024 22:06:20 +0200
Subject: [PATCH 054/247] Add plugin live-command.nvim
---
lua/config/live-command.lua | 6 ++++++
lua/plugin_specs.lua | 10 ++++++++++
2 files changed, 16 insertions(+)
create mode 100644 lua/config/live-command.lua
diff --git a/lua/config/live-command.lua b/lua/config/live-command.lua
new file mode 100644
index 00000000..23230135
--- /dev/null
+++ b/lua/config/live-command.lua
@@ -0,0 +1,6 @@
+require("live-command").setup {
+ defaults = {
+ enable_highlighting = false,
+ inline_highlighting = false,
+ },
+}
diff --git a/lua/plugin_specs.lua b/lua/plugin_specs.lua
index 35d75aa1..7a163096 100644
--- a/lua/plugin_specs.lua
+++ b/lua/plugin_specs.lua
@@ -563,6 +563,16 @@ local plugin_specs = {
require("copilot").setup {}
end,
},
+ {
+ "smjonas/live-command.nvim",
+ -- live-command supports semantic versioning via Git tags
+ -- tag = "2.*",
+ cmd = "Preview",
+ config = function()
+ require("config.live-command")
+ end,
+ event = "VeryLazy"
+ },
}
require("lazy").setup {
From b9cf3cc6edd97e8e1a0b46833e09de3ef1f91f8c Mon Sep 17 00:00:00 2001
From: jdhao
Date: Fri, 20 Sep 2024 21:25:00 +0200
Subject: [PATCH 055/247] update conf for plugin live-command.nvim
---
lua/config/live-command.lua | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/lua/config/live-command.lua b/lua/config/live-command.lua
index 23230135..7174a8de 100644
--- a/lua/config/live-command.lua
+++ b/lua/config/live-command.lua
@@ -1,6 +1,4 @@
require("live-command").setup {
- defaults = {
- enable_highlighting = false,
- inline_highlighting = false,
- },
+ enable_highlighting = true,
+ inline_highlighting = true,
}
From 3040fa7969538e5143cdd747d609e1488adf589f Mon Sep 17 00:00:00 2001
From: jdhao
Date: Wed, 9 Oct 2024 17:35:59 +0200
Subject: [PATCH 056/247] use a cmp-fork for now
Until cmp is maintained again or switch??
---
lua/plugin_specs.lua | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/lua/plugin_specs.lua b/lua/plugin_specs.lua
index 7a163096..93499876 100644
--- a/lua/plugin_specs.lua
+++ b/lua/plugin_specs.lua
@@ -23,7 +23,8 @@ end
local plugin_specs = {
-- auto-completion engine
{
- "hrsh7th/nvim-cmp",
+ "iguanacucumber/magazine.nvim",
+ name = "nvim-cmp",
-- event = 'InsertEnter',
event = "VeryLazy",
dependencies = {
@@ -38,7 +39,6 @@ local plugin_specs = {
require("config.nvim-cmp")
end,
},
-
{
"neovim/nvim-lspconfig",
event = { "BufRead", "BufNewFile" },
@@ -571,7 +571,7 @@ local plugin_specs = {
config = function()
require("config.live-command")
end,
- event = "VeryLazy"
+ event = "VeryLazy",
},
}
From d715ce8f31d4251f2695cddf30df5b2f4908d8bd Mon Sep 17 00:00:00 2001
From: jdhao
Date: Wed, 9 Oct 2024 17:58:18 +0200
Subject: [PATCH 057/247] update supported nvim version to 0.10.2
---
README.md | 6 +++---
init.lua | 2 +-
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/README.md b/README.md
index 76f3de5c..fb5ac952 100644
--- a/README.md
+++ b/README.md
@@ -13,7 +13,7 @@
-
+
@@ -21,8 +21,8 @@
-
-
+
+
diff --git a/init.lua b/init.lua
index 77e5c42d..f63e3947 100644
--- a/init.lua
+++ b/init.lua
@@ -13,7 +13,7 @@ vim.loader.enable()
local utils = require("utils")
-local expected_version = "0.10.1"
+local expected_version = "0.10.2"
utils.is_compatible_version(expected_version)
local config_dir = vim.fn.stdpath("config")
From 5426c88a90326a3f94af864dbb93eeb18dca6f9b Mon Sep 17 00:00:00 2001
From: jdhao
Date: Tue, 5 Nov 2024 21:42:51 +0100
Subject: [PATCH 058/247] update Leaderf setting
Only search file content and not file name when using Leaderf rg
---
viml_conf/plugins.vim | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/viml_conf/plugins.vim b/viml_conf/plugins.vim
index 9b223a6d..19e9befe 100644
--- a/viml_conf/plugins.vim
+++ b/viml_conf/plugins.vim
@@ -79,7 +79,7 @@ let g:Lf_WorkingDirectoryMode = 'a'
nnoremap ff :Leaderf file --popup
" Grep project files in popup window
-nnoremap fg :Leaderf rg --no-messages --popup
+nnoremap fg :Leaderf rg --no-messages --popup --nameOnly
" Search vim help files
nnoremap fh :Leaderf help --popup
From 4171f190f2fefb7b9ab3c4f095e957c09f3a46f8 Mon Sep 17 00:00:00 2001
From: jdhao
Date: Tue, 5 Nov 2024 21:46:43 +0100
Subject: [PATCH 059/247] Add plugin nvim-lightbulb to hint code actions
---
lua/plugin_specs.lua | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/lua/plugin_specs.lua b/lua/plugin_specs.lua
index 93499876..0dc3a1a2 100644
--- a/lua/plugin_specs.lua
+++ b/lua/plugin_specs.lua
@@ -573,6 +573,14 @@ local plugin_specs = {
end,
event = "VeryLazy",
},
+ {
+ -- 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("nvim-lightbulb").setup { autocmd = { enabled = true } }
+ end,
+ },
}
require("lazy").setup {
From 590bd6c7e6259ab9107eeb7a22a47b04bafeafa8 Mon Sep 17 00:00:00 2001
From: jdhao
Date: Tue, 5 Nov 2024 21:53:52 +0100
Subject: [PATCH 060/247] use stylua to format lua files
---
after/ftplugin/lua.vim | 2 ++
1 file changed, 2 insertions(+)
diff --git a/after/ftplugin/lua.vim b/after/ftplugin/lua.vim
index 914dd843..cb1abf54 100644
--- a/after/ftplugin/lua.vim
+++ b/after/ftplugin/lua.vim
@@ -3,3 +3,5 @@ set formatoptions-=o
set formatoptions-=r
nnoremap :luafile %
+
+nnoremap f !stylua %
From 94cade03be3e87bf096d5c6e78d3d520c3c50ddf Mon Sep 17 00:00:00 2001
From: jdhao
Date: Tue, 5 Nov 2024 21:59:58 +0100
Subject: [PATCH 061/247] enable inlayhint for lua_ls server
The client side inlayhint can be enabled by uncommentting the code in
this PR.
---
lua/config/lsp.lua | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/lua/config/lsp.lua b/lua/config/lsp.lua
index 69c7b7d5..25f1a7d7 100644
--- a/lua/config/lsp.lua
+++ b/lua/config/lsp.lua
@@ -51,6 +51,10 @@ local custom_attach = function(client, bufnr)
map("n", "f", vim.lsp.buf.format, { desc = "format code" })
end
+ -- Uncomment code below to enable inlay hint from language server, some LSP server supports inlay hint,
+ -- but disable this feature by default, so you may need to enable inlay hint in the LSP server config.
+ -- vim.lsp.inlay_hint.enable(true, {buffer=bufnr})
+
api.nvim_create_autocmd("CursorHold", {
buffer = bufnr,
callback = function()
@@ -220,8 +224,8 @@ if utils.executable("bash-language-server") then
}
end
+-- settings for lua-language-server can be found on https://luals.github.io/wiki/settings/
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 {
on_attach = custom_attach,
settings = {
@@ -230,6 +234,9 @@ if utils.executable("lua-language-server") then
-- Tell the language server which version of Lua you're using (most likely LuaJIT in the case of Neovim)
version = "LuaJIT",
},
+ hint = {
+ enable = true
+ }
},
},
capabilities = capabilities,
From 97f72936acaaaab1d10bd986ba27febc2e4510b0 Mon Sep 17 00:00:00 2001
From: jdhao
Date: Tue, 5 Nov 2024 22:03:46 +0100
Subject: [PATCH 062/247] Enable LSP format also for visual selection
---
lua/config/lsp.lua | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lua/config/lsp.lua b/lua/config/lsp.lua
index 25f1a7d7..6d0b2865 100644
--- a/lua/config/lsp.lua
+++ b/lua/config/lsp.lua
@@ -48,7 +48,7 @@ local custom_attach = function(client, bufnr)
-- Set some key bindings conditional on server capabilities
if client.server_capabilities.documentFormattingProvider then
- map("n", "f", vim.lsp.buf.format, { desc = "format code" })
+ map({"n", "x"}, "f", vim.lsp.buf.format, { desc = "format code" })
end
-- Uncomment code below to enable inlay hint from language server, some LSP server supports inlay hint,
From 9769c24633e9302528bd04850e2acd70e2e16062 Mon Sep 17 00:00:00 2001
From: jdhao
Date: Tue, 5 Nov 2024 22:07:09 +0100
Subject: [PATCH 063/247] 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)
---
lua/config/lsp.lua | 119 ++++++++++++++++++++++++++++-----------------
1 file changed, 74 insertions(+), 45 deletions(-)
diff --git a/lua/config/lsp.lua b/lua/config/lsp.lua
index 6d0b2865..8cd83d5c 100644
--- a/lua/config/lsp.lua
+++ b/lua/config/lsp.lua
@@ -3,6 +3,7 @@ local api = vim.api
local keymap = vim.keymap
local lsp = vim.lsp
local diagnostic = vim.diagnostic
+local lspconfig = require("lspconfig")
local utils = require("utils")
@@ -114,69 +115,97 @@ local custom_attach = function(client, bufnr)
end
local capabilities = require('cmp_nvim_lsp').default_capabilities()
+
-- required by nvim-ufo
capabilities.textDocument.foldingRange = {
dynamicRegistration = false,
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
- local venv_path = os.getenv('VIRTUAL_ENV')
- local py_path = nil
- -- decide which python executable to use for mypy
- if venv_path ~= nil then
- py_path = venv_path .. "/bin/python3"
- else
- py_path = vim.g.python3_host_prog
- end
+if utils.executable('pyright') then
+ local new_capability = {
+ -- this will remove some of the diagnostics that duplicates those from ruff, idea taken and adapted from
+ -- here: https://github.com/astral-sh/ruff-lsp/issues/384#issuecomment-1989619482
+ textDocument = {
+ publishDiagnostics = {
+ tagSupport = {
+ valueSet = { 2 }
+ }
+ }
+ }
+ }
+ local merged_capability = vim.tbl_deep_extend("force", capabilities, new_capability)
- lspconfig.pylsp.setup {
+ lspconfig.pyright.setup {
+ cmd = { "delance-langserver", "--stdio" },
on_attach = custom_attach,
+ -- capabilities = merged_capability,
+ capabilities = capabilities,
settings = {
- pylsp = {
- plugins = {
- -- formatter options
- black = { enabled = true },
- autopep8 = { enabled = false },
- yapf = { enabled = false },
- -- linter options
- pylint = { enabled = true, executable = "pylint" },
- ruff = { enabled = false },
- pyflakes = { enabled = false },
- pycodestyle = { enabled = false },
- -- type checker
- pylsp_mypy = {
- enabled = true,
- overrides = { "--python-executable", py_path, true },
- report_progress = true,
- live_mode = false
+ pyright = {
+ -- disable import sorting and use Ruff for this
+ disableOrganizeImports = true,
+ disableTaggedHints = false,
+ },
+ python = {
+ analysis = {
+ autoSearchPaths = true,
+ diagnosticMode = "workspace",
+ typeCheckingMode = "standard",
+ useLibraryCodeForTypes = true,
+ -- we can this setting below to redefine some diagnostics
+ diagnosticSeverityOverrides = {
+ deprecateTypingAliases = false,
+ },
+ -- inlay hint settings are provided by pylance?
+ 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
- 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
+
+if utils.executable("ruff") then
+ require('lspconfig').ruff.setup({
+ on_attach = custom_attach,
+ capabilities = capabilities,
+ init_options = {
+ -- the settings can be found here: https://docs.astral.sh/ruff/editors/settings/
+ settings = {
+ organizeImports = true,
+ }
+ }
+ })
end
--- if utils.executable('pyright') then
--- lspconfig.pyright.setup{
--- on_attach = custom_attach,
--- capabilities = capabilities
--- }
--- else
--- vim.notify("pyright not found!", vim.log.levels.WARN, {title = 'Nvim-config'})
--- end
+-- Disable ruff hover feature in favor of Pyright
+vim.api.nvim_create_autocmd("LspAttach", {
+ group = vim.api.nvim_create_augroup('lsp_attach_disable_ruff_hover', { clear = true }),
+ callback = function(args)
+ local client = vim.lsp.get_client_by_id(args.data.client_id)
+ -- vim.print(client.name, client.server_capabilities)
+
+ if client == nil then
+ return
+ end
+ if client.name == 'ruff' then
+ client.server_capabilities.hoverProvider = false
+ end
+ end,
+ desc = 'LSP: Disable hover capability from Ruff',
+})
if utils.executable("ltex-ls") then
lspconfig.ltex.setup {
From fe3d5e5922f41c4d4576120808b501f4b18888d8 Mon Sep 17 00:00:00 2001
From: jdhao
Date: Tue, 5 Nov 2024 22:16:07 +0100
Subject: [PATCH 064/247] remove plugin committia.vim
---
lua/plugin_specs.lua | 3 ---
1 file changed, 3 deletions(-)
diff --git a/lua/plugin_specs.lua b/lua/plugin_specs.lua
index 0dc3a1a2..9149ef7c 100644
--- a/lua/plugin_specs.lua
+++ b/lua/plugin_specs.lua
@@ -357,9 +357,6 @@ local plugin_specs = {
end,
},
- -- Better git commit experience
- { "rhysd/committia.vim", lazy = true },
-
{
"sindrets/diffview.nvim",
},
From 1141a18c5f113e618ef73ce0c0b35b1786f9764c Mon Sep 17 00:00:00 2001
From: jdhao
Date: Wed, 6 Nov 2024 23:19:29 +0100
Subject: [PATCH 065/247] update config for pyright
---
lua/config/lsp.lua | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/lua/config/lsp.lua b/lua/config/lsp.lua
index 8cd83d5c..d5dd354d 100644
--- a/lua/config/lsp.lua
+++ b/lua/config/lsp.lua
@@ -144,8 +144,7 @@ if utils.executable('pyright') then
lspconfig.pyright.setup {
cmd = { "delance-langserver", "--stdio" },
on_attach = custom_attach,
- -- capabilities = merged_capability,
- capabilities = capabilities,
+ capabilities = merged_capability,
settings = {
pyright = {
-- disable import sorting and use Ruff for this
From 8dfae271d020e198e385382c4f31b15ad4d10405 Mon Sep 17 00:00:00 2001
From: jdhao
Date: Thu, 7 Nov 2024 21:51:31 +0100
Subject: [PATCH 066/247] use plaintext for pyright hover request
see my comment here for the details: https://www.reddit.com/r/neovim/comments/1gdv1rc/comment/lvt9nlm/
---
lua/config/lsp.lua | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/lua/config/lsp.lua b/lua/config/lsp.lua
index d5dd354d..2f61e91a 100644
--- a/lua/config/lsp.lua
+++ b/lua/config/lsp.lua
@@ -136,7 +136,11 @@ if utils.executable('pyright') then
tagSupport = {
valueSet = { 2 }
}
- }
+ },
+ hover = {
+ contentFormat = { "plaintext" },
+ dynamicRegistration = true,
+ },
}
}
local merged_capability = vim.tbl_deep_extend("force", capabilities, new_capability)
From d86f5994833cc3a108c81787f788fbc76108cdca Mon Sep 17 00:00:00 2001
From: jdhao
Date: Fri, 8 Nov 2024 22:56:53 +0100
Subject: [PATCH 067/247] update the fold level allowed for statuscol.nvim
---
lua/config/nvim-statuscol.lua | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lua/config/nvim-statuscol.lua b/lua/config/nvim-statuscol.lua
index a0998de6..3b860479 100644
--- a/lua/config/nvim-statuscol.lua
+++ b/lua/config/nvim-statuscol.lua
@@ -3,7 +3,7 @@ local ffi = require("statuscol.ffidef")
local C = ffi.C
-- only show fold level up to this level
-local fold_level_limit = 2
+local fold_level_limit = 3
local function foldfunc(args)
local foldinfo = C.fold_info(args.wp, args.lnum)
if foldinfo.level > fold_level_limit then
From 88802681405ecb6458551af53f2e645ce65bd4e1 Mon Sep 17 00:00:00 2001
From: jdhao
Date: Tue, 26 Nov 2024 23:57:28 +0100
Subject: [PATCH 068/247] 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.
---
plugin/command.lua | 58 ++++++++++++++++++++++++++++++++++++++++++++++
plugin/command.vim | 3 ---
2 files changed, 58 insertions(+), 3 deletions(-)
create mode 100644 plugin/command.lua
diff --git a/plugin/command.lua b/plugin/command.lua
new file mode 100644
index 00000000..b8b744cf
--- /dev/null
+++ b/plugin/command.lua
@@ -0,0 +1,58 @@
+-- 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 = string.gsub(full_path, project_root, "")
+ 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
+ vim.api.nvim_err_write(string.format("unsupported range: %s", range))
+ end
+end, {
+ desc = "Format JSON string",
+ range = "%",
+})
diff --git a/plugin/command.vim b/plugin/command.vim
index 68b11f4d..5ed7b738 100644
--- a/plugin/command.vim
+++ b/plugin/command.vim
@@ -45,6 +45,3 @@ function! s:md_to_pdf() abort
echoerr "Error running command"
endif
endfunction
-
-" json format
-command! -range JSONFormat ,!python -m json.tool
From 7645751dc1a3769995defaafb04d61f71f37cd63 Mon Sep 17 00:00:00 2001
From: jdhao
Date: Wed, 27 Nov 2024 00:04:44 +0100
Subject: [PATCH 069/247] Update readme
---
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.md b/README.md
index fb5ac952..24c7ea13 100644
--- a/README.md
+++ b/README.md
@@ -191,7 +191,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-m` | Normal | macOS/Win | Markdown previewing in system browser |
| `Alt-Shift-m` | Normal | macOS/Win | Stopping Markdown previewing in system browser |
-| `ob` | Normal/Visual | macOS/Win | Open link under cursor or search visual selection |
| `ctrl-u` | Insert | Linux/macOS/Win | Turn word under cursor to upper case |
| `ctrl-t` | Insert | Linux/macOS/Win | Turn word under cursor to title case |
| `jk` | Insert | Linux/macOS/Win | Return to Normal mode without lagging |
@@ -206,6 +205,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` |
| `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` |
+| `CopyPath` | copy current file path to clipboard | `CopyPath relative` |
# Contributing
From ab75189231d8a787d011fda4d38a1ee90c27c5e6 Mon Sep 17 00:00:00 2001
From: jdhao
Date: Fri, 29 Nov 2024 23:24:03 +0100
Subject: [PATCH 070/247] Fix command CopyPath issue
the string.gsub in lua is not flexible and use vim.fn.substitute()
instead.
---
plugin/command.lua | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/plugin/command.lua b/plugin/command.lua
index b8b744cf..560dea15 100644
--- a/plugin/command.lua
+++ b/plugin/command.lua
@@ -16,7 +16,7 @@ vim.api.nvim_create_user_command("CopyPath", function(context)
return
end
- file_path = string.gsub(full_path, project_root, "")
+ file_path = vim.fn.substitute(full_path, project_root, "", "g")
end
if context["args"] == "absolute" then
From d941be482b69d6dc997eeead02eea2d68ad9d972 Mon Sep 17 00:00:00 2001
From: jdhao
Date: Sun, 8 Dec 2024 21:34:08 +0100
Subject: [PATCH 071/247] update lualine config
---
lua/config/lualine.lua | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/lua/config/lualine.lua b/lua/config/lualine.lua
index 08ead79a..dc996310 100644
--- a/lua/config/lualine.lua
+++ b/lua/config/lualine.lua
@@ -140,13 +140,15 @@ require("lualine").setup {
options = {
icons_enabled = true,
theme = "auto",
+ component_separators = { left = '⏐', right = '⏐' },
section_separators = "",
- component_separators = "",
disabled_filetypes = {},
always_divide_middle = true,
},
sections = {
- lualine_a = { "mode" },
+ lualine_a = {
+ "mode",
+ },
lualine_b = {
{
"branch",
@@ -154,6 +156,7 @@ require("lualine").setup {
-- truncate branch name in case the name is too long
return string.sub(name, 1, 20)
end,
+ color = { gui = "italic,bold" },
},
{
virtual_env,
@@ -192,7 +195,7 @@ require("lualine").setup {
},
},
lualine_y = {
- "encoding",
+ { "encoding", fmt = string.upper },
{
"fileformat",
symbols = {
@@ -212,7 +215,8 @@ require("lualine").setup {
mixed_indent,
color = "WarningMsg",
},
- "progress"
+ "location",
+ "progress",
},
},
inactive_sections = {
From 64b41fbd58382e42946bfc3d75ed4b5ff3039db4 Mon Sep 17 00:00:00 2001
From: jdhao
Date: Thu, 19 Dec 2024 22:00:21 +0100
Subject: [PATCH 072/247] use native lua api instead of vim.cmd
---
lua/custom-autocmd.lua | 41 ++++++++++++++++++++---------------------
1 file changed, 20 insertions(+), 21 deletions(-)
diff --git a/lua/custom-autocmd.lua b/lua/custom-autocmd.lua
index 51a648ab..b3ec858b 100644
--- a/lua/custom-autocmd.lua
+++ b/lua/custom-autocmd.lua
@@ -165,8 +165,9 @@ api.nvim_create_autocmd("FileType", {
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))
+ 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,
@@ -204,20 +205,18 @@ api.nvim_create_autocmd("ColorScheme", {
pattern = "*",
desc = "Define or overrride some highlight groups",
callback = function()
- vim.cmd([[
- " For yank highlight
- highlight YankColor ctermfg=59 ctermbg=41 guifg=#34495E guibg=#2ECC71
+ -- For yank highlight
+ vim.api.nvim_set_hl(0, "YankColor", { fg = "#34495E", bg = "#2ECC71", ctermfg = 59, ctermbg = 41 })
- " For cursor colors
- highlight Cursor cterm=bold gui=bold guibg=#00c918 guifg=black
- highlight Cursor2 guifg=red guibg=red
+ -- For cursor colors
+ vim.api.nvim_set_hl(0, "Cursor", { fg = "black", bg = "#00c918", bold = true })
+ vim.api.nvim_set_hl(0, "Cursor2", { fg = "red", bg = "red" })
- " For floating windows border highlight
- highlight FloatBorder guifg=LightGreen guibg=NONE
+ -- For floating windows border highlight
+ vim.api.nvim_set_hl(0, "FloatBorder", { fg = "LightGreen" })
- " highlight for matching parentheses
- highlight MatchParen cterm=bold,underline gui=bold,underline
- ]])
+ -- highlight for matching parentheses
+ vim.api.nvim_set_hl(0, "MatchParen", { bold = true, underline = true })
end,
})
@@ -226,14 +225,14 @@ api.nvim_create_autocmd("BufEnter", {
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",
callback = function(ev)
- local quit_filetypes = {'qf', 'vista', 'NvimTree'}
+ local quit_filetypes = { "qf", "vista", "NvimTree" }
local should_quit = true
local tabwins = api.nvim_tabpage_list_wins(0)
for _, win in pairs(tabwins) do
local buf = api.nvim_win_get_buf(win)
- local bf = fn.getbufvar(buf, '&filetype')
+ local bf = fn.getbufvar(buf, "&filetype")
if fn.index(quit_filetypes, bf) == -1 then
should_quit = false
@@ -243,14 +242,14 @@ api.nvim_create_autocmd("BufEnter", {
if should_quit then
vim.cmd("qall")
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 }),
pattern = "*",
desc = "check if we are inside Git repo",
- command = "call utils#Inside_git_repo()"
+ command = "call utils#Inside_git_repo()",
})
-- ref: https://vi.stackexchange.com/a/169/15292
@@ -258,8 +257,8 @@ api.nvim_create_autocmd("BufReadPre", {
group = api.nvim_create_augroup("large_file", { clear = true }),
pattern = "*",
desc = "check if we are inside Git repo",
- callback = function (ev)
- local file_size_limit =524288 -- 0.5MB
+ callback = function(ev)
+ local file_size_limit = 524288 -- 0.5MB
local f = ev.file
if fn.getfsize(f) > file_size_limit or fn.getfsize(f) == -2 then
@@ -271,5 +270,5 @@ api.nvim_create_autocmd("BufReadPre", {
vim.bo.bufhidden = "unload"
vim.bo.undolevels = -1
end
- end
+ end,
})
From 54eb3ca811a4d6a47c035dfafa5410779024003c Mon Sep 17 00:00:00 2001
From: jdhao
Date: Thu, 19 Dec 2024 22:08:22 +0100
Subject: [PATCH 073/247] install new plugins
---
lua/plugin_specs.lua | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/lua/plugin_specs.lua b/lua/plugin_specs.lua
index 9149ef7c..bd522f11 100644
--- a/lua/plugin_specs.lua
+++ b/lua/plugin_specs.lua
@@ -542,7 +542,6 @@ local plugin_specs = {
},
{
"CopilotC-Nvim/CopilotChat.nvim",
- branch = "canary",
dependencies = {
{ "zbirenbaum/copilot.lua" }, -- or github/copilot.vim
{ "nvim-lua/plenary.nvim" }, -- for curl, log wrapper
@@ -578,6 +577,17 @@ local plugin_specs = {
require("nvim-lightbulb").setup { autocmd = { enabled = true } }
end,
},
+ {
+ "Bekaboo/dropbar.nvim",
+ },
+ {
+ "vhyrro/luarocks.nvim",
+ priority = 1000, -- Very high priority is required, luarocks.nvim should run as the first plugin in your config.
+ opts = {
+ rocks = { "lua-toml" }, -- specifies a list of rocks to install
+ -- luarocks_build_args = { "--with-lua=/my/path" }, -- extra options to pass to luarocks's configuration script
+ },
+ },
}
require("lazy").setup {
@@ -589,5 +599,6 @@ require("lazy").setup {
},
rocks = {
enabled = false,
+ hererocks = false,
},
}
From 917ab82ffbc4065d4d061fdec080a5f6f31666d4 Mon Sep 17 00:00:00 2001
From: jdhao
Date: Thu, 19 Dec 2024 22:12:40 +0100
Subject: [PATCH 074/247] update dict
---
spell/en.utf-8.add | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/spell/en.utf-8.add b/spell/en.utf-8.add
index 42e271e3..da182b78 100644
--- a/spell/en.utf-8.add
+++ b/spell/en.utf-8.add
@@ -470,3 +470,9 @@ qpdf
Elasticsearch
kibana
submodule
+unix
+GCP
+Kubernetes
+pubsub
+Luarocks
+luarocks
From 5328c477a89706ac5f7184744cfb128ae27f4f1c Mon Sep 17 00:00:00 2001
From: jdhao
Date: Thu, 19 Dec 2024 22:15:48 +0100
Subject: [PATCH 075/247] reformat with stylua
---
init.lua | 2 +-
lua/colorschemes.lua | 8 ++--
lua/config/dashboard-nvim.lua | 14 +++----
lua/config/git-linker.lua | 22 ++++++++---
lua/config/gitsigns.lua | 8 ++--
lua/config/hlslens.lua | 2 +-
lua/config/lsp.lua | 73 ++++++++++++++++++-----------------
lua/config/lualine.lua | 2 +-
lua/config/nvim_hop.lua | 4 +-
lua/config/treesitter.lua | 2 +-
lua/config/which-key.lua | 4 +-
lua/globals.lua | 24 ++++++------
12 files changed, 89 insertions(+), 76 deletions(-)
diff --git a/init.lua b/init.lua
index f63e3947..bd897828 100644
--- a/init.lua
+++ b/init.lua
@@ -28,6 +28,6 @@ require("custom-autocmd")
-- all the user-defined mappings
require("mappings")
-- 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"))
-- colorscheme settings
require("colorschemes")
diff --git a/lua/colorschemes.lua b/lua/colorschemes.lua
index 132e3c28..36b66593 100644
--- a/lua/colorschemes.lua
+++ b/lua/colorschemes.lua
@@ -50,18 +50,18 @@ M.colorscheme_conf = {
end,
onedarkpro = function()
-- set colorscheme after options
- vim.cmd('colorscheme onedark_vivid')
+ vim.cmd("colorscheme onedark_vivid")
end,
material = function()
vim.g.material_style = "oceanic"
- vim.cmd('colorscheme material')
+ vim.cmd("colorscheme material")
end,
- arctic = function ()
+ arctic = function()
vim.cmd("colorscheme arctic")
end,
kanagawa = function()
vim.cmd("colorscheme kanagawa-wave")
- end
+ end,
}
--- Use a random colorscheme from the pre-defined list of colorschemes.
diff --git a/lua/config/dashboard-nvim.lua b/lua/config/dashboard-nvim.lua
index 9017d961..562c124a 100644
--- a/lua/config/dashboard-nvim.lua
+++ b/lua/config/dashboard-nvim.lua
@@ -59,17 +59,17 @@ conf.center = {
},
}
-dashboard.setup({
- theme = 'doom',
- shortcut_type = 'number',
- config = conf
-})
+dashboard.setup {
+ theme = "doom",
+ shortcut_type = "number",
+ config = conf,
+}
api.nvim_create_autocmd("FileType", {
pattern = "dashboard",
group = api.nvim_create_augroup("dashboard_enter", { clear = true }),
- callback = function ()
+ callback = function()
keymap.set("n", "q", ":qa", { buffer = true, silent = true })
keymap.set("n", "e", ":enew", { buffer = true, silent = true })
- end
+ end,
})
diff --git a/lua/config/git-linker.lua b/lua/config/git-linker.lua
index e3fb3e67..cbb42420 100644
--- a/lua/config/git-linker.lua
+++ b/lua/config/git-linker.lua
@@ -5,16 +5,26 @@ gitlinker.setup {
callbacks = {
["dev.azure.com"] = function(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.lend == nil then
url_data.lend = url_data.lstart
end
- url = url .. "?path=/" .. url_data.file .. "&version=GC" .. url_data.rev .. "&line=" .. url_data.lstart .. "&lineEnd=" .. url_data.lend .. "&lineStartColumn=1" .. "&lineEndColumn=120"
+ url = url
+ .. "?path=/"
+ .. url_data.file
+ .. "&version=GC"
+ .. url_data.rev
+ .. "&line="
+ .. url_data.lstart
+ .. "&lineEnd="
+ .. url_data.lend
+ .. "&lineStartColumn=1"
+ .. "&lineEndColumn=120"
end
return url
- end
+ end,
},
mappings = nil,
}
@@ -28,9 +38,9 @@ end, {
})
keymap.set("n", "gbr", function()
- gitlinker.get_repo_url({
- action_callback = gitlinker.actions.open_in_browser
- })
+ gitlinker.get_repo_url {
+ action_callback = gitlinker.actions.open_in_browser,
+ }
end, {
silent = true,
desc = "Git: browse repo in browser",
diff --git a/lua/config/gitsigns.lua b/lua/config/gitsigns.lua
index f272dcc9..8bad6b6d 100644
--- a/lua/config/gitsigns.lua
+++ b/lua/config/gitsigns.lua
@@ -45,13 +45,13 @@ gs.setup {
end,
}
-vim.api.nvim_create_autocmd('ColorScheme', {
+vim.api.nvim_create_autocmd("ColorScheme", {
pattern = "*",
callback = function()
- vim.cmd [[
+ vim.cmd([[
hi GitSignsChangeInline gui=reverse
hi GitSignsAddInline gui=reverse
hi GitSignsDeleteInline gui=reverse
- ]]
- end
+ ]])
+ end,
})
diff --git a/lua/config/hlslens.lua b/lua/config/hlslens.lua
index cbf540ad..0f59bca8 100644
--- a/lua/config/hlslens.lua
+++ b/lua/config/hlslens.lua
@@ -14,7 +14,7 @@ local activate_hlslens = function(direction)
-- Deal with the case that there is no such pattern in current buffer.
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)
api.nvim_err_writeln(msg_part)
return
diff --git a/lua/config/lsp.lua b/lua/config/lsp.lua
index 2f61e91a..87d88fc5 100644
--- a/lua/config/lsp.lua
+++ b/lua/config/lsp.lua
@@ -13,10 +13,10 @@ local set_qflist = function(buf_num, severity)
diagnostics = diagnostic.get(buf_num, { severity = severity })
local qf_items = diagnostic.toqflist(diagnostics)
- vim.fn.setqflist({}, ' ', { title = 'Diagnostics', items = qf_items })
+ vim.fn.setqflist({}, " ", { title = "Diagnostics", items = qf_items })
-- open quickfix by default
- vim.cmd[[copen]]
+ vim.cmd([[copen]])
end
local custom_attach = function(client, bufnr)
@@ -39,7 +39,9 @@ local custom_attach = function(client, bufnr)
-- this puts diagnostics from opened files to quickfix
map("n", "qw", diagnostic.setqflist, { desc = "put window diagnostics to qf" })
-- this puts diagnostics from current buffer to quickfix
- map("n", "qb", function() set_qflist(bufnr) end, { desc = "put buffer diagnostics to qf" })
+ map("n", "qb", function()
+ set_qflist(bufnr)
+ end, { desc = "put buffer diagnostics to qf" })
map("n", "ca", vim.lsp.buf.code_action, { desc = "LSP code action" })
map("n", "wa", vim.lsp.buf.add_workspace_folder, { desc = "add workspace folder" })
map("n", "wr", vim.lsp.buf.remove_workspace_folder, { desc = "remove workspace folder" })
@@ -49,7 +51,7 @@ local custom_attach = function(client, bufnr)
-- Set some key bindings conditional on server capabilities
if client.server_capabilities.documentFormattingProvider then
- map({"n", "x"}, "f", vim.lsp.buf.format, { desc = "format code" })
+ map({ "n", "x" }, "f", vim.lsp.buf.format, { desc = "format code" })
end
-- Uncomment code below to enable inlay hint from language server, some LSP server supports inlay hint,
@@ -72,8 +74,9 @@ local custom_attach = function(client, bufnr)
end
local cursor_pos = api.nvim_win_get_cursor(0)
- if (cursor_pos[1] ~= vim.b.diagnostics_pos[1] or cursor_pos[2] ~= vim.b.diagnostics_pos[2])
- and #diagnostic.get() > 0
+ if
+ (cursor_pos[1] ~= vim.b.diagnostics_pos[1] or cursor_pos[2] ~= vim.b.diagnostics_pos[2])
+ and #diagnostic.get() > 0
then
diagnostic.open_float(nil, float_opts)
end
@@ -91,20 +94,20 @@ local custom_attach = function(client, bufnr)
]])
local gid = api.nvim_create_augroup("lsp_document_highlight", { clear = true })
- api.nvim_create_autocmd("CursorHold" , {
+ api.nvim_create_autocmd("CursorHold", {
group = gid,
buffer = bufnr,
- callback = function ()
+ callback = function()
lsp.buf.document_highlight()
- end
+ end,
})
- api.nvim_create_autocmd("CursorMoved" , {
+ api.nvim_create_autocmd("CursorMoved", {
group = gid,
buffer = bufnr,
- callback = function ()
+ callback = function()
lsp.buf.clear_references()
- end
+ end,
})
end
@@ -114,12 +117,12 @@ local custom_attach = function(client, bufnr)
end
end
-local capabilities = require('cmp_nvim_lsp').default_capabilities()
+local capabilities = require("cmp_nvim_lsp").default_capabilities()
-- required by nvim-ufo
capabilities.textDocument.foldingRange = {
- dynamicRegistration = false,
- lineFoldingOnly = true
+ dynamicRegistration = false,
+ lineFoldingOnly = true,
}
-- For what diagnostic is enabled in which type checking mode, check doc:
@@ -127,21 +130,21 @@ capabilities.textDocument.foldingRange = {
-- 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('pyright') then
+if utils.executable("pyright") then
local new_capability = {
-- this will remove some of the diagnostics that duplicates those from ruff, idea taken and adapted from
-- here: https://github.com/astral-sh/ruff-lsp/issues/384#issuecomment-1989619482
textDocument = {
publishDiagnostics = {
tagSupport = {
- valueSet = { 2 }
- }
+ valueSet = { 2 },
+ },
},
hover = {
contentFormat = { "plaintext" },
dynamicRegistration = true,
},
- }
+ },
}
local merged_capability = vim.tbl_deep_extend("force", capabilities, new_capability)
@@ -177,25 +180,25 @@ if utils.executable('pyright') then
},
}
else
- vim.notify("pyright not found!", vim.log.levels.WARN, { title = 'Nvim-config' })
+ vim.notify("pyright not found!", vim.log.levels.WARN, { title = "Nvim-config" })
end
if utils.executable("ruff") then
- require('lspconfig').ruff.setup({
+ require("lspconfig").ruff.setup {
on_attach = custom_attach,
capabilities = capabilities,
init_options = {
-- the settings can be found here: https://docs.astral.sh/ruff/editors/settings/
settings = {
organizeImports = true,
- }
- }
- })
+ },
+ },
+ }
end
-- Disable ruff hover feature in favor of Pyright
vim.api.nvim_create_autocmd("LspAttach", {
- group = vim.api.nvim_create_augroup('lsp_attach_disable_ruff_hover', { clear = true }),
+ group = vim.api.nvim_create_augroup("lsp_attach_disable_ruff_hover", { clear = true }),
callback = function(args)
local client = vim.lsp.get_client_by_id(args.data.client_id)
-- vim.print(client.name, client.server_capabilities)
@@ -203,11 +206,11 @@ vim.api.nvim_create_autocmd("LspAttach", {
if client == nil then
return
end
- if client.name == 'ruff' then
+ if client.name == "ruff" then
client.server_capabilities.hoverProvider = false
end
end,
- desc = 'LSP: Disable hover capability from Ruff',
+ desc = "LSP: Disable hover capability from Ruff",
})
if utils.executable("ltex-ls") then
@@ -217,11 +220,11 @@ if utils.executable("ltex-ls") then
filetypes = { "text", "plaintex", "tex", "markdown" },
settings = {
ltex = {
- language = "en"
+ language = "en",
},
},
flags = { debounce_text_changes = 300 },
-}
+ }
end
if utils.executable("clangd") then
@@ -267,8 +270,8 @@ if utils.executable("lua-language-server") then
version = "LuaJIT",
},
hint = {
- enable = true
- }
+ enable = true,
+ },
},
},
capabilities = capabilities,
@@ -276,10 +279,10 @@ if utils.executable("lua-language-server") then
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" })
+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 {
diff --git a/lua/config/lualine.lua b/lua/config/lualine.lua
index dc996310..d41e2e69 100644
--- a/lua/config/lualine.lua
+++ b/lua/config/lualine.lua
@@ -140,7 +140,7 @@ require("lualine").setup {
options = {
icons_enabled = true,
theme = "auto",
- component_separators = { left = '⏐', right = '⏐' },
+ component_separators = { left = "⏐", right = "⏐" },
section_separators = "",
disabled_filetypes = {},
always_divide_middle = true,
diff --git a/lua/config/nvim_hop.lua b/lua/config/nvim_hop.lua
index 11aa60dc..205543d5 100644
--- a/lua/config/nvim_hop.lua
+++ b/lua/config/nvim_hop.lua
@@ -4,7 +4,7 @@ hop.setup {
case_insensitive = true,
char2_fallback_key = "",
quit_key = "",
- match_mappings = { "zh_sc" }
+ match_mappings = { "zh_sc" },
}
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 HopNextKey2 cterm=bold ctermfg=176 gui=bold guibg=#ff00ff guifg=#ffffff
]])
- end
+ end,
})
diff --git a/lua/config/treesitter.lua b/lua/config/treesitter.lua
index 41118594..2b455531 100644
--- a/lua/config/treesitter.lua
+++ b/lua/config/treesitter.lua
@@ -3,6 +3,6 @@ require("nvim-treesitter.configs").setup {
ignore_install = {}, -- List of parsers to ignore installing
highlight = {
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
},
}
diff --git a/lua/config/which-key.lua b/lua/config/which-key.lua
index 13b736c9..136895a4 100644
--- a/lua/config/which-key.lua
+++ b/lua/config/which-key.lua
@@ -1,6 +1,6 @@
require("which-key").setup {
preset = "modern",
icons = {
- mappings = false
- }
+ mappings = false,
+ },
}
diff --git a/lua/globals.lua b/lua/globals.lua
index ee964273..7e651765 100644
--- a/lua/globals.lua
+++ b/lua/globals.lua
@@ -1,28 +1,28 @@
local fn = vim.fn
local api = vim.api
-local utils = require('utils')
+local utils = require("utils")
------------------------------------------------------------------------
-- custom variables --
------------------------------------------------------------------------
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_mac = utils.has("macunix") and true or false
+vim.g.is_mac = utils.has("macunix") and true or false
vim.g.logging_level = "info"
------------------------------------------------------------------------
-- builtin variables --
------------------------------------------------------------------------
-vim.g.loaded_perl_provider = 0 -- Disable perl provider
-vim.g.loaded_ruby_provider = 0 -- Disable ruby provider
-vim.g.loaded_node_provider = 0 -- Disable node provider
-vim.g.did_install_default_menus = 1 -- do not load menu
+vim.g.loaded_perl_provider = 0 -- Disable perl provider
+vim.g.loaded_ruby_provider = 0 -- Disable ruby provider
+vim.g.loaded_node_provider = 0 -- Disable node provider
+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
- 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
vim.g.python3_host_prog = fn.exepath("python3")
end
@@ -32,18 +32,18 @@ else
end
-- Custom mapping (see `:h mapleader` for more info)
-vim.g.mapleader = ','
+vim.g.mapleader = ","
-- Enable highlighting for lua HERE doc inside vim script
-vim.g.vimsyn_embed = 'l'
+vim.g.vimsyn_embed = "l"
-- Use English as main language
-vim.cmd [[language en_US.UTF-8]]
+vim.cmd([[language en_US.UTF-8]])
-- Disable loading certain plugins
-- 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.netrw_liststyle = 3
if vim.g.is_win then
From 1d66475cae7cfd52433bf6a20ab6776734f18087 Mon Sep 17 00:00:00 2001
From: jdhao
Date: Thu, 19 Dec 2024 23:37:03 +0100
Subject: [PATCH 076/247] 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
---
lua/config/lualine.lua | 8 ++++++--
viml_conf/options.vim | 2 ++
2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/lua/config/lualine.lua b/lua/config/lualine.lua
index d41e2e69..587e6ac5 100644
--- a/lua/config/lualine.lua
+++ b/lua/config/lualine.lua
@@ -175,8 +175,8 @@ require("lualine").setup {
source = diff,
},
{
- ime_state,
- color = { fg = "black", bg = "#f46868" },
+ "%S",
+ color = { gui = "bold", fg = "cyan" },
},
{
spell,
@@ -184,6 +184,10 @@ require("lualine").setup {
},
},
lualine_x = {
+ {
+ ime_state,
+ color = { fg = "black", bg = "#f46868" },
+ },
{
get_active_lsp,
icon = " LSP:",
diff --git a/viml_conf/options.vim b/viml_conf/options.vim
index ca0d66ad..ee4466fa 100644
--- a/viml_conf/options.vim
+++ b/viml_conf/options.vim
@@ -179,3 +179,5 @@ set diffopt+=linematch:60
set nowrap " do no wrap
set noruler
+
+set showcmdloc=statusline
From 7e706515a85f9a8931c8bdd14440ac9419405061 Mon Sep 17 00:00:00 2001
From: jdhao
Date: Thu, 19 Dec 2024 23:43:40 +0100
Subject: [PATCH 077/247] 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.
---
after/ftplugin/lua.vim | 2 +-
lua/config/lsp.lua | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/after/ftplugin/lua.vim b/after/ftplugin/lua.vim
index cb1abf54..1c60d66a 100644
--- a/after/ftplugin/lua.vim
+++ b/after/ftplugin/lua.vim
@@ -4,4 +4,4 @@ set formatoptions-=r
nnoremap :luafile %
-nnoremap f !stylua %
+nnoremap f silent !stylua %
diff --git a/lua/config/lsp.lua b/lua/config/lsp.lua
index 87d88fc5..f2c8492c 100644
--- a/lua/config/lsp.lua
+++ b/lua/config/lsp.lua
@@ -50,7 +50,7 @@ local custom_attach = function(client, bufnr)
end, { desc = "list workspace folder" })
-- 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", "x" }, "f", vim.lsp.buf.format, { desc = "format code" })
end
From f95d4c09b4245f53eec2397ab3ece9fd4a8c45b9 Mon Sep 17 00:00:00 2001
From: jdhao
Date: Fri, 20 Dec 2024 23:54:09 +0100
Subject: [PATCH 078/247] disable mouse
---
viml_conf/options.vim | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/viml_conf/options.vim b/viml_conf/options.vim
index ee4466fa..23c24661 100644
--- a/viml_conf/options.vim
+++ b/viml_conf/options.vim
@@ -72,7 +72,7 @@ set wildmode=list:longest
set scrolloff=3
" Use mouse to select and resize windows, etc.
-set mouse=nic " Enable mouse in several mode
+set mouse=
set mousemodel=popup " Set the behaviour of mouse
set mousescroll=ver:1,hor:0
From a02f317a1dfc8f48f53c8da4c9772b19551593ab Mon Sep 17 00:00:00 2001
From: jdhao
Date: Sun, 22 Dec 2024 13:55:53 +0100
Subject: [PATCH 079/247] update supported nvim version to v0.10.3
---
README.md | 6 +++---
init.lua | 2 +-
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/README.md b/README.md
index 24c7ea13..9c86471b 100644
--- a/README.md
+++ b/README.md
@@ -13,7 +13,7 @@
-
+
@@ -21,8 +21,8 @@
-
-
+
+
diff --git a/init.lua b/init.lua
index bd897828..c40ee79e 100644
--- a/init.lua
+++ b/init.lua
@@ -13,7 +13,7 @@ vim.loader.enable()
local utils = require("utils")
-local expected_version = "0.10.2"
+local expected_version = "0.10.3"
utils.is_compatible_version(expected_version)
local config_dir = vim.fn.stdpath("config")
From c7fb090e4ce94e72414169a247ac62f049d6b03b Mon Sep 17 00:00:00 2001
From: jdhao
Date: Sun, 22 Dec 2024 13:58:11 +0100
Subject: [PATCH 080/247] update README
---
README.md | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/README.md b/README.md
index 9c86471b..3813bf09 100644
--- a/README.md
+++ b/README.md
@@ -9,12 +9,12 @@
-
-
-
+
+
+
From 9a6584bec3d4e459b1521248e6e7df766df9a230 Mon Sep 17 00:00:00 2001
From: jdhao
Date: Wed, 29 Jan 2025 00:20:39 +0100
Subject: [PATCH 081/247] add plugin colorzier
---
lua/plugin_specs.lua | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/lua/plugin_specs.lua b/lua/plugin_specs.lua
index bd522f11..890a4c88 100644
--- a/lua/plugin_specs.lua
+++ b/lua/plugin_specs.lua
@@ -588,6 +588,12 @@ local plugin_specs = {
-- luarocks_build_args = { "--with-lua=/my/path" }, -- extra options to pass to luarocks's configuration script
},
},
+ {
+ "catgoose/nvim-colorizer.lua",
+ event = "BufReadPre",
+ opts = { -- set to setup table
+ },
+ },
}
require("lazy").setup {
From 70e9943aacfa3d9c3cc3846d9bc8762de903df42 Mon Sep 17 00:00:00 2001
From: jdhao
Date: Wed, 12 Feb 2025 23:31:18 +0100
Subject: [PATCH 082/247] update supported nvim version to latest stable
Update a few plugins
---
README.md | 5 +----
init.lua | 2 +-
lua/plugin_specs.lua | 15 ++++++++-------
viml_conf/plugins.vim | 3 ---
4 files changed, 10 insertions(+), 15 deletions(-)
diff --git a/README.md b/README.md
index 3813bf09..b4a7bef1 100644
--- a/README.md
+++ b/README.md
@@ -10,7 +10,7 @@
-
+
@@ -21,9 +21,6 @@
-
-
-
diff --git a/init.lua b/init.lua
index c40ee79e..cd15458f 100644
--- a/init.lua
+++ b/init.lua
@@ -13,7 +13,7 @@ vim.loader.enable()
local utils = require("utils")
-local expected_version = "0.10.3"
+local expected_version = "0.10.4"
utils.is_compatible_version(expected_version)
local config_dir = vim.fn.stdpath("config")
diff --git a/lua/plugin_specs.lua b/lua/plugin_specs.lua
index 890a4c88..bdc9e5dd 100644
--- a/lua/plugin_specs.lua
+++ b/lua/plugin_specs.lua
@@ -278,15 +278,9 @@ local plugin_specs = {
-- Multiple cursor plugin like Sublime Text?
-- 'mg979/vim-visual-multi'
- -- Autosave files on certain events
- { "907th/vim-auto-save", event = "InsertEnter" },
-
-- Show undo history visually
{ "simnalamburt/vim-mundo", cmd = { "MundoToggle", "MundoShow" } },
- -- better UI for some nvim actions
- { "stevearc/dressing.nvim" },
-
-- Manage your yank history
{
"gbprod/yanky.nvim",
@@ -513,7 +507,14 @@ local plugin_specs = {
require("config.which-key")
end,
},
-
+ {
+ "folke/snacks.nvim",
+ priority = 1000,
+ lazy = false,
+ opts = {
+ input = { enabled = true },
+ },
+ },
-- show and trim trailing whitespaces
{ "jdhao/whitespace.nvim", event = "VeryLazy" },
diff --git a/viml_conf/plugins.vim b/viml_conf/plugins.vim
index 19e9befe..415bd786 100644
--- a/viml_conf/plugins.vim
+++ b/viml_conf/plugins.vim
@@ -384,6 +384,3 @@ function! s:wilder_init() abort
echohl Error |echomsg "Wilder.nvim missing"| echohl None
endtry
endfunction
-
-""""""""""""""""""""""""""""""vim-auto-save settings""""""""""""""""""""""""""""""
-let g:auto_save = 1 " enable AutoSave on Vim startup
From 94497c0a73e283d86895ca9ec528d3d86a787b63 Mon Sep 17 00:00:00 2001
From: jdhao
Date: Thu, 13 Feb 2025 00:40:35 +0100
Subject: [PATCH 083/247] snack config update
---
lua/plugin_specs.lua | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/lua/plugin_specs.lua b/lua/plugin_specs.lua
index bdc9e5dd..3a07173e 100644
--- a/lua/plugin_specs.lua
+++ b/lua/plugin_specs.lua
@@ -512,7 +512,16 @@ local plugin_specs = {
priority = 1000,
lazy = false,
opts = {
- input = { enabled = true },
+ -- 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
From 7f5374325584d0a5df8929c978343b48f9102362 Mon Sep 17 00:00:00 2001
From: jdhao
Date: Fri, 14 Feb 2025 22:03:52 +0100
Subject: [PATCH 084/247] 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.
---
lua/custom-autocmd.lua | 43 ------------------------------------------
1 file changed, 43 deletions(-)
diff --git a/lua/custom-autocmd.lua b/lua/custom-autocmd.lua
index b3ec858b..0d6b1b0c 100644
--- a/lua/custom-autocmd.lua
+++ b/lua/custom-autocmd.lua
@@ -135,49 +135,6 @@ api.nvim_create_autocmd("TermOpen", {
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 })
api.nvim_create_autocmd({ "BufEnter", "FocusGained", "InsertLeave", "WinEnter" }, {
pattern = "*",
From ee4bce46710e4c58e65e1c41ec5530440768ac9d Mon Sep 17 00:00:00 2001
From: jdhao
Date: Sat, 15 Feb 2025 14:36:24 +0100
Subject: [PATCH 085/247] enable mouse in normal mode
---
viml_conf/options.vim | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/viml_conf/options.vim b/viml_conf/options.vim
index 23c24661..1e3d2ae4 100644
--- a/viml_conf/options.vim
+++ b/viml_conf/options.vim
@@ -72,7 +72,7 @@ set wildmode=list:longest
set scrolloff=3
" Use mouse to select and resize windows, etc.
-set mouse=
+set mouse=n
set mousemodel=popup " Set the behaviour of mouse
set mousescroll=ver:1,hor:0
From 28bda349e84a0da79dffb14faba449554f6f9f18 Mon Sep 17 00:00:00 2001
From: jdhao
Date: Sat, 15 Feb 2025 18:58:15 +0100
Subject: [PATCH 086/247] Update lualine config (#375)
- components are re-ordered
- add new component to show git ahead/behind info
- remove some unused component
---
lua/config/lualine.lua | 165 ++++++++++++++++++++++++++++++++++-------
1 file changed, 139 insertions(+), 26 deletions(-)
diff --git a/lua/config/lualine.lua b/lua/config/lualine.lua
index 587e6ac5..6a932e2f 100644
--- a/lua/config/lualine.lua
+++ b/lua/config/lualine.lua
@@ -1,5 +1,111 @@
local fn = vim.fn
+local git_status_cache = {}
+
+local get_cmd_out = function(cmd)
+ local result = vim.system(cmd, { text = true }):wait()
+
+ if result.code ~= 0 then
+ -- vim.print(vim.inspect(result))
+ return false, result.stderr
+ end
+
+ return true, result.stdout
+end
+
+local function split_cmd_string(cmd_str)
+ return vim.tbl_filter(function(element)
+ if element ~= "" then
+ return true
+ end
+ return false
+ end, vim.split(cmd_str, " "))
+end
+
+local function get_branch_name()
+ local branch_cmd_str = "git rev-parse --abbrev-ref HEAD"
+ local branch_cmd = split_cmd_string(branch_cmd_str)
+ local success, branch_output = get_cmd_out(branch_cmd)
+
+ if not success then
+ return
+ end
+ local branch_name = string.gsub(branch_output, "\n$", "")
+ -- print(string.format("branch: %s", branch_name))
+
+ return branch_name
+end
+
+local function update_git_status()
+ -- Fetch the latest changes from the remote repository (replace 'origin' if needed)
+ local fetch_cmd = split_cmd_string("git fetch origin")
+
+ local fetch_success, _ = get_cmd_out(fetch_cmd)
+ if not fetch_success then
+ return
+ end
+
+ local branch_name = get_branch_name()
+ if branch_name == nil then
+ return
+ end
+
+ -- Get the number of commits behind
+ local behind_cmd_str = string.format("git rev-list --count %s..origin/%s", branch_name, branch_name)
+ local behind_cmd = split_cmd_string(behind_cmd_str)
+ local behind_success, behind_output = get_cmd_out(behind_cmd)
+ if behind_success then
+ local behind_count = tonumber(behind_output:match("(%d+)")) or 0
+ git_status_cache.behind = behind_count
+ end
+
+ -- Get the number of commits ahead
+ local ahead_cmd_str = string.format("git rev-list --count origin/%s..%s", branch_name, branch_name)
+ local ahead_cmd = split_cmd_string(ahead_cmd_str)
+ local ahead_success, ahead_output = get_cmd_out(ahead_cmd)
+ if ahead_success then
+ local ahead_count = tonumber(ahead_output:match("(%d+)")) or 0
+ git_status_cache.ahead = ahead_count
+ end
+end
+
+local function get_ahead_behind_info()
+ local status = git_status_cache
+ if not status then
+ return ""
+ end
+
+ local msg = ""
+
+ if type(status.behind) == "number" and status.behind > 0 then
+ local behind_str = string.format("↓[%d] ", status.behind)
+ msg = msg .. behind_str
+ end
+
+ if type(status.ahead) == "number" and status.ahead > 0 then
+ local ahead_str = string.format("↑[%d] ", status.ahead)
+ msg = msg .. ahead_str
+ end
+
+ return msg
+end
+
+local timer = vim.uv.new_timer()
+
+local branch_name = get_branch_name()
+-- run frequency in seconds
+local interval = 30
+local ms = interval * 1000
+if branch_name ~= nil then
+ timer:start(
+ 0,
+ ms,
+ vim.schedule_wrap(function()
+ update_git_status()
+ end)
+ )
+end
+
local function spell()
if vim.o.spell then
return string.format("[SPELL]")
@@ -119,7 +225,7 @@ local virtual_env = function()
end
local get_active_lsp = function()
- local msg = "No Active Lsp"
+ local msg = "🚫"
local buf_ft = vim.api.nvim_get_option_value("filetype", {})
local clients = vim.lsp.get_clients { bufnr = 0 }
if next(clients) == nil then
@@ -147,7 +253,12 @@ require("lualine").setup {
},
sections = {
lualine_a = {
- "mode",
+ {
+ "filename",
+ symbols = {
+ readonly = "[🔒]",
+ },
+ },
},
lualine_b = {
{
@@ -159,21 +270,20 @@ require("lualine").setup {
color = { gui = "italic,bold" },
},
{
- virtual_env,
- color = { fg = "black", bg = "#F1CA81" },
- },
- },
- lualine_c = {
- {
- "filename",
- symbols = {
- readonly = "[🔒]",
- },
+ get_ahead_behind_info,
+ -- "",
+ color = { fg = "#E0C479" },
},
{
"diff",
source = diff,
},
+ {
+ virtual_env,
+ color = { fg = "black", bg = "#F1CA81" },
+ },
+ },
+ lualine_c = {
{
"%S",
color = { gui = "bold", fg = "cyan" },
@@ -184,22 +294,29 @@ require("lualine").setup {
},
},
lualine_x = {
- {
- ime_state,
- color = { fg = "black", bg = "#f46868" },
- },
{
get_active_lsp,
- icon = " LSP:",
+ icon = "📡",
},
{
"diagnostics",
sources = { "nvim_diagnostic" },
symbols = { error = "🆇 ", warn = "⚠️ ", info = "ℹ️ ", hint = " " },
},
+ {
+ trailing_space,
+ color = "WarningMsg",
+ },
+ {
+ mixed_indent,
+ color = "WarningMsg",
+ },
},
lualine_y = {
- { "encoding", fmt = string.upper },
+ {
+ "encoding",
+ fmt = string.upper,
+ },
{
"fileformat",
symbols = {
@@ -209,16 +326,12 @@ require("lualine").setup {
},
},
"filetype",
- },
- lualine_z = {
- {
- trailing_space,
- color = "WarningMsg",
- },
{
- mixed_indent,
- color = "WarningMsg",
+ ime_state,
+ color = { fg = "black", bg = "#f46868" },
},
+ },
+ lualine_z = {
"location",
"progress",
},
From ac421715d364949e72aa030afd83bd77fa49161a Mon Sep 17 00:00:00 2001
From: jdhao
Date: Sun, 16 Feb 2025 01:15:07 +0100
Subject: [PATCH 087/247] 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.
---
lua/config/lualine.lua | 101 ++++++++++++-----------------------------
1 file changed, 30 insertions(+), 71 deletions(-)
diff --git a/lua/config/lualine.lua b/lua/config/lualine.lua
index 6a932e2f..f2e54f9c 100644
--- a/lua/config/lualine.lua
+++ b/lua/config/lualine.lua
@@ -2,71 +2,44 @@ local fn = vim.fn
local git_status_cache = {}
-local get_cmd_out = function(cmd)
- local result = vim.system(cmd, { text = true }):wait()
-
- if result.code ~= 0 then
- -- vim.print(vim.inspect(result))
- return false, result.stderr
+local on_exit_fetch = function(result)
+ if result.code == 0 then
+ git_status_cache.fetch_success = true
end
-
- return true, result.stdout
end
-local function split_cmd_string(cmd_str)
- return vim.tbl_filter(function(element)
- if element ~= "" then
- return true
+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
- return false
- end, vim.split(cmd_str, " "))
+ end
end
-local function get_branch_name()
- local branch_cmd_str = "git rev-parse --abbrev-ref HEAD"
- local branch_cmd = split_cmd_string(branch_cmd_str)
- local success, branch_output = get_cmd_out(branch_cmd)
-
- if not success then
- return
- end
- local branch_name = string.gsub(branch_output, "\n$", "")
- -- print(string.format("branch: %s", branch_name))
+local async_cmd = function(cmd_str, on_exit)
+ local cmd = vim.tbl_filter(function(element)
+ return element ~= ""
+ end, vim.split(cmd_str, " "))
- return branch_name
+ vim.system(cmd, { text = true }, on_exit)
end
-local function update_git_status()
+local async_git_status_update = function()
-- Fetch the latest changes from the remote repository (replace 'origin' if needed)
- local fetch_cmd = split_cmd_string("git fetch origin")
-
- local fetch_success, _ = get_cmd_out(fetch_cmd)
- if not fetch_success then
- return
- end
-
- local branch_name = get_branch_name()
- if branch_name == nil then
+ async_cmd("git fetch origin", on_exit_fetch)
+ if not git_status_cache.fetch_success then
return
end
-- Get the number of commits behind
- local behind_cmd_str = string.format("git rev-list --count %s..origin/%s", branch_name, branch_name)
- local behind_cmd = split_cmd_string(behind_cmd_str)
- local behind_success, behind_output = get_cmd_out(behind_cmd)
- if behind_success then
- local behind_count = tonumber(behind_output:match("(%d+)")) or 0
- git_status_cache.behind = behind_count
- end
+ -- 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 = string.format("git rev-list --count origin/%s..%s", branch_name, branch_name)
- local ahead_cmd = split_cmd_string(ahead_cmd_str)
- local ahead_success, ahead_output = get_cmd_out(ahead_cmd)
- if ahead_success then
- local ahead_count = tonumber(ahead_output:match("(%d+)")) or 0
- git_status_cache.ahead = ahead_count
- end
+ local ahead_cmd_str = "git rev-list --count @{upstream}..HEAD"
+ async_cmd(ahead_cmd_str, handle_numeric_result("ahead_count"))
end
local function get_ahead_behind_info()
@@ -77,34 +50,21 @@ local function get_ahead_behind_info()
local msg = ""
- if type(status.behind) == "number" and status.behind > 0 then
- local behind_str = string.format("↓[%d] ", status.behind)
- msg = msg .. behind_str
+ 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.ahead) == "number" and status.ahead > 0 then
- local ahead_str = string.format("↑[%d] ", status.ahead)
- msg = msg .. ahead_str
+ 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 timer = vim.uv.new_timer()
-
-local branch_name = get_branch_name()
--- run frequency in seconds
-local interval = 30
-local ms = interval * 1000
-if branch_name ~= nil then
- timer:start(
- 0,
- ms,
- vim.schedule_wrap(function()
- update_git_status()
- end)
- )
-end
+local timer = vim.loop.new_timer()
+timer:start(0, 1000, async_git_status_update)
local function spell()
if vim.o.spell then
@@ -271,7 +231,6 @@ require("lualine").setup {
},
{
get_ahead_behind_info,
- -- "",
color = { fg = "#E0C479" },
},
{
From 2242961925be4549e81ecdca5505f9845158d116 Mon Sep 17 00:00:00 2001
From: jdhao
Date: Sun, 16 Feb 2025 19:13:24 +0100
Subject: [PATCH 088/247] Remove obsolete func (#377)
- remove function: SynGroup, HasColorscheme and
GetGitBranch
- rewrite Inside_git_repo in lua instead
---
autoload/utils.vim | 38 --------------------------------------
lua/custom-autocmd.lua | 6 ++++--
lua/mappings.lua | 3 ---
lua/utils.lua | 14 ++++++++++++++
4 files changed, 18 insertions(+), 43 deletions(-)
diff --git a/autoload/utils.vim b/autoload/utils.vim
index a004bd58..14fb651e 100644
--- a/autoload/utils.vim
+++ b/autoload/utils.vim
@@ -10,23 +10,6 @@ function! s:Single_quote(str) abort
return "'" . substitute(copy(a:str), "'", "''", 'g') . "'"
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
function! utils#VimFolds(lnum) abort
" get content of current line and the line below
@@ -146,27 +129,6 @@ function! utils#iso_time(timestamp) abort
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.
" Ref: https://stackoverflow.com/q/2573021/6064933 and https://unix.stackexchange.com/q/8101/221410 .
function! utils#CaptureCommandOutput(command) abort
diff --git a/lua/custom-autocmd.lua b/lua/custom-autocmd.lua
index 0d6b1b0c..e03a0222 100644
--- a/lua/custom-autocmd.lua
+++ b/lua/custom-autocmd.lua
@@ -206,14 +206,16 @@ api.nvim_create_autocmd({ "VimEnter", "DirChanged" }, {
group = api.nvim_create_augroup("git_repo_check", { clear = true }),
pattern = "*",
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
api.nvim_create_autocmd("BufReadPre", {
group = api.nvim_create_augroup("large_file", { clear = true }),
pattern = "*",
- desc = "check if we are inside Git repo",
+ desc = "optimize for large file",
callback = function(ev)
local file_size_limit = 524288 -- 0.5MB
local f = ev.file
diff --git a/lua/mappings.lua b/lua/mappings.lua
index 7b4980ea..368035bf 100644
--- a/lua/mappings.lua
+++ b/lua/mappings.lua
@@ -143,9 +143,6 @@ keymap.set("x", "c", '"_c')
-- Remove trailing whitespace characters
keymap.set("n", "", "StripTrailingWhitespace", { desc = "remove trailing space" })
--- check the syntax group of current cursor position
-keymap.set("n", "st", "call utils#SynGroup()", { desc = "check syntax group" })
-
-- Copy entire buffer.
keymap.set("n", "y", "%yank", { desc = "yank entire buffer" })
diff --git a/lua/utils.lua b/lua/utils.lua
index 86a97d08..a1a37777 100644
--- a/lua/utils.lua
+++ b/lua/utils.lua
@@ -79,4 +79,18 @@ function M.is_compatible_version(expected_version)
return true
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
From 4b8c490abd5d6b9cad33841b61142674cab26e67 Mon Sep 17 00:00:00 2001
From: jdhao
Date: Sun, 16 Feb 2025 19:20:21 +0100
Subject: [PATCH 089/247] 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.
---
lua/config/gitsigns.lua | 6 +++---
lua/config/lualine.lua | 12 +++++++-----
2 files changed, 10 insertions(+), 8 deletions(-)
diff --git a/lua/config/gitsigns.lua b/lua/config/gitsigns.lua
index 8bad6b6d..c7216b7e 100644
--- a/lua/config/gitsigns.lua
+++ b/lua/config/gitsigns.lua
@@ -8,7 +8,7 @@ gs.setup {
topdelete = { text = "‾" },
changedelete = { text = "│" },
},
- word_diff = true,
+ word_diff = false,
on_attach = function(bufnr)
local function map(mode, l, r, opts)
opts = opts or {}
@@ -38,10 +38,10 @@ gs.setup {
end, { expr = true, desc = "previous hunk" })
-- Actions
- map("n", "hp", gs.preview_hunk)
+ map("n", "hp", gs.preview_hunk, { desc = "preview hunk" })
map("n", "hb", function()
gs.blame_line { full = true }
- end)
+ end, { desc = "blame hunk" })
end,
}
diff --git a/lua/config/lualine.lua b/lua/config/lualine.lua
index f2e54f9c..a9bfdbf9 100644
--- a/lua/config/lualine.lua
+++ b/lua/config/lualine.lua
@@ -42,7 +42,9 @@ local async_git_status_update = function()
async_cmd(ahead_cmd_str, handle_numeric_result("ahead_count"))
end
-local function get_ahead_behind_info()
+local function get_git_ahead_behind_info()
+ async_git_status_update()
+
local status = git_status_cache
if not status then
return ""
@@ -63,9 +65,6 @@ local function get_ahead_behind_info()
return msg
end
-local timer = vim.loop.new_timer()
-timer:start(0, 1000, async_git_status_update)
-
local function spell()
if vim.o.spell then
return string.format("[SPELL]")
@@ -210,6 +209,9 @@ require("lualine").setup {
section_separators = "",
disabled_filetypes = {},
always_divide_middle = true,
+ refresh = {
+ statusline = 500,
+ },
},
sections = {
lualine_a = {
@@ -230,7 +232,7 @@ require("lualine").setup {
color = { gui = "italic,bold" },
},
{
- get_ahead_behind_info,
+ get_git_ahead_behind_info,
color = { fg = "#E0C479" },
},
{
From 93166c65a57c846212cc98d988a8012c65cb1db7 Mon Sep 17 00:00:00 2001
From: jdhao
Date: Sun, 16 Feb 2025 19:52:34 +0100
Subject: [PATCH 090/247] update colorscheme config (#379)
---
lua/colorschemes.lua | 17 ++++++++++++-----
1 file changed, 12 insertions(+), 5 deletions(-)
diff --git a/lua/colorschemes.lua b/lua/colorschemes.lua
index 36b66593..12149699 100644
--- a/lua/colorschemes.lua
+++ b/lua/colorschemes.lua
@@ -1,5 +1,4 @@
--- This module will load a random colorscheme on nvim startup process.
-
local utils = require("utils")
local M = {}
@@ -8,9 +7,14 @@ local M = {}
-- the same as the colorscheme name itself.
M.colorscheme_conf = {
onedark = function()
- vim.cmd([[colorscheme onedark]])
+ -- Lua
+ require("onedark").setup {
+ style = "darker",
+ }
+ require("onedark").load()
end,
edge = function()
+ vim.g.edge_style = "default"
vim.g.edge_enable_italic = 1
vim.g.edge_better_performance = 1
@@ -26,13 +30,14 @@ M.colorscheme_conf = {
-- foreground option can be material, mix, or original
vim.g.gruvbox_material_foreground = "original"
--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_better_performance = 1
vim.cmd([[colorscheme gruvbox-material]])
end,
everforest = function()
+ vim.g.everforest_background = "hard"
vim.g.everforest_enable_italic = 1
vim.g.everforest_better_performance = 1
@@ -50,10 +55,11 @@ M.colorscheme_conf = {
end,
onedarkpro = function()
-- set colorscheme after options
- vim.cmd("colorscheme onedark_vivid")
+ -- onedark_vivid does not enough contrast
+ vim.cmd("colorscheme onedark_dark")
end,
material = function()
- vim.g.material_style = "oceanic"
+ vim.g.material_style = "darker"
vim.cmd("colorscheme material")
end,
arctic = function()
@@ -67,6 +73,7 @@ M.colorscheme_conf = {
--- Use a random colorscheme from the pre-defined list of colorschemes.
M.rand_colorscheme = function()
local colorscheme = utils.rand_element(vim.tbl_keys(M.colorscheme_conf))
+ colorscheme = "gruvbox_material"
if not vim.tbl_contains(vim.tbl_keys(M.colorscheme_conf), colorscheme) then
local msg = "Invalid colorscheme: " .. colorscheme
From ab059bbb6d440322af791b93024d1711e4d13b28 Mon Sep 17 00:00:00 2001
From: jdhao
Date: Sun, 16 Feb 2025 20:15:41 +0100
Subject: [PATCH 091/247] 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
---
lua/config/treesitter-textobjects.lua | 44 +++++++++++++++++++++++++++
lua/plugin_specs.lua | 12 +++++---
2 files changed, 52 insertions(+), 4 deletions(-)
create mode 100644 lua/config/treesitter-textobjects.lua
diff --git a/lua/config/treesitter-textobjects.lua b/lua/config/treesitter-textobjects.lua
new file mode 100644
index 00000000..32e9e5f6
--- /dev/null
+++ b/lua/config/treesitter-textobjects.lua
@@ -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 '') 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,
+ },
+ },
+}
diff --git a/lua/plugin_specs.lua b/lua/plugin_specs.lua
index 3a07173e..9342b6d6 100644
--- a/lua/plugin_specs.lua
+++ b/lua/plugin_specs.lua
@@ -61,10 +61,14 @@ local plugin_specs = {
require("config.treesitter")
end,
},
-
- -- Python-related text object
- { "jeetsukumaran/vim-pythonsense", ft = { "python" } },
-
+ {
+ "nvim-treesitter/nvim-treesitter-textobjects",
+ event = "VeryLazy",
+ branch = "master",
+ config = function()
+ require("config.treesitter-textobjects")
+ end,
+ },
{ "machakann/vim-swap", event = "VeryLazy" },
-- IDE for Lisp
From 2383eb70755ce72e0375169051309c01dd33c480 Mon Sep 17 00:00:00 2001
From: jdhao
Date: Sun, 16 Feb 2025 21:03:17 +0100
Subject: [PATCH 092/247] switch back to nvim-cmp (#381)
---
lua/config/lsp.lua | 2 +-
lua/plugin_specs.lua | 5 +++--
2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/lua/config/lsp.lua b/lua/config/lsp.lua
index f2c8492c..1496010e 100644
--- a/lua/config/lsp.lua
+++ b/lua/config/lsp.lua
@@ -117,7 +117,7 @@ local custom_attach = function(client, bufnr)
end
end
-local capabilities = require("cmp_nvim_lsp").default_capabilities()
+local capabilities = vim.lsp.protocol.make_client_capabilities()
-- required by nvim-ufo
capabilities.textDocument.foldingRange = {
diff --git a/lua/plugin_specs.lua b/lua/plugin_specs.lua
index 9342b6d6..6f6faa12 100644
--- a/lua/plugin_specs.lua
+++ b/lua/plugin_specs.lua
@@ -23,7 +23,7 @@ end
local plugin_specs = {
-- auto-completion engine
{
- "iguanacucumber/magazine.nvim",
+ "hrsh7th/nvim-cmp",
name = "nvim-cmp",
-- event = 'InsertEnter',
event = "VeryLazy",
@@ -39,6 +39,7 @@ local plugin_specs = {
require("config.nvim-cmp")
end,
},
+
{
"neovim/nvim-lspconfig",
event = { "BufRead", "BufNewFile" },
@@ -385,7 +386,7 @@ local plugin_specs = {
end
return false
end,
- build = "cd app && npm install",
+ build = "cd app && npm install && git restore .",
ft = { "markdown" },
},
From a00e1fd92a6ce35ea315b723553ff40265f0ab8c Mon Sep 17 00:00:00 2001
From: jdhao
Date: Wed, 5 Mar 2025 23:08:27 +0100
Subject: [PATCH 093/247] Remove luarocks (#383)
remove luarocks.nvim as it is causing startup delays
---
.gitignore | 1 +
lua/plugin_specs.lua | 8 --------
2 files changed, 1 insertion(+), 8 deletions(-)
diff --git a/.gitignore b/.gitignore
index 75dbbbba..178e9446 100644
--- a/.gitignore
+++ b/.gitignore
@@ -4,3 +4,4 @@ en.utf-8.add.spl
.netrwhist
*.log
.DS_Store
+lazy-lock.json
diff --git a/lua/plugin_specs.lua b/lua/plugin_specs.lua
index 6f6faa12..5a8b3383 100644
--- a/lua/plugin_specs.lua
+++ b/lua/plugin_specs.lua
@@ -595,14 +595,6 @@ local plugin_specs = {
{
"Bekaboo/dropbar.nvim",
},
- {
- "vhyrro/luarocks.nvim",
- priority = 1000, -- Very high priority is required, luarocks.nvim should run as the first plugin in your config.
- opts = {
- rocks = { "lua-toml" }, -- specifies a list of rocks to install
- -- luarocks_build_args = { "--with-lua=/my/path" }, -- extra options to pass to luarocks's configuration script
- },
- },
{
"catgoose/nvim-colorizer.lua",
event = "BufReadPre",
From 8cba1ba234604069cee272eb55649203c21d9dde Mon Sep 17 00:00:00 2001
From: Okarin
Date: Fri, 21 Mar 2025 14:42:33 +0100
Subject: [PATCH 094/247] 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.
---
lua/plugin_specs.lua | 6 ------
1 file changed, 6 deletions(-)
diff --git a/lua/plugin_specs.lua b/lua/plugin_specs.lua
index 5a8b3383..ba229206 100644
--- a/lua/plugin_specs.lua
+++ b/lua/plugin_specs.lua
@@ -50,12 +50,6 @@ local plugin_specs = {
{
"nvim-treesitter/nvim-treesitter",
- enabled = function()
- if vim.g.is_mac then
- return true
- end
- return false
- end,
event = "VeryLazy",
build = ":TSUpdate",
config = function()
From f005a8303d5e275a07ec423a0b42c5e0f4083c21 Mon Sep 17 00:00:00 2001
From: jdhao
Date: Wed, 26 Mar 2025 22:33:39 +0100
Subject: [PATCH 095/247] 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
---
README.md | 2 +-
init.lua | 2 +-
lua/config/hlslens.lua | 4 ++--
lua/config/lsp.lua | 39 +++++++++++++++++----------------------
lua/custom-autocmd.lua | 2 +-
lua/globals.lua | 3 ++-
lua/utils.lua | 4 ++--
plugin/command.lua | 3 ++-
viml_conf/options.vim | 1 +
9 files changed, 29 insertions(+), 31 deletions(-)
diff --git a/README.md b/README.md
index b4a7bef1..e3b9542c 100644
--- a/README.md
+++ b/README.md
@@ -10,7 +10,7 @@
-
+
diff --git a/init.lua b/init.lua
index cd15458f..aa7d3c39 100644
--- a/init.lua
+++ b/init.lua
@@ -13,7 +13,7 @@ vim.loader.enable()
local utils = require("utils")
-local expected_version = "0.10.4"
+local expected_version = "0.11.0"
utils.is_compatible_version(expected_version)
local config_dir = vim.fn.stdpath("config")
diff --git a/lua/config/hlslens.lua b/lua/config/hlslens.lua
index 0f59bca8..e216a645 100644
--- a/lua/config/hlslens.lua
+++ b/lua/config/hlslens.lua
@@ -16,7 +16,7 @@ local activate_hlslens = function(direction)
if not status then
local start_idx, _ = string.find(msg, "E486", 1, true)
local msg_part = string.sub(msg, start_idx)
- api.nvim_err_writeln(msg_part)
+ api.nvim_echo({ { msg_part } }, true, { err = true })
return
end
@@ -40,7 +40,7 @@ local check_cursor_word = function()
local result = cursor_word == ""
if result then
local msg = "E348: No string under cursor"
- api.nvim_err_writeln(msg)
+ api.nvim_echo({ { msg } }, true, { err = true })
end
return result, cursor_word
diff --git a/lua/config/lsp.lua b/lua/config/lsp.lua
index 1496010e..a9633d5d 100644
--- a/lua/config/lsp.lua
+++ b/lua/config/lsp.lua
@@ -30,12 +30,18 @@ local custom_attach = function(client, bufnr)
map("n", "gd", vim.lsp.buf.definition, { desc = "go to definition" })
map("n", "", vim.lsp.buf.definition)
- map("n", "K", vim.lsp.buf.hover)
+ map("n", "K", function()
+ vim.lsp.buf.hover { border = "rounded" }
+ end)
map("n", "", vim.lsp.buf.signature_help)
map("n", "rn", vim.lsp.buf.rename, { desc = "varialbe rename" })
map("n", "gr", vim.lsp.buf.references, { desc = "show references" })
- map("n", "[d", diagnostic.goto_prev, { desc = "previous diagnostic" })
- map("n", "]d", diagnostic.goto_next, { desc = "next diagnostic" })
+ map("n", "[d", function()
+ diagnostic.jump { count = -1, float = true }
+ end, { desc = "previous diagnostic" })
+ map("n", "]d", function()
+ diagnostic.jump { count = 1, float = true }
+ end, { desc = "next diagnostic" })
-- this puts diagnostics from opened files to quickfix
map("n", "qw", diagnostic.setqflist, { desc = "put window diagnostics to qf" })
-- this puts diagnostics from current buffer to quickfix
@@ -278,28 +284,17 @@ if utils.executable("lua-language-server") then
}
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,
+ signs = {
+ text = {
+ [diagnostic.severity.ERROR] = "🆇",
+ [diagnostic.severity.WARN] = "⚠️",
+ [diagnostic.severity.INFO] = "ℹ️",
+ [diagnostic.severity.HINT] = "",
+ },
+ },
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",
-})
diff --git a/lua/custom-autocmd.lua b/lua/custom-autocmd.lua
index e03a0222..3cbe54d5 100644
--- a/lua/custom-autocmd.lua
+++ b/lua/custom-autocmd.lua
@@ -22,7 +22,7 @@ api.nvim_create_autocmd({ "TextYankPost" }, {
pattern = "*",
group = yank_group,
callback = function()
- vim.highlight.on_yank { higroup = "YankColor", timeout = 300 }
+ vim.hl.on_yank { higroup = "YankColor", timeout = 300 }
end,
})
diff --git a/lua/globals.lua b/lua/globals.lua
index 7e651765..e0bdad69 100644
--- a/lua/globals.lua
+++ b/lua/globals.lua
@@ -27,7 +27,8 @@ if utils.executable("python3") then
vim.g.python3_host_prog = fn.exepath("python3")
end
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
end
diff --git a/lua/utils.lua b/lua/utils.lua
index a1a37777..d77dc1a9 100644
--- a/lua/utils.lua
+++ b/lua/utils.lua
@@ -61,7 +61,7 @@ function M.is_compatible_version(expected_version)
if expect_ver == nil then
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
end
@@ -73,7 +73,7 @@ function M.is_compatible_version(expected_version)
expected_version,
_ver
)
- vim.api.nvim_err_writeln(msg)
+ vim.api.nvim_echo({ { msg } }, true, { err = true })
end
return true
diff --git a/plugin/command.lua b/plugin/command.lua
index 560dea15..006e3724 100644
--- a/plugin/command.lua
+++ b/plugin/command.lua
@@ -50,7 +50,8 @@ vim.api.nvim_create_user_command("JSONFormat", function(context)
local cmd_str = string.format("%s,%s!python -m json.tool", line1, line2)
vim.fn.execute(cmd_str)
else
- vim.api.nvim_err_write(string.format("unsupported range: %s", range))
+ local msg = string.format("unsupported range: %s", range)
+ vim.api.nvim_echo({ { msg } }, true, { err = true })
end
end, {
desc = "Format JSON string",
diff --git a/viml_conf/options.vim b/viml_conf/options.vim
index 1e3d2ae4..d0e813d2 100644
--- a/viml_conf/options.vim
+++ b/viml_conf/options.vim
@@ -124,6 +124,7 @@ set pumheight=10 " Maximum number of items to show in popup menu
set pumblend=5 " pseudo transparency for completion menu
set winblend=0 " pseudo transparency for floating window
+set winborder=none
" Insert mode key word completion setting
set complete+=kspell complete-=w complete-=b complete-=u complete-=t
From 5f662f143b2589260f88522027a859ab9d502629 Mon Sep 17 00:00:00 2001
From: jdhao
Date: Fri, 28 Mar 2025 20:27:02 +0100
Subject: [PATCH 096/247] update various config after nvim 0.11 release (#386)
---
lua/config/lsp.lua | 61 +++++++++++++++++++++----------------------
lua/globals.lua | 3 +++
lua/mappings.lua | 13 ---------
viml_conf/options.vim | 2 ++
4 files changed, 35 insertions(+), 44 deletions(-)
diff --git a/lua/config/lsp.lua b/lua/config/lsp.lua
index a9633d5d..32dc0ecf 100644
--- a/lua/config/lsp.lua
+++ b/lua/config/lsp.lua
@@ -1,4 +1,3 @@
-local fn = vim.fn
local api = vim.api
local keymap = vim.keymap
local lsp = vim.lsp
@@ -31,16 +30,16 @@ local custom_attach = function(client, bufnr)
map("n", "gd", vim.lsp.buf.definition, { desc = "go to definition" })
map("n", "", vim.lsp.buf.definition)
map("n", "K", function()
- vim.lsp.buf.hover { border = "rounded" }
+ vim.lsp.buf.hover { border = "single", max_height = 25 }
end)
map("n", "", vim.lsp.buf.signature_help)
map("n", "rn", vim.lsp.buf.rename, { desc = "varialbe rename" })
map("n", "gr", vim.lsp.buf.references, { desc = "show references" })
map("n", "[d", function()
- diagnostic.jump { count = -1, float = true }
+ diagnostic.jump { count = -1 }
end, { desc = "previous diagnostic" })
map("n", "]d", function()
- diagnostic.jump { count = 1, float = true }
+ diagnostic.jump { count = 1 }
end, { desc = "next diagnostic" })
-- this puts diagnostics from opened files to quickfix
map("n", "qw", diagnostic.setqflist, { desc = "put window diagnostics to qf" })
@@ -64,33 +63,6 @@ local custom_attach = function(client, bufnr)
-- but disable this feature by default, so you may need to enable inlay hint in the LSP server config.
-- vim.lsp.inlay_hint.enable(true, {buffer=bufnr})
- api.nvim_create_autocmd("CursorHold", {
- buffer = bufnr,
- callback = function()
- local float_opts = {
- focusable = false,
- close_events = { "BufLeave", "CursorMoved", "InsertEnter", "FocusLost" },
- border = "rounded",
- source = "always", -- show source in diagnostic popup window
- prefix = " ",
- }
-
- if not vim.b.diagnostics_pos then
- vim.b.diagnostics_pos = { nil, nil }
- end
-
- local cursor_pos = api.nvim_win_get_cursor(0)
- if
- (cursor_pos[1] ~= vim.b.diagnostics_pos[1] or cursor_pos[2] ~= vim.b.diagnostics_pos[2])
- and #diagnostic.get() > 0
- then
- diagnostic.open_float(nil, float_opts)
- end
-
- vim.b.diagnostics_pos = cursor_pos
- end,
- })
-
-- The blow command will highlight the current variable and its usages in the buffer.
if client.server_capabilities.documentHighlightProvider then
vim.cmd([[
@@ -288,6 +260,7 @@ end
diagnostic.config {
underline = false,
virtual_text = false,
+ virtual_lines = false,
signs = {
text = {
[diagnostic.severity.ERROR] = "🆇",
@@ -297,4 +270,30 @@ diagnostic.config {
},
},
severity_sort = true,
+ float = {
+ source = true,
+ header = "Diagnostics:",
+ prefix = " ",
+ border = "single",
+ },
}
+
+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 cursor_pos[1] ~= vim.b.diagnostics_pos[1] or cursor_pos[2] ~= vim.b.diagnostics_pos[2] then
+ diagnostic.open_float()
+ end
+
+ vim.b.diagnostics_pos = cursor_pos
+ end,
+})
diff --git a/lua/globals.lua b/lua/globals.lua
index e0bdad69..2163360a 100644
--- a/lua/globals.lua
+++ b/lua/globals.lua
@@ -69,3 +69,6 @@ vim.g.loaded_matchparen = 1
-- Disable sql omni completion, it is broken.
vim.g.loaded_sql_completion = 1
+
+-- control how to show health check window
+vim.g.health = { style = nil }
diff --git a/lua/mappings.lua b/lua/mappings.lua
index 368035bf..9915ef5c 100644
--- a/lua/mappings.lua
+++ b/lua/mappings.lua
@@ -23,19 +23,6 @@ keymap.set("n", "q", "x", { silent = true, desc = "quit current
-- Quit all opened buffers
keymap.set("n", "Q", "qa!", { silent = true, desc = "quit nvim" })
--- Navigation in the location and quickfix list
-keymap.set("n", "[l", "lpreviouszv", { silent = true, desc = "previous location item" })
-keymap.set("n", "]l", "lnextzv", { silent = true, desc = "next location item" })
-
-keymap.set("n", "[L", "lfirstzv", { silent = true, desc = "first location item" })
-keymap.set("n", "]L", "llastzv", { silent = true, desc = "last location item" })
-
-keymap.set("n", "[q", "cpreviouszv", { silent = true, desc = "previous qf item" })
-keymap.set("n", "]q", "cnextzv", { silent = true, desc = "next qf item" })
-
-keymap.set("n", "[Q", "cfirstzv", { silent = true, desc = "first qf item" })
-keymap.set("n", "]Q", "clastzv", { silent = true, desc = "last qf item" })
-
-- Close location list or quickfix list if they are present, see https://superuser.com/q/355325/736190
keymap.set("n", [[\x]], "windo lclose cclose ", {
silent = true,
diff --git a/viml_conf/options.vim b/viml_conf/options.vim
index d0e813d2..31902859 100644
--- a/viml_conf/options.vim
+++ b/viml_conf/options.vim
@@ -115,6 +115,8 @@ set shortmess+=S
" Disable showing intro message (:intro)
set shortmess+=I
+set messagesopt=wait:5000,history:500
+
" Completion behaviour
" set completeopt+=noinsert " Auto select the first completion entry
set completeopt+=menuone " Show menu even if there is only one item
From a8a1b929212c9d2a015a14215dd58d94bc7bdfe8 Mon Sep 17 00:00:00 2001
From: jdhao
Date: Fri, 28 Mar 2025 20:29:39 +0100
Subject: [PATCH 097/247] update floating window highlight (#387)
---
lua/custom-autocmd.lua | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/lua/custom-autocmd.lua b/lua/custom-autocmd.lua
index 3cbe54d5..2f7356a6 100644
--- a/lua/custom-autocmd.lua
+++ b/lua/custom-autocmd.lua
@@ -170,7 +170,11 @@ api.nvim_create_autocmd("ColorScheme", {
vim.api.nvim_set_hl(0, "Cursor2", { fg = "red", bg = "red" })
-- For floating windows border highlight
- vim.api.nvim_set_hl(0, "FloatBorder", { fg = "LightGreen" })
+ vim.api.nvim_set_hl(0, "FloatBorder", { fg = "LightGreen", bg = "None", bold = true })
+
+ local hl = vim.api.nvim_get_hl(0, { name = "NormalFloat" })
+ -- 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 })
From 12147bec86d83f85c7ea59921f8248760d6f42f0 Mon Sep 17 00:00:00 2001
From: jdhao
Date: Sun, 30 Mar 2025 17:55:51 +0200
Subject: [PATCH 098/247] Use glance.nvim for lsp references/implementations
preview (#388)
---
lua/config/glance.lua | 12 ++++++++++++
lua/plugin_specs.lua | 8 +++++++-
2 files changed, 19 insertions(+), 1 deletion(-)
create mode 100644 lua/config/glance.lua
diff --git a/lua/config/glance.lua b/lua/config/glance.lua
new file mode 100644
index 00000000..daaef828
--- /dev/null
+++ b/lua/config/glance.lua
@@ -0,0 +1,12 @@
+local glance = require("glance")
+
+glance.setup {
+ height = 25,
+ border = {
+ enable = true,
+ },
+}
+
+vim.keymap.set("n", "gd", "Glance definitions")
+vim.keymap.set("n", "gr", "Glance references")
+vim.keymap.set("n", "gi", "Glance implementations")
diff --git a/lua/plugin_specs.lua b/lua/plugin_specs.lua
index ba229206..2bdbd623 100644
--- a/lua/plugin_specs.lua
+++ b/lua/plugin_specs.lua
@@ -47,7 +47,13 @@ local plugin_specs = {
require("config.lsp")
end,
},
-
+ {
+ "dnlhc/glance.nvim",
+ config = function()
+ require("config.glance")
+ end,
+ envnt = "VeryLazy",
+ },
{
"nvim-treesitter/nvim-treesitter",
event = "VeryLazy",
From 0816faee76a4d4308816fea6c74342212e6e291e Mon Sep 17 00:00:00 2001
From: jdhao
Date: Sun, 30 Mar 2025 17:58:09 +0200
Subject: [PATCH 099/247] Separate diagnostic config from lsp ones (#389)
---
init.lua | 9 ++++-
lua/config/lsp.lua | 75 +----------------------------------------
lua/diagnostic-conf.lua | 66 ++++++++++++++++++++++++++++++++++++
3 files changed, 75 insertions(+), 75 deletions(-)
create mode 100644 lua/diagnostic-conf.lua
diff --git a/init.lua b/init.lua
index aa7d3c39..4beead9f 100644
--- a/init.lua
+++ b/init.lua
@@ -29,5 +29,12 @@ require("custom-autocmd")
require("mappings")
-- all the plugins installed and their configurations
vim.cmd("source " .. vim.fs.joinpath(config_dir, "viml_conf/plugins.vim"))
+
+-- diagnostic related config
+require("diagnostic-conf")
+
-- colorscheme settings
-require("colorschemes")
+local color_scheme = require("colorschemes")
+
+-- Load a random colorscheme
+color_scheme.rand_colorscheme()
diff --git a/lua/config/lsp.lua b/lua/config/lsp.lua
index 32dc0ecf..374ab88d 100644
--- a/lua/config/lsp.lua
+++ b/lua/config/lsp.lua
@@ -6,18 +6,6 @@ local lspconfig = require("lspconfig")
local utils = require("utils")
--- set quickfix list from diagnostics in a certain buffer, not the whole workspace
-local set_qflist = function(buf_num, severity)
- local diagnostics = nil
- diagnostics = diagnostic.get(buf_num, { severity = severity })
-
- local qf_items = diagnostic.toqflist(diagnostics)
- vim.fn.setqflist({}, " ", { title = "Diagnostics", items = qf_items })
-
- -- open quickfix by default
- vim.cmd([[copen]])
-end
-
local custom_attach = function(client, bufnr)
-- Mappings.
local map = function(mode, l, r, opts)
@@ -30,23 +18,10 @@ local custom_attach = function(client, bufnr)
map("n", "gd", vim.lsp.buf.definition, { desc = "go to definition" })
map("n", "", vim.lsp.buf.definition)
map("n", "K", function()
- vim.lsp.buf.hover { border = "single", max_height = 25 }
+ vim.lsp.buf.hover { border = "single", max_height = 25, max_width = 120 }
end)
map("n", "", vim.lsp.buf.signature_help)
map("n", "rn", vim.lsp.buf.rename, { desc = "varialbe rename" })
- map("n", "gr", vim.lsp.buf.references, { desc = "show references" })
- map("n", "[d", function()
- diagnostic.jump { count = -1 }
- end, { desc = "previous diagnostic" })
- map("n", "]d", function()
- diagnostic.jump { count = 1 }
- end, { desc = "next diagnostic" })
- -- this puts diagnostics from opened files to quickfix
- map("n", "qw", diagnostic.setqflist, { desc = "put window diagnostics to qf" })
- -- this puts diagnostics from current buffer to quickfix
- map("n", "qb", function()
- set_qflist(bufnr)
- end, { desc = "put buffer diagnostics to qf" })
map("n", "ca", vim.lsp.buf.code_action, { desc = "LSP code action" })
map("n", "wa", vim.lsp.buf.add_workspace_folder, { desc = "add workspace folder" })
map("n", "wr", vim.lsp.buf.remove_workspace_folder, { desc = "remove workspace folder" })
@@ -65,12 +40,6 @@ local custom_attach = function(client, bufnr)
-- The blow command will highlight the current variable and its usages in the buffer.
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,
@@ -255,45 +224,3 @@ if utils.executable("lua-language-server") then
capabilities = capabilities,
}
end
-
--- 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",
- },
-}
-
-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 cursor_pos[1] ~= vim.b.diagnostics_pos[1] or cursor_pos[2] ~= vim.b.diagnostics_pos[2] then
- diagnostic.open_float()
- end
-
- vim.b.diagnostics_pos = cursor_pos
- end,
-})
diff --git a/lua/diagnostic-conf.lua b/lua/diagnostic-conf.lua
new file mode 100644
index 00000000..e50a4be9
--- /dev/null
+++ b/lua/diagnostic-conf.lua
@@ -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", "qw", diagnostic.setqflist, { desc = "put window diagnostics to qf" })
+
+-- this puts diagnostics from current buffer to quickfix
+vim.keymap.set("n", "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,
+})
From b82c1c112fd59bddd770f05932028d9a7bd0b336 Mon Sep 17 00:00:00 2001
From: jdhao
Date: Sun, 30 Mar 2025 18:02:28 +0200
Subject: [PATCH 100/247] update colorscheme (#390)
1. Remove catppuccin, it is too purple/blue for me
2. use another nightfox variant
---
lua/colorschemes.lua | 20 ++------------------
1 file changed, 2 insertions(+), 18 deletions(-)
diff --git a/lua/colorschemes.lua b/lua/colorschemes.lua
index 12149699..978af758 100644
--- a/lua/colorschemes.lua
+++ b/lua/colorschemes.lua
@@ -44,14 +44,7 @@ M.colorscheme_conf = {
vim.cmd([[colorscheme everforest]])
end,
nightfox = function()
- vim.cmd([[colorscheme nordfox]])
- end,
- catppuccin = function()
- -- available option: latte, frappe, macchiato, mocha
- vim.g.catppuccin_flavour = "frappe"
- require("catppuccin").setup()
-
- vim.cmd([[colorscheme catppuccin]])
+ vim.cmd([[colorscheme carbonfox]])
end,
onedarkpro = function()
-- set colorscheme after options
@@ -73,14 +66,6 @@ M.colorscheme_conf = {
--- Use a random colorscheme from the pre-defined list of colorschemes.
M.rand_colorscheme = function()
local colorscheme = utils.rand_element(vim.tbl_keys(M.colorscheme_conf))
- colorscheme = "gruvbox_material"
-
- 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
M.colorscheme_conf[colorscheme]()
@@ -92,5 +77,4 @@ M.rand_colorscheme = function()
end
end
--- Load a random colorscheme
-M.rand_colorscheme()
+return M
From 265f171172beb1289806bbc22c632c39048cfb86 Mon Sep 17 00:00:00 2001
From: jdhao
Date: Sun, 30 Mar 2025 18:58:23 +0200
Subject: [PATCH 101/247] remove unused variable
---
lua/config/lsp.lua | 1 -
1 file changed, 1 deletion(-)
diff --git a/lua/config/lsp.lua b/lua/config/lsp.lua
index 374ab88d..abc10167 100644
--- a/lua/config/lsp.lua
+++ b/lua/config/lsp.lua
@@ -1,7 +1,6 @@
local api = vim.api
local keymap = vim.keymap
local lsp = vim.lsp
-local diagnostic = vim.diagnostic
local lspconfig = require("lspconfig")
local utils = require("utils")
From 625a4ffa475ee3d6ce6a66dc6d92840f6033f98e Mon Sep 17 00:00:00 2001
From: jdhao
Date: Sun, 30 Mar 2025 20:21:35 +0200
Subject: [PATCH 102/247] update config for lazydev and nvim-lightbulb (#391)
---
lua/config/lightbulb.lua | 20 ++++++++++++++++++++
lua/plugin_specs.lua | 11 +++++++++--
2 files changed, 29 insertions(+), 2 deletions(-)
create mode 100644 lua/config/lightbulb.lua
diff --git a/lua/config/lightbulb.lua b/lua/config/lightbulb.lua
new file mode 100644
index 00000000..8f49746b
--- /dev/null
+++ b/lua/config/lightbulb.lua
@@ -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,
+}
diff --git a/lua/plugin_specs.lua b/lua/plugin_specs.lua
index 2bdbd623..b5d64b3d 100644
--- a/lua/plugin_specs.lua
+++ b/lua/plugin_specs.lua
@@ -553,7 +553,13 @@ local plugin_specs = {
{
"folke/lazydev.nvim",
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",
@@ -589,7 +595,7 @@ local plugin_specs = {
-- see discussion here: https://github.com/neovim/neovim/issues/14869
"kosayoda/nvim-lightbulb",
config = function()
- require("nvim-lightbulb").setup { autocmd = { enabled = true } }
+ require("config.lightbulb")
end,
},
{
@@ -603,6 +609,7 @@ local plugin_specs = {
},
}
+---@diagnostic disable-next-line: missing-fields
require("lazy").setup {
spec = plugin_specs,
ui = {
From 72e6480933339a993643e8023b93b8fa57bf088c Mon Sep 17 00:00:00 2001
From: jdhao
Date: Sun, 30 Mar 2025 20:54:53 +0200
Subject: [PATCH 103/247] Use LspAttach to configure buffer behavior (#392)
---
lua/config/lsp.lua | 152 +++++++++++++++++++++------------------------
1 file changed, 71 insertions(+), 81 deletions(-)
diff --git a/lua/config/lsp.lua b/lua/config/lsp.lua
index abc10167..42d263f1 100644
--- a/lua/config/lsp.lua
+++ b/lua/config/lsp.lua
@@ -5,63 +5,77 @@ local lspconfig = require("lspconfig")
local utils = require("utils")
-local custom_attach = function(client, bufnr)
- -- Mappings.
- local map = function(mode, l, r, opts)
- opts = opts or {}
- opts.silent = true
- opts.buffer = bufnr
- keymap.set(mode, l, r, opts)
- end
-
- map("n", "gd", vim.lsp.buf.definition, { desc = "go to definition" })
- map("n", "", vim.lsp.buf.definition)
- map("n", "K", function()
- vim.lsp.buf.hover { border = "single", max_height = 25, max_width = 120 }
- end)
- map("n", "", vim.lsp.buf.signature_help)
- map("n", "rn", vim.lsp.buf.rename, { desc = "varialbe rename" })
- map("n", "ca", vim.lsp.buf.code_action, { desc = "LSP code action" })
- map("n", "wa", vim.lsp.buf.add_workspace_folder, { desc = "add workspace folder" })
- map("n", "wr", vim.lsp.buf.remove_workspace_folder, { desc = "remove workspace folder" })
- map("n", "wl", function()
- vim.print(vim.lsp.buf.list_workspace_folders())
- end, { desc = "list workspace folder" })
-
- -- Set some key bindings conditional on server capabilities
- if client.server_capabilities.documentFormattingProvider and client.name ~= "lua_ls" then
- map({ "n", "x" }, "f", vim.lsp.buf.format, { desc = "format code" })
- end
-
- -- Uncomment code below to enable inlay hint from language server, some LSP server supports inlay hint,
- -- but disable this feature by default, so you may need to enable inlay hint in the LSP server config.
- -- vim.lsp.inlay_hint.enable(true, {buffer=bufnr})
-
- -- The blow command will highlight the current variable and its usages in the buffer.
- if client.server_capabilities.documentHighlightProvider then
- 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
+vim.api.nvim_create_autocmd("LspAttach", {
+ group = vim.api.nvim_create_augroup("buf_behavior_conf", { clear = true }),
+ callback = function(event_context)
+ local client = vim.lsp.get_client_by_id(event_context.data.client_id)
+ -- vim.print(client.name, client.server_capabilities)
+
+ if not client then
+ return
+ end
+
+ local bufnr = event_context.buf
+
+ -- Mappings.
+ local map = function(mode, l, r, opts)
+ opts = opts or {}
+ opts.silent = true
+ opts.buffer = bufnr
+ keymap.set(mode, l, r, opts)
+ end
+
+ map("n", "gd", vim.lsp.buf.definition, { desc = "go to definition" })
+ map("n", "", vim.lsp.buf.definition)
+ map("n", "K", function()
+ vim.lsp.buf.hover { border = "single", max_height = 25, max_width = 120 }
+ end)
+ map("n", "", vim.lsp.buf.signature_help)
+ map("n", "rn", vim.lsp.buf.rename, { desc = "varialbe rename" })
+ map("n", "ca", vim.lsp.buf.code_action, { desc = "LSP code action" })
+ map("n", "wa", vim.lsp.buf.add_workspace_folder, { desc = "add workspace folder" })
+ map("n", "wr", vim.lsp.buf.remove_workspace_folder, { desc = "remove workspace folder" })
+ map("n", "wl", function()
+ vim.print(vim.lsp.buf.list_workspace_folders())
+ end, { desc = "list workspace folder" })
+
+ -- Set some key bindings conditional on server capabilities
+ if client.server_capabilities.documentFormattingProvider and client.name ~= "lua_ls" then
+ map({ "n", "x" }, "f", vim.lsp.buf.format, { desc = "format code" })
+ end
+
+ -- Disable ruff hover feature in favor of Pyright
+ if client.name == "ruff" then
+ client.server_capabilities.hoverProvider = false
+ end
+
+ -- Uncomment code below to enable inlay hint from language server, some LSP server supports inlay hint,
+ -- but disable this feature by default, so you may need to enable inlay hint in the LSP server config.
+ -- vim.lsp.inlay_hint.enable(true, {buffer=bufnr})
+
+ -- The blow command will highlight the current variable and its usages in the buffer.
+ if client.server_capabilities.documentHighlightProvider then
+ local gid = api.nvim_create_augroup("lsp_document_highlight", { clear = true })
+ api.nvim_create_autocmd("CursorHold", {
+ group = gid,
+ buffer = bufnr,
+ callback = function()
+ lsp.buf.document_highlight()
+ end,
+ })
+
+ api.nvim_create_autocmd("CursorMoved", {
+ group = gid,
+ buffer = bufnr,
+ callback = function()
+ lsp.buf.clear_references()
+ end,
+ })
+ end
+ end,
+ nested = true,
+ desc = "Configure buffer keymap and behavior based on LSP",
+})
local capabilities = vim.lsp.protocol.make_client_capabilities()
@@ -96,7 +110,6 @@ if utils.executable("pyright") then
lspconfig.pyright.setup {
cmd = { "delance-langserver", "--stdio" },
- on_attach = custom_attach,
capabilities = merged_capability,
settings = {
pyright = {
@@ -131,7 +144,6 @@ end
if utils.executable("ruff") then
require("lspconfig").ruff.setup {
- on_attach = custom_attach,
capabilities = capabilities,
init_options = {
-- the settings can be found here: https://docs.astral.sh/ruff/editors/settings/
@@ -142,26 +154,8 @@ if utils.executable("ruff") then
}
end
--- Disable ruff hover feature in favor of Pyright
-vim.api.nvim_create_autocmd("LspAttach", {
- group = vim.api.nvim_create_augroup("lsp_attach_disable_ruff_hover", { clear = true }),
- callback = function(args)
- local client = vim.lsp.get_client_by_id(args.data.client_id)
- -- vim.print(client.name, client.server_capabilities)
-
- if client == nil then
- return
- end
- if client.name == "ruff" then
- client.server_capabilities.hoverProvider = false
- end
- end,
- desc = "LSP: Disable hover capability from Ruff",
-})
-
if utils.executable("ltex-ls") then
lspconfig.ltex.setup {
- on_attach = custom_attach,
cmd = { "ltex-ls" },
filetypes = { "text", "plaintex", "tex", "markdown" },
settings = {
@@ -175,7 +169,6 @@ end
if utils.executable("clangd") then
lspconfig.clangd.setup {
- on_attach = custom_attach,
capabilities = capabilities,
filetypes = { "c", "cpp", "cc" },
flags = {
@@ -187,7 +180,6 @@ end
-- set up vim-language-server
if utils.executable("vim-language-server") then
lspconfig.vimls.setup {
- on_attach = custom_attach,
flags = {
debounce_text_changes = 500,
},
@@ -200,7 +192,6 @@ end
-- set up bash-language-server
if utils.executable("bash-language-server") then
lspconfig.bashls.setup {
- on_attach = custom_attach,
capabilities = capabilities,
}
end
@@ -208,7 +199,6 @@ end
-- settings for lua-language-server can be found on https://luals.github.io/wiki/settings/
if utils.executable("lua-language-server") then
lspconfig.lua_ls.setup {
- on_attach = custom_attach,
settings = {
Lua = {
runtime = {
From bfc531656a5de86e1209cbc1a78b71cddaa53099 Mon Sep 17 00:00:00 2001
From: jdhao
Date: Sun, 30 Mar 2025 20:56:43 +0200
Subject: [PATCH 104/247] Add option messagesopt config
---
viml_conf/options.vim | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/viml_conf/options.vim b/viml_conf/options.vim
index 31902859..08d984bd 100644
--- a/viml_conf/options.vim
+++ b/viml_conf/options.vim
@@ -115,7 +115,7 @@ set shortmess+=S
" Disable showing intro message (:intro)
set shortmess+=I
-set messagesopt=wait:5000,history:500
+set messagesopt=hit-enter,history:500
" Completion behaviour
" set completeopt+=noinsert " Auto select the first completion entry
From d17289cd6ba06138ab06f99fc208c0cd0fa91c84 Mon Sep 17 00:00:00 2001
From: jdhao
Date: Sun, 30 Mar 2025 21:00:21 +0200
Subject: [PATCH 105/247] use builtin log level enum to specify log level
(#393)
---
lua/colorschemes.lua | 6 ------
lua/globals.lua | 2 +-
2 files changed, 1 insertion(+), 7 deletions(-)
diff --git a/lua/colorschemes.lua b/lua/colorschemes.lua
index 978af758..2365e5cd 100644
--- a/lua/colorschemes.lua
+++ b/lua/colorschemes.lua
@@ -69,12 +69,6 @@ M.rand_colorscheme = function()
-- Load the colorscheme and its settings
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
return M
diff --git a/lua/globals.lua b/lua/globals.lua
index 2163360a..d1a06a76 100644
--- a/lua/globals.lua
+++ b/lua/globals.lua
@@ -10,7 +10,7 @@ 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_mac = utils.has("macunix") and true or false
-vim.g.logging_level = "info"
+vim.g.logging_level = vim.log.levels.INFO
------------------------------------------------------------------------
-- builtin variables --
From f76ef3dbb46711c1de2b25b92d7092f8d5a13272 Mon Sep 17 00:00:00 2001
From: jdhao
Date: Sun, 30 Mar 2025 21:01:02 +0200
Subject: [PATCH 106/247] fix diagnostic issues
---
lua/custom-autocmd.lua | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/lua/custom-autocmd.lua b/lua/custom-autocmd.lua
index 2f7356a6..dba479e7 100644
--- a/lua/custom-autocmd.lua
+++ b/lua/custom-autocmd.lua
@@ -37,7 +37,8 @@ api.nvim_create_autocmd({ "CursorMoved" }, {
api.nvim_create_autocmd("TextYankPost", {
pattern = "*",
group = yank_group,
- callback = function(ev)
+ ---@diagnostic disable-next-line: unused-local
+ callback = function(context)
if vim.v.event.operator == "y" then
vim.fn.setpos(".", vim.g.current_cursor_pos)
end
@@ -185,7 +186,8 @@ api.nvim_create_autocmd("BufEnter", {
pattern = "*",
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",
- callback = function(ev)
+ ---@diagnostic disable-next-line: unused-local
+ callback = function(context)
local quit_filetypes = { "qf", "vista", "NvimTree" }
local should_quit = true
@@ -193,9 +195,9 @@ api.nvim_create_autocmd("BufEnter", {
for _, win in pairs(tabwins) do
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
end
end
From 7fa77fbfbfc4ac0a67df90b9e61ac55d5e893ef5 Mon Sep 17 00:00:00 2001
From: Ya Zhuang <499038+zhuangya@users.noreply.github.com>
Date: Mon, 31 Mar 2025 14:50:35 +0800
Subject: [PATCH 107/247] fix typo (#394)
---
lua/plugin_specs.lua | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lua/plugin_specs.lua b/lua/plugin_specs.lua
index b5d64b3d..475006c0 100644
--- a/lua/plugin_specs.lua
+++ b/lua/plugin_specs.lua
@@ -52,7 +52,7 @@ local plugin_specs = {
config = function()
require("config.glance")
end,
- envnt = "VeryLazy",
+ event = "VeryLazy",
},
{
"nvim-treesitter/nvim-treesitter",
From 60852c0473c88065c1c3d7bc95e9823eacb0e335 Mon Sep 17 00:00:00 2001
From: jdhao
Date: Wed, 2 Apr 2025 18:20:01 +0200
Subject: [PATCH 108/247] Switch from LeaderF to Fzf-lua as the default fuzzy
finder (#395)
---
README.md | 7 ++--
lua/config/dashboard-nvim.lua | 6 +--
lua/plugin_specs.lua | 28 ++++++-------
viml_conf/plugins.vim | 79 -----------------------------------
4 files changed, 18 insertions(+), 102 deletions(-)
diff --git a/README.md b/README.md
index e3b9542c..a03da8f2 100644
--- a/README.md
+++ b/README.md
@@ -59,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).
+ 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).
-+ 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 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).
@@ -79,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)
+ Animated GUI style notification via [nvim-notify](https://github.com/rcarriga/nvim-notify).
+ 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)
+ Code folding with [nvim-ufo](https://github.com/kevinhwang91/nvim-ufo) and [statuscol.nvim](https://github.com/luukvbaal/statuscol.nvim)
+ ......
@@ -94,10 +93,10 @@ For more UI demos, check [here](https://github.com/jdhao/nvim-config/issues/15).
-## File fuzzy finding using LeaderF
+## File fuzzy finding using fzf-lua
-
+
## Code autocompletion with nvim-cmp
diff --git a/lua/config/dashboard-nvim.lua b/lua/config/dashboard-nvim.lua
index 562c124a..fd921717 100644
--- a/lua/config/dashboard-nvim.lua
+++ b/lua/config/dashboard-nvim.lua
@@ -23,19 +23,19 @@ conf.center = {
{
icon = " ",
desc = "Find File ",
- action = "Leaderf file --popup",
+ action = "FzfLua files",
key = " f f",
},
{
icon = " ",
desc = "Recently opened files ",
- action = "Leaderf mru --popup",
+ action = "FzfLua oldfiles",
key = " f r",
},
{
icon = " ",
desc = "Project grep ",
- action = "Leaderf rg --popup",
+ action = "FzfLua live_grep",
key = " f g",
},
{
diff --git a/lua/plugin_specs.lua b/lua/plugin_specs.lua
index 475006c0..5f201bd5 100644
--- a/lua/plugin_specs.lua
+++ b/lua/plugin_specs.lua
@@ -106,20 +106,6 @@ local plugin_specs = {
require("config.hlslens")
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",
cmd = "Telescope",
@@ -132,8 +118,18 @@ local plugin_specs = {
-- optional for icon support
dependencies = { "nvim-tree/nvim-web-devicons" },
config = function()
- -- calling `setup` is optional for customization
- require("fzf-lua").setup {}
+ require("fzf-lua").setup {
+ winopts = {
+ row = 0.5,
+ height = 0.7,
+ },
+ }
+
+ vim.keymap.set("n", "ff", "FzfLua files", { desc = "Fuzzy find files" })
+ vim.keymap.set("n", "fg", "FzfLua live_grep", { desc = "Fuzzy grep files" })
+ vim.keymap.set("n", "fh", "FzfLua helptags", { desc = "Fuzzy grep tags in help files" })
+ vim.keymap.set("n", "ft", "FzfLua btags", { desc = "Fuzzy search buffer tags" })
+ vim.keymap.set("n", "fb", "FzfLua buffers", { desc = "Fuzzy search opened buffers" })
end,
},
{
diff --git a/viml_conf/plugins.vim b/viml_conf/plugins.vim
index 415bd786..cbf8ec4f 100644
--- a/viml_conf/plugins.vim
+++ b/viml_conf/plugins.vim
@@ -34,85 +34,6 @@ let g:UltiSnipsSnippetDirectories=['UltiSnips', 'my_snippets']
"""""""""""""""""""""""""" vlime settings """"""""""""""""""""""""""""""""
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 ff :Leaderf file --popup
-
-" Grep project files in popup window
-nnoremap fg :Leaderf rg --no-messages --popup --nameOnly
-
-" Search vim help files
-nnoremap fh :Leaderf help --popup
-
-" Search tags in current buffer
-nnoremap ft :Leaderf bufTag --popup
-
-" Switch buffers
-nnoremap fb :Leaderf buffer --popup
-
-" Search recent files
-nnoremap fr :Leaderf mru --popup --absolute-path
-
-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 = {'': [''], '': ['']}
-
-" 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 """"""""""""""""""""""""""""""""""
let g:vista#renderer#icons = {
\ 'member': '',
From c4160b6f85c93ad482d91a45f134e22970cb9d36 Mon Sep 17 00:00:00 2001
From: jdhao
Date: Wed, 2 Apr 2025 21:30:25 +0200
Subject: [PATCH 109/247] update handling of large files (#396)
---
lua/custom-autocmd.lua | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/lua/custom-autocmd.lua b/lua/custom-autocmd.lua
index dba479e7..62b6e7eb 100644
--- a/lua/custom-autocmd.lua
+++ b/lua/custom-autocmd.lua
@@ -228,8 +228,13 @@ api.nvim_create_autocmd("BufReadPre", {
if fn.getfsize(f) > file_size_limit or fn.getfsize(f) == -2 then
vim.o.eventignore = "all"
+
+ -- show ruler
+ vim.o.ruler = true
+
-- turning off relative number helps a lot
vim.wo.relativenumber = false
+ vim.wo.number = false
vim.bo.swapfile = false
vim.bo.bufhidden = "unload"
From 9e6be1f00128bc23d4217666c51fdead0763e882 Mon Sep 17 00:00:00 2001
From: jdhao
Date: Wed, 2 Apr 2025 21:33:32 +0200
Subject: [PATCH 110/247] update type hints
---
lua/utils.lua | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/lua/utils.lua b/lua/utils.lua
index d77dc1a9..f9963e71 100644
--- a/lua/utils.lua
+++ b/lua/utils.lua
@@ -3,12 +3,11 @@ local version = vim.version
local M = {}
+--- Check if an executable exists
+--- @param name string An executable name/path
+--- @return boolean
function M.executable(name)
- if fn.executable(name) > 0 then
- return true
- end
-
- return false
+ return fn.executable(name) > 0
end
--- check whether a feature exists in Nvim
From ad4a0e82dc49d9b019a6fd82dfe953ed01ecbe41 Mon Sep 17 00:00:00 2001
From: jdhao
Date: Wed, 2 Apr 2025 21:57:37 +0200
Subject: [PATCH 111/247] Simplify condition check (#397)
---
lua/plugin_specs.lua | 64 ++++++++++----------------------------------
1 file changed, 14 insertions(+), 50 deletions(-)
diff --git a/lua/plugin_specs.lua b/lua/plugin_specs.lua
index 5f201bd5..d2025249 100644
--- a/lua/plugin_specs.lua
+++ b/lua/plugin_specs.lua
@@ -77,10 +77,7 @@ local plugin_specs = {
{
"vlime/vlime",
enabled = function()
- if utils.executable("sbcl") then
- return true
- end
- return false
+ return utils.executable("sbcl")
end,
config = function(plugin)
vim.opt.rtp:append(plugin.dir .. "/vim")
@@ -236,11 +233,7 @@ local plugin_specs = {
vim.g.netrw_nogx = 1 -- disable netrw gx
end,
enabled = function()
- if vim.g.is_win or vim.g.is_mac then
- return true
- else
- return false
- end
+ return vim.g.is_win or vim.g.is_mac
end,
dependencies = { "nvim-lua/plenary.nvim" },
config = true, -- default settings
@@ -252,11 +245,7 @@ local plugin_specs = {
{
"liuchengxu/vista.vim",
enabled = function()
- if utils.executable("ctags") then
- return true
- else
- return false
- end
+ return utils.executable("ctags")
end,
cmd = "Vista",
},
@@ -302,10 +291,7 @@ local plugin_specs = {
{
"lyokha/vim-xkbswitch",
enabled = function()
- if vim.g.is_mac and utils.executable("xkbswitch") then
- return true
- end
- return false
+ return vim.g.is_mac and utils.executable("xkbswitch")
end,
event = { "InsertEnter" },
},
@@ -313,10 +299,7 @@ local plugin_specs = {
{
"Neur1n/neuims",
enabled = function()
- if vim.g.is_win then
- return true
- end
- return false
+ return vim.g.is_win
end,
event = { "InsertEnter" },
},
@@ -365,22 +348,19 @@ local plugin_specs = {
},
-- Another markdown plugin
- { "preservim/vim-markdown", ft = { "markdown" } },
+ -- { "preservim/vim-markdown", ft = { "markdown" } },
-- Faster footnote generation
{ "vim-pandoc/vim-markdownfootnotes", ft = { "markdown" } },
-- 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)
{
"iamcco/markdown-preview.nvim",
enabled = function()
- if vim.g.is_win or vim.g.is_mac then
- return true
- end
- return false
+ return vim.g.is_win or vim.g.is_mac
end,
build = "cd app && npm install && git restore .",
ft = { "markdown" },
@@ -389,10 +369,7 @@ local plugin_specs = {
{
"rhysd/vim-grammarous",
enabled = function()
- if vim.g.is_mac then
- return true
- end
- return false
+ return vim.g.is_mac
end,
ft = { "markdown" },
},
@@ -413,10 +390,7 @@ local plugin_specs = {
{
"lervag/vimtex",
enabled = function()
- if utils.executable("latex") then
- return true
- end
- return false
+ return utils.executable("latex")
end,
ft = { "tex" },
},
@@ -427,10 +401,7 @@ local plugin_specs = {
{
"tmux-plugins/vim-tmux",
enabled = function()
- if utils.executable("tmux") then
- return true
- end
- return false
+ return utils.executable("tmux")
end,
ft = { "tmux" },
},
@@ -447,8 +418,7 @@ local plugin_specs = {
{
"glacambre/firenvim",
enabled = function()
- local result = vim.g.is_win or vim.g.is_mac
- return result
+ return vim.g.is_win or vim.g.is_mac
end,
-- it seems that we can only call the firenvim function directly.
-- Using vim.fn or vim.cmd to call this function will fail.
@@ -471,10 +441,7 @@ local plugin_specs = {
{
"sakhnik/nvim-gdb",
enabled = function()
- if vim.g.is_win or vim.g.is_linux then
- return true
- end
- return false
+ return vim.g.is_win or vim.g.is_linux
end,
build = { "bash install.sh" },
lazy = true,
@@ -486,10 +453,7 @@ local plugin_specs = {
{
"ojroques/vim-oscyank",
enabled = function()
- if vim.g.is_linux then
- return true
- end
- return false
+ return vim.g.is_linux
end,
cmd = { "OSCYank", "OSCYankReg" },
},
From ea2b4a728dd837a4b844cf45de26f3f3251c638e Mon Sep 17 00:00:00 2001
From: jdhao
Date: Fri, 4 Apr 2025 18:16:20 +0200
Subject: [PATCH 112/247] remove plugin vim-markdown (#398)
use tree-sitter based markdown render instead.
---
lua/plugin_specs.lua | 16 +---------------
viml_conf/plugins.vim | 19 -------------------
2 files changed, 1 insertion(+), 34 deletions(-)
diff --git a/lua/plugin_specs.lua b/lua/plugin_specs.lua
index d2025249..7f4281fb 100644
--- a/lua/plugin_specs.lua
+++ b/lua/plugin_specs.lua
@@ -115,18 +115,7 @@ local plugin_specs = {
-- optional for icon support
dependencies = { "nvim-tree/nvim-web-devicons" },
config = function()
- require("fzf-lua").setup {
- winopts = {
- row = 0.5,
- height = 0.7,
- },
- }
-
- vim.keymap.set("n", "ff", "FzfLua files", { desc = "Fuzzy find files" })
- vim.keymap.set("n", "fg", "FzfLua live_grep", { desc = "Fuzzy grep files" })
- vim.keymap.set("n", "fh", "FzfLua helptags", { desc = "Fuzzy grep tags in help files" })
- vim.keymap.set("n", "ft", "FzfLua btags", { desc = "Fuzzy search buffer tags" })
- vim.keymap.set("n", "fb", "FzfLua buffers", { desc = "Fuzzy search opened buffers" })
+ require("config.fzf-lua")
end,
},
{
@@ -347,9 +336,6 @@ local plugin_specs = {
end,
},
- -- Another markdown plugin
- -- { "preservim/vim-markdown", ft = { "markdown" } },
-
-- Faster footnote generation
{ "vim-pandoc/vim-markdownfootnotes", ft = { "markdown" } },
diff --git a/viml_conf/plugins.vim b/viml_conf/plugins.vim
index cbf8ec4f..70a74467 100644
--- a/viml_conf/plugins.vim
+++ b/viml_conf/plugins.vim
@@ -72,25 +72,6 @@ let g:neoformat_c_clangformat = {
let g:neoformat_enabled_cpp = ['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"""""""""""""""""""
" Only setting this for suitable platforms
if g:is_win || g:is_mac
From 58261611609ec4b3e134aa42edeb31e8cc01a288 Mon Sep 17 00:00:00 2001
From: jdhao
Date: Fri, 4 Apr 2025 18:17:24 +0200
Subject: [PATCH 113/247] move fzf-lua config to separate file
---
lua/config/fzf-lua.lua | 15 +++++++++++++++
1 file changed, 15 insertions(+)
create mode 100644 lua/config/fzf-lua.lua
diff --git a/lua/config/fzf-lua.lua b/lua/config/fzf-lua.lua
new file mode 100644
index 00000000..7d818c2f
--- /dev/null
+++ b/lua/config/fzf-lua.lua
@@ -0,0 +1,15 @@
+require("fzf-lua").setup {
+ winopts = {
+ row = 0.5,
+ height = 0.7,
+ },
+ files = {
+ previewer = false,
+ },
+}
+
+vim.keymap.set("n", "ff", "FzfLua files", { desc = "Fuzzy find files" })
+vim.keymap.set("n", "fg", "FzfLua live_grep", { desc = "Fuzzy grep files" })
+vim.keymap.set("n", "fh", "FzfLua helptags", { desc = "Fuzzy grep tags in help files" })
+vim.keymap.set("n", "ft", "FzfLua btags", { desc = "Fuzzy search buffer tags" })
+vim.keymap.set("n", "fb", "