feat: add blink.cmp and disable custom completion pipeline
This commit is contained in:
+37
-3
@@ -99,9 +99,7 @@ vim.keymap.set("n", "gr", "<Nop>")
|
||||
vim.cmd.aunmenu({ "PopUp.-1-" })
|
||||
vim.cmd.aunmenu({ "PopUp.How-to\\ disable\\ mouse" })
|
||||
|
||||
-- Insert-mode Emacs bindings
|
||||
vim.keymap.set("i", "<C-f>", "<Right>")
|
||||
vim.keymap.set("i", "<C-b>", "<Left>")
|
||||
-- Insert-mode Emacs bindings (C-f/C-b live further down inside hover_scroll_map)
|
||||
vim.keymap.set("i", "<C-a>", "<C-o>^")
|
||||
vim.keymap.set("i", "<C-e>", function()
|
||||
-- Fall through to Vim's default (close popup + revert) during completion.
|
||||
@@ -160,8 +158,43 @@ vim.keymap.set("n", "K", function()
|
||||
vim.lsp.buf.hover({ max_width = 80 })
|
||||
end)
|
||||
vim.keymap.set({ "i", "s" }, "<C-s>", function()
|
||||
local winid = vim.b.lsp_floating_preview
|
||||
if winid and vim.api.nvim_win_is_valid(winid) then
|
||||
vim.api.nvim_win_close(winid, false)
|
||||
return
|
||||
end
|
||||
vim.lsp.buf.signature_help({ max_width = 80 })
|
||||
end)
|
||||
|
||||
---@param mode string | string[]
|
||||
---@param key string
|
||||
---@param direction "up" | "down"
|
||||
---@param count integer
|
||||
---@param fallback? string
|
||||
local function hover_scroll_map(mode, key, direction, count, fallback)
|
||||
vim.keymap.set(mode, key, function()
|
||||
local winid = vim.b.lsp_floating_preview
|
||||
if not winid or not vim.api.nvim_win_is_valid(winid) then
|
||||
return fallback or key
|
||||
end
|
||||
vim.schedule(function()
|
||||
local scroll_key = direction == "down" and vim.keycode("<C-e>")
|
||||
or vim.keycode("<C-y>")
|
||||
vim.api.nvim_win_call(winid, function()
|
||||
vim.cmd.normal({
|
||||
args = { count .. scroll_key },
|
||||
bang = true,
|
||||
})
|
||||
end)
|
||||
end)
|
||||
return ""
|
||||
end, { expr = true, replace_keycodes = true })
|
||||
end
|
||||
hover_scroll_map({ "n", "s" }, "<C-f>", "down", 5)
|
||||
hover_scroll_map({ "n", "s" }, "<C-b>", "up", 5)
|
||||
hover_scroll_map("i", "<C-f>", "down", 5, "<Right>")
|
||||
hover_scroll_map("i", "<C-b>", "up", 5, "<Left>")
|
||||
|
||||
---@param key string
|
||||
---@param dir 1 | -1
|
||||
local function snippet_jump_map(key, dir)
|
||||
@@ -174,6 +207,7 @@ local function snippet_jump_map(key, dir)
|
||||
end
|
||||
snippet_jump_map("<Tab>", 1)
|
||||
snippet_jump_map("<S-Tab>", -1)
|
||||
|
||||
vim.keymap.set({ "n", "i" }, "<C-h>", vim.lsp.buf.document_highlight)
|
||||
vim.keymap.set({ "n", "x" }, "<leader>lf", vim.lsp.buf.format)
|
||||
vim.keymap.set("n", "grl", function()
|
||||
|
||||
@@ -6,16 +6,9 @@ local GROUP = vim.api.nvim_create_augroup("ow.lsp.completion", { clear = true })
|
||||
|
||||
local popup = Popup.new()
|
||||
|
||||
local M = {}
|
||||
|
||||
---@param capabilities lsp.ClientCapabilities
|
||||
function M.apply_capabilities(capabilities)
|
||||
capabilities.textDocument.completion.completionItem.snippetSupport = true
|
||||
end
|
||||
|
||||
---@param client vim.lsp.Client
|
||||
---@param buf integer
|
||||
function M.on_attach(client, buf)
|
||||
local function on_attach(client, buf)
|
||||
if
|
||||
not client:supports_method(
|
||||
vim.lsp.protocol.Methods.textDocument_completion
|
||||
@@ -34,7 +27,29 @@ function M.on_attach(client, buf)
|
||||
})
|
||||
end
|
||||
|
||||
local M = {}
|
||||
|
||||
function M.setup()
|
||||
vim.lsp.config("*", {
|
||||
capabilities = {
|
||||
textDocument = {
|
||||
completion = {
|
||||
completionItem = { snippetSupport = true },
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd("LspAttach", {
|
||||
group = GROUP,
|
||||
callback = function(ev)
|
||||
local client = vim.lsp.get_client_by_id(ev.data.client_id)
|
||||
if client then
|
||||
on_attach(client, ev.buf)
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd("CompleteChanged", {
|
||||
group = GROUP,
|
||||
callback = function(ev)
|
||||
|
||||
+2
-6
@@ -4,7 +4,6 @@
|
||||
---@field context lsp.HandlerContext
|
||||
|
||||
local codelens = require("lsp.codelens")
|
||||
local completion = require("lsp.completion")
|
||||
local diagnostic = require("lsp.diagnostic")
|
||||
local log = require("log")
|
||||
|
||||
@@ -43,8 +42,6 @@ local function on_attach(client, buf)
|
||||
client.settings
|
||||
) or client.settings
|
||||
|
||||
completion.on_attach(client, buf)
|
||||
|
||||
vim.api.nvim_clear_autocmds({ group = GROUP, buffer = buf })
|
||||
vim.api.nvim_create_autocmd("LspProgress", {
|
||||
buffer = buf,
|
||||
@@ -91,8 +88,7 @@ function M.setup()
|
||||
"zls",
|
||||
})
|
||||
|
||||
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
||||
completion.apply_capabilities(capabilities)
|
||||
local capabilities = require("blink.cmp").get_lsp_capabilities({}, true)
|
||||
vim.lsp.config("*", {
|
||||
capabilities = capabilities,
|
||||
})
|
||||
@@ -107,7 +103,7 @@ function M.setup()
|
||||
end,
|
||||
})
|
||||
|
||||
completion.setup()
|
||||
-- require("lsp.completion").setup()
|
||||
codelens.setup()
|
||||
|
||||
vim.lsp.log.set_level(vim.log.levels.WARN)
|
||||
|
||||
Reference in New Issue
Block a user