Перешел на lazy nvim, навел порядок в плагинах

This commit is contained in:
Alexander Neonxp Kiryukhin 2025-05-02 16:05:47 +03:00
parent 91873ed81a
commit 446d2716e7
Signed by: NeonXP
SSH key fingerprint: SHA256:SVt7TjxbVc87m1QYaQziOJ0N3OCFURv2g76gD/UTTXI
25 changed files with 790 additions and 469 deletions

View file

@ -1,14 +1,23 @@
local fn = vim.fn local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
local install_path = fn.stdpath("data") .. "/site/pack/packer/start/packer.nvim" if not (vim.uv or vim.loop).fs_stat(lazypath) then
if fn.empty(fn.glob(install_path)) > 0 then local lazyrepo = "https://github.com/folke/lazy.nvim.git"
packer_bootstrap = local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath })
fn.system({ "git", "clone", "--depth", "1", "https://github.com/wbthomason/packer.nvim", install_path }) 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 end
vim.opt.rtp:prepend(lazypath)
vim.g.mapleader = " " vim.g.mapleader = " "
vim.g.maplocalleader = " " vim.g.maplocalleader = " "
vim.g.colorcolumn = 120
vim.cmd([[packadd packer.nvim]]) vim.g.loaded_netrw = 1
vim.g.loaded_netrwPlugin = 1
require("options") require("options")
require("plugins") require("plugins")
@ -16,4 +25,4 @@ require("keymaps")
require("autocommands") require("autocommands")
require("lsp") require("lsp")
require("dap") require("dap")
require("colors") require("onedark").load()

36
nvim/lazy-lock.json Normal file
View file

@ -0,0 +1,36 @@
{
"LuaSnip": { "branch": "master", "commit": "03c8e67eb7293c404845b3982db895d59c0d1538" },
"cmp-buffer": { "branch": "main", "commit": "b74fab3656eea9de20a9b8116afa3cfc4ec09657" },
"cmp-nvim-lsp": { "branch": "main", "commit": "a8912b88ce488f411177fc8aed358b04dc246d7b" },
"cmp-path": { "branch": "main", "commit": "c6635aae33a50d6010bf1aa756ac2398a2d54c32" },
"cmp_luasnip": { "branch": "master", "commit": "98d9cb5c2c38532bd9bdb481067b20fea8f32e90" },
"conform.nvim": { "branch": "master", "commit": "372fc521f8421b7830ea6db4d6ea3bae1c77548c" },
"friendly-snippets": { "branch": "main", "commit": "572f5660cf05f8cd8834e096d7b4c921ba18e175" },
"go.nvim": { "branch": "master", "commit": "37ec4d9be3edef64b725bfe29684e1fe019873bc" },
"goerr-nvim": { "branch": "main", "commit": "d30ba1cab652e78dbf6a644eb4823be57e9af203" },
"goimpl.nvim": { "branch": "main", "commit": "2548d42c4db0645dea14f27e67c4b19b7030f1cf" },
"guihua.lua": { "branch": "master", "commit": "0cc9631914ffcbe3e474e809c610d12a75b660cf" },
"headlines.nvim": { "branch": "master", "commit": "bf17c96a836ea27c0a7a2650ba385a7783ed322e" },
"indent-blankline.nvim": { "branch": "master", "commit": "005b56001b2cb30bfa61b7986bc50657816ba4ba" },
"lazy.nvim": { "branch": "main", "commit": "6c3bda4aca61a13a9c63f1c1d1b16b9d3be90d7a" },
"lsp_signature.nvim": { "branch": "master", "commit": "a793d02b6a5e639fa9d3f2a89a839fa688ab2d0a" },
"lualine.nvim": { "branch": "master", "commit": "15884cee63a8c205334ab13ab1c891cd4d27101a" },
"nvim-cmp": { "branch": "main", "commit": "b5311ab3ed9c846b585c0c15b7559be131ec4be9" },
"nvim-dap": { "branch": "master", "commit": "8df427aeba0a06c6577dc3ab82de3076964e3b8d" },
"nvim-dap-go": { "branch": "main", "commit": "8763ced35b19c8dc526e04a70ab07c34e11ad064" },
"nvim-dap-ui": { "branch": "master", "commit": "73a26abf4941aa27da59820fd6b028ebcdbcf932" },
"nvim-lspconfig": { "branch": "master", "commit": "12506bdaccd94964d4fb40367e36ade1960c8947" },
"nvim-nio": { "branch": "master", "commit": "21f5324bfac14e22ba26553caf69ec76ae8a7662" },
"nvim-tree.lua": { "branch": "master", "commit": "582ae48c9e43d2bcd55dfcc8e2e7a1f29065d924" },
"nvim-treesitter": { "branch": "master", "commit": "94ea4f436d2b59c80f02e293466c374584f03b8c" },
"nvim-treesitter-context": { "branch": "master", "commit": "6daca3ad780f045550b820f262002f35175a6c04" },
"nvim-treesitter-textobjects": { "branch": "master", "commit": "ed373482db797bbf71bdff37a15c7555a84dce47" },
"nvim-web-devicons": { "branch": "master", "commit": "2c2b4eafce6cdd0cb165036faa17396eff18f847" },
"onedark.nvim": { "branch": "master", "commit": "0e5512d1bebd1f08954710086f87a5caa173a924" },
"plenary.nvim": { "branch": "master", "commit": "857c5ac632080dba10aae49dba902ce3abf91b35" },
"popup.nvim": { "branch": "master", "commit": "b7404d35d5d3548a82149238289fa71f7f6de4ac" },
"smartcolumn.nvim": { "branch": "main", "commit": "92f3773af80d674f1eb61e112dca79e2fa449fd1" },
"telescope-file-browser.nvim": { "branch": "master", "commit": "626998e5c1b71c130d8bc6cf7abb6709b98287bb" },
"telescope.nvim": { "branch": "master", "commit": "a4ed82509cecc56df1c7138920a1aeaf246c0ac5" },
"vim-snippets": { "branch": "master", "commit": "f0a3184d9f90b96b044d5914625a25c554d7f301" }
}

