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

Compare commits

..

No commits in common. "b30cc9ed782a1d93154907e692078725e74ff31d" and "fe9565831929d047f623e68c72173fb2f9624ecc" have entirely different histories.

11 changed files with 34 additions and 36 deletions

View File

@ -3,3 +3,7 @@ set formatoptions-=o
set formatoptions-=r set formatoptions-=r
nnoremap <buffer><silent> <F9> :luafile %<CR> nnoremap <buffer><silent> <F9> :luafile %<CR>
" Use nvim-treesitter for folding
set foldmethod=expr
set foldexpr=nvim_treesitter#foldexpr()

View File

@ -12,3 +12,7 @@ set tabstop=4 " number of visual spaces per TAB
set softtabstop=4 " number of spaces in tab when editing set softtabstop=4 " number of spaces in tab when editing
set shiftwidth=4 " number of spaces to use for autoindent set shiftwidth=4 " number of spaces to use for autoindent
set expandtab " expand tab to spaces so that tabs are spaces set expandtab " expand tab to spaces so that tabs are spaces
" Use nvim-treesitter for folding
set foldmethod=expr
set foldexpr=nvim_treesitter#foldexpr()

View File

@ -14,21 +14,15 @@ vim.loader.enable()
local version = vim.version local version = vim.version
-- check if we have the latest stable version of nvim -- check if we have the latest stable version of nvim
local expected_ver_str = "0.10.1" local expected_ver = "0.10.1"
local expect_ver = version.parse(expected_ver_str) local expect_ver = version.parse(expected_ver)
local actual_ver = vim.version() local actual_ver = 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) local result = version.cmp(expect_ver, actual_ver)
if result ~= 0 then if result ~= 0 then
local _ver = string.format("%s.%s.%s", actual_ver.major, actual_ver.minor, actual_ver.patch) local _ver = string.format("%s.%s.%s", actual_ver.major, actual_ver.minor, actual_ver.patch)
local msg = string.format("Expect nvim %s, but got %s instead. Use at your own risk!", expected_ver_str, _ver) local msg = string.format("Expect nvim %s, but got %s instead. Use at your own risk!", expected_ver, _ver)
vim.api.nvim_err_writeln(msg) vim.api.nvim_err_writeln(msg)
end end

View File

@ -6,7 +6,6 @@ keymap.set("n", "<leader>gc", "<cmd>Git commit<cr>", { desc = "Git commit" })
keymap.set("n", "<leader>gd", "<cmd>Gdiffsplit<cr>", { desc = "Git diff" }) keymap.set("n", "<leader>gd", "<cmd>Gdiffsplit<cr>", { desc = "Git diff" })
keymap.set("n", "<leader>gpl", "<cmd>Git pull<cr>", { desc = "Git pull" }) keymap.set("n", "<leader>gpl", "<cmd>Git pull<cr>", { desc = "Git pull" })
keymap.set("n", "<leader>gpu", "<cmd>15 split|term git push<cr>", { desc = "Git push" }) keymap.set("n", "<leader>gpu", "<cmd>15 split|term git push<cr>", { desc = "Git push" })
keymap.set("v", "<leader>gb", ":Git blame<cr>", { desc = "Git blame line" })
-- convert git to Git in command line mode -- convert git to Git in command line mode
vim.fn["utils#Cabbrev"]("git", "Git") vim.fn['utils#Cabbrev']('git', 'Git')

View File

