adopt neovim 0.12 native editing features
This commit is contained in:
parent
fa39d0a36c
commit
282e5e0f0b
18 changed files with 125 additions and 215 deletions
|
|
@ -25,9 +25,5 @@ return {
|
|||
},
|
||||
})
|
||||
|
||||
-- Integration with nvim-cmp
|
||||
local cmp_autopairs = require('nvim-autopairs.completion.cmp')
|
||||
local cmp = require('cmp')
|
||||
cmp.event:on('confirm_done', cmp_autopairs.on_confirm_done())
|
||||
end,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,69 +0,0 @@
|
|||
return {
|
||||
"hrsh7th/nvim-cmp",
|
||||
event = "InsertEnter",
|
||||
dependencies = {
|
||||
"hrsh7th/cmp-nvim-lsp",
|
||||
"hrsh7th/cmp-buffer",
|
||||
"hrsh7th/cmp-path",
|
||||
"L3MON4D3/LuaSnip",
|
||||
"zbirenbaum/copilot-cmp", -- Copilot completion source
|
||||
},
|
||||
opts = function()
|
||||
local cmp = require("cmp")
|
||||
local luasnip = require("luasnip")
|
||||
|
||||
return {
|
||||
snippet = {
|
||||
expand = function(args)
|
||||
luasnip.lsp_expand(args.body)
|
||||
end,
|
||||
},
|
||||
mapping = cmp.mapping.preset.insert({
|
||||
["<C-Space>"] = cmp.mapping.complete(),
|
||||
["<CR>"] = cmp.mapping.confirm({ select = false }),
|
||||
["<C-n>"] = cmp.mapping.select_next_item(),
|
||||
["<C-p>"] = cmp.mapping.select_prev_item(),
|
||||
["<C-e>"] = cmp.mapping.abort(),
|
||||
}),
|
||||
sources = cmp.config.sources({
|
||||
{ name = "copilot", group_index = 2 }, -- Copilot suggestions (priority 1)
|
||||
{ name = "nvim_lsp", group_index = 2 },
|
||||
{ name = "path", group_index = 2 },
|
||||
{ name = "buffer", group_index = 2 },
|
||||
}),
|
||||
preselect = cmp.PreselectMode.None,
|
||||
completion = { completeopt = "menu,menuone,noinsert,noselect" },
|
||||
window = {
|
||||
completion = cmp.config.window.bordered({
|
||||
border = {
|
||||
{ "🭽", "FloatBorder" },
|
||||
{ "▔", "FloatBorder" },
|
||||
{ "🭾", "FloatBorder" },
|
||||
{ "▕", "FloatBorder" },
|
||||
{ "🭿", "FloatBorder" },
|
||||
{ "▁", "FloatBorder" },
|
||||
{ "🭼", "FloatBorder" },
|
||||
{ "▏", "FloatBorder" },
|
||||
},
|
||||
winhighlight = "Normal:Normal,FloatBorder:FloatBorder,CursorLine:PmenuSel",
|
||||
}),
|
||||
documentation = cmp.config.window.bordered({
|
||||
border = {
|
||||
{ "🭽", "FloatBorder" },
|
||||
{ "▔", "FloatBorder" },
|
||||
{ "🭾", "FloatBorder" },
|
||||
{ "▕", "FloatBorder" },
|
||||
{ "🭿", "FloatBorder" },
|
||||
{ "▁", "FloatBorder" },
|
||||
{ "🭼", "FloatBorder" },
|
||||
{ "▏", "FloatBorder" },
|
||||
},
|
||||
winhighlight = "Normal:Normal,FloatBorder:FloatBorder",
|
||||
}),
|
||||
},
|
||||
}
|
||||
end,
|
||||
config = function(_, opts)
|
||||
require("cmp").setup(opts)
|
||||
end,
|
||||
}
|
||||
|
|
@ -1,22 +1,23 @@
|
|||
-- GitHub Copilot: AI-powered code completion
|
||||
-- GitHub Copilot inline suggestions, separate from the native completion menu.
|
||||
return {
|
||||
{
|
||||
'zbirenbaum/copilot.lua',
|
||||
cmd = 'Copilot',
|
||||
event = 'InsertEnter', -- Lazy load on first insert mode entry
|
||||
opts = {
|
||||
suggestion = { enabled = false }, -- Disable inline suggestions (use cmp instead)
|
||||
panel = { enabled = false }, -- Disable panel (use cmp instead)
|
||||
filetypes = {
|
||||
['*'] = true, -- Enable for all filetypes
|
||||
'zbirenbaum/copilot.lua',
|
||||
cmd = 'Copilot',
|
||||
event = 'InsertEnter',
|
||||
opts = {
|
||||
suggestion = {
|
||||
enabled = true,
|
||||
auto_trigger = true,
|
||||
hide_during_completion = true,
|
||||
keymap = {
|
||||
accept = '<M-l>',
|
||||
next = '<M-]>',
|
||||
prev = '<M-[>',
|
||||
dismiss = '<C-]>',
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
'zbirenbaum/copilot-cmp',
|
||||
dependencies = { 'zbirenbaum/copilot.lua' },
|
||||
config = function()
|
||||
require('copilot_cmp').setup()
|
||||
end,
|
||||
panel = { enabled = false },
|
||||
filetypes = {
|
||||
['*'] = true,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,12 +1,7 @@
|
|||
return {
|
||||
"neovim/nvim-lspconfig",
|
||||
event = { "BufReadPre", "BufNewFile" },
|
||||
dependencies = {
|
||||
"hrsh7th/cmp-nvim-lsp",
|
||||
},
|
||||
config = function()
|
||||
local capabilities = require("cmp_nvim_lsp").default_capabilities()
|
||||
|
||||
-- Load trusted project-local LSP settings from .nvim.lua.
|
||||
local function load_project_lsp_settings(server_name, root_dir)
|
||||
if not root_dir then
|
||||
|
|
@ -66,6 +61,13 @@ return {
|
|||
-- Setup keymaps for this buffer
|
||||
setup_keymaps(args.buf)
|
||||
|
||||
if client:supports_method("textDocument/completion") then
|
||||
vim.lsp.completion.enable(true, client.id, args.buf)
|
||||
if vim.fn.has("nvim-0.12") == 1 then
|
||||
vim.bo[args.buf].complete = "o^20"
|
||||
end
|
||||
end
|
||||
|
||||
-- Load and send project-specific settings
|
||||
local project_settings = load_project_lsp_settings(client.name, client.root_dir)
|
||||
if project_settings.settings then
|
||||
|
|
@ -88,13 +90,8 @@ return {
|
|||
local function configure(server_name, opts)
|
||||
opts = opts or {}
|
||||
|
||||
-- Merge with defaults
|
||||
local config = vim.tbl_deep_extend("force", {
|
||||
capabilities = capabilities,
|
||||
}, opts)
|
||||
|
||||
-- Configure the server using the new API
|
||||
vim.lsp.config(server_name, config)
|
||||
vim.lsp.config(server_name, opts)
|
||||
end
|
||||
|
||||
-- Configure all servers
|
||||
|
|
|
|||
|
|
@ -131,19 +131,19 @@ return {
|
|||
-- Setup autotag
|
||||
require("nvim-ts-autotag").setup({
|
||||
opts = {
|
||||
enable_close = true, -- Auto close tags
|
||||
enable_rename = true, -- Auto rename pairs of tags
|
||||
enable_close_on_slash = true, -- Auto close on trailing </
|
||||
enable_close = false,
|
||||
enable_rename = false,
|
||||
enable_close_on_slash = false,
|
||||
},
|
||||
-- Limit to relevant filetypes
|
||||
-- Enable only in filetypes that can contain HTML-style tags.
|
||||
per_filetype = {
|
||||
["html"] = { enable_close = true },
|
||||
["php"] = { enable_close = true },
|
||||
["javascript"] = { enable_close = true },
|
||||
["javascriptreact"] = { enable_close = true },
|
||||
["typescript"] = { enable_close = true },
|
||||
["typescriptreact"] = { enable_close = true },
|
||||
["vue"] = { enable_close = true },
|
||||
["html"] = { enable_close = true, enable_rename = true, enable_close_on_slash = true },
|
||||
["php"] = { enable_close = true, enable_rename = true, enable_close_on_slash = true },
|
||||
["javascript"] = { enable_close = true, enable_rename = true, enable_close_on_slash = true },
|
||||
["javascriptreact"] = { enable_close = true, enable_rename = true, enable_close_on_slash = true },
|
||||
["typescript"] = { enable_close = true, enable_rename = true, enable_close_on_slash = true },
|
||||
["typescriptreact"] = { enable_close = true, enable_rename = true, enable_close_on_slash = true },
|
||||
["vue"] = { enable_close = true, enable_rename = true, enable_close_on_slash = true },
|
||||
},
|
||||
})
|
||||
end,
|
||||
|
|
|
|||
|
|
@ -1,15 +0,0 @@
|
|||
-- Phase 6.8: undotree for visual undo history
|
||||
return {
|
||||
'mbbill/undotree',
|
||||
cmd = 'UndotreeToggle', -- Lazy load on command
|
||||
keys = {
|
||||
{ '<leader>u', '<cmd>UndotreeToggle<cr>', desc = 'Undotree: Toggle undo tree' },
|
||||
},
|
||||
config = function()
|
||||
-- Configure undotree
|
||||
vim.g.undotree_WindowLayout = 2 -- Layout: diff at bottom
|
||||
vim.g.undotree_ShortIndicators = 1 -- Use short time indicators
|
||||
vim.g.undotree_SetFocusWhenToggle = 1 -- Focus undotree when toggled
|
||||
vim.g.undotree_DiffAutoOpen = 1 -- Auto open diff window
|
||||
end,
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue