mirror of
https://github.com/pnx/dotfiles
synced 2026-06-17 11:30:02 +02:00
new nvim config
This commit is contained in:
parent
4b730d3924
commit
7388c9bfd3
78 changed files with 1291 additions and 43 deletions
24
nvim-old/lua/plugins/ide/cmp.lua
Normal file
24
nvim-old/lua/plugins/ide/cmp.lua
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
return {
|
||||
'hrsh7th/nvim-cmp',
|
||||
version = false,
|
||||
event = "InsertEnter",
|
||||
dependencies = {
|
||||
'hrsh7th/cmp-buffer',
|
||||
'hrsh7th/cmp-path',
|
||||
'hrsh7th/cmp-nvim-lsp',
|
||||
'L3MON4D3/LuaSnip',
|
||||
'onsails/lspkind-nvim',
|
||||
},
|
||||
opts = require('config.plugins.cmp'),
|
||||
config = function(_, opts)
|
||||
local cmp = require('cmp')
|
||||
|
||||
cmp.setup(opts)
|
||||
|
||||
-- insert () on function completion using autopairs
|
||||
cmp.event:on(
|
||||
'confirm_done',
|
||||
require('nvim-autopairs.completion.cmp').on_confirm_done()
|
||||
)
|
||||
end
|
||||
}
|
||||
38
nvim-old/lua/plugins/ide/conform.lua
Normal file
38
nvim-old/lua/plugins/ide/conform.lua
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
local config = require('config.plugins.conform')
|
||||
|
||||
return {
|
||||
'stevearc/conform.nvim',
|
||||
dependencies = {
|
||||
"williamboman/mason.nvim",
|
||||
"zapling/mason-conform.nvim"
|
||||
},
|
||||
cmd = { "ConformInfo", "Format" },
|
||||
keys = config.keys or {},
|
||||
opts = config.opts or {},
|
||||
config = function (_, opts)
|
||||
|
||||
-- Create command to format a buffer or range.
|
||||
vim.api.nvim_create_user_command("Format", function(args)
|
||||
local range = nil
|
||||
if args.count ~= -1 then
|
||||
local end_line = vim.api.nvim_buf_get_lines(0, args.line2 - 1, args.line2, true)[1]
|
||||
range = {
|
||||
start = { args.line1, 0 },
|
||||
["end"] = { args.line2, end_line:len() },
|
||||
}
|
||||
end
|
||||
|
||||
local opt = opts.format_options
|
||||
if range ~= nil then
|
||||
opt = vim.tbl_deep_extend("force", opt, { range = range })
|
||||
end
|
||||
|
||||
require("conform").format(opt)
|
||||
end, { range = true })
|
||||
|
||||
require('conform').setup(opts)
|
||||
|
||||
-- setup mason-conform to autmagically install formatters.
|
||||
require('mason-conform').setup()
|
||||
end
|
||||
}
|
||||
18
nvim-old/lua/plugins/ide/copilot.lua
Normal file
18
nvim-old/lua/plugins/ide/copilot.lua
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
return {
|
||||
"zbirenbaum/copilot.lua",
|
||||
cmd = "Copilot",
|
||||
event = "InsertEnter",
|
||||
opts = {
|
||||
suggestion = {
|
||||
enabled = true,
|
||||
auto_trigger = true,
|
||||
keymap = {
|
||||
accept = "<C-F>",
|
||||
},
|
||||
},
|
||||
panel = {
|
||||
enabled = true,
|
||||
auto_refresh = true,
|
||||
},
|
||||
}
|
||||
}
|
||||
91
nvim-old/lua/plugins/ide/dap.lua
Normal file
91
nvim-old/lua/plugins/ide/dap.lua
Normal file
|
|
@ -0,0 +1,91 @@
|
|||
return {
|
||||
"mfussenegger/nvim-dap",
|
||||
dependencies = {
|
||||
{
|
||||
"folke/which-key.nvim",
|
||||
-- optional = true,
|
||||
opts = {
|
||||
defaults = {
|
||||
["<leader>D"] = { name = "+debug" },
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
"rcarriga/nvim-dap-ui",
|
||||
-- stylua: ignore
|
||||
keys = {
|
||||
{ "<leader>Dr", function() require("dap").continue({ }) end, desc = "Dap Run/Continue" },
|
||||
{ "<leader>Du", function() require("dapui").toggle({ }) end, desc = "Dap UI" },
|
||||
{ "<leader>De", function() require("dapui").eval() end, desc = "Eval", mode = {"n", "v"} },
|
||||
},
|
||||
opts = {},
|
||||
config = function(_, opts)
|
||||
-- setup dap config by VsCode launch.json file
|
||||
-- require("dap.ext.vscode").load_launchjs()
|
||||
local dap = require("dap")
|
||||
local dapui = require("dapui")
|
||||
dapui.setup(opts)
|
||||
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
|
||||
end,
|
||||
},
|
||||
},
|
||||
keys = {
|
||||
{ "<leader>Dw", function() require("dap.ui.widgets").hover() end, desc = "Widgets" },
|
||||
{ "<leader>Db", function() require'dap'.toggle_breakpoint() end, desc = "Toggle breakpoint" },
|
||||
},
|
||||
config = function()
|
||||
vim.api.nvim_set_hl(0, "DapStoppedLine", { default = true, link = "Visual" })
|
||||
|
||||
local dap = require "dap"
|
||||
dap.adapters.delve = {
|
||||
type = 'server',
|
||||
port = '${port}',
|
||||
executable = {
|
||||
command = 'dlv',
|
||||
args = {'dap', '-l', '127.0.0.1:${port}'},
|
||||
}
|
||||
}
|
||||
|
||||
dap.configurations.go = {
|
||||
{
|
||||
type = "delve",
|
||||
name = "Debug",
|
||||
request = "launch",
|
||||
program = "${file}"
|
||||
},
|
||||
{
|
||||
type = "delve",
|
||||
name = "Debug test", -- configuration for debugging test files
|
||||
request = "launch",
|
||||
mode = "test",
|
||||
program = "${file}"
|
||||
},
|
||||
-- works with go.mod packages and sub packages
|
||||
{
|
||||
type = "delve",
|
||||
name = "Debug test (go.mod)",
|
||||
request = "launch",
|
||||
mode = "test",
|
||||
program = "./${relativeFileDirname}"
|
||||
}
|
||||
}
|
||||
-- local Config = require("lazyvim.config")
|
||||
|
||||
|
||||
-- for name, sign in pairs(Config.icons.dap) do
|
||||
-- sign = type(sign) == "table" and sign or { sign }
|
||||
-- vim.fn.sign_define(
|
||||
-- "Dap" .. name,
|
||||
-- { text = sign[1], texthl = sign[2] or "DiagnosticInfo", linehl = sign[3], numhl = sign[3] }
|
||||
-- )
|
||||
-- end
|
||||
end,
|
||||
}
|
||||
1
nvim-old/lua/plugins/ide/glow.lua
Normal file
1
nvim-old/lua/plugins/ide/glow.lua
Normal file
|
|
@ -0,0 +1 @@
|
|||
return {"ellisonleao/glow.nvim", config = true, cmd = "Glow"}
|
||||
92
nvim-old/lua/plugins/ide/lsp.lua
Normal file
92
nvim-old/lua/plugins/ide/lsp.lua
Normal file
|
|
@ -0,0 +1,92 @@
|
|||
return {
|
||||
'neovim/nvim-lspconfig',
|
||||
dependencies = {
|
||||
'williamboman/mason.nvim',
|
||||
'williamboman/mason-lspconfig.nvim',
|
||||
'hrsh7th/cmp-nvim-lsp',
|
||||
{ 'folke/neodev.nvim', opts = {} },
|
||||
},
|
||||
opts = require('config.plugins.lsp'),
|
||||
config = function(_, opts)
|
||||
-- Setup Mason to automatically install LSP servers
|
||||
require('mason').setup()
|
||||
require('mason-lspconfig').setup({ automatic_installation = true })
|
||||
local augroup = vim.api.nvim_create_augroup("Lsp", {})
|
||||
local lspconfig = require('lspconfig')
|
||||
local capabilities = require('cmp_nvim_lsp').default_capabilities()
|
||||
capabilities.textDocument.completion.completionItem.snippetSupport = false
|
||||
|
||||
vim.lsp.handlers['textDocument/hover'] = vim.lsp.with(
|
||||
vim.lsp.handlers.hover,
|
||||
{ border = 'single' }
|
||||
)
|
||||
|
||||
vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, {
|
||||
focusable = true,
|
||||
style = "minimal",
|
||||
border = "single",
|
||||
})
|
||||
|
||||
vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with(
|
||||
vim.lsp.diagnostic.on_publish_diagnostics, {
|
||||
virtual_text = false,
|
||||
}
|
||||
)
|
||||
|
||||
for name, server_opt in pairs(opts.servers) do
|
||||
local on_attach = function(client, bufnr)
|
||||
for bind, settings in pairs(opts.mappings) do
|
||||
vim.keymap.set('n', bind, settings[1], vim.tbl_deep_extend("force", settings[2], { buffer = bufnr }))
|
||||
end
|
||||
|
||||
vim.api.nvim_clear_autocmds({ group = augroup, buffer = bufnr })
|
||||
|
||||
-- Add format on save if configured and client supports it.
|
||||
if server_opt.format_on_save and client.supports_method("textDocument/formatting") then
|
||||
vim.api.nvim_create_autocmd("BufWritePre", {
|
||||
group = augroup,
|
||||
buffer = bufnr,
|
||||
callback = function()
|
||||
vim.lsp.buf.format()
|
||||
end,
|
||||
})
|
||||
end
|
||||
|
||||
if server_opt.on_save then
|
||||
vim.api.nvim_create_autocmd("BufWritePre", {
|
||||
group = augroup,
|
||||
buffer = bufnr,
|
||||
callback = server_opt.on_save,
|
||||
})
|
||||
end
|
||||
|
||||
|
||||
if client.supports_method("textDocument/documentHighlight") then
|
||||
vim.api.nvim_create_autocmd("CursorHold", {
|
||||
group = augroup,
|
||||
buffer = bufnr,
|
||||
callback = function() vim.lsp.buf.document_highlight() end
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd("CursorHoldI", {
|
||||
group = augroup,
|
||||
buffer = bufnr,
|
||||
callback = function() vim.lsp.buf.document_highlight() end
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd("CursorMoved", {
|
||||
group = augroup,
|
||||
buffer = bufnr,
|
||||
callback = function() vim.lsp.buf.clear_references() end
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
lspconfig[name].setup({
|
||||
settings = server_opt.settings or {},
|
||||
capabilities = capabilities,
|
||||
on_attach = on_attach
|
||||
})
|
||||
end
|
||||
end
|
||||
}
|
||||
4
nvim-old/lua/plugins/ide/neodev.lua
Normal file
4
nvim-old/lua/plugins/ide/neodev.lua
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
return {
|
||||
"folke/neodev.nvim",
|
||||
opts = {}
|
||||
}
|
||||
58
nvim-old/lua/plugins/ide/neotest.lua
Normal file
58
nvim-old/lua/plugins/ide/neotest.lua
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
return {
|
||||
"nvim-neotest/neotest",
|
||||
dependencies = {
|
||||
"nvim-neotest/nvim-nio",
|
||||
"nvim-lua/plenary.nvim",
|
||||
"antoinemadec/FixCursorHold.nvim",
|
||||
"nvim-treesitter/nvim-treesitter",
|
||||
"nvim-neotest/neotest-go",
|
||||
"olimorris/neotest-phpunit",
|
||||
{
|
||||
"folke/which-key.nvim",
|
||||
optional = true,
|
||||
opts = {
|
||||
defaults = {
|
||||
["<leader>t"] = { name = "+test" },
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
keys = {
|
||||
{"<leader>tn", ":lua require('neotest').run.run()<cr>", desc = "test nearest", silent = true},
|
||||
{"<leader>tf", ":lua require('neotest').run.run(vim.fn.expand('%'))<cr>", desc = "test file"},
|
||||
{"<leader>ta", ":lua require('neotest').output_panel.open()<cr>:lua require('neotest').run.run({suite = true})<cr>", desc = "test all"},
|
||||
{"<leader>ts", ":lua require('neotest').run.stop()<cr>", desc = "stop test"},
|
||||
{"<leader>tq", ":lua require('neotest').output_panel.close()<cr>", desc = "close output window"},
|
||||
{"<leader>te", ":Neotest summary<cr>", desc = "Open test explorer"}
|
||||
},
|
||||
opts = function()
|
||||
local icons = require('config.icons').test
|
||||
|
||||
return {
|
||||
adapters = {
|
||||
require("neotest-go")({
|
||||
recursive_run = true
|
||||
}),
|
||||
require("neotest-phpunit")
|
||||
},
|
||||
icons = {
|
||||
child_indent = "│",
|
||||
child_prefix = "├",
|
||||
collapsed = "─",
|
||||
expanded = "┐",
|
||||
failed = icons.failed,
|
||||
final_child_indent = " ",
|
||||
final_child_prefix = "└",
|
||||
non_collapsible = "─",
|
||||
passed = icons.ok,
|
||||
running = icons.running,
|
||||
skipped = icons.skipped,
|
||||
unknown = icons.unknown,
|
||||
watching = icons.watch
|
||||
},
|
||||
summery = {
|
||||
open = "botleft vsplit"
|
||||
}
|
||||
}
|
||||
end
|
||||
}
|
||||
8
nvim-old/lua/plugins/ide/trouble.lua
Normal file
8
nvim-old/lua/plugins/ide/trouble.lua
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
local conf = require("config.plugins.trouble") or {}
|
||||
|
||||
return {
|
||||
"folke/trouble.nvim",
|
||||
dependencies = { "nvim-tree/nvim-web-devicons" },
|
||||
keys = conf.keys or {},
|
||||
opts = conf.opts or {},
|
||||
}
|
||||
6
nvim-old/lua/plugins/ide/undotree.lua
Normal file
6
nvim-old/lua/plugins/ide/undotree.lua
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
return {
|
||||
"mbbill/undotree",
|
||||
keys = {
|
||||
{"<leader>u", ":UndotreeToggle<CR>", desc = "Toggle undotree"},
|
||||
},
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue