Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 2 additions & 49 deletions lua/config/lsp.lua
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ vim.diagnostic.config({
jump = { on_jump = vim.diagnostic.open_float },
})

local u = require('utils')
local lsp_group = vim.api.nvim_create_augroup('my.lsp', { clear = true })

vim.api.nvim_create_autocmd('LspAttach', {
Expand All @@ -56,55 +57,13 @@ vim.api.nvim_create_autocmd('LspAttach', {
local client = assert(vim.lsp.get_client_by_id(ev.data.client_id))
local bufnr = ev.buf

local map = function(mode, lhs, rhs, opts)
opts = opts or {}
opts.buffer = bufnr
vim.keymap.set(mode, lhs, rhs, opts)
end

-- diagnostics
map('n', '<leader>D', vim.diagnostic.open_float)

-- completion
vim.lsp.completion.enable(true, client.id, bufnr)

-- navigation
if client:supports_method('textDocument/definition') then
map('n', 'gd', vim.lsp.buf.definition)
end

if client:supports_method('textDocument/declaration') then
map('n', 'gD', vim.lsp.buf.declaration)
end

if client:supports_method('textDocument/typeDefinition') then
map('n', '<leader>gt', vim.lsp.buf.type_definition)
end

if client:supports_method('textDocument/implementation') then
map('n', 'gri', vim.lsp.buf.implementation)
end

if client:supports_method('callHierarchy/incomingCalls') then
map('n', 'grI', vim.lsp.buf.incoming_calls)
end

-- editing
if client:supports_method('textDocument/rename') then
map('n', '<leader>R', vim.lsp.buf.rename)
end
u.map('n', '<leader>D', vim.diagnostic.open_float)

if client:supports_method('textDocument/onTypeFormatting') then
vim.lsp.on_type_formatting.enable()
end

map('i', '<M-s>', vim.lsp.buf.signature_help)

-- -- UI extras
-- if client:supports_method('textDocument/documentSymbol') then
-- require('nvim-navic').attach(client, bufnr)
-- end

if client:supports_method('textDocument/documentColor') then
vim.lsp.document_color.enable(true, bufnr)
end
Expand All @@ -113,12 +72,6 @@ vim.api.nvim_create_autocmd('LspAttach', {
vim.lsp.inlay_hint.enable(true)
end

if client:supports_method('textDocument/inlineCompletion') then
vim.lsp.inline_completion.enable(true, { bufnr = bufnr })
map('i', '<C-F>', vim.lsp.inline_completion.get, { desc = 'Accept inline completion' })
map('i', '<C-G>', vim.lsp.inline_completion.select, { desc = 'Cycle inline completion' })
end

if client:supports_method('textDocument/documentHighlight') then
vim.api.nvim_create_autocmd({ 'CursorHold', 'CursorHoldI' }, {
buffer = bufnr,
Expand Down