kitchen sink...
just gonna put the changes that I can remember making here: - replace blink with native completion (omnifunc) - remove some unneeded plugins - add a misc function for making sure complex bindings don't cause flickering - remove some stale snippets - remove folding (I don't find myself folding that often)
This commit is contained in:
65
lua/core/lsp/binds.lua
Normal file
65
lua/core/lsp/binds.lua
Normal file
@ -0,0 +1,65 @@
|
||||
local misc = require("core.misc")
|
||||
local map, auto = misc.map, misc.auto
|
||||
|
||||
local function on_list(opts)
|
||||
vim.fn.setqflist({}, "r", opts)
|
||||
if #opts.items > 1 then
|
||||
vim.cmd.copen()
|
||||
|
||||
-- get to the closest reference to the cursor (likely the one gr or gd was
|
||||
-- called on)
|
||||
local closest, distance = 1, false
|
||||
for i, item in ipairs(opts.items) do
|
||||
if item.filename and vim.fn.expand("%:p") == item.filename then
|
||||
local lnum = vim.api.nvim_win_get_cursor(0)[1]
|
||||
if item.lnum then
|
||||
local new_distance = math.abs(lnum - item.lnum)
|
||||
if not distance or new_distance < distance then
|
||||
distance = new_distance
|
||||
closest = i
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
vim.cmd(".cc! "..closest)
|
||||
end
|
||||
else
|
||||
vim.cmd(".cc! 1")
|
||||
end
|
||||
end
|
||||
|
||||
-- disable the default keybinds (they're bad)
|
||||
for _, bind in ipairs({ "grn", "gra", "gri", "grr" }) do
|
||||
pcall(vim.keymap.del, "n", bind)
|
||||
end
|
||||
|
||||
local group = misc.augroup("lsp.bind")
|
||||
auto("LspAttach", {
|
||||
group = group,
|
||||
callback = function(ctx)
|
||||
local list_opts = { on_list = on_list }
|
||||
local opts = { buffer = ctx.buf, nowait = true }
|
||||
|
||||
-- LSP actions
|
||||
map("n", "K", vim.lsp.buf.hover, opts)
|
||||
map("n", "gd", function() vim.lsp.buf.definition(list_opts) end, opts)
|
||||
map("n", "gD", function() vim.lsp.buf.declaration(list_opts) end, opts)
|
||||
map("n", "gi", function() vim.lsp.buf.implementation(list_opts) end, opts)
|
||||
map("n", "gy", function() vim.lsp.buf.type_definition(list_opts) end, opts)
|
||||
map("n", "gr", function() vim.lsp.buf.references(nil, list_opts) end, opts)
|
||||
map("n", "<S-Tab>", vim.lsp.buf.signature_help, opts)
|
||||
map("n", { "<leader>r", "<F2>" }, vim.lsp.buf.rename, opts)
|
||||
map("n", { "gA", "<F4>" }, vim.lsp.buf.code_action, opts)
|
||||
|
||||
-- Diagnostics
|
||||
map("n", "[d", function()
|
||||
vim.diagnostic.jump({ count = -1 })
|
||||
end, opts)
|
||||
map("n", "]d", function()
|
||||
vim.diagnostic.jump({ count = 1 })
|
||||
end, opts)
|
||||
|
||||
-- formatting
|
||||
map("n", "<leader>c", vim.lsp.buf.format)
|
||||
end
|
||||
})
|
Reference in New Issue
Block a user