nvim lazy plugin management part 2

This commit is contained in:
2025-07-15 16:25:52 +05:00
parent 0d1b98f65e
commit 386d50d7ce
21 changed files with 318 additions and 347 deletions

View File

@ -1,12 +1,4 @@
require("user.keymaps") require("user.keymaps")
require("user.lazy")
require("user.themes.kanagawa")
require("user.options") require("user.options")
require("user.cmp") require("user.lazy")
require("user.lsp")
require("user.lsp_format")
-- require("user.dap.dapui")
-- require("user.dap.dap")

View File

@ -1,128 +0,0 @@
local cmp_status_ok, cmp = pcall(require, "cmp")
if not cmp_status_ok then
return
end
local snip_status_ok, luasnip = pcall(require, "luasnip")
if not snip_status_ok then
return
end
require("luasnip/loaders/from_vscode").lazy_load()
local check_backspace = function()
local col = vim.fn.col "." - 1
return col == 0 or vim.fn.getline("."):sub(col, col):match "%s"
end
local cmp_kinds = {
Text = '',
Method = '',
Function = '',
Constructor = '',
Field = '',
Variable = '',
Class = '',
Interface = '',
Module = '',
Property = '',
Unit = '',
Value = '',
Enum = '',
Keyword = '',
Snippet = '',
Color = '',
File = '',
Reference = '',
Folder = '',
EnumMember = '',
Constant = '',
Struct = '',
Event = '',
Operator = '',
TypeParameter = '',
}
cmp.setup {
snippet = {
expand = function(args)
luasnip.lsp_expand(args.body) -- For `luasnip` users.
end,
},
mapping = {
["<C-k>"] = cmp.mapping.select_prev_item(),
["<C-j>"] = cmp.mapping.select_next_item(),
["<C-b>"] = cmp.mapping(cmp.mapping.scroll_docs(-1), { "i", "c" }),
["<C-f>"] = cmp.mapping(cmp.mapping.scroll_docs(1), { "i", "c" }),
["<C-Space>"] = cmp.mapping(cmp.mapping.complete(), { "i", "c" }),
["<C-y>"] = cmp.config.disable, -- Specify `cmp.config.disable` if you want to remove the default `<C-y>` mapping.
["<C-e>"] = cmp.mapping {
i = cmp.mapping.abort(),
c = cmp.mapping.close(),
},
-- Accept currently selected item. If none selected, `select` first item.
-- Set `select` to `false` to only confirm explicitly selected items.
["<CR>"] = cmp.mapping.confirm { select = false },
["<Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_next_item()
elseif luasnip.expandable() then
luasnip.expand()
elseif luasnip.expand_or_jumpable() then
luasnip.expand_or_jump()
elseif check_backspace() then
fallback()
else
fallback()
end
end, {
"i",
"s",
}),
["<S-Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_prev_item()
elseif luasnip.jumpable(-1) then
luasnip.jump(-1)
else
fallback()
end
end, {
"i",
"s",
}),
},
formatting = {
fields = { "kind", "abbr", "menu" },
format = function(entry, vim_item)
-- Kind icons
vim_item.kind = string.format("%s", cmp_kinds[vim_item.kind])
vim_item.menu = ({
nvim_lsp = "[LSP]",
luasnip = "[Snippet]",
buffer = "[Buffer]",
path = "[Path]",
})[entry.source.name]
return vim_item
end,
},
sources = {
{ name = "nvim_lsp" },
{ name = "luasnip" },
{ name = "buffer" },
{ name = "path" },
},
confirm_opts = {
behavior = cmp.ConfirmBehavior.Replace,
select = false,
},
window = {
documentation = {
border = { "", "", "", "", "", "", "", "" },
},
},
experimental = {
ghost_text = false,
native_menu = false,
},
}

View File

