update nvim

This commit is contained in:
hhhh hgfh 2025-11-08 02:12:26 +03:00
parent c1de9ef4ff
commit af02e31fe9
25 changed files with 957 additions and 133 deletions

View file

@ -0,0 +1,64 @@
local bufferline = require('bufferline')
bufferline.setup {
options = {
mode = "buffers", -- set to "tabs" to only show tabpages instead
style_preset = bufferline.style_preset.default,
themable = true,
indicator = {
icon = '▎',
style = 'icon',
},
buffer_close_icon = '󰅖',
modified_icon = '● ',
close_icon = '',
left_trunc_marker = '',
right_trunc_marker = '',
max_name_length = 18,
max_prefix_length = 15,
truncate_names = true,
tab_size = 18,
custom_filter = function(buf_number, buf_numbers)
if vim.bo[buf_number].filetype ~= "<i-dont-want-to-see-this>" then
return true
end
if vim.fn.bufname(buf_number) ~= "<buffer-name-I-dont-want>" then
return true
end
if vim.fn.getcwd() == "<work-repo>" and vim.bo[buf_number].filetype ~= "wiki" then
return true
end
if buf_numbers[1] ~= buf_number then
return true
end
end,
offsets = {
{
filetype = "NvimTree",
text = "File Explorer",
text_align = "left",
separator = true
}
},
color_icons = true,
get_element_icon = function(element)
local icon, hl = require('nvim-web-devicons').get_icon_by_filetype(element.filetype, { default = false })
return icon, hl
end,
show_buffer_icons = true,
show_buffer_close_icons = true,
show_close_icon = true,
show_tab_indicators = true,
separator_style = "slant",
enforce_regular_tabs = false,
always_show_bufferline = true,
auto_toggle_bufferline = true,
hover = {
enabled = true,
delay = 200,
reveal = {'close'}
},
pick = {
alphabet = "abcdefghijklmopqrstuvwxyzABCDEFGHIJKLMOPQRSTUVWXYZ1234567890",
},
}
}

56
nvim/lua/configs/cmp.lua Normal file
View file

@ -0,0 +1,56 @@
local cmp = require "cmp"
local options = {
completion = { completeopt = "menu,menuone" },
snippet = {
expand = function(args)
require("luasnip").lsp_expand(args.body)
end,
},
mapping = {
["<C-p>"] = cmp.mapping.select_prev_item(),
["<C-n>"] = cmp.mapping.select_next_item(),
["<C-d>"] = cmp.mapping.scroll_docs(-4),
["<C-f>"] = cmp.mapping.scroll_docs(4),
["<C-Space>"] = cmp.mapping.complete(),
["<C-e>"] = cmp.mapping.close(),
["<CR>"] = cmp.mapping.confirm {
behavior = cmp.ConfirmBehavior.Insert,
select = true,
},
["<Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_next_item()
elseif require("luasnip").expand_or_jumpable() then
require("luasnip").expand_or_jump()
else
fallback()
end
end, { "i", "s" }),
["<S-Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_prev_item()
elseif require("luasnip").jumpable(-1) then
require("luasnip").jump(-1)
else
fallback()
end
end, { "i", "s" }),
},
sources = {
{ name = "nvim_lsp" },
{ name = "luasnip" },
{ name = "buffer" },
{ name = "nvim_lua" },
{ name = "async_path" },
},
}
return vim.tbl_deep_extend("force", options, {})

View file

@ -2,14 +2,12 @@ local options = {
formatters_by_ft = {
lua = { "stylua" },
cpp = { "clang-format" },
-- html = { "prettier" },
},
-- format_on_save = {
-- -- These options will be passed to conform.format()
-- timeout_ms = 500,
-- lsp_fallback = true,
-- },
format_on_save = {
timeout_ms = 500,
lsp_fallback = true,
},
}
return options

View file

@ -0,0 +1,53 @@
return {
signs = {
add = { text = "▎" },
change = { text = "▎" },
delete = { text = "" },
topdelete = { text = "" },
changedelete = { text = "▎" },
untracked = { text = "▎" },
},
signs_staged = {
add = { text = "▎" },
change = { text = "▎" },
delete = { text = "" },
topdelete = { text = "" },
changedelete = { text = "▎" },
},
on_attach = function(buffer)
local gs = package.loaded.gitsigns
local function map(mode, l, r, desc)
vim.keymap.set(mode, l, r, { buffer = buffer, desc = desc, silent = true })
end
-- stylua: ignore start
map("n", "]h", function()
if vim.wo.diff then
vim.cmd.normal({ "]c", bang = true })
else
gs.nav_hunk("next")
end
end, "Next Hunk")
map("n", "[h", function()
if vim.wo.diff then
vim.cmd.normal({ "[c", bang = true })
else
gs.nav_hunk("prev")
end
end, "Prev Hunk")
map("n", "]H", function() gs.nav_hunk("last") end, "Last Hunk")
map("n", "[H", function() gs.nav_hunk("first") end, "First Hunk")
map({ "n", "x" }, "<leader>ghs", ":Gitsigns stage_hunk<CR>", "Stage Hunk")
map({ "n", "x" }, "<leader>ghr", ":Gitsigns reset_hunk<CR>", "Reset Hunk")
map("n", "<leader>ghS", gs.stage_buffer, "Stage Buffer")
map("n", "<leader>ghu", gs.undo_stage_hunk, "Undo Stage Hunk")
map("n", "<leader>ghR", gs.reset_buffer, "Reset Buffer")
map("n", "<leader>ghp", gs.preview_hunk_inline, "Preview Hunk Inline")
map("n", "<leader>ghb", function() gs.blame_line({ full = true }) end, "Blame Line")
map("n", "<leader>ghB", function() gs.blame() end, "Blame Buffer")
map("n", "<leader>ghd", gs.diffthis, "Diff This")
map("n", "<leader>ghD", function() gs.diffthis("~") end, "Diff This ~")
map({ "o", "x" }, "ih", ":<C-U>Gitsigns select_hunk<CR>", "GitSigns Select Hunk")
end,
}

