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

Compare commits

...

7 Commits

Author SHA1 Message Date
jdhao
b30cc9ed78 update user dictionary 2024-08-06 06:05:20 +08:00
jdhao
b3a26e4226 update load condtion for nvim-tree 2024-08-06 06:02:02 +08:00
jdhao
794b098090 Add git blame mapping 2024-08-06 05:59:14 +08:00
jdhao
b728b39784 update type hint for functions 2024-08-06 05:35:19 +08:00
jdhao
acc3ed7829 show error message only when no word is under cursor 2024-08-06 05:33:24 +08:00
jdhao
44e9e5a1ce Fix lua_ls diagnostic warnings 2024-08-06 05:24:16 +08:00
jdhao
5502d29f40 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
2024-08-06 05:17:51 +08:00
11 changed files with 36 additions and 34 deletions

View File

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

View File

@ -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()

View File

@ -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

View File

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

View File

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

View File

@ -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)

View File

@ -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,

View File

@ -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", "<leader>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 [[

View File

@ -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,
@ -527,7 +527,7 @@ local plugin_specs = {
-- file explorer
{
"nvim-tree/nvim-tree.lua",
keys = { "<space>s" },
event = "VeryLazy",
dependencies = { "nvim-tree/nvim-web-devicons" },
config = function()
require("config.nvim-tree")

View File

@ -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

View File

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