@ -36,15 +36,11 @@ keymap.set("n", "N", "", {
}) })
local no_word_under_cursor = function() local no_word_under_cursor = function()
local cursor_word = vim.fn.expand("<cword>") local word_under_cursor = vim.fn.expand("<cword>")
local result = cursor_word == "" local msg = "E348: No string under cursor"
if result then api.nvim_err_writeln(msg)
local msg = "E348: No string under cursor" return word_under_cursor == ""
api.nvim_err_writeln(msg)
end
return result
end end
keymap.set("n", "*", "", { keymap.set("n", "*", "", {

View File

@ -1,5 +1,6 @@
local handler = function(virtText, lnum, endLnum, width, truncate) local handler = function(virtText, lnum, endLnum, width, truncate)
local newVirtText = {} local newVirtText = {}
local totalLines = vim.api.nvim_buf_line_count(0)
local foldedLines = endLnum - lnum local foldedLines = endLnum - lnum
local suffix = (" 󰁂 %d"):format(foldedLines) local suffix = (" 󰁂 %d"):format(foldedLines)
local sufWidth = vim.fn.strdisplaywidth(suffix) local sufWidth = vim.fn.strdisplaywidth(suffix)

View File

@ -127,7 +127,6 @@ local get_active_lsp = function()
end end
for _, client in ipairs(clients) do for _, client in ipairs(clients) do
---@diagnostic disable-next-line: undefined-field
local filetypes = client.config.filetypes local filetypes = client.config.filetypes
if filetypes and vim.fn.index(filetypes, buf_ft) ~= -1 then if filetypes and vim.fn.index(filetypes, buf_ft) ~= -1 then
return client.name return client.name
@ -150,7 +149,7 @@ require("lualine").setup {
lualine_b = { lualine_b = {
{ {
"branch", "branch",
fmt = function(name, _) fmt = function(name, context)
-- truncate branch name in case the name is too long -- truncate branch name in case the name is too long
return string.sub(name, 1, 20) return string.sub(name, 1, 20)
end, end,

View File

@ -1,4 +1,5 @@
local keymap = vim.keymap local keymap = vim.keymap
local api = vim.api
local uv = vim.uv local uv = vim.uv
-- Save key strokes (now we do not need to press shift to enter command mode). -- Save key strokes (now we do not need to press shift to enter command mode).
@ -214,9 +215,6 @@ keymap.set("n", "<leader>cb", function()
local cnt = 0 local cnt = 0
local blink_times = 7 local blink_times = 7
local timer = uv.new_timer() local timer = uv.new_timer()
if timer == nil then
return
end
timer:start(0, 100, vim.schedule_wrap(function() timer:start(0, 100, vim.schedule_wrap(function()
vim.cmd [[ vim.cmd [[

View File

@ -194,9 +194,9 @@ local plugin_specs = {
require("statuscol").setup { require("statuscol").setup {
relculright = true, relculright = true,
segments = { segments = {
{ text = { builtin.foldfunc }, click = "v:lua.ScFa" },
{ text = { "%s" }, click = "v:lua.ScSa" }, { text = { "%s" }, click = "v:lua.ScSa" },
{ text = { builtin.lnumfunc, " " }, click = "v:lua.ScLa" }, { text = { builtin.lnumfunc, " " }, click = "v:lua.ScLa" },
{ text = { builtin.foldfunc, " " }, condition = {true, builtin.not_empty}, click = "v:lua.ScFa" },
}, },
} }
end, end,
@ -527,7 +527,7 @@ local plugin_specs = {
-- file explorer -- file explorer
{ {
"nvim-tree/nvim-tree.lua", "nvim-tree/nvim-tree.lua",
event = "VeryLazy", keys = { "<space>s" },
dependencies = { "nvim-tree/nvim-web-devicons" }, dependencies = { "nvim-tree/nvim-web-devicons" },
config = function() config = function()
require("config.nvim-tree") require("config.nvim-tree")

View File

@ -11,8 +11,9 @@ function M.executable(name)
end end
--- check whether a feature exists in Nvim --- check whether a feature exists in Nvim
--- @param feat string the feature name, like `nvim-0.7` or `unix`. --- @feat: string
--- @return boolean --- the feature name, like `nvim-0.7` or `unix`.
--- return: bool
M.has = function(feat) M.has = function(feat)
if fn.has(feat) == 1 then if fn.has(feat) == 1 then
return true return true
@ -32,9 +33,8 @@ end
--- Generate random integers in the range [Low, High], inclusive, --- Generate random integers in the range [Low, High], inclusive,
--- adapted from https://stackoverflow.com/a/12739441/6064933 --- adapted from https://stackoverflow.com/a/12739441/6064933
--- @param low integer the lower value for this range --- @low: the lower value for this range
--- @param high integer the upper value for this range --- @high: the upper value for this range
--- @return integer
function M.rand_int(low, high) function M.rand_int(low, high)
-- Use lua to generate random int, see also: https://stackoverflow.com/a/20157671/6064933 -- Use lua to generate random int, see also: https://stackoverflow.com/a/20157671/6064933
math.randomseed(os.time()) math.randomseed(os.time())
@ -43,11 +43,17 @@ function M.rand_int(low, high)
end end
--- Select a random element from a sequence/list. --- Select a random element from a sequence/list.
--- @param seq any[] the sequence to choose an element --- @seq: the sequence to choose an element
function M.rand_element(seq) function M.rand_element(seq)
local idx = M.rand_int(1, #seq) local idx = M.rand_int(1, #seq)
return seq[idx] return seq[idx]
end end
function M.add_pack(name)
local status, error = pcall(vim.cmd, "packadd " .. name)
return status
end
return M return M

View File

@ -467,6 +467,3 @@ pylintrc
PYTHONPATH PYTHONPATH
Uvicorn Uvicorn
qpdf qpdf
Elasticsearch
kibana
submodule