@ -1,81 +0,0 @@
local dap_status_ok, dap = pcall(require, "dap")
if not dap_status_ok then
return
end
local dapui_status_ok, dapui = pcall(require, "dapui")
if not dapui_status_ok then
return
end
dap.adapters.coreclr = {
type = 'executable',
command = '/home/nikita/.local/share/nvim/mason/bin/netcoredbg',
args = { '--interpreter=vscode' }
}
vim.g.dotnet_build_project = function()
local default_path = vim.fn.getcwd() .. '/'
if vim.g['dotnet_last_proj_path'] ~= nil then
default_path = vim.g['dotnet_last_proj_path']
end
local path = vim.fn.input('Path to your *proj file', default_path, 'file')
vim.g['dotnet_last_proj_path'] = path
local cmd = 'dotnet build -c Debug ' .. path .. ' > /dev/null'
print('')
print('Cmd to execute: ' .. cmd)
local f = os.execute(cmd)
if f == 0 then
print('\nBuild: ✔️ ')
else
print('\nBuild: ❌ (code: ' .. f .. ')')
end
end
vim.g.dotnet_get_dll_path = function()
local request = function()
return vim.fn.input('Path to dll', vim.fn.getcwd(), 'file')
end
if vim.g['dotnet_last_dll_path'] == nil then
vim.g['dotnet_last_dll_path'] = request()
else
if vim.fn.confirm('Do you want to change the path to dll?\n' .. vim.g['dotnet_last_dll_path'], '&yes\n&no', 2) == 1 then
vim.g['dotnet_last_dll_path'] = request()
end
end
return vim.g['dotnet_last_dll_path']
end
local config = {
{
type = "coreclr",
name = "launch - netcoredbg",
request = "launch",
-- console = "integratedTerminal",
cwd = "${workspaceFolder}/src/ClientService.AspNet",
launchSettingsFilePath = "${workspaceFolder}/src/ClientService.AspNet/Properties/launchSettings.json",
launchSettingsProfile = "ClientService.AspNet",
program = function()
if vim.fn.confirm('Should I recompile first?', '&yes\n&no', 2) == 1 then
vim.g.dotnet_build_project()
end
return vim.g.dotnet_get_dll_path()
end,
},
}
dap.configurations.cs = config
--Autostart ui when debugging
dap.listeners.after.event_initialized["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

View File

@ -1,6 +0,0 @@
local dapui_status_ok, dapui = pcall(require, "dapui")
if not dapui_status_ok then
return
end
dapui.setup()

View File

@ -1,5 +1,3 @@
local fn = vim.fn
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then if not vim.loop.fs_stat(lazypath) then
vim.fn.system({ vim.fn.system({
@ -21,61 +19,11 @@ end
lazy.setup( lazy.setup(
{ {
change_detection = {
enabled = false,
},
spec = { spec = {
{ import = "user.plugins" }, { import = "user.plugins" },
{ "hrsh7th/nvim-cmp", event = "VeryLazy" }, -- The completion plugin
{ "hrsh7th/cmp-buffer", event = "VeryLazy" }, -- buffer completions
{ "hrsh7th/cmp-path", event = "VeryLazy" }, -- path completions
{ "hrsh7th/cmp-cmdline", event = "VeryLazy" }, -- cmdline completions
{ "saadparwaiz1/cmp_luasnip", event = "VeryLazy" }, -- snippet completions
{ "hrsh7th/cmp-nvim-lsp", event = "VeryLazy" },
-- snippets
-- LSP
{ "williamboman/mason.nvim", event = "VeryLazy" }, -- simple to use language server installer
{ "williamboman/mason-lspconfig.nvim", event = "VeryLazy" },
{ "neovim/nvim-lspconfig", event = "VeryLazy" }, -- enable LSP
{
"folke/zen-mode.nvim",
opts = {
window = {
backdrop = 1
}
},
event = "VeryLazy"
},
{
"nvimtools/none-ls.nvim",
event = "VeryLazy"
},
{ "lukas-reineke/lsp-format.nvim", event = "VeryLazy" },
--comment out
{ "tpope/vim-commentary", event = "VeryLazy" },
{ "windwp/nvim-ts-autotag", event = "VeryLazy" },
{
"rebelot/kanagawa.nvim",
lazy = false,
priority = 1000,
},
--debugging
{ "mfussenegger/nvim-dap", event = "VeryLazy" },
{
"rcarriga/nvim-dap-ui",
dependencies = {
"mfussenegger/nvim-dap",
"nvim-neotest/nvim-nio"
},
event = { "VeryLazy" }
},
}, },
} }
) )

View File

@ -1,12 +0,0 @@
local status_ok, mason = pcall(require, "mason")
if not status_ok then
return
end
mason.setup()
require("user.lsp.mason_lsp_config")
require("user.lsp.diagnostics_config").setup()
-- require("user.lsp.none_ls")
vim.cmd([[ command! Format execute 'lua vim.lsp.buf.format{async=true}' ]])

View File

@ -1,7 +0,0 @@
require("lsp-format").setup {}
local on_attach = function(client)
require "lsp-format".on_attach(client)
end
require "lspconfig".gopls.setup { on_attach = on_attach }

View File

@ -0,0 +1,133 @@
return {
{
"hrsh7th/nvim-cmp",
event = "VeryLazy",
config = function()
local cmp = require "cmp"
local luasnip = require "luasnip"
require("luasnip/loaders/from_vscode").lazy_load()
local check_backspace = function()
local col = vim.fn.col "." - 1
return col == 0 or vim.fn.getline("."):sub(col, col):match "%s"
end
local cmp_kinds = {
Text = '',
Method = '',
Function = '',
Constructor = '',
Field = '',
Variable = '',
Class = '',
Interface = '',
Module = '',
Property = '',
Unit = '',
Value = '',
Enum = '',
Keyword = '',
Snippet = '',
Color = '',
File = '',
Reference = '',
Folder = '',
EnumMember = '',
Constant = '',
Struct = '',
Event = '',
Operator = '',
TypeParameter = '',
}
cmp.setup {
snippet = {
expand = function(args)
luasnip.lsp_expand(args.body) -- For `luasnip` users.
end,
},
mapping = {
["<C-k>"] = cmp.mapping.select_prev_item(),
["<C-j>"] = cmp.mapping.select_next_item(),
["<C-b>"] = cmp.mapping(cmp.mapping.scroll_docs(-1), { "i", "c" }),
["<C-f>"] = cmp.mapping(cmp.mapping.scroll_docs(1), { "i", "c" }),
["<C-Space>"] = cmp.mapping(cmp.mapping.complete(), { "i", "c" }),
["<C-y>"] = cmp.config.disable, -- Specify `cmp.config.disable` if you want to remove the default `<C-y>` mapping.
["<C-e>"] = cmp.mapping {
i = cmp.mapping.abort(),
c = cmp.mapping.close(),
},
-- Accept currently selected item. If none selected, `select` first item.
-- Set `select` to `false` to only confirm explicitly selected items.
["<CR>"] = cmp.mapping.confirm { select = false },
["<Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_next_item()
elseif luasnip.expandable() then
luasnip.expand()
elseif luasnip.expand_or_jumpable() then
luasnip.expand_or_jump()
elseif check_backspace() then
fallback()
else
fallback()
end
end, {
"i",
"s",
}),
["<S-Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_prev_item()
elseif luasnip.jumpable(-1) then
luasnip.jump(-1)
else
fallback()
end
end, {
"i",
"s",
}),
},
formatting = {
fields = { "kind", "abbr", "menu" },
format = function(entry, vim_item)
-- Kind icons
vim_item.kind = string.format("%s", cmp_kinds[vim_item.kind])
vim_item.menu = ({
nvim_lsp = "[LSP]",
luasnip = "[Snippet]",
buffer = "[Buffer]",
path = "[Path]",
})[entry.source.name]
return vim_item
end,
},
sources = {
{ name = "nvim_lsp" },
{ name = "luasnip" },
{ name = "buffer" },
{ name = "path" },
},
confirm_opts = {
behavior = cmp.ConfirmBehavior.Replace,
select = false,
},
window = {
documentation = {
border = { "", "", "", "", "", "", "", "" },
},
},
experimental = {
ghost_text = false,
native_menu = false,
},
}
end
}, -- The completion plugin
{ "hrsh7th/cmp-buffer", event = "VeryLazy" }, -- buffer completions
{ "hrsh7th/cmp-path", event = "VeryLazy" }, -- path completions
{ "hrsh7th/cmp-cmdline", event = "VeryLazy" }, -- cmdline completions
{ "saadparwaiz1/cmp_luasnip", event = "VeryLazy" }, -- snippet completions
{ "hrsh7th/cmp-nvim-lsp", event = "VeryLazy" },
}

View File

@ -0,0 +1,85 @@
return {
{
"mfussenegger/nvim-dap",
event = "VeryLazy",
config = function()
local dap = require "dap"
local dapui = require "dapui"
dap.adapters.coreclr = {
type = 'executable',
command = '/home/nikita/.local/share/nvim/mason/bin/netcoredbg',
args = { '--interpreter=vscode' }
}
vim.g.dotnet_build_project = function()
local default_path = vim.fn.getcwd() .. '/'
if vim.g['dotnet_last_proj_path'] ~= nil then
default_path = vim.g['dotnet_last_proj_path']
end
local path = vim.fn.input('Path to your *proj file', default_path, 'file')
vim.g['dotnet_last_proj_path'] = path
local cmd = 'dotnet build -c Debug ' .. path .. ' > /dev/null'
print('')
print('Cmd to execute: ' .. cmd)
local f = os.execute(cmd)
if f == 0 then
print('\nBuild: ✔️ ')
else
print('\nBuild: ❌ (code: ' .. f .. ')')
end
end
vim.g.dotnet_get_dll_path = function()
local request = function()
return vim.fn.input('Path to dll', vim.fn.getcwd(), 'file')
end
if vim.g['dotnet_last_dll_path'] == nil then
vim.g['dotnet_last_dll_path'] = request()
else
if vim.fn.confirm('Do you want to change the path to dll?\n' .. vim.g['dotnet_last_dll_path'], '&yes\n&no', 2) == 1 then
vim.g['dotnet_last_dll_path'] = request()
end
end
return vim.g['dotnet_last_dll_path']
end
local config = {
{
type = "coreclr",
name = "launch - netcoredbg",
request = "launch",
-- console = "integratedTerminal",
cwd = "${workspaceFolder}/src/ClientService.AspNet",
launchSettingsFilePath = "${workspaceFolder}/src/ClientService.AspNet/Properties/launchSettings.json",
launchSettingsProfile = "ClientService.AspNet",
program = function()
if vim.fn.confirm('Should I recompile first?', '&yes\n&no', 2) == 1 then
vim.g.dotnet_build_project()
end
return vim.g.dotnet_get_dll_path()
end,
},
}
dap.configurations.cs = config
--Autostart ui when debugging
dap.listeners.after.event_initialized["dapui_config"] = function()
dapui.open()
end
end
},
{
"rcarriga/nvim-dap-ui",
dependencies = {
"mfussenegger/nvim-dap",
"nvim-neotest/nvim-nio"
},
event = { "VeryLazy" },
config = true
},
}

View File

@ -0,0 +1,34 @@
return {
{
"williamboman/mason.nvim",
event = "VeryLazy",
config = true
}, -- simple to use language server installer
{
"williamboman/mason-lspconfig.nvim",
event = "VeryLazy",
config = function()
require("user.plugins.lsp.mason_lsp_config")
require("user.plugins.lsp.diagnostics_config").setup()
-- require("user.lsp.none_ls")
vim.cmd([[ command! Format execute 'lua vim.lsp.buf.format{async=true}' ]])
end
},
{ "neovim/nvim-lspconfig", event = "VeryLazy" }, -- enable LSP
{
"lukas-reineke/lsp-format.nvim",
event = "VeryLazy",
config = function()
local on_attach = function(client)
require("lsp-format").on_attach(client)
end
require("lspconfig").gopls.setup { on_attach = on_attach }
end
},
{
"nvimtools/none-ls.nvim",
event = "VeryLazy"
},
}

View File

@ -1,5 +1,4 @@
return { return {
{ "L3MON4D3/LuaSnip", event = "VeryLazy" }, --snippet engine { "L3MON4D3/LuaSnip", event = "VeryLazy" }, --snippet engine
{ "rafamadriz/friendly-snippets", event = "VeryLazy" }, -- a bunch of snippets to use { "rafamadriz/friendly-snippets", event = "VeryLazy" }, -- a bunch of snippets to use
{ {
@ -7,5 +6,4 @@ return {
run = "yarn install --frozen-lockfile && yarn compile", run = "yarn install --frozen-lockfile && yarn compile",
event = "VeryLazy" event = "VeryLazy"
}, },
} }

View File

@ -1,11 +1,13 @@
return { return {
{ {
"nvim-telescope/telescope.nvim", "nvim-telescope/telescope.nvim",
config = function() dependencies = { "nvim-telescope/telescope-media-files.nvim", "nvim-lua/plenary.nvim" },
lazy = false,
config = function(_, _opts)
local telescope = require("telescope") local telescope = require("telescope")
telescope.load_extension("media_files") telescope.setup(_opts)
local telescope_builtin = require("telescope.builtin") telescope.load_extension("media_files")
local which_key = require("which-key") local which_key = require("which-key")
which_key.add({ which_key.add({
@ -115,7 +117,5 @@ return {
}, },
} }
end, end,
event = "VeryLazy" }
},
{ "nvim-telescope/telescope-media-files.nvim", event = "VeryLazy" },
} }

View File

@ -0,0 +1,39 @@
return {
"rebelot/kanagawa.nvim",
lazy = false,
priority = 1000,
opts = {
compile = false, -- enable compiling the colorscheme
undercurl = true, -- enable undercurls
commentStyle = { italic = true },
functionStyle = {},
keywordStyle = { italic = true },
statementStyle = { bold = true },
typeStyle = {},
transparent = true, -- do not set background color
dimInactive = false, -- dim inactive window `:h hl-NormalNC`
terminalColors = true, -- define vim.g.terminal_color_{0,17}
colors = {
-- add/modify theme and palette colors
palette = {},
theme = { wave = {}, lotus = {}, dragon = {}, all = { ui = { bg_gutter = "none" } } },
},
overrides = function(colors) -- add/modify highlights
local theme = colors.theme
return {
CursorLine = { bg = "#272735" },
}
end,
theme = "wave", -- Load "wave" theme when 'background' option is not set
background = { -- map the value of 'background' option to a theme
dark = "wave", -- try "dragon" !
},
},
config = function(_, _opts)
require("kanagawa").setup(_opts)
vim.cmd("colorscheme kanagawa")
end
}

View File

@ -1,8 +1,8 @@
return { return {
{ {
"nvim-treesitter/nvim-treesitter", "nvim-treesitter/nvim-treesitter",
run = ":TSUpdate", build = ":TSUpdate",
event = "VeryLazy", lazy = false,
-- init = function(plugin) -- init = function(plugin)
-- require("nvim-treesitter") -- require("nvim-treesitter")
-- end, -- end,
@ -34,5 +34,8 @@ return {
}, },
}, },
}, },
config = function (_, opts)
require("nvim-treesitter.configs").setup(opts)
end
}, },
} }

View File

@ -72,8 +72,10 @@ return {
filetypes = { "TelescopePrompt" }, filetypes = { "TelescopePrompt" },
}, },
}, },
config = function() config = function(_, opts)
local which_key = require("which-key") local which_key = require("which-key")
which_key.setup(opts)
which_key.add({ which_key.add({
{ "<leader>", group = "Hotkeys" }, { "<leader>", group = "Hotkeys" },
{ "<leader>?", ":WhichKey <CR>", desc = "Show keybindings" }, { "<leader>?", ":WhichKey <CR>", desc = "Show keybindings" },
@ -82,14 +84,6 @@ return {
{ "<leader>F", ":lua vim.lsp.buf.format() <CR>", desc = "Format file" }, { "<leader>F", ":lua vim.lsp.buf.format() <CR>", desc = "Format file" },
}) })
-- which_key.add({
-- { "<leader>f", group = "Find" },
-- { "<leader>ff", "<cmd>lua require'telescope.builtin'.find_files(require('telescope.themes').get_dropdown({ previewer = false }))<cr>", desc = "Find file" },
-- { "<leader>fw", "<cmd>lua require'telescope.builtin'.live_grep()<cr>", desc = "Grep file" },
-- { "<leader>fb", "<cmd>lua require'telescope.builtin'.buffers()<cr>", desc = "Find buffer" },
-- { "<leader>fh", "<cmd>lua require'telescope.builtin'.resume()<cr>", desc = "Resume last search" },
-- })
which_key.add({ which_key.add({
{ "<leader>g", group = "Git" }, { "<leader>g", group = "Git" },
{ "<leader>gb", toggle_gitsigns_blame, desc = "Toggle git blame view" }, { "<leader>gb", toggle_gitsigns_blame, desc = "Toggle git blame view" },

View File

@ -0,0 +1,9 @@
return {
"folke/zen-mode.nvim",
opts = {
window = {
backdrop = 1
}
},
event = "VeryLazy"
}

View File

@ -1,29 +0,0 @@
require("kanagawa").setup({
compile = false, -- enable compiling the colorscheme
undercurl = true, -- enable undercurls
commentStyle = { italic = true },
functionStyle = {},
keywordStyle = { italic = true },
statementStyle = { bold = true },
typeStyle = {},
transparent = true, -- do not set background color
dimInactive = false, -- dim inactive window `:h hl-NormalNC`
terminalColors = true, -- define vim.g.terminal_color_{0,17}
colors = {
-- add/modify theme and palette colors
palette = {},
theme = { wave = {}, lotus = {}, dragon = {}, all = { ui = { bg_gutter = "none" } } },
},
overrides = function(colors) -- add/modify highlights
local theme = colors.theme
return {
CursorLine = { bg = "#272735" },
}
end,
theme = "wave", -- Load "wave" theme when 'background' option is not set
background = { -- map the value of 'background' option to a theme
dark = "wave", -- try "dragon" !
},
})
vim.cmd("colorscheme kanagawa")

View File

@ -1 +0,0 @@
vim.g.tokyonight_style = "night"