feat: convert to blink, major lsp changes, lualine
This commit is contained in:
parent
82102e5e29
commit
51ab444c0d
44 changed files with 1387 additions and 700 deletions
68
lua/lsp/keybindings.lua
Normal file
68
lua/lsp/keybindings.lua
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
-- LSP keybindings and autocmds
|
||||
-- Extracted from legacy lsp.lua plugin configuration
|
||||
|
||||
-- LSP attach autocmd with keybindings
|
||||
vim.api.nvim_create_autocmd('LspAttach', {
|
||||
group = vim.api.nvim_create_augroup('kickstart-lsp-attach', { clear = true }),
|
||||
callback = function(event)
|
||||
local map = function(keys, func, desc)
|
||||
vim.keymap.set('n', keys, func, { buffer = event.buf, desc = 'LSP: ' .. desc })
|
||||
end
|
||||
|
||||
-- Navigation keybindings
|
||||
map('gd', require('telescope.builtin').lsp_definitions, '[G]oto [D]efinition')
|
||||
map('gI', require('telescope.builtin').lsp_implementations, '[G]oto [I]mplementation')
|
||||
map('<leader>D', require('telescope.builtin').lsp_type_definitions, 'Type [D]efinition')
|
||||
map('<leader>ds', require('telescope.builtin').lsp_document_symbols, '[D]ocument [S]ymbols')
|
||||
map('<leader>ws', require('telescope.builtin').lsp_dynamic_workspace_symbols, '[W]orkspace [S]ymbols')
|
||||
map('<leader>rn', vim.lsp.buf.rename, '[R]e[n]ame')
|
||||
map('<leader>ca', vim.lsp.buf.code_action, '[C]ode [A]ction')
|
||||
|
||||
-- LSP gr
|
||||
map('grn', vim.lsp.buf.rename, '[R]e[n]ame') -- rename
|
||||
map('gra', vim.lsp.buf.code_action, '[G]oto Code [A]ction', { 'n', 'x' })
|
||||
map('grr', require('telescope.builtin').lsp_references, '[G]oto [R]eferences')
|
||||
map('gri', require('telescope.builtin').lsp_implementations, '[G]oto [I]mplementation')
|
||||
map('grd', require('telescope.builtin').lsp_definitions, '[G]oto [D]efinition') -- func def
|
||||
map('grD', vim.lsp.buf.declaration, '[G]oto [D]eclaration') -- header def
|
||||
map('grt', require('telescope.builtin').lsp_type_definitions, '[G]oto [T]ype Definition')
|
||||
map('gO', require('telescope.builtin').lsp_document_symbols, 'Open Document Symbols') -- open symbols
|
||||
map('gW', require('telescope.builtin').lsp_dynamic_workspace_symbols, 'Open Workspace Symbols') -- open ws
|
||||
|
||||
-- Document highlighting
|
||||
local client = vim.lsp.get_client_by_id(event.data.client_id)
|
||||
if client and client.supports_method(vim.lsp.protocol.Methods.textDocument_documentHighlight) then
|
||||
local highlight_augroup = vim.api.nvim_create_augroup('kickstart-lsp-highlight', { clear = false })
|
||||
vim.api.nvim_create_autocmd({ 'CursorHold', 'CursorHoldI' }, {
|
||||
buffer = event.buf,
|
||||
group = highlight_augroup,
|
||||
callback = vim.lsp.buf.document_highlight,
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd({ 'CursorMoved', 'CursorMovedI' }, {
|
||||
buffer = event.buf,
|
||||
group = highlight_augroup,
|
||||
callback = vim.lsp.buf.clear_references,
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd('LspDetach', {
|
||||
group = vim.api.nvim_create_augroup('kickstart-lsp-detach', { clear = true }),
|
||||
callback = function(event2)
|
||||
vim.lsp.buf.clear_references()
|
||||
vim.api.nvim_clear_autocmds { group = 'kickstart-lsp-highlight', buffer = event2.buf }
|
||||
end,
|
||||
})
|
||||
end
|
||||
|
||||
-- Inlay hints toggle
|
||||
if client and client.supports_method(vim.lsp.protocol.Methods.textDocument_inlayHint) then
|
||||
map('<leader>th', function()
|
||||
vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled { bufnr = event.buf })
|
||||
end, '[T]oggle Inlay [H]ints')
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
vim.keymap.set('n', '<leader>td', function()
|
||||
vim.diagnostic.enable(not vim.diagnostic.is_enabled())
|
||||
end, { silent = true, noremap = true, desc = '[d]iagnostics' })
|
||||
Loading…
Add table
Add a link
Reference in a new issue