kitchen sink
This commit is contained in:
90
lua/core/lsp/functions.lua
Normal file
90
lua/core/lsp/functions.lua
Normal file
@ -0,0 +1,90 @@
|
||||
local misc = require('core.misc')
|
||||
local map = misc.map
|
||||
|
||||
local M = {}
|
||||
|
||||
function M.setup()
|
||||
vim.diagnostic.config {
|
||||
virtual_text = false,
|
||||
virtual_lines = {
|
||||
only_current_line = true,
|
||||
},
|
||||
signs = true,
|
||||
update_in_insert = false,
|
||||
underline = true,
|
||||
severity_sort = true
|
||||
}
|
||||
|
||||
vim.lsp.handlers['textDocument/hover'] = vim.lsp.with(
|
||||
vim.lsp.handlers.hover, { border = 'solid' })
|
||||
|
||||
vim.lsp.handlers['textDocument/signatureHelp'] = vim.lsp.with(
|
||||
vim.lsp.handlers.signature_help, { border = 'solid' })
|
||||
|
||||
for _, v in pairs({
|
||||
{ "DiagnosticSignError", "x" },
|
||||
{ "DiagnosticSignWarn", "!" },
|
||||
{ "DiagnosticSignInfo", "i" },
|
||||
{ "DiagnosticSignHint", "h" }
|
||||
}) do
|
||||
vim.fn.sign_define(v[1], { text = v[2], texthl = v[1] })
|
||||
end
|
||||
end
|
||||
|
||||
--- generate client capabilities for lsp servers
|
||||
---@return table capabilities
|
||||
function M.capabilities()
|
||||
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
||||
capabilities.textDocument.completion.completionItem = {
|
||||
snippetSupport = true,
|
||||
preselectSupport = true,
|
||||
insertReplaceSupport = true,
|
||||
labelDetailsSupport = true,
|
||||
deprecatedSupport = true,
|
||||
commitCharactersSupport = true,
|
||||
tagSupport = {
|
||||
valueSet = { 1 }
|
||||
},
|
||||
resolveSupport = {
|
||||
properties = {
|
||||
"documentation",
|
||||
"detail",
|
||||
"additionalTextEdits"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return capabilities
|
||||
end
|
||||
|
||||
--- setup basic options on lsp attach
|
||||
---@param client number client number
|
||||
---@param bufnr number buffer number
|
||||
function M.attach(client, bufnr)
|
||||
local opts = { buffer = bufnr }
|
||||
-- LSP actions
|
||||
map('n', 'K', vim.lsp.buf.hover, opts)
|
||||
map('n', 'gd', vim.lsp.buf.definition, opts)
|
||||
map('n', 'gD', vim.lsp.buf.declaration)
|
||||
map('n', 'gi', vim.lsp.buf.implementation, opts)
|
||||
map('n', 'gy', vim.lsp.buf.type_definition, opts)
|
||||
map('n', 'gr', vim.lsp.buf.references, opts)
|
||||
map('n', '<S-Tab>', vim.lsp.buf.signature_help, opts)
|
||||
map('n', '<leader>r', vim.lsp.buf.rename, opts)
|
||||
map('n', '<F2>', vim.lsp.buf.rename, opts)
|
||||
map('n', 'gA', vim.lsp.buf.code_action, {
|
||||
buffer = bufnr,
|
||||
desc = 'check code actions',
|
||||
})
|
||||
map('n', '<F4>', vim.lsp.buf.code_action, {
|
||||
buffer = bufnr,
|
||||
desc = 'check code actions'
|
||||
})
|
||||
|
||||
-- Diagnostics
|
||||
map('n', '[d', vim.diagnostic.goto_prev, opts)
|
||||
map('n', ']d', vim.diagnostic.goto_next, opts)
|
||||
-- map('n', 'qD', vim.diagnostic.setqflist, opts)
|
||||
end
|
||||
|
||||
return M
|
@ -1,3 +1,3 @@
|
||||
function file_name(args, parent, user_args)
|
||||
function file_name(_, _, _)
|
||||
return vim.fn.expand("%:t:r")
|
||||
end
|
||||
|
Reference in New Issue
Block a user