View file

@ -1,47 +1,26 @@
return {
defaults = { lazy = true },
install = { colorscheme = { "nvchad" } },
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not (vim.uv or vim.loop).fs_stat(lazypath) then
local lazyrepo = "https://github.com/folke/lazy.nvim.git"
local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath })
if vim.v.shell_error ~= 0 then
vim.api.nvim_echo({
{ "Failed to clone lazy.nvim:\n", "ErrorMsg" },
{ out, "WarningMsg" },
{ "\nPress any key to exit..." },
}, true, {})
vim.fn.getchar()
os.exit(1)
end
end
vim.opt.rtp:prepend(lazypath)
ui = {
icons = {
ft = "",
lazy = "󰂠 ",
loaded = "",
not_loaded = "",
},
},
vim.g.mapleader = " "
vim.g.maplocalleader = "\\"
performance = {
rtp = {
disabled_plugins = {
"2html_plugin",
"tohtml",
"getscript",
"getscriptPlugin",
"gzip",
"logipat",
"netrw",
"netrwPlugin",
"netrwSettings",
"netrwFileHandlers",
"matchit",
"tar",
"tarPlugin",
"rrhelper",
"spellfile_plugin",
"vimball",
"vimballPlugin",
"zip",
"zipPlugin",
"tutor",
"rplugin",
"syntax",
"synmenu",
"optwin",
"compiler",
"bugreport",
"ftplugin",
},
},
require("lazy").setup({
spec = {
{ import = "plugins" },
},
}
install = { colorscheme = { "darcula-dark" } },
checker = { enabled = true },
})

View file

@ -0,0 +1,34 @@
local M = {}
local api = vim.api
local function check_triggeredChars(triggerChars)
local cur_line = api.nvim_get_current_line()
local pos = api.nvim_win_get_cursor(0)[2]
local prev_char = cur_line:sub(pos - 1, pos - 1)
local cur_char = cur_line:sub(pos, pos)
for _, char in ipairs(triggerChars) do
if cur_char == char or prev_char == char then
return true
end
end
end
M.setup = function(client, bufnr)
local group = api.nvim_create_augroup("LspSignature", { clear = false })
api.nvim_clear_autocmds { group = group, buffer = bufnr }
local triggerChars = client.server_capabilities.signatureHelpProvider.triggerCharacters
api.nvim_create_autocmd("TextChangedI", {
group = group,
buffer = bufnr,
callback = function()
if check_triggeredChars(triggerChars) then
vim.lsp.buf.signature_help { focus = false, silent = true, max_height = 7, border = "single" }
end
end,
})
end
return M

View file

@ -0,0 +1,65 @@
local on_attach = require("configs.lsp.e-lspconfig").on_attach
local on_init = require("configs.lsp.e-lspconfig").on_init
local capabilities = require("configs.lsp.e-lspconfig").capabilities
-- clangd lsp server
vim.lsp.config('clangd', {
on_attach = on_attach,
on_init = on_init,
capabilities = capabilities,
cmd = {
"clangd",
"--background-index",
"--background-index-priority=normal",
"--clang-tidy",
"--experimental-modules-support",
"--all-scopes-completion",
"--completion-style=detailed",
"--header-insertion=iwyu",
"--limit-references=5",
"--malloc-trim",
"--pch-storage=disk",
},
filetypes = { "c", "cpp", "objc", "objcpp" },
init_options = {
fallbackFlags = {'-std=c++20'},
}
})
vim.lsp.enable('clangd')
-- Lua
vim.lsp.config('lua_ls', {
cmd = { 'lua-language-server' },
filetypes = { 'lua' },
root_markers = { '.luarc.json', '.luarc.jsonc', '.git' },
single_file_support = true,
settings = {
Lua = {
telemetry = { enable = false },
runtime = { version = 'LuaJIT' },
diagnostics = { globals = { 'vim' } },
workspace = {
checkThirdParty = false,
library = {
vim.env.VIMRUNTIME,
vim.fn.stdpath('config'),
},
},
},
}
})
vim.lsp.enable('lua_ls')
-- Bash
vim.lsp.config('bashls', {
cmd = { 'bash-language-server', 'start' },
filetypes = { 'sh', 'bash' },
root_markers = { '.git' },
single_file_support = true,
})
vim.lsp.enable('bashls')
-- For all
vim.diagnostic.config({
virtual_text = false,
})