View file

@ -124,7 +124,16 @@ vim.api.nvim_create_autocmd({ "BufReadPost", "BufWinEnter", "WinEnter" }, {
end end
end, end,
}) })
vim.api.nvim_create_autocmd({ "VimEnter" }, {
callback = function(data)
local directory = vim.fn.isdirectory(data.file) == 1
if not directory then
return
end
vim.cmd.cd(data.file)
require("nvim-tree.api").tree.open()
end,
})
-- vim.api.nvim_create_autocmd("InsertEnter", { -- vim.api.nvim_create_autocmd("InsertEnter", {
-- pattern = "*", -- pattern = "*",
-- command = "set norelativenumber", -- command = "set norelativenumber",

View file

@ -1,39 +0,0 @@
require("onedark").setup({
style = "darker",
transparent = false, -- Show/hide background
term_colors = true, -- Change terminal color as per the selected theme style
ending_tildes = true, -- Show the end-of-buffer tildes. By default they are hidden
cmp_itemkind_reverse = false, -- reverse item kind highlights in cmp menu
-- toggle theme style ---
toggle_style_key = nil, -- keybind to toggle theme style. Leave it nil to disable it, or set it to a string, for example "<leader>ts"
toggle_style_list = { "dark", "darker", "cool", "deep", "warm", "warmer", "light" }, -- List of styles to toggle between
-- Change code style ---
-- Options are italic, bold, underline, none
-- You can configure multiple style with comma separated, For e.g., keywords = 'italic,bold'
code_style = {
comments = "italic",
keywords = "none",
functions = "none",
strings = "none",
variables = "none",
},
-- Lualine options --
lualine = {
transparent = false, -- lualine center bar transparency
},
-- Custom Highlights --
colors = {}, -- Override default colors
highlights = {}, -- Override highlight groups
-- Plugins Config --
diagnostics = {
darker = true, -- darker colors for diagnostic
undercurl = true, -- use undercurl instead of underline for diagnostics
background = true, -- use background color for virtual text
},
})
require("onedark").load()

View file

@ -19,15 +19,16 @@ map("v", "K", ":m '<-2<CR>gv=gv", { noremap = true, silent = true })
map("v", "<", "<gv", { noremap = true, silent = true }) map("v", "<", "<gv", { noremap = true, silent = true })
map("v", ">", ">gv", { noremap = true, silent = true }) map("v", ">", ">gv", { noremap = true, silent = true })
-- Управление буферами -- -- {{{ Управление буферами --
kmap("n", "<leader>bn", "<cmd>bnext<CR>", { noremap = true, silent = true, desc = "Next buffer" }) kmap("n", "<leader>bn", "<cmd>bnext<CR>", { noremap = true, silent = true, desc = "Next buffer" })
kmap("n", "<leader>bp", "<cmd>bprevious<CR>", { noremap = true, silent = true, desc = "Previous buffer" }) kmap("n", "<leader>bp", "<cmd>bprevious<CR>", { noremap = true, silent = true, desc = "Previous buffer" })
kmap("n", "<leader>bd", "<cmd>bdelete<CR>", { noremap = true, silent = true, desc = "Delete buffer" }) kmap("n", "<leader>bd", "<cmd>bdelete<CR>", { noremap = true, silent = true, desc = "Delete buffer" })
kmap("n", "<leader>w", "<cmd>wa<CR>", { noremap = true, silent = true, desc = "Save all files" }) kmap("n", "<leader>w", "<cmd>wa<CR>", { noremap = true, silent = true, desc = "Save all files" })
kmap("n", "qq", "<cmd>q<CR>", { noremap = true, silent = true, desc = "Exit" }) kmap("n", "qq", "<cmd>q<CR>", { noremap = true, silent = true, desc = "Exit" })
kmap("n", "<leader>vs", "<cmd>vsplit<CR>", { noremap = true, silent = true, desc = "Vertical split" }) kmap("n", "<leader>vs", "<cmd>vsplit<CR>", { noremap = true, silent = true, desc = "Vertical split" })
-- }}}
-- Управление вкладками -- -- {{{ Управление вкладками --
kmap("n", "<A-Right>", ":tabnext<CR>", { noremap = true, silent = true, desc = "Next tab" }) kmap("n", "<A-Right>", ":tabnext<CR>", { noremap = true, silent = true, desc = "Next tab" })
kmap("n", "<A-Left>", ":tabprevious<CR>", { noremap = true, silent = true, desc = "Previous tab" }) kmap("n", "<A-Left>", ":tabprevious<CR>", { noremap = true, silent = true, desc = "Previous tab" })
kmap("n", "<leader>tn", ":tabnew<CR>", { noremap = true, silent = true, desc = "New tab" }) kmap("n", "<leader>tn", ":tabnew<CR>", { noremap = true, silent = true, desc = "New tab" })
@ -38,116 +39,51 @@ for i = 1, 9 do
kmap("n", "<A-" .. i .. ">", ":tabn " .. i .. "<CR>", { noremap = true, silent = true, desc = "Go to tab " .. i }) kmap("n", "<A-" .. i .. ">", ":tabn " .. i .. "<CR>", { noremap = true, silent = true, desc = "Go to tab " .. i })
end end
-- Файловый менеджер -- -- }}}
kmap("n", "<F3>", ":NvimTreeToggle<CR>", { noremap = true, silent = true, desc = "Toggle file tree" })
-- kmap("n", "<leader>tt", ":NvimTreeToggle<CR>", { noremap = true, silent = true, desc = "Toggle file tree" })
kmap("n", "<leader>tt", ":split<CR>:terminal<CR>:startinsert<CR>", { noremap = true, silent = true }) kmap("n", "<leader>tt", ":split<CR>:terminal<CR>:startinsert<CR>", { noremap = true, silent = true })
-- Поиск с Telescope -- -- {{{ LSP функции
kmap("n", "<leader>ff", "<cmd>Telescope find_files<CR>", { noremap = true, silent = true, desc = "Find files" })
kmap("n", "<leader>fg", "<cmd>Telescope live_grep<CR>", { noremap = true, silent = true, desc = "Live grep" })
kmap("n", "<leader>fb", "<cmd>Telescope buffers<CR>", { noremap = true, silent = true, desc = "Find buffers" })
kmap("n", "<leader>fe", "<cmd>Telescope file_browser<CR>", { noremap = true, silent = true, desc = "File browser" })
-- LSP функции --
kmap("n", "<leader>e", vim.diagnostic.open_float, { noremap = true, silent = true, desc = "Show diagnostics" }) kmap("n", "<leader>e", vim.diagnostic.open_float, { noremap = true, silent = true, desc = "Show diagnostics" })
kmap("n", "d[", vim.diagnostic.goto_prev, { noremap = true, silent = true, desc = "Previous diagnostic" }) kmap("n", "d[", vim.diagnostic.goto_prev, { noremap = true, silent = true, desc = "Previous diagnostic" })
kmap("n", "d]", vim.diagnostic.goto_next, { noremap = true, silent = true, desc = "Next diagnostic" }) kmap("n", "d]", vim.diagnostic.goto_next, { noremap = true, silent = true, desc = "Next diagnostic" })
kmap("n", "gD", vim.lsp.buf.declaration, { noremap = true, silent = true, desc = "Go to declaration" }) kmap("n", "gD", vim.lsp.buf.declaration, { noremap = true, silent = true, desc = "Go to declaration" })
kmap("n", "gd", vim.lsp.buf.definition, { noremap = true, silent = true, desc = "Go to definition" }) kmap("n", "gd", vim.lsp.buf.definition, { noremap = true, silent = true, desc = "Go to definition" })
kmap("n", "K", vim.lsp.buf.hover, { noremap = true, silent = true, desc = "Show documentation" }) kmap("n", "K", vim.lsp.buf.hover, { noremap = true, silent = true, desc = "Show documentation" })
kmap("n", "gi", vim.lsp.buf.implementation, { noremap = true, silent = true, desc = "Go to implementation" }) kmap("n", "gi", vim.lsp.buf.implementation, { noremap = true, silent = true, desc = "Go to implementation" })
kmap("n", "<C-k>", vim.lsp.buf.signature_help, { noremap = true, silent = true, desc = "Signature help" }) kmap("n", "<C-k>", vim.lsp.buf.signature_help, { noremap = true, silent = true, desc = "Signature help" })
kmap( kmap(
"n", "n",
"<leader>wa", "<leader>wa",
vim.lsp.buf.add_workspace_folder, vim.lsp.buf.add_workspace_folder,
{ noremap = true, silent = true, desc = "Add workspace folder" } { noremap = true, silent = true, desc = "Add workspace folder" }
) )
kmap( kmap(
"n", "n",
"<leader>wr", "<leader>wr",
vim.lsp.buf.remove_workspace_folder, vim.lsp.buf.remove_workspace_folder,
{ noremap = true, silent = true, desc = "Remove workspace folder" } { noremap = true, silent = true, desc = "Remove workspace folder" }
) )
kmap("n", "<leader>wl", function() kmap("n", "<leader>wl", function()
print(vim.inspect(vim.lsp.buf.list_workspace_folders())) print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
end, { noremap = true, silent = true, desc = "List workspace folders" }) end, { noremap = true, silent = true, desc = "List workspace folders" })
kmap("n", "<leader>D", vim.lsp.buf.type_definition, { noremap = true, silent = true, desc = "Type definition" }) kmap("n", "<leader>D", vim.lsp.buf.type_definition, { noremap = true, silent = true, desc = "Type definition" })
kmap("n", "<leader>rn", vim.lsp.buf.rename, { noremap = true, silent = true, desc = "Rename symbol" })
kmap("n", "<leader>ca", vim.lsp.buf.code_action, { noremap = true, silent = true, desc = "Code actions" }) kmap("n", "<A-CR>", vim.lsp.buf.code_action, { noremap = true, silent = true, desc = "Code actions" })
kmap("n", "gr", vim.lsp.buf.references, { noremap = true, silent = true, desc = "Find references" }) kmap("n", "gr", vim.lsp.buf.references, { noremap = true, silent = true, desc = "Find references" })
-- Отладка (DAP) -- kmap("n", "<F2>", vim.lsp.buf.rename, { noremap = true, silent = true, desc = "Rename symbol" })
kmap("n", "<F9>", "<cmd>lua require'dapui'.toggle()<CR>", { noremap = true, silent = true, desc = "Toggle debug UI" })
kmap("n", "<F5>", function()
require("dap").continue()
end)
kmap("n", "<F10>", function()
require("dap").step_over()
end)
kmap("n", "<F11>", function()
require("dap").step_into()
end)
kmap("n", "<F12>", function()
require("dap").step_out()
end)
kmap(
"n",
"<leader>dt",
"<cmd>lua require'dapui'.toggle()<CR>",
{ noremap = true, silent = true, desc = "Toggle debug UI" }
)
kmap("n", "<leader>dc", function()
require("dap").continue()
end)
kmap("n", "<leader>so", function()
require("dap").step_over()
end)
kmap("n", "<leader>si", function()
require("dap").step_into()
end)
kmap("n", "<leader>st", function()
require("dap").step_out()
end)
kmap("n", "<Leader>b", function() -- }}}
require("dap").toggle_breakpoint()
end)
kmap("n", "<Leader>B", function()
require("dap").set_breakpoint()
end)
kmap("n", "<Leader>lp", function()
require("dap").set_breakpoint(nil, nil, vim.fn.input("Log point message: "))
end)
kmap("n", "<Leader>dr", function()
require("dap").repl.open()
end)
kmap("n", "<Leader>dl", function()
require("dap").run_last()
end)
kmap({ "n", "v" }, "<Leader>dh", function()
require("dap.ui.widgets").hover()
end)
kmap({ "n", "v" }, "<Leader>dp", function()
require("dap.ui.widgets").preview()
end)
kmap("n", "<Leader>df", function()
local widgets = require("dap.ui.widgets")
widgets.centered_float(widgets.frames)
end)
kmap("n", "<Leader>ds", function()
local widgets = require("dap.ui.widgets")
widgets.centered_float(widgets.scopes)
end)
-- Кастомная функция для NvimTree --
local function change_root_to_global_cwd()
local api = require("nvim-tree.api")
local global_cwd = vim.fn.getcwd(-1, -1)
api.tree.change_root(global_cwd)
end
kmap("n", "<C-c>", change_root_to_global_cwd, { noremap = true, silent = true, desc = "Change tree root to CWD" })

View file

@ -1,48 +1,10 @@
local cmp = require('cmp')
local source_mapping = {
buffer = '[Buffer]',
nvim_lsp = '[LSP]',
nvim_lua = '[Lua]',
cmp_tabnine = '[TN]',
path = '[Path]',
}
cmp.setup({
mapping = cmp.mapping.preset.insert({
['<C-y>'] = cmp.mapping.confirm({ select = true }),
['<C-d>'] = cmp.mapping.scroll_docs(-4),
['<C-u>'] = cmp.mapping.scroll_docs(4),
['<C-Space>'] = cmp.mapping.complete(),
}),
snippet = {
expand = function(args)
require('luasnip').lsp_expand(args.body)
end,
},
formatting = {
format = function(entry, vim_item)
local menu = source_mapping[entry.source.name]
vim_item.menu = menu
return vim_item
end
},
sources = cmp.config.sources({
{ name = 'nvim_lsp' },
{ name = 'luasnip' },
}, {
{ name = 'buffer' },
})
})
-- инициализация LSP для различных ЯП -- инициализация LSP для различных ЯП
local lspconfig = require('lspconfig') local lspconfig = require("lspconfig")
local util = require('lspconfig/util') local util = require("lspconfig/util")
local function config(_config) local function config(_config)
return vim.tbl_deep_extend('force', { return vim.tbl_deep_extend("force", {
capabilities = require('cmp_nvim_lsp').default_capabilities(vim.lsp.protocol.make_client_capabilities()), capabilities = require("cmp_nvim_lsp").default_capabilities(vim.lsp.protocol.make_client_capabilities()),
}, _config or {}) }, _config or {})
end end
@ -50,9 +12,9 @@ end
-- https://github.com/golang/tools/blob/master/gopls/doc/vim.md#neovim-install -- https://github.com/golang/tools/blob/master/gopls/doc/vim.md#neovim-install
lspconfig.gopls.setup(config({ lspconfig.gopls.setup(config({
on_attach = on_attach, on_attach = on_attach,
cmd = { 'gopls', 'serve' }, cmd = { "gopls", "serve" },
filetypes = { 'go', 'go.mod' }, filetypes = { "go", "go.mod" },
root_dir = util.root_pattern('go.work', 'go.mod', '.git'), root_dir = util.root_pattern("go.work", "go.mod", ".git"),
settings = { settings = {
gopls = { gopls = {
analyses = { analyses = {
@ -60,6 +22,6 @@ lspconfig.gopls.setup(config({
shadow = true, shadow = true,
}, },
staticcheck = true, staticcheck = true,
} },
} },
})) }))

View file

@ -1,6 +1,3 @@
vim.g.loaded_netrw = 1
vim.g.loaded_netrwPlugin = 1
local options = { local options = {
backup = false, backup = false,
clipboard = "unnamedplus", clipboard = "unnamedplus",
@ -35,9 +32,10 @@ local options = {
scrolloff = 8, scrolloff = 8,
sidescrolloff = 8, sidescrolloff = 8,
syntax = "on", syntax = "on",
foldmethod = "expr", foldmethod = "marker",
foldexpr = "nvim_treesitter#foldexpr()", foldmarker = "{{{,}}}",
foldlevelstart = 99, --foldexpr = "nvim_treesitter#foldexpr()",
foldlevelstart = 0,
foldenable = true, foldenable = true,
} }

54
nvim/lua/plugins.lua Normal file
View file

@ -0,0 +1,54 @@
local plugins = {
{ "nvim-lua/plenary.nvim" },
{ "neovim/nvim-lspconfig" },
{ "Snyssfx/goerr-nvim" },
{
"lukas-reineke/indent-blankline.nvim",
main = "ibl",
--@module "ibl"
--@type ibl.config
config = true,
},
{
"lukas-reineke/headlines.nvim",
dependencies = "nvim-treesitter/nvim-treesitter",
config = true,
},
{
"mfussenegger/nvim-dap",
},
{
"ray-x/lsp_signature.nvim",
event = "VeryLazy",
config = true,
},
require("plugins.cmp"),
require("plugins.onedark"),
require("plugins.treesitter"),
require("plugins.tree"),
require("plugins.conform"),
require("plugins.dapui"),
require("plugins.dap"),
require("plugins.go"),
require("plugins.goimpl"),
require("plugins.lualine"),
require("plugins.telescope"),
require("plugins.columns"),
}
require("lazy").setup(plugins, {
performance = {
rtp = {
disabled_plugins = {
"gzip",
"matchit",
"matchparen",
"netrwPlugin",
"tarPlugin",
"tohtml",
"tutor",
"zipPlugin",
},
},
},
})

View file

@ -1,39 +1,69 @@
local cmp = require'cmp' return {
cmp.setup{ "hrsh7th/nvim-cmp",
snippet = { dependencies = {
-- REQUIRED - you must specify a snippet engine "hrsh7th/cmp-nvim-lsp",
expand = function(args) "hrsh7th/cmp-buffer",
vim.fn["vsnip#anonymous"](args.body) -- For `vsnip` users. "hrsh7th/cmp-path",
-- require('luasnip').lsp_expand(args.body) -- For `luasnip` users. "saadparwaiz1/cmp_luasnip",
-- require('snippy').expand_snippet(args.body) -- For `snippy` users. {
-- vim.fn["UltiSnips#Anon"](args.body) -- For `ultisnips` users. "L3MON4D3/LuaSnip",
-- vim.snippet.expand(args.body) -- For native neovim snippets (Neovim v0.10+) lazy = true,
version = "v2.*",
-- For `mini.snippets` users: build = "make install_jsregexp",
-- local insert = MiniSnippets.config.expand.insert or MiniSnippets.default_insert opts = {
-- insert({ body = args.body }) -- Insert at cursor history = true,
-- cmp.resubscribe({ "TextChangedI", "TextChangedP" }) delete_check_events = "TextChanged",
-- require("cmp.config").set_onetime({ sources = {} }) },
end, dependencies = { "rafamadriz/friendly-snippets" },
config = function()
require("plugins.snippets")
end,
},
}, },
window = { config = function()
completion = cmp.config.window.bordered(), local cmp = require("cmp")
documentation = cmp.config.window.bordered(), local source_mapping = {
}, buffer = "[Buffer]",
mapping = cmp.mapping.preset.insert({ nvim_lsp = "[LSP]",
['<C-b>'] = cmp.mapping.scroll_docs(-4), nvim_lua = "[Lua]",
['<C-f>'] = cmp.mapping.scroll_docs(4), path = "[Path]",
['<C-Space>'] = cmp.mapping.complete(), }
['<C-e>'] = cmp.mapping.abort(), cmp.setup({
['<CR>'] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items. mapping = cmp.mapping.preset.insert({
}), ["<CR>"] = cmp.mapping.confirm({ select = true }),
sources = cmp.config.sources({ ["<Tab>"] = cmp.mapping(function(fallback)
{ name = 'nvim_lsp' }, if require("luasnip").expand_or_jumpable() then
{ name = 'vsnip' }, -- For vsnip users. require("luasnip").expand_or_jump()
-- { name = 'luasnip' }, -- For luasnip users. else
-- { name = 'ultisnips' }, -- For ultisnips users. fallback()
-- { name = 'snippy' }, -- For snippy users. end
}, { end, { "i", "s" }),
{ name = 'buffer' }, ["<S-Tab>"] = cmp.mapping(function(fallback)
}) if require("luasnip").jumpable(-1) then
require("luasnip").jump(-1)
else
fallback()
end
end, { "i", "s" }),
}),
snippet = {
expand = function(args)
require("luasnip").lsp_expand(args.body)
end,
},
formatting = {
format = function(entry, vim_item)
vim_item.menu = source_mapping[entry.source.name] or "[Unknown]"
return vim_item
end,
},
sources = cmp.config.sources({
{ name = "nvim_lsp", priority = 1000 },
{ name = "luasnip", priority = 750 },
{ name = "path", priority = 500 },
}, {
{ name = "buffer" },
}),
})
end,
} }

View file

@ -0,0 +1,10 @@
return {
"m4xshen/smartcolumn.nvim",
opts = {
colorcolumn = "80",
disabled_filetypes = { "help", "text" },
custom_colorcolumn = {},
scope = "file",
editorconfig = true,
},
}

View file

@ -0,0 +1,34 @@
return {
"stevearc/conform.nvim",
opts = {
formatters_by_ft = {
javascript = { "prettier" },
typescript = { "prettier" },
javascriptreact = { "prettier" },
typescriptreact = { "prettier" },
css = { "prettier" },
html = { "prettier" },
json = { "prettier" },
yaml = { "prettier" },
markdown = { "prettier" },
graphql = { "prettier" },
lua = { "stylua" },
python = { "isort", "black" },
go = { "gofmt" },
},
format_on_save = {
lsp_fallback = true,
async = false,
timeout_ms = 500,
},
},
keys = {
{
"<leader>mp",
function()
require("conform").format({ lsp_fallback = true, async = false, timeout_ms = 500 })
end,
desc = "Format file or range (in visual mode)",
},
},
}

View file

@ -1,9 +1,153 @@
require("dap-go").setup() return {
require("dap").adapters.go = { "leoluz/nvim-dap-go",
type = "server", dependencies = { "mfussenegger/nvim-dap" },
port = "${port}", opts = true,
executable = { config = function()
command = "dlv", local dap, dapui = require("dap"), require("dapui")
args = { "dap", "-l", "127.0.0.1:${port}" },
dap.adapters.go = {
type = "server",
port = "${port}",
executable = {
command = "dlv",
args = { "dap", "-l", "127.0.0.1:${port}" },
},
}
dap.listeners.before.attach.dapui_config = function()
dapui.open()
end
dap.listeners.before.launch.dapui_config = function()
dapui.open()
end
dap.listeners.before.event_terminated.dapui_config = function()
dapui.close()
end
dap.listeners.before.event_exited.dapui_config = function()
dapui.close()
end
vim.api.nvim_set_hl(0, "DapBreakpoint", { ctermbg = 0, fg = "#993939", bg = "#31353f" })
vim.api.nvim_set_hl(0, "DapLogPoint", { ctermbg = 0, fg = "#61afef", bg = "#31353f" })
vim.api.nvim_set_hl(0, "DapStopped", { ctermbg = 0, fg = "#98c379", bg = "#31353f" })
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" }
)
end,
keys = {
{
"<F5>",
function()
require("dap").continue()
end,
silent = true,
},
{
"<F10>",
function()
require("dap").step_over()
end,
silent = true,
},
{
"<F11>",
function()
require("dap").step_into()
end,
silent = true,
},
{
"<F12>",
function()
require("dap").step_out()
end,
silent = true,
},
{
"<leader>dc",
function()
require("dap").continue()
end,
silent = true,
},
{
"<leader>so",
function()
require("dap").step_over()
end,
silent = true,
},
{
"<leader>si",
function()
require("dap").step_into()
end,
silent = true,
},
{
"<leader>st",
function()
require("dap").step_out()
end,
silent = true,
},
{
"<leader>b",
function()
require("dap").toggle_breakpoint()
end,
silent = true,
},
{
"<A-b>",
function()
require("dap").toggle_breakpoint()
end,
silent = true,
},
{
"<Leader>B",
function()
require("dap").set_breakpoint()
end,
silent = true,
},
{
"<Leader>lp",
function()
require("dap").set_breakpoint(nil, nil, vim.fn.input("Log point message: "))
end,
silent = true,
},
{
"<Leader>dr",
function()
require("dap").repl.open()
end,
silent = true,
},
{
"<Leader>dl",
function()
require("dap").run_last()
end,
silent = true,
},
}, },
} }

View file

@ -0,0 +1,75 @@
return {
"rcarriga/nvim-dap-ui",
dependencies = {
"mfussenegger/nvim-dap",
"nvim-neotest/nvim-nio",
},
keys = {
{
"<leader>du",
function()
require("dapui").toggle()
end,
silent = true,
},
{
"<Leader>dh",
function()
require("dap.ui.widgets").hover()
end,
silent = true,
},
{
"<Leader>dp",
function()
require("dap.ui.widgets").preview()
end,
silent = true,
},
{
"<Leader>ds",
function()
local widgets = require("dap.ui.widgets")
widgets.centered_float(widgets.scopes)
end,
silent = true,
},
},
opts = {
icons = {
expanded = "",
collapsed = "",
},
mappings = {
open = "o",
remove = "d",
edit = "e",
repl = "r",
toggle = "t",
},
expand_lines = vim.fn.has("nvim-0.7"),
layouts = {
{
elements = {
"repl",
"breakpoints",
"scopes",
},
size = 0.3,
position = "bottom",
},
},
floating = {
max_height = nil,
max_width = nil,
border = "single",
mappings = {
close = { "q", "<Esc>" },
},
},
windows = { indent = 1 },
render = {
max_type_length = nil,
},
},
}

View file

@ -1,28 +0,0 @@
local conform = require("conform")
conform.setup({
formatters_by_ft = {
javascript = { "prettier" },
typescript = { "prettier" },
javascriptreact = { "prettier" },
typescriptreact = { "prettier" },
css = { "prettier" },
html = { "prettier" },
json = { "prettier" },
yaml = { "prettier" },
markdown = { "prettier" },
graphql = { "prettier" },
lua = { "stylua" },
python = { "isort", "black" },
go = { "gofmt" },
},
format_on_save = {
lsp_fallback = true,
async = false,
timeout_ms = 500,
},
})
vim.keymap.set({ "n", "v" }, "<leader>mp", function()
conform.format({ lsp_fallback = true, async = false, timeout_ms = 500 })
end, { desc = "Format file or range (in visual mode)" })

12
nvim/lua/plugins/go.lua Normal file
View file

@ -0,0 +1,12 @@
return {
"ray-x/go.nvim",
dependencies = {
"ray-x/guihua.lua",
"neovim/nvim-lspconfig",
"nvim-treesitter/nvim-treesitter",
},
config = true,
event = { "CmdlineEnter" },
ft = { "go", "gomod" },
build = ':lua require("go.install").update_all_sync()',
}

View file

@ -0,0 +1,21 @@
return {
"edolphin-ydf/goimpl.nvim",
dependencies = {
"nvim-lua/plenary.nvim",
"nvim-lua/popup.nvim",
"nvim-telescope/telescope.nvim",
"nvim-treesitter/nvim-treesitter",
},
config = function()
require("telescope").load_extension("goimpl")
end,
keys = {
{
"<leader>im",
function()
require("telescope").extensions.goimpl.goimpl({})
end,
desc = "Generate stub for interface on a type for golang",
},
},
}

View file

@ -1,99 +0,0 @@
return require("packer").startup({
function(use)
use("wbthomason/packer.nvim")
use("nvim-lua/plenary.nvim")
use("neovim/nvim-lspconfig")
use("navarasu/onedark.nvim")
use("Snyssfx/goerr-nvim")
use({
"lukas-reineke/indent-blankline.nvim",
config = function()
require("ibl").setup()
end,
})
use({
"rcarriga/nvim-dap-ui",
requires = { "mfussenegger/nvim-dap", "nvim-neotest/nvim-nio" },
})
use({
"leoluz/nvim-dap-go",
requires = { "mfussenegger/nvim-dap" },
config = function()
require("plugins.dap")
end,
})
use({
"hrsh7th/nvim-cmp",
requires = {
"hrsh7th/cmp-nvim-lsp",
"hrsh7th/cmp-buffer",
"hrsh7th/cmp-path",
"hrsh7th/cmp-vsnip",
"hrsh7th/vim-vsnip",
},
config = function()
require("plugins.cmp")
end,
})
use({
"nvim-lualine/lualine.nvim",
config = function()
require("plugins.lualine")
end,
})
use({
"nvim-treesitter/nvim-treesitter",
run = ":TSUpdate",
config = function()
require("plugins.treesitter")
end,
})
use({ "nvim-telescope/telescope-file-browser.nvim" })
use({
"nvim-telescope/telescope.nvim",
config = function()
require("plugins.telescope")
end,
requires = "nvim-lua/plenary.nvim",
})
use({
"nvim-tree/nvim-tree.lua",
requires = {
"nvim-tree/nvim-web-devicons",
},
config = function()
require("plugins.tree")
end,
})
use({
"stevearc/conform.nvim",
config = function()
require("plugins.format")
end,
})
use({
"mfussenegger/nvim-dap",
config = function()
local dap = require("dap")
-- Общие конфигурации для Go
dap.configurations.go = {
{
type = "go",
name = "Debug",
request = "launch",
program = "${file}",
showLog = true,
console = "integratedTerminal",
},
}
end,
})
if packer_bootstrap then
require("packer").sync()
end
end,
config = {
-- The root has to be a directory named "pack"
package_root = vim.fn.stdpath("data") .. "/site/pack",
},
})

View file

@ -1,40 +1,43 @@
require('lualine').setup { return {
options = { "nvim-lualine/lualine.nvim",
icons_enabled = true, opts = {
theme = 'auto', options = {
component_separators = { left = '', right = ''}, icons_enabled = true,
section_separators = { left = '', right = ''}, theme = "auto",
disabled_filetypes = { component_separators = { left = "", right = "" },
statusline = {}, section_separators = { left = "", right = "" },
winbar = {}, disabled_filetypes = {
statusline = {},
winbar = {},
},
ignore_focus = {},
always_divide_middle = true,
globalstatus = false,
refresh = {
statusline = 1000,
tabline = 1000,
winbar = 1000,
},
}, },
ignore_focus = {}, sections = {
always_divide_middle = true, lualine_a = { "mode" },
globalstatus = false, lualine_b = { "branch", "diff", "diagnostics" },
refresh = { lualine_c = { "filename" },
statusline = 1000, lualine_x = { "encoding", "fileformat", "filetype" },
tabline = 1000, lualine_y = { "progress" },
winbar = 1000, lualine_z = { "location" },
} },
inactive_sections = {
lualine_a = {},
lualine_b = {},
lualine_c = { "filename" },
lualine_x = { "location" },
lualine_y = {},
lualine_z = {},
},
tabline = {},
winbar = {},
inactive_winbar = {},
extensions = {},
}, },
sections = {
lualine_a = {'mode'},
lualine_b = {'branch', 'diff', 'diagnostics'},
lualine_c = {'filename'},
lualine_x = {'encoding', 'fileformat', 'filetype'},
lualine_y = {'progress'},
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,33 @@
return {
"navarasu/onedark.nvim",
opts = {
style = "darker",
transparent = false, -- Show/hide background
term_colors = true, -- Change terminal color as per the selected theme style
ending_tildes = true, -- Show the end-of-buffer tildes. By default they are hidden
cmp_itemkind_reverse = false, -- reverse item kind highlights in cmp menu
toggle_style_key = nil, -- keybind to toggle theme style. Leave it nil to disable it, or set it to a string, for example "<leader>ts"
toggle_style_list = { "dark", "darker", "cool", "deep", "warm", "warmer", "light" }, -- List of styles to toggle between
code_style = {
comments = "italic",
keywords = "none",
functions = "none",
strings = "none",
variables = "none",
},
lualine = {
transparent = false, -- lualine center bar transparency
},
colors = {}, -- Override default colors
highlights = {}, -- Override highlight groups
diagnostics = {
darker = true, -- darker colors for diagnostic
undercurl = true, -- use undercurl instead of underline for diagnostics
background = true, -- use background color for virtual text
},
},
}

View file

@ -0,0 +1,8 @@
require("luasnip").config.setup({
history = true,
update_events = "TextChanged,TextChangedI",
})
require("luasnip.loaders.from_vscode").lazy_load()
require("luasnip.loaders.from_vscode").lazy_load({
paths = { vim.fn.stdpath("config") .. "/snippets" },
})

View file

@ -1,10 +1,19 @@
require("telescope").setup({ return {
pickers = { "nvim-telescope/telescope.nvim",
buffers = { dependencies = { "nvim-lua/plenary.nvim" },
initial_mode = "normal", opts = {
pickers = {
buffers = {
initial_mode = "normal",
},
},
defaults = {
file_ignore_patterns = { "vendor", "node_modules" },
}, },
}, },
defaults = { keys = {
file_ignore_patterns = { "vendor", "node_modules" }, { "<leader>ff", "<cmd>Telescope find_files<CR>", noremap = true, silent = true, desc = "Find files" },
{ "<leader>fg", "<cmd>Telescope live_grep<CR>", noremap = true, silent = true, desc = "Live grep" },
{ "<leader>fb", "<cmd>Telescope buffers<CR>", noremap = true, silent = true, desc = "Find buffers" },
}, },
}) }

View file

@ -1,27 +1,51 @@
require("nvim-tree").setup({ return {
sort = { "nvim-tree/nvim-tree.lua",
sorter = "case_sensitive", dependencies = {
"nvim-tree/nvim-web-devicons",
}, },
view = { opts = {
width = 30, hijack_directories = {
}, enable = true, -- Перехватывать открытие директорий
git = { auto_open = true, -- Автоматически открывать при старте
enable = true, },
}, sort = {
renderer = { sorter = "case_sensitive",
group_empty = true, },
highlight_git = true, view = {
icons = { width = 30,
show = { },
git = true, git = {
enable = true,
},
renderer = {
group_empty = true,
highlight_git = true,
icons = {
show = {
git = true,
},
}, },
}, },
filters = {
dotfiles = false,
},
update_focused_file = {
enable = true,
update_root = false,
},
}, },
filters = { keys = {
dotfiles = false, {
"<C-c>",
function()
local api = require("nvim-tree.api")
local global_cwd = vim.fn.getcwd(-1, -1)
api.tree.change_root(global_cwd)
end,
noremap = true,
silent = true,
desc = "Change tree root to CWD",
},
{ "<F3>", ":NvimTreeToggle<CR>", noremap = true, silent = true, desc = "Toggle file tree" },
}, },
update_focused_file = { }
enable = true,
update_root = false,
},
})

View file

@ -1,47 +1,66 @@
require("nvim-treesitter.configs").setup({ return {
highlight = { enable = true }, "nvim-treesitter/nvim-treesitter",
ensure_installed = { build = ":TSUpdate",
"c", opts = {
"lua", highlight = { enable = true },
"python", ensure_installed = {
"bash", "c",
"go", "lua",
"html", "python",
"css", "bash",
"javascript", "go",
"typescript", "html",
"git_config", "css",
"git_rebase", "javascript",
"gitattributes", "typescript",
"gitcommit", "git_config",
"gitignore", "git_rebase",
"gomod", "gitattributes",
"gosum", "gitcommit",
"gotmpl", "gitignore",
"gowork", "gomod",
"hjson", "gosum",
"ini", "gotmpl",
"json", "gowork",
"json5", "hjson",
"jsonnet", "ini",
"latex", "json",
"make", "json5",
"markdown", "jsonnet",
"markdown_inline", "latex",
"nginx", "make",
"proto", "markdown",
"rust", "markdown_inline",
"templ", "nginx",
"todotxt", "proto",
"toml", "rust",
"tsx", "templ",
"typescript", "todotxt",
"vim", "toml",
"vimdoc", "tsx",
"xml", "typescript",
"yaml", "vim",
"sql", "vimdoc",
"ssh_config", "xml",
"yaml",
"sql",
"ssh_config",
},
ignore_install = { "gdhsader", "phpdoc" },
indent = { enable = true },
auto_install = true,
sync_install = false,
textobjects = { select = { enable = true, lookahead = true } },
}, },
ignore_install = { "gdhsader", "phpdoc" }, dependencies = {
}) { "nvim-treesitter/nvim-treesitter-textobjects" },
{
"nvim-treesitter/nvim-treesitter-context",
opts = {
enable = true,
mode = "topline",
line_numbers = true,
},
},
},
}

23
nvim/snippets/go.json Normal file
View file

@ -0,0 +1,23 @@
{
"package line": {
"body": ["package ${TM_DIRECTORY/.+\\/(.+)$/${1:/downcase}/}", "", "$0"],
"description": "package header",
"prefix": "pkg"
},
"structure constructor": {
"body": [
"// New$1 returns new $1.",
"func New${1:type}(${2}) *$1 {",
"\t$3",
"\treturn &$1{$4}",
"}"
],
"description": "constructor for structure type",
"prefix": "construct"
},
"if err := ...; err != nil": {
"prefix": "iferr",
"body": "if err := ${1}; err != nil {\n\t${2:return ${3:nil, }${4:err}}\n}",
"description": "Snippet for if err := ...; err != nil"
}
}

View file

@ -0,0 +1,38 @@
{
"name": "gotools",
"displayName": "Golang Tools",
"description": "Tools for productive work",
"version": "0.1.5",
"engines": {
"vscode": "^1.80.0"
},
"publisher": "neonxp",
"license": "GPL-3.0-or-later",
"author": {
"name": "Alexander NeonXP Kiryukhin",
"email": "a.kiryukhin@mail.ru",
"url": "https://neonxp.ru/"
},
"repository": {
"type": "git",
"url": "https://github.com/neonxp/GoTools"
},
"icon": "icon.png",
"categories": [
"Programming Languages",
"Snippets",
"Other"
],
"keywords": [
"go",
"golang"
],
"contributes": {
"snippets": [
{
"language": "go",
"path": "./go.json"
}
]
}
}