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

@ -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,30 @@
local M = {}
M.setup = function()
local config = {
virtual_text = true,
signs = {
text = {
[vim.diagnostic.severity.ERROR] = '',
[vim.diagnostic.severity.WARN] = '',
[vim.diagnostic.severity.HINT] = '',
[vim.diagnostic.severity.INFO] = '',
}
},
update_in_insert = true,
underline = true,
severity_sort = true,
float = {
focusable = true,
style = "minimal",
border = "rounded",
source = "always",
header = "",
prefix = "",
},
}
vim.diagnostic.config(config)
end
return M

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

@ -0,0 +1,48 @@
local mason_lspconfig = require("mason-lspconfig")
vim.lsp.enable({
"omnisharp",
"pylsp",
"rust_analyzer",
})
-- TODO: this does not work, need to install pylsp-mypy plugin manually
local function extra_args()
local virtual = os.getenv("VIRTUAL_ENV") or "/usr"
return { "--python-executable", virtual .. "/bin/python3", true }
end
vim.lsp.config('pylsp', {
settings = {
["pylsp"] = {
enabled = true,
plugins = {
pycodestyle = {
ignore = { "E501", "E231", "W503" },
maxLineLength = 100,
},
pyls_isort = { enabled = true },
pylsp_mypy = {
enabled = true,
-- this will make mypy to use the virtual environment
-- if not activated then it will use the system python(more specifically /usr/bin/python3)
overrides = extra_args(),
report_progress = true,
live_mode = true,
},
},
}
}
})
vim.lsp.config('rust_analyzer', {
settings = {
["rust-analyzer"] = {
cargo = {
features = "all",
},
},
}
})
mason_lspconfig.setup()

View File

@ -0,0 +1,25 @@
local null_ls_status_ok, null_ls = pcall(require, "null-ls")
if not null_ls_status_ok then
return
end
local formatting = null_ls.builtins.formatting
local diagnostics = null_ls.builtins.diagnostics
null_ls.builtins.diagnostics.mypy.with({
extra_args = function()
local virtual = os.getenv("VIRTUAL_ENV") or "/usr"
return { "--python-executable", virtual .. "/bin/python3" }
end,
})
null_ls.setup({
debug = false,
sources = {
-- formatting.prettier.with({ extra_args = { "--no-semi", "--single-quote", "--jsx-single-quote" } }),
-- formatting.black.with({ extra_args = { "--fast" } }),
-- formatting.isort,
formatting.stylua,
-- diagnostics.mypy,
},
})

View File

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

View File

@ -1,11 +1,13 @@
return {
{
"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")
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")
which_key.add({
@ -115,7 +117,5 @@ return {
},
}
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 {
{
"nvim-treesitter/nvim-treesitter",
run = ":TSUpdate",
event = "VeryLazy",
build = ":TSUpdate",
lazy = false,
-- init = function(plugin)
-- require("nvim-treesitter")
-- 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" },
},
},
config = function()
config = function(_, opts)
local which_key = require("which-key")
which_key.setup(opts)
which_key.add({
{ "<leader>", group = "Hotkeys" },
{ "<leader>?", ":WhichKey <CR>", desc = "Show keybindings" },
@ -82,14 +84,6 @@ return {
{ "<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({
{ "<leader>g", group = "Git" },
{ "<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"
}