View file

@ -0,0 +1,54 @@
require('lualine').setup {
options = {
icons_enabled = true,
theme = 'auto',
component_separators = { left = '', right = ''},
section_separators = { left = '', right = ''},
disabled_filetypes = {
statusline = {},
winbar = {},
},
ignore_focus = {},
always_divide_middle = true,
always_show_tabline = true,
globalstatus = false,
refresh = {
statusline = 1000,
tabline = 1000,
winbar = 1000,
refresh_time = 16, -- ~60fps
events = {
'WinEnter',
'BufEnter',
'BufWritePost',
'SessionLoadPost',
'FileChangedShellPost',
'VimResized',
'Filetype',
'CursorMoved',
'CursorMovedI',
'ModeChanged',
},
}
},
sections = {
lualine_a = {'mode'},
lualine_b = {'branch', 'diff', 'diagnostics'},
lualine_c = {'filename'},
lualine_x = {'fileformat', 'filetype'},
lualine_y = {'lsp_status'},
lualine_z = {'location'}
},
inactive_sections = {
lualine_a = {},
lualine_b = {},
lualine_c = {'filename'},
lualine_x = {'location'},
lualine_y = {},
lualine_z = {}
},
tabline = {},
winbar = {},
inactive_winbar = {},
extensions = {}
}

View file

@ -0,0 +1,23 @@
-- vscode format
require("luasnip.loaders.from_vscode").lazy_load { exclude = vim.g.vscode_snippets_exclude or {} }
require("luasnip.loaders.from_vscode").lazy_load { paths = vim.g.vscode_snippets_path or "" }
-- snipmate format
require("luasnip.loaders.from_snipmate").load()
require("luasnip.loaders.from_snipmate").lazy_load { paths = vim.g.snipmate_snippets_path or "" }
-- lua format
require("luasnip.loaders.from_lua").load()
require("luasnip.loaders.from_lua").lazy_load { paths = vim.g.lua_snippets_path or "" }
-- fix luasnip #258
vim.api.nvim_create_autocmd("InsertLeave", {
callback = function()
if
require("luasnip").session.current_nodes[vim.api.nvim_get_current_buf()]
and not require("luasnip").session.jump_active
then
require("luasnip").unlink_current()
end
end,
})

View file

@ -0,0 +1,32 @@
return {
filters = { dotfiles = false },
disable_netrw = true,
hijack_cursor = true,
sync_root_with_cwd = true,
update_focused_file = {
enable = true,
update_root = false,
},
view = {
width = 30,
preserve_window_proportions = true,
},
renderer = {
root_folder_label = false,
highlight_git = true,
indent_markers = { enable = true },
icons = {
glyphs = {
default = "󰈚",
folder = {
default = "",
empty = "",
empty_open = "",
open = "",
symlink = "",
},
git = { unmerged = "" },
},
},
},
}

View file

@ -0,0 +1,22 @@
return {
defaults = {
prompt_prefix = "",
selection_caret = " ",
entry_prefix = " ",
sorting_strategy = "ascending",
layout_config = {
horizontal = {
prompt_position = "top",
preview_width = 0.55,
},
width = 0.87,
height = 0.80,
},
mappings = {
n = { ["q"] = require("telescope.actions").close },
},
},
extensions_list = { "themes", "terms" },
extensions = {},
}

View file

@ -0,0 +1,47 @@
return {
ensure_installed = {
"bash",
"c",
"cpp",
"cmake",
"diff",
"doxygen",
"git_config",
"gitcommit",
"gitignore",
"html",
"javadoc",
"javascript",
"jsdoc",
"json",
"jsonc",
"lua",
"luadoc",
"luap",
"make",
"markdown",
"markdown_inline",
"meson",
"printf",
"python",
"query",
"regex",
"sql",
"toml",
"tsx",
"typescript",
"vim",
"vimdoc",
"xml",
"yaml",
},
highlight = {
enable = true,
use_languagetree = true,
},
indent = {
enable = true,
},
}

19
nvim/lua/configs/ufo.lua Normal file
View file

@ -0,0 +1,19 @@
vim.o.foldcolumn = '1'
vim.o.foldlevel = 99
vim.o.foldlevelstart = 99
vim.o.foldenable = true
vim.keymap.set('n', 'zR', require('ufo').openAllFolds)
vim.keymap.set('n', 'zM', require('ufo').closeAllFolds)
vim.keymap.set('n', 'zP', function ()
local winid = require('ufo').peekFoldedLinesUnderCursor()
if not winid then
vim.lsp.buf.hover()
end
end, {desc = "Peek folder"})
require("ufo").setup({
provider_selector = function (bufnr, filetype, buftype)
return { 'lsp', 'indent' }
end
})