refactor: update nvim settings

This commit is contained in:
hhhh hgfh 2026-02-08 16:52:42 +03:00
parent af02e31fe9
commit 6748725b17
33 changed files with 1390 additions and 344 deletions

View file

@ -1,4 +1,3 @@
local cmp = require "cmp"
local options = {

View file

@ -2,9 +2,11 @@ local options = {
formatters_by_ft = {
lua = { "stylua" },
cpp = { "clang-format" },
go = { "gofmr" },
},
format_on_save = {
-- These options will be passed to conform.format()
timeout_ms = 500,
lsp_fallback = true,
},

View file

@ -1,53 +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
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
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,
-- 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

@ -21,6 +21,6 @@ require("lazy").setup({
spec = {
{ import = "plugins" },
},
install = { colorscheme = { "darcula-dark" } },
install = { colorscheme = { "habamax" } },
checker = { enabled = true },
})

View file

@ -1,34 +1,55 @@
local M = {}
local api = vim.api
local map = vim.keymap.set
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)
-- export on_attach & capabilities
M.on_attach = function(_, bufnr)
local function opts(desc)
return { buffer = bufnr, desc = "LSP " .. desc }
end
for _, char in ipairs(triggerChars) do
if cur_char == char or prev_char == char then
return true
map("n", "gD", vim.lsp.buf.declaration, opts "Go to declaration")
map("n", "gd", vim.lsp.buf.definition, opts "Go to definition")
map("n", "<leader>wa", vim.lsp.buf.add_workspace_folder, opts "Add workspace folder")
map("n", "<leader>wr", vim.lsp.buf.remove_workspace_folder, opts "Remove workspace folder")
map("n", "<leader>wl", function()
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
end, opts "List workspace folders")
map("n", "<leader>D", vim.lsp.buf.type_definition, opts "Go to type definition")
end
-- disable semanticTokens
M.on_init = function(client, _)
if vim.fn.has "nvim-0.11" ~= 1 then
if client.supports_method "textDocument/semanticTokens" then
client.server_capabilities.semanticTokensProvider = nil
end
else
if client:supports_method "textDocument/semanticTokens" then
client.server_capabilities.semanticTokensProvider = nil
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 }
M.capabilities = vim.lsp.protocol.make_client_capabilities()
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
M.capabilities.textDocument.completion.completionItem = {
documentationFormat = { "markdown", "plaintext" },
snippetSupport = true,
preselectSupport = true,
insertReplaceSupport = true,
labelDetailsSupport = true,
deprecatedSupport = true,
commitCharactersSupport = true,
tagSupport = { valueSet = { 1 } },
resolveSupport = {
properties = {
"documentation",
"detail",
"additionalTextEdits",
},
},
}
return M

View file

