-- 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 pcall(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

to

will be changed by the lsp -- to if client:supports_method('textDocument/linkedEditingRange') then pcall(vim.lsp.linked_editing_range.enable, true, { client_id = client.id }) end -- disabled for now cause I don't like it -- -- enable type formatting which allows lsps to modify text while you're -- -- typing for example if you insert {} in a string in python basedpyright -- -- will change the string to a format string -- if client:supports_method('textDocument/onTypeFormatting') then -- pcall(vim.lsp.on_type_formatting.enable, true, { client_id = client.id }) -- end end })