before change to base lazy

This commit is contained in:
Martin-Melody 2024-10-28 22:16:06 +00:00
parent c51b67a644
commit 3022b2eb12
6 changed files with 185 additions and 131 deletions

126
init.lua
View File

@ -89,6 +89,7 @@ P.S. You can delete this when you're done too. It's your config now! :)
-- NOTE: Must happen before plugins are loaded (otherwise wrong leader will be used) -- NOTE: Must happen before plugins are loaded (otherwise wrong leader will be used)
vim.g.mapleader = ' ' vim.g.mapleader = ' '
vim.g.maplocalleader = ' ' vim.g.maplocalleader = ' '
vim.g.lazyvim_picker = 'telescope'
-- Add the clipboard configuration for win32yank -- Add the clipboard configuration for win32yank
if vim.fn.has 'win32' == 1 or vim.fn.has 'win64' == 1 then if vim.fn.has 'win32' == 1 or vim.fn.has 'win64' == 1 then
@ -229,8 +230,7 @@ vim.keymap.set('n', '<C-k>', '<C-w><C-k>', { desc = 'Move focus to the upper win
-- [[ Custom Keymaps ]] -- [[ Custom Keymaps ]]
-- Keymap to close the current buffer but keep split windows open -- Keymap to close the current buffer but keep split windows open
vim.keymap.set('n', '<leader>bD', ':bp | bd #<CR>', { noremap = true, silent = true, desc = "Close buffer but keep split" }) vim.keymap.set('n', '<leader>bD', ':bp | bd #<CR>', { noremap = true, silent = true, desc = 'Close buffer but keep split' })
-- Vim Rest Console -- Vim Rest Console
vim.keymap.set('n', '<leader>r', ':Vrc<CR>', { noremap = true, silent = true }) vim.keymap.set('n', '<leader>r', ':Vrc<CR>', { noremap = true, silent = true })
@ -282,11 +282,32 @@ vim.opt.rtp:prepend(lazypath)
-- --
-- NOTE: Here is where you install your plugins. -- NOTE: Here is where you install your plugins.
require('lazy').setup({ require('lazy').setup({
spec = {
--spec = { -- add LazyVim and import its plugins
--{ 'LazyVim/LazyVim', import = 'lazyvim.plugins' }, { 'LazyVim/LazyVim', import = 'lazyvim.plugins' },
--{ import = 'custom.plugins' }, -- import/override with your plugins
--}, { import = 'custom.plugins' },
},
defaults = {
-- By default, only LazyVim plugins will be lazy-loaded. Your custom plugins will load during startup.
-- If you know what you're doing, you can set this to `true` to have all your custom plugins lazy-loaded by default.
lazy = false,
-- It's recommended to leave version=false for now, since a lot the plugin that support versioning,
-- have outdated releases, which may break your Neovim install.
version = false, -- always use the latest git commit
-- version = "*", -- try installing the latest stable version for plugins that support semver
},
install = { colorscheme = { 'catppuccin', 'habamax' } },
checker = {
enabled = true, -- check for plugin updates periodically
notify = false, -- notify on update
}, -- automatically check for plugin updates
performance = {
rtp = {
-- disable some rtp plugins
disabled_plugins = {},
},
},
-- NOTE: Plugins can be added with a link (or for a github repo: 'owner/repo' link). -- NOTE: Plugins can be added with a link (or for a github repo: 'owner/repo' link).
'tpope/vim-sleuth', -- Detect tabstop and shiftwidth automatically 'tpope/vim-sleuth', -- Detect tabstop and shiftwidth automatically
@ -384,7 +405,7 @@ require('lazy').setup({
{ -- Useful plugin to show you pending keybinds. { -- Useful plugin to show you pending keybinds.
'folke/which-key.nvim', 'folke/which-key.nvim',
event = 'VimEnter', -- Sets the loading event to 'VimEnter' event = 'VeryLazy', -- Sets the loading event to 'VimEnter'
config = function() -- This is the function that runs, AFTER loading config = function() -- This is the function that runs, AFTER loading
require('which-key').setup() require('which-key').setup()
@ -451,6 +472,7 @@ require('lazy').setup({
-- This opens a window that shows you all of the keymaps for the current -- This opens a window that shows you all of the keymaps for the current
-- Telescope picker. This is really useful to discover what Telescope can -- Telescope picker. This is really useful to discover what Telescope can
-- do as well as how to actually do it! -- do as well as how to actually do it!
-- [[ Configure Telescope ]] -- [[ Configure Telescope ]]
-- See `:help telescope` and `:help telescope.setup()` -- See `:help telescope` and `:help telescope.setup()`
require('telescope').setup { require('telescope').setup {
@ -510,9 +532,8 @@ require('lazy').setup({
builtin.find_files { cwd = vim.fn.stdpath 'config' } builtin.find_files { cwd = vim.fn.stdpath 'config' }
end, { desc = '[S]earch [N]eovim files' }) end, { desc = '[S]earch [N]eovim files' })
-- Shortcut for searching Obsidian files
vim.keymap.set('n', '<leader>so', function() vim.keymap.set('n', '<leader>so', function()
builtin.find_files { cwd = '~/Obsidian/vaults/' } telescope.builtin.find_files { cwd = '~/Obsidian/vaults/' }
end, { desc = '[S]earch [O]bsidian files' }) end, { desc = '[S]earch [O]bsidian files' })
end, end,
}, },
@ -801,12 +822,12 @@ require('lazy').setup({
-- `friendly-snippets` contains a variety of premade snippets. -- `friendly-snippets` contains a variety of premade snippets.
-- See the README about individual language/framework/plugin snippets: -- See the README about individual language/framework/plugin snippets:
-- https://github.com/rafamadriz/friendly-snippets -- https://github.com/rafamadriz/friendly-snippets
-- { {
-- 'rafamadriz/friendly-snippets', 'rafamadriz/friendly-snippets',
-- config = function() config = function()
-- require('luasnip.loaders.from_vscode').lazy_load() require('luasnip.loaders.from_vscode').lazy_load()
-- end, end,
-- }, },
}, },
}, },
'saadparwaiz1/cmp_luasnip', 'saadparwaiz1/cmp_luasnip',
@ -821,6 +842,7 @@ require('lazy').setup({
-- See `:help cmp` -- See `:help cmp`
local cmp = require 'cmp' local cmp = require 'cmp'
local luasnip = require 'luasnip' local luasnip = require 'luasnip'
require 'custom.snips' -- Ensure this points to where your custom snippets file is located
luasnip.config.setup {} luasnip.config.setup {}
cmp.setup { cmp.setup {
@ -831,64 +853,59 @@ require('lazy').setup({
}, },
completion = { completeopt = 'menu,menuone,noinsert' }, completion = { completeopt = 'menu,menuone,noinsert' },
-- For an understanding of why these mappings were
-- chosen, you will need to read `:help ins-completion`
--
-- No, but seriously. Please read `:help ins-completion`, it is really good!
mapping = cmp.mapping.preset.insert { mapping = cmp.mapping.preset.insert {
-- Select the [n]ext item -- Existing mappings
['<C-n>'] = cmp.mapping.select_next_item(), ['<C-n>'] = cmp.mapping.select_next_item(),
-- Select the [p]revious item
['<C-p>'] = cmp.mapping.select_prev_item(), ['<C-p>'] = cmp.mapping.select_prev_item(),
-- Scroll the documentation window [b]ack / [f]orward
['<C-b>'] = cmp.mapping.scroll_docs(-4), ['<C-b>'] = cmp.mapping.scroll_docs(-4),
['<C-f>'] = cmp.mapping.scroll_docs(4), ['<C-f>'] = cmp.mapping.scroll_docs(4),
-- Accept ([y]es) the completion.
-- This will auto-import if your LSP supports it.
-- This will expand snippets if the LSP sent a snippet.
['<C-y>'] = cmp.mapping.confirm { select = true }, ['<C-y>'] = cmp.mapping.confirm { select = true },
-- If you prefer more traditional completion keymaps,
-- you can uncomment the following lines
--['<CR>'] = cmp.mapping.confirm { select = true },
--['<Tab>'] = cmp.mapping.select_next_item(),
--['<S-Tab>'] = cmp.mapping.select_prev_item(),
-- Manually trigger a completion from nvim-cmp.
-- Generally you don't need this, because nvim-cmp will display
-- completions whenever it has completion options available.
['<C-Space>'] = cmp.mapping.complete {}, ['<C-Space>'] = cmp.mapping.complete {},
-- Think of <c-l> as moving to the right of your snippet expansion. -- LuaSnip keybindings
-- So if you have a snippet that's like: ['<C-j>'] = cmp.mapping(function()
-- function $name($args) if luasnip.expand_or_jumpable() then
-- $body luasnip.expand_or_jump()
-- end end
-- end, { 'i', 's' }), -- Jump forward in the snippet
-- <c-l> will move you to the right of each of the expansion locations.
-- <c-h> is similar, except moving you backwards. ['<C-k>'] = cmp.mapping(function()
if luasnip.jumpable(-1) then
luasnip.jump(-1)
end
end, { 'i', 's' }), -- Jump backward in the snippet
['<C-l>'] = cmp.mapping(function() ['<C-l>'] = cmp.mapping(function()
if luasnip.expand_or_locally_jumpable() then if luasnip.expand_or_locally_jumpable() then
luasnip.expand_or_jump() luasnip.expand_or_jump()
end end
end, { 'i', 's' }), end, { 'i', 's' }),
['<C-h>'] = cmp.mapping(function() ['<C-h>'] = cmp.mapping(function()
if luasnip.locally_jumpable(-1) then if luasnip.locally_jumpable(-1) then
luasnip.jump(-1) luasnip.jump(-1)
end end
end, { 'i', 's' }), end, { 'i', 's' }),
-- For more advanced Luasnip keymaps (e.g. selecting choice nodes, expansion) see: -- Optionally, you could add Tab and Shift-Tab to cycle through items or placeholders
-- https://github.com/L3MON4D3/LuaSnip?tab=readme-ov-file#keymaps ['<Tab>'] = cmp.mapping(function(fallback)
if luasnip.expand_or_jumpable() then
luasnip.expand_or_jump()
else
fallback()
end
end, { 'i', 's' }),
['<S-Tab>'] = cmp.mapping(function(fallback)
if luasnip.jumpable(-1) then
luasnip.jump(-1)
else
fallback()
end
end, { 'i', 's' }),
}, },
-- Additional sources for completion
sources = { sources = {
{
name = 'lazydev',
-- set group index to 0 to skip loading LuaLS completions as lazydev recommends it
group_index = 0,
},
{ name = 'nvim_lsp' }, { name = 'nvim_lsp' },
{ name = 'luasnip' }, { name = 'luasnip' },
{ name = 'path' }, { name = 'path' },
@ -1115,6 +1132,9 @@ require('lazy').setup({
-- Completion -- Completion
require 'custom.plugins.completion', require 'custom.plugins.completion',
-- lspsaga
require 'custom.plugins.lspsaga',
}, { }, {
ui = { ui = {
-- If you are using a Nerd Font: set icons to an empty table which will use the -- If you are using a Nerd Font: set icons to an empty table which will use the

View File

@ -1,6 +1,13 @@
{ {
"extras": [ "extras": [
"lazyvim.plugins.extras.coding.luasnip",
"lazyvim.plugins.extras.coding.yanky",
"lazyvim.plugins.extras.editor.overseer",
"lazyvim.plugins.extras.lang.angular",
"lazyvim.plugins.extras.lang.json",
"lazyvim.plugins.extras.lang.markdown",
"lazyvim.plugins.extras.lang.typescript",
"lazyvim.plugins.extras.util.dot"
], ],
"news": { "news": {
"NEWS.md": "6520" "NEWS.md": "6520"

View File

@ -2,116 +2,65 @@ return {
{ {
'mfussenegger/nvim-dap', 'mfussenegger/nvim-dap',
dependencies = { dependencies = {
'leoluz/nvim-dap-go',
'rcarriga/nvim-dap-ui', 'rcarriga/nvim-dap-ui',
'theHamsta/nvim-dap-virtual-text', 'theHamsta/nvim-dap-virtual-text',
'nvim-neotest/nvim-nio', 'williamboman/mason.nvim', -- for installing netcoredbg
'williamboman/mason.nvim',
}, },
config = function() config = function()
local dap = require 'dap' local dap = require 'dap'
local ui = require 'dapui' local dapui = require 'dapui'
require('dapui').setup() -- Setup DAP UI
require('dap-go').setup() dapui.setup()
require('nvim-dap-virtual-text').setup {} require('nvim-dap-virtual-text').setup()
-- Configuration for .NET Core (ASP.NET Core) using net8.0 -- CoreCLR Adapter Configuration for .NET
dap.adapters.coreclr = { dap.adapters.coreclr = {
type = 'executable', type = 'executable',
command = '/usr/local/bin/netcoredbg/netcoredbg', -- Update with the correct path to netcoredbg command = '/usr/local/bin/netcoredbg/netcoredbg',
args = { '--interpreter=vscode' }, args = { '--interpreter=vscode' },
} }
-- DAP Configuration for .NET Core
dap.configurations.cs = { dap.configurations.cs = {
{ {
type = 'coreclr', type = 'coreclr',
name = 'Launch ASP.NET Core', name = 'Launch .NET Core Web API',
request = 'launch', request = 'launch',
preLaunchTask = function()
-- Run the project before launching the debugger
local build_cmd = 'dotnet publish --configuration Debug --runtime linux-x64 --self-contained'
print('Running: ' .. build_cmd)
vim.fn.system(build_cmd)
end,
program = function() program = function()
local cwd = vim.fn.getcwd() return vim.fn.input('Path to dll: ', vim.fn.getcwd() .. '/bin/Debug/net8.0/linux-x64/MelodyFitnessApi.dll', 'file')
local dll = vim.fn.glob(cwd .. '/bin/Debug/net8.0/linux-x64/MelodyFitnessApi.dll', 0, 1)
if #dll == 0 then
print 'No DLL found in bin/Debug/net8.0/linux-x64'
return ''
end
print('Using program: ' .. dll[1])
return dll[1]
end, end,
cwd = '${workspaceFolder}', cwd = '${workspaceFolder}',
stopAtEntry = false, stopAtEntry = false,
console = 'integratedTerminal',
}, },
{ {
type = 'coreclr', type = 'coreclr',
name = 'Attach ASP.NET Core', name = 'Attach to .NET Core',
request = 'attach', request = 'attach',
processId = require('dap.utils').pick_process, processId = require('dap.utils').pick_process,
cwd = '${workspaceFolder}', cwd = '${workspaceFolder}',
}, },
} }
-- Configuration for Ionic Angular (JavaScript/TypeScript) using Firefox -- Key mappings for debugging
dap.adapters.chrome = { vim.keymap.set('n', '<F5>', dap.continue)
type = 'executable', vim.keymap.set('n', '<F10>', dap.step_over)
command = 'node', vim.keymap.set('n', '<F11>', dap.step_into)
args = { os.getenv 'HOME' .. '/.vscode/extensions/vscode-chrome-debug/out/src/chromeDebug.js' }, vim.keymap.set('n', '<F12>', dap.step_out)
} vim.keymap.set('n', '<Leader>b', dap.toggle_breakpoint)
dap.configurations.javascript = { vim.keymap.set('n', '<Leader>B', function()
{ dap.set_breakpoint(vim.fn.input 'Breakpoint condition: ')
type = 'chrome',
name = 'Attach to Chrome (Ionic App)',
request = 'attach',
program = '${file}',
cwd = vim.fn.getcwd(),
sourceMaps = true,
protocol = 'inspector',
port = 9222, -- Port where Chrome is listening
url = 'https://localhost:8100/login', -- URL of your running Ionic app
webRoot = '${workspaceFolder}',
timeout = 20000, -- Optional: Increase if you experience timeouts
address = '0.0.0.0',
},
}
dap.configurations.typescript = dap.configurations.javascript
vim.keymap.set('n', '<space>tb', dap.toggle_breakpoint)
vim.keymap.set('n', '<space>gb', dap.run_to_cursor)
vim.keymap.set('n', '<space>?', function()
require('dapui').eval(nil, { enter = true })
end) end)
vim.keymap.set('n', '<F1>', dap.continue) -- Automatically open/close DAP UI on start/end
vim.keymap.set('n', '<F2>', dap.step_into) dap.listeners.after.event_initialized['dapui_config'] = function()
vim.keymap.set('n', '<F3>', dap.step_over) dapui.open()
vim.keymap.set('n', '<F4>', dap.step_out)
vim.keymap.set('n', '<F5>', dap.step_back)
vim.keymap.set('n', '<F12>', dap.restart)
-- Key mapping to toggle the DAP UI
vim.keymap.set('n', '<Leader>dui', function()
ui.toggle()
end)
dap.listeners.before.attach.dapui_config = function()
ui.open()
end end
dap.listeners.before.launch.dapui_config = function() dap.listeners.before.event_terminated['dapui_config'] = function()
ui.open() dapui.close()
end end
dap.listeners.before.event_terminated.dapui_config = function() dap.listeners.before.event_exited['dapui_config'] = function()
ui.close() dapui.close()
end
dap.listeners.before.event_exited.dapui_config = function()
ui.close()
end end
end, end,
}, },

View File

@ -0,0 +1,45 @@
return {
'nvimdev/lspsaga.nvim',
dependencies = {
'nvim-tree/nvim-web-devicons',
'nvim-treesitter/nvim-treesitter',
},
config = function()
-- Setup lspsaga with your custom settings
require('lspsaga').setup {
use_saga_diagnostic_sign = true,
error_sign = 'E',
warn_sign = 'W',
hint_sign = 'H',
infor_sign = 'I',
code_action_icon = '💡',
finder_action_keys = {
open = 'o',
vsplit = 's',
split = 'i',
quit = 'q',
scroll_down = '<C-f>',
scroll_up = '<C-b>',
},
code_action_keys = {
quit = 'q',
exec = '<CR>',
},
rename_action_quit = '<C-c>',
definition_preview_icon = '🔍',
border_style = 'round',
rename_prompt_prefix = '',
}
-- Add custom key mappings for lspsaga
local opts = { noremap = true, silent = true }
-- Key mappings for lspsaga actions
vim.api.nvim_set_keymap('n', '<leader>ca', ':Lspsaga code_action<CR>', opts) -- Code action
vim.api.nvim_set_keymap('n', '<leader>rn', ':Lspsaga rename<CR>', opts) -- Rename
vim.api.nvim_set_keymap('n', 'gh', ':Lspsaga hover_doc<CR>', opts) -- Hover doc
vim.api.nvim_set_keymap('n', 'gd', ':Lspsaga lsp_finder<CR>', opts) -- LSP finder
vim.api.nvim_set_keymap('n', '[e', ':Lspsaga diagnostic_jump_prev<CR>', opts) -- Previous diagnostic
vim.api.nvim_set_keymap('n', ']e', ':Lspsaga diagnostic_jump_next<CR>', opts) -- Next diagnostic
end,
}

32
lua/custom/snips.lua Normal file
View File

@ -0,0 +1,32 @@
local ls = require 'luasnip'
local s = ls.snippet
local t = ls.text_node
local f = ls.function_node
-- Function to generate the namespace based on the file path
local function generate_namespace()
local file_path = vim.fn.expand '%:p:h' -- Get the file path of the current buffer
-- Adjust 'src' or 'project_root' based on your directory structure
local namespace = file_path:gsub('.*src[\\/]', ''):gsub('[\\/]', '.') -- Replace slashes with dots
return 'namespace ' .. namespace
end
-- Function to get the file name (without extension) as the class name
local function get_class_name()
return vim.fn.expand '%:t:r' -- Get the file name without the extension
end
-- Snippet for C# class generation
ls.add_snippets('cs', {
s('myclass', { -- Updated the trigger from 'class' to 'myclass'
-- Insert the namespace based on the file path
f(generate_namespace, {}),
t { '', '' }, -- Line break after namespace
-- Generate class name based on file name
t 'public class ',
f(get_class_name, {}),
t { '', '{', '\t' },
ls.insert_node(0), -- Cursor here
t { '', '}' }, -- End of class
}),
})

View File

@ -16,6 +16,7 @@ return {
opts = { opts = {
filesystem = { filesystem = {
window = { window = {
position = 'float',
mappings = { mappings = {
['\\'] = 'close_window', ['\\'] = 'close_window',
-- Add a new key mapping to open a terminal in a floating window -- Add a new key mapping to open a terminal in a floating window