@ -2,7 +2,7 @@ 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
-- C/C++
vim.lsp.config('clangd', {
on_attach = on_attach,
on_init = on_init,
@ -17,16 +17,48 @@ vim.lsp.config('clangd', {
"--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'},
}
filetypes = { "c", "cpp", "h", "hpp", "objc", "objcpp" },
root_markers = { '.git' },
})
vim.lsp.enable('clangd')
-- Go (gopls) lsp server
vim.lsp.config('gopls', {
on_attach = on_attach,
on_init = on_init,
capabilities = capabilities,
cmd = { 'gopls' },
filetypes = { 'go', 'gomod', 'gowork', 'gotmpl' },
root_markers = { 'go.mod', '.git' },
single_file_support = true,
settings = {
gopls = {
completeUnimported = true,
usePlaceholders = true,
analyses = {
unusedparams = true,
},
staticcheck = true,
gofumpt = true,
},
},
})
vim.lsp.enable('gopls')
-- PhP
vim.lsp.config('phpactor', {
cmd = { 'phpactor', 'language-server' },
filetypes = { 'php' },
root_markers = { 'composer.json', '.git' },
init_options = {
["language_server_phpstan.enabled"] = false,
["language_server_psalm.enabled"] = false,
}
})
vim.lsp.enable('phpactor')
-- Lua
vim.lsp.config('lua_ls', {
cmd = { 'lua-language-server' },
@ -59,6 +91,16 @@ vim.lsp.config('bashls', {
})
vim.lsp.enable('bashls')
-- Meson
vim.lsp.config('meson_ls', {
cmd = { 'mesonlsp' },
filetypes = { 'meson' },
root_markers = { 'meson.build', '.git' },
single_file_support = true,
settings = {}
})
vim.lsp.enable('meson_ls')
-- For all
vim.diagnostic.config({
virtual_text = false,

View file

@ -1,34 +0,0 @@
require("nvchad.configs.lspconfig").defaults()
local on_attach = require("nvchad.configs.lspconfig").on_attach
local on_init = require("nvchad.configs.lspconfig").on_init
local capabilities = require("nvchad.configs.lspconfig").capabilities
-- clangd lsp server
vim.lsp.config('clangd', {
on_attach = on_attach,
on_init = on_init,
capabilities = capabilities,
cmd = {
"clangd",
"--background-index",
"--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.diagnostic.config({
virtual_text = false,
})
vim.lsp.enable('clangd')

View file

@ -9,15 +9,3 @@ require("luasnip.loaders.from_snipmate").lazy_load { paths = vim.g.snipmate_snip
-- 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

@ -69,17 +69,16 @@ function M.setup()
dapui.close({})
end
-- Настройка подсветки для точек останова (ИСПРАВЛЕННАЯ ВЕРСИЯ)
-- Цвета на задний фон для debug
vim.api.nvim_set_hl(0, 'DapBreakpoint', { fg = '#993939', bg = '#31353f' })
vim.api.nvim_set_hl(0, 'DapLogPoint', { fg = '#61afef', bg = '#31353f' })
vim.api.nvim_set_hl(0, 'DapStopped', { fg = '#98c379', bg = '#31353f' })
-- Настройка значков (эта часть правильная)
-- Настройка значков для точек останова :cite[1]:cite[10]
vim.fn.sign_define('DapBreakpoint', { text='', texthl='DapBreakpoint', linehl='DapBreakpoint', numhl='DapBreakpoint' })
vim.fn.sign_define('DapBreakpointCondition', { text='ﳁ', texthl='DapBreakpoint', linehl='DapBreakpoint', numhl='DapBreakpoint' })
vim.fn.sign_define('DapBreakpointRejected', { text='', texthl='DapBreakpoint', linehl='DapBreakpoint', numhl= 'DapBreakpoint' })
vim.fn.sign_define('DapLogPoint', { text='', texthl='DapLogPoint', linehl='DapLogPoint', numhl= 'DapLogPoint' })
vim.fn.sign_define('DapStopped', { text='', texthl='DapStopped', linehl='DapStopped', numhl= 'DapStopped' })
vim.fn.sign_define('DapStopped', { text='', texthl='DapStopped', linehl='DapStopped', numhl= 'DapStopped' })vim.fn.sign_define("DapBreakpointRejected", { text = "❌", texthl = "LspDiagnosticsSignHint" })
end
return M

View file

@ -1,5 +1,5 @@
return {
filters = { dotfiles = false },
filters = { dotfiles = false, git_ignored = false, },
disable_netrw = true,
hijack_cursor = true,
sync_root_with_cwd = true,

View file

View file

@ -1,4 +1,4 @@
return {
require("telescope").setup(){
defaults = {
prompt_prefix = "",
selection_caret = " ",
@ -17,6 +17,6 @@ return {
},
},
extensions_list = { "themes", "terms" },
extensions = {},
extensions_list = { "themes", "terms", "noice", "persisted" },
extensions = { "noice", "persisted" },
}

View file

@ -1,8 +1,8 @@
return {
ensure_installed = {
"bash",
"c",
"cpp",
"make",
"cmake",
"diff",
"doxygen",
@ -18,10 +18,11 @@ return {
"lua",
"luadoc",
"luap",
"make",
"markdown",
"markdown_inline",
"meson",
"php",
"phpdoc",
"printf",
"python",
"query",
@ -33,7 +34,7 @@ return {
"vim",
"vimdoc",
"xml",
"yaml",
"yaml"
},
highlight = {
@ -41,7 +42,5 @@ return {
use_languagetree = true,
},
indent = {
enable = true,
},
indent = { enable = true },
}

View file

@ -1,19 +1,21 @@
vim.o.foldcolumn = '1'
vim.o.foldlevel = 99
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
-- Using ufo provider need remap `zR` and `zM`. If Neovim is 0.6.1, remap yourself
vim.keymap.set('n', 'zR', require('ufo').openAllFolds)
vim.keymap.set('n', 'zM', require('ufo').closeAllFolds)
vim.keymap.set('n', 'zP', function ()
vim.keymap.set('n', 'zK', function()
local winid = require('ufo').peekFoldedLinesUnderCursor()
if not winid then
vim.lsp.buf.hover()
end
end, {desc = "Peek folder"})
end, {desc = "Peek Fold"})
require("ufo").setup({
provider_selector = function (bufnr, filetype, buftype)
provider_selector = function(bufnr, filetype, buftype)
return { 'lsp', 'indent' }
end
})