mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-01-23 17:50:04 +08:00
style(lsp): format lsp.lua
This commit is contained in:
parent
83a6f0c608
commit
a392dc347b
@ -5,71 +5,71 @@ M.clients = {}
|
|||||||
-- which can be called via vim.lsp.start_client()
|
-- which can be called via vim.lsp.start_client()
|
||||||
|
|
||||||
function M.register(filetype, cmd)
|
function M.register(filetype, cmd)
|
||||||
M.clients[filetype] = {
|
M.clients[filetype] = {
|
||||||
['cmd'] = cmd
|
['cmd'] = cmd,
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
local function spliteof(data, delimiter)
|
local function spliteof(data, delimiter)
|
||||||
local result = { }
|
local result = {}
|
||||||
local from = 1
|
local from = 1
|
||||||
local delim_from, delim_to = string.find( data, delimiter, from )
|
local delim_from, delim_to = string.find(data, delimiter, from)
|
||||||
while delim_from do
|
while delim_from do
|
||||||
table.insert( result, string.sub( data, from , delim_from-1 ) )
|
table.insert(result, string.sub(data, from, delim_from - 1))
|
||||||
from = delim_to + 1
|
from = delim_to + 1
|
||||||
delim_from, delim_to = string.find( data, delimiter, from )
|
delim_from, delim_to = string.find(data, delimiter, from)
|
||||||
end
|
end
|
||||||
table.insert( result, string.sub( data, from ) )
|
table.insert(result, string.sub(data, from))
|
||||||
return result
|
return result
|
||||||
end
|
end
|
||||||
--
|
--
|
||||||
-- if data.contents is a string and not empty
|
-- if data.contents is a string and not empty
|
||||||
-- silent put =a:data
|
-- silent put =a:data
|
||||||
-- return 'markdown'
|
-- return 'markdown'
|
||||||
-- if data
|
-- if data
|
||||||
function M.hover_callback(success, data)
|
function M.hover_callback(success, data)
|
||||||
if not success then
|
if not success then
|
||||||
vim.api.nvim_command('call SpaceVim#util#echoWarn("Failed to retrieve hover information")')
|
vim.api.nvim_command('call SpaceVim#util#echoWarn("Failed to retrieve hover information")')
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
if (type(data.contents) == "table") then
|
if type(data.contents) == 'table' then
|
||||||
vim.api.nvim_command('leftabove split __lspdoc__')
|
vim.api.nvim_command('leftabove split __lspdoc__')
|
||||||
vim.api.nvim_command('set filetype=markdown.lspdoc')
|
vim.api.nvim_command('set filetype=markdown.lspdoc')
|
||||||
vim.api.nvim_command('setlocal nobuflisted')
|
vim.api.nvim_command('setlocal nobuflisted')
|
||||||
vim.api.nvim_command('setlocal buftype=nofile')
|
vim.api.nvim_command('setlocal buftype=nofile')
|
||||||
vim.api.nvim_command('setlocal bufhidden=wipe')
|
vim.api.nvim_command('setlocal bufhidden=wipe')
|
||||||
vim.api.nvim_buf_set_lines(0, 0, -1, 0, spliteof(data.contents.value, "\n"))
|
vim.api.nvim_buf_set_lines(0, 0, -1, 0, spliteof(data.contents.value, '\n'))
|
||||||
elseif type(data.contents) == 'string' and data.contents ~= '' then
|
elseif type(data.contents) == 'string' and data.contents ~= '' then
|
||||||
-- for k, v in pairs(data) do
|
-- for k, v in pairs(data) do
|
||||||
-- print(k .. " - " .. v)
|
-- print(k .. " - " .. v)
|
||||||
-- kind is filetype
|
-- kind is filetype
|
||||||
-- value is contents string
|
-- value is contents string
|
||||||
-- end
|
-- end
|
||||||
vim.api.nvim_command('leftabove split __lspdoc__')
|
vim.api.nvim_command('leftabove split __lspdoc__')
|
||||||
vim.api.nvim_command('set filetype=markdown.lspdoc')
|
vim.api.nvim_command('set filetype=markdown.lspdoc')
|
||||||
vim.api.nvim_command('setlocal nobuflisted')
|
vim.api.nvim_command('setlocal nobuflisted')
|
||||||
vim.api.nvim_command('setlocal buftype=nofile')
|
vim.api.nvim_command('setlocal buftype=nofile')
|
||||||
vim.api.nvim_command('setlocal bufhidden=wipe')
|
vim.api.nvim_command('setlocal bufhidden=wipe')
|
||||||
vim.api.nvim_buf_set_lines(0, 0, -1, 0, spliteof(data.contents, "\n"))
|
vim.api.nvim_buf_set_lines(0, 0, -1, 0, spliteof(data.contents, '\n'))
|
||||||
elseif type(data.contents.language) ~= 'string' and data.contents.language ~= '' then
|
elseif type(data.contents.language) ~= 'string' and data.contents.language ~= '' then
|
||||||
vim.api.nvim_command('leftabove split __lspdoc__')
|
vim.api.nvim_command('leftabove split __lspdoc__')
|
||||||
vim.api.nvim_command('set filetype=markdown.lspdoc')
|
vim.api.nvim_command('set filetype=markdown.lspdoc')
|
||||||
vim.api.nvim_command('setlocal nobuflisted')
|
vim.api.nvim_command('setlocal nobuflisted')
|
||||||
vim.api.nvim_command('setlocal buftype=nofile')
|
vim.api.nvim_command('setlocal buftype=nofile')
|
||||||
vim.api.nvim_command('setlocal bufhidden=wipe')
|
vim.api.nvim_command('setlocal bufhidden=wipe')
|
||||||
vim.api.nvim_buf_set_lines(0, 0, -1, 0, {'```' .. data.contents.language})
|
vim.api.nvim_buf_set_lines(0, 0, -1, 0, { '```' .. data.contents.language })
|
||||||
vim.api.nvim_buf_set_lines(0, 1, -1, 0, spliteof(data.contents, "\n"))
|
vim.api.nvim_buf_set_lines(0, 1, -1, 0, spliteof(data.contents, '\n'))
|
||||||
vim.api.nvim_buf_set_lines(0, -1, -1, 0, {'```'})
|
vim.api.nvim_buf_set_lines(0, -1, -1, 0, { '```' })
|
||||||
elseif type(data.contents.kind) ~= 'string' and data.contents.kind ~= '' then
|
elseif type(data.contents.kind) ~= 'string' and data.contents.kind ~= '' then
|
||||||
vim.api.nvim_command('leftabove split __lspdoc__')
|
vim.api.nvim_command('leftabove split __lspdoc__')
|
||||||
vim.api.nvim_command('set filetype=' .. data.contents.kind .. '.lspdoc')
|
vim.api.nvim_command('set filetype=' .. data.contents.kind .. '.lspdoc')
|
||||||
vim.api.nvim_command('setlocal nobuflisted')
|
vim.api.nvim_command('setlocal nobuflisted')
|
||||||
vim.api.nvim_command('setlocal buftype=nofile')
|
vim.api.nvim_command('setlocal buftype=nofile')
|
||||||
vim.api.nvim_command('setlocal bufhidden=wipe')
|
vim.api.nvim_command('setlocal bufhidden=wipe')
|
||||||
vim.api.nvim_buf_set_lines(0, 0, -1, 0, spliteof(data.contents, "\n"))
|
vim.api.nvim_buf_set_lines(0, 0, -1, 0, spliteof(data.contents, '\n'))
|
||||||
else
|
else
|
||||||
print('No hover information found')
|
print('No hover information found')
|
||||||
end
|
end
|
||||||
-- print(type(data))
|
-- print(type(data))
|
||||||
end
|
end
|
||||||
return M
|
return M
|
||||||
|
Loading…
Reference in New Issue
Block a user