30 lines
912 B
Lua
30 lines
912 B
Lua
-- wtf why does the language server protocol have these features?
|
|
-- partially stolen from https://github.com/glepnir/nvim
|
|
|
|
local misc = require("core.misc")
|
|
local auto = misc.auto
|
|
local wtf_group = misc.augroup("lsp.wtf")
|
|
|
|
auto('LspAttach', {
|
|
group = wtf_group,
|
|
callback = function(ctx)
|
|
local client = vim.lsp.get_client_by_id(ctx.data.client_id)
|
|
if not client then
|
|
return
|
|
end
|
|
|
|
-- highlight color codes via lsp (supported by cssls)
|
|
-- #ff0000
|
|
if client:supports_method('textDocument/documentColor') then
|
|
vim.lsp.document_color.enable(true, ctx.buf)
|
|
end
|
|
|
|
-- enable linked editing this allows lsps to modify things like html tags
|
|
-- for example when you change <p> to <a> </p> will be changed by the lsp
|
|
-- to </a>
|
|
if client:supports_method('textDocument/linkedEditingRange') then
|
|
vim.lsp.linked_editing_range.enable(true, { client_id = client.id })
|
|
end
|
|
end
|
|
})
|