当前位置: 首页 > 编程日记 > 正文

服务器云ide_语言服务器协议如何影响IDE的未来

服务器云ide

The release of Visual Studio Code single-handedly impacted the developer ecosystem in such a way that there's no going back now. It's open source, free, and most importantly, a super powerful tool.

Visual Studio Code的发布以一种无可匹敌的方式对开发人员生态系统产生了单方面的影响。 它是开源的,免费的,而且最重要的是,它是一个超级强大的工具。

But with VSCode, Microsoft gave life to another super important thing back in 2016, which is less well-known. It is called Language Server Protocol.

但是,借助VSCode,微软早在2016年就实现了另一个超级重要的东西,这鲜为人知。 它称为语言服务器协议。

什么是语言服务器协议? (What is Language Server Protocol?)

Language Server Protocol (LSP) is a protocol or a way of talking to language servers (just like HTTP or FTP).

语言服务器协议(LSP)是一种协议或与语言服务器对话的方式(就像HTTP或FTP一样)。

Language servers are special programs that run on regular servers. They take in the meta state of editor in which you're coding (for example, where your cursor is currently inside the editor, which token you're hovering over right now), and return a set of actions/instructions – what token should appear next, what should happen when you CMD/Ctrl-click that token, and so on.

语言服务器是在常规服务器上运行的特殊程序。 它们采用您正在编码的编辑器的元状态(例如,光标当前位于编辑器中的位置,您现在将鼠标悬停在哪个标记上),并返回一组操作/指令–应该使用什么标记出现在接下来,当您按CMD / Ctrl键单击该令牌时会发生什么,依此类推。

This communication happens using a set of rules defined by the protocol. Language Server Protocol could be thought of as a trimmed down version of HTTP and communicates only on JSON-RPC.

使用协议定义的一组规则进行通信。 可以将语言服务器协议视为HTTP的精简版本,并且仅在JSON-RPC上进行通信。

为什么需要LSP? (Why is LSP required?)

You see those fancy autosuggestion and error messages popping up in VSCode all the time? And how, just by adding a simple extension from the VSCode marketplace, you get all that IntelliSense power for a completely different language like C, Python, Java, and so on? That comes from LSP.

您会一直在VSCode中看到那些花哨的自动提示和错误消息吗? 以及如何通过仅从VSCode市场添加一个简单的扩展,就如何为完全不同的语言(如C,Python,Java等)获得所有IntelliSense的功能? 那来自LSP。

Support for autocompletion and IntelliSense for HTML/CSS/JavaScript comes baked into VSCode (just like PyCharm comes baked in with Python support). However, the same support for other languages can be implemented using Language Server Protocol for those languages.

VSCode支持对自动完成和IntelliSenseHTML / CSS / JavaScript支持(就像PyCharm随Python支持一起包含)一样。 但是,可以使用其他语言的语言服务器协议来实现对其他语言的相同支持。

什么是JSON-RPC? (What is JSON-RPC?)

JSON-RPC stands for JSON Remote Procedure Call. It is an architecture (similar to how REST is an architecture) but with the fundamental unit being a procedure call rather than an API endpoint in the case of REST.

JSON-RPC代表JSON远程过程调用。 它是一种体系结构(类似于REST的体系结构),但基本单元是过程调用而不是REST的API端点。

Here's a simple payload for JSON-RPC:

这是JSON-RPC的简单有效负载:

// Request
curl -X POST —data '{"jsonrpc": "2.0","method": "runThisFunction","params": [ "some-param", 2 ],"id": 1
}'
// Response
{"jsonrpc": "2.0","result": "codedamn","id": 1
}

In this example we're sending a JSON encoded payload following RPC specification. If the server is configured to handle JSON-RPC correctly, it will execute the method runThisFunction with the passed parameters and return the result in the form as shown.

在此示例中,我们将按照RPC规范发送JSON编码的有效负载。 如果服务器配置为正确处理JSON-RPC,它将使用传递的参数执行方法runThisFunction ,并以所示形式返回结果。

LSP + JSON-RPC (LSP + JSON-RPC)

LSP uses JSON-RPC to communicate to remote server. It follows this:

LSP使用JSON-RPC与远程服务器进行通信。 它遵循此:

Content-Length: <bytes of JSON>\r\n\r\n<json-payload>

To write an example, it'll be like this:

写一个例子,就像这样:

Content-Length: 78{"jsonrpc":"2.0","method":"runThisFunction","params":["some-param",2],"id":1}

The LSP requires you to pass the Content-Length header followed by 2 CRLF tokens \r\n. When the running language servers like ccls receive this, they'll respond with an appropriate message:

LSP要求您传递Content-Length标头,后跟2个CRLF令牌\r\n 。 当运行中的语言服务器(如ccls收到此消息时,它们将以适当的消息响应:

Of course, in the example above, you can see that ccls says that there is no method called runThisFunction. But you can see that the remote server also responds with a Content-Length header with a JSON-RPC specification.

当然,在上面的示例中,您可以看到ccls表示没有名为runThisFunction方法。 但是您可以看到,远程服务器还使用Content-Length标头和JSON-RPC规范进行响应。

为什么这一切都重要? (Why does all this matter?)

With the introduction of a formal protocol LSP, Microsoft reduced the famous M x N problem to an M + N problem.

通过引入正式协议LSP,Microsoft将著名的M x N问题简化为M + N问题。

M = Different languages (C, C++, PHP, Python, Node, Swift, Go, etc.)N = Different editors (VSCode, Eclipse, Notepad++, Sublime Text, etc.)

M =不同的语言(C,C ++,PHP,Python,Node,Swift,Go等)N =不同的编辑器(VSCode,Eclipse,Notepad ++,Sublime Text等)

Previously, for M editors to support N languages, you need M*N solutions. That is, every editor had to implement native support for every language differently.

以前,要使M个编辑器支持N种语言,您需要M * N解决方案。 也就是说,每个编辑者必须以不同的方式实现对每种语言的本机支持。

With the introduction of LSP, the editor only needed to implement support for the Language Server Protocol. Once it did, anyone who makes a language server (following the LSP standards) can be seamlessly integrated with the editor, without the editor ever intelligently "knowing" what language it is working with!

随着LSP的引入,编辑器仅需要实现对语言服务器协议的支持。 完成后,任何制作语言服务器(遵循LSP标准)的人都可以与编辑器无缝集成,而无需编辑器智能地“知道”它使用的语言!

IDE的未来 (The future of IDEs)

As more and more languages come out with their language servers, people will have more ability to choose the editor they like best.

随着越来越多的语言与他们的语言服务器一起出现,人们将拥有更多选择最喜欢的编辑器的能力。

No longer will you have to stick to only XCode for Swift development, or PyCharm for Python. Not only this, but LSPs can also be implemented straight into JavaScript to support IntelliSense in the browser like I'm doing at codedamn, a platform for developers to learn and grow! It's an exciting time to be alive!

您将不再只需要为Swift开发而坚持使用XCode或为Python而坚持使用PyCharm。 不仅如此,而且LSP也可以直接在JavaScript中实现,以在浏览器中支持IntelliSense,就像我在codedamn (开发人员学习和成长的平台)所做的那样 ! 这是活着令人兴奋的时刻!

Peace,Mehul

和平,回h

翻译自: https://www.freecodecamp.org/news/language-server-protocol-and-the-future-of-ide/

服务器云ide

相关文章:

仅需6步,教你轻易撕掉app开发框架的神秘面纱(6):各种公共方法及工具类的封装

为什么要封装公共方法 封装公共方法有2方面的原因&#xff1a; 一是功能方面的原因&#xff1a;有些方法很多地方都会用&#xff0c;而且它输入输出明确&#xff0c;并且跟业务逻辑无关。比如检查用户是否登录&#xff0c;检查某串数字是否为合法的手机号。像这种方法就应该封…

MySQL优化配置之query_cache_size

原理MySQL查询缓存保存查询返回的完整结果。当查询命中该缓存&#xff0c;会立刻返回结果&#xff0c;跳过了解析&#xff0c;优化和执行阶段。 查询缓存会跟踪查询中涉及的每个表&#xff0c;如果这写表发生变化&#xff0c;那么和这个表相关的所有缓存都将失效。 但是随着服…

request.getSession()

request.getSession(); 与request.getSession(false);区别 服务器把session信息发送给浏览器 浏览器会将session信息存入本地cookie中 服务器本地内存中也会留一个此session信息 以后用户发送请求时 浏览器都会把session信息发送给服务器 服务器会依照浏览器发送过来的se…

alpine 交互sh_在这个免费的交互式教程中学习Alpine JS

alpine 交互shAlpine.js is a rugged, minimal framework for composing Javascript behavior in your markup. Thats right, in your markup! Alpine.js是一个坚固的最小框架&#xff0c;用于在标记中构成Javascript行为。 是的&#xff0c;在您的标记中&#xff01; It allo…

浅谈 MVP in Android

一、概述 对于MVP&#xff08;Model View Presenter&#xff09;&#xff0c;大多数人都能说出一二&#xff1a;“MVC的演化版本”&#xff0c;“让Model和View完全解耦”等等。本篇博文仅是为了做下记录&#xff0c;提出一些自己的看法&#xff0c;和帮助大家如何针对一个Acti…

test markdown

test test public void main(String[] args){System.out.println("test"); } 转载于:https://www.cnblogs.com/cozybz/p/5427053.html

java开发工具对比eclipse·myeclipse·idea

eclipse:不说了&#xff0c;习惯了 myeclipse&#xff1a;MyEclipse更适合企业开发者&#xff0c;更团队开发 idea:idea更适合个人开发者,细节优化更好转载于:https://www.cnblogs.com/gjack/p/8136964.html

软件测试质量过程检测文档_如何编写实际上有效的质量检查文档

软件测试质量过程检测文档A software product is like an airplane: it must undergo a technical check before launch.软件产品就像飞机&#xff1a;必须在发射前经过技术检查。 Quality Assurance is a necessary step towards launching a successful software product. I…

Android深度探索--HAL与驱动开发----第一章读书笔记

1.1 Android拥有非常完善的系统构架可以分为四层&#xff1a; 第一层&#xff1a;Linux内核。主要包括驱动程序以及管理内存、进程、电源等资源的程序 第二层&#xff1a;C/C代码库。主要包括Linux的.so文件以及嵌入到APK程序中的NDK代码 第三层&#xff1a;android SDK API …

[NOI2011]Noi嘉年华

题解:我们设计状态方程如下: num[i][j]表示从时间i到j中有多少个 pre[i][j]表示时间1~i中,A选了j个时的B能选的数量的最大值. nex[i][j]表示时间i~cnt中,A选了j个时的B能选的数量的最大值. mus[i][j]表示从时间i到j的保证选时,A和B选的数量中的较小值的最大值. ①对于num数组直…

只有20%的iOS程序员能看懂:详解intrinsicContentSize 及 约束优先级/content Hugging/content Compression Resistance

在了解intrinsicContentSize之前&#xff0c;我们需要先了解2个概念&#xff1a; AutoLayout在做什么约束优先级是什么意思。 如果不了解这两个概念&#xff0c;看intinsic content size没有任何意义。 注&#xff1a;由于上面这几个概念都是针对UIView或其子类(UILabel&…

redux rxjs_可观察的RxJS和Redux入门指南

redux rxjsRedux-Observable is an RxJS-based middleware for Redux that allows developers to work with async actions. Its an alternative to redux-thunk and redux-saga.Redux-Observable是Redux的基于RxJS的中间件&#xff0c;允许开发人员使用异步操作。 它是redux-t…

javascript数组排序和prototype详解

原型的概念:&#xff1a;原型对象里的所有属性和方法 被所有构造函数实例化出来的对象所共享&#xff0c;类似于java中的 static 正因为共享所以单一的操作 就会影响了全局&#xff0c;因此使用时需注意 基于prototype&#xff1a;为数组扩展方法 //获取数组最大值function get…

Qt 在Label上面绘制罗盘

自己写的一个小小的电子罗盘的一个小程序&#xff0c;不过是项目的一部分&#xff0c;只可以贴绘制部分代码 效果如下图 首先开始自己写的时候&#xff0c;虽然知道Qt 的坐标系是从左上角开始的&#xff0c;所以&#xff0c;使用了算法&#xff0c;在绘制后&#xff0c;在移动回…

终极方案!解决正确设置LaunchImage后仍然不显示的问题

对于如何设置LaunchImage&#xff0c;网络上有各种各样的教程。 主要分2点&#xff1a; 1. 正确设置图片尺寸 2. 取消LaunchScreen.xib 但是经过上述步骤之后&#xff0c;你觉得完全没有问题了&#xff0c;但是仍然无法显示LaunchImage。 或者&#xff0c;你在多个模拟器上…

c# 持续集成 单元测试_如何在不进行单元测试的情况下设置持续集成

c# 持续集成 单元测试Do you think continuous integration is not for you because you have no automated tests? Or no unit tests at all? Not true. Tests are important. But there are many more aspects to continuous integration than just testing. Lets see what…

Handlebars模板引擎

介绍 Handlebars 是 JavaScript 一个语义模板库&#xff0c;通过对view和data的分离来快速构建Web模板。它采用"Logic-less template"&#xff08;无逻辑模版&#xff09;的思路&#xff0c;在加载时被预编译&#xff0c;而不是到了客户端执行到代码时再去编译&#…

字符集图标制作

字符集图标&#xff1a; 将网页上常见的icon做成font&#xff08;字符集&#xff09;&#xff0c;以字体的方式插入到网页上&#xff0c;作用是减轻服务器负担&#xff0c;减少宽带。 我最常在这两个网站上下载字体图标&#xff1a; https://icomoon.io/app/#/select https://w…

Adobe源码泄漏?3行代码搞定,Flash动画无缝导入Android/iOS/cocos2dx(一)

[注] iOS代码已重构&#xff0c;效率提升90%&#xff0c;200层动画不卡。[2016.10.27] 项目介绍 项目名称&#xff1a;FlashAnimationToMobile 源码。 使用方法点这里。 这是一个把flash中的关键帧动画(不是序列帧)导出&#xff0c;然后在iOS&#xff0f;Android原生应用中解…

背景图像位置css_CSS背景图像大小教程–如何对整页背景图像进行编码

背景图像位置cssThis tutorial will show you a simple way to code a full page background image using CSS. And youll also learn how to make that image responsive to your users screen size.本教程将向您展示一种使用CSS编写整页背景图像的简单方法。 您还将学习如何使…

复习es6-解构赋值+字符串的扩展

1. 数组的解构赋值 从数组中获得变量的值&#xff0c;给对应的声明变量赋值,&#xff0c;有次序和对应位置赋值 解构赋值的时候右边必须可以遍历 解构赋值可以使用默认值 惰性求值&#xff0c;当赋值时候为undefined时候&#xff0c;默认是个函数就会执行函数 2.对象解构赋值 与…

Adobe源码泄漏?3行代码搞定,Flash动画无缝导入Android/iOS/cocos2dx(二)

[注] iOS代码已重构&#xff0c;效率提升90%&#xff0c;200层动画不卡。[2016.10.27] 上一篇 点此阅读 简要介绍了FlashToAnimation的功能&#xff0c;也就是将flash动画无缝导入到Android/iOS及cocos2dx中运行, 这一篇介绍这个库的使用方法。点此查看源码。 准备工作 首先…

the user operation is waiting for building workspace to complete解决办法

如果你在开发android应用程序中总是出现一个提示&#xff0c;显示“the user operation is waiting for "building workspace" to complete”&#xff0c;解决办法如下&#xff1a; 1.选择菜单栏的“Project”,然后把菜单栏中“Build Automatically”前面的对钩去掉。…

ios开发趋势_2020年将成为iOS应用开发的主要趋势

ios开发趋势Technology has always brought something new with time. And with these ever-changing technologies, you need to stay updated to get all the benefits from whats new. 随着时间的流逝&#xff0c;技术总是带来新的东西。 借助这些不断变化的技术&#xff0c…

http 权威指南 目录

第一部分 HTTP&#xff1a;Web的基础 第1章 HTTP概述 1.1 HTTP——因特网的多媒体信使 1.2 Web客户端和服务器 1.3 资源 1.3.1 媒体类型 1.3.2 URI 1.3.3 URL 1.3.4 URN 1.4 事务 1.4.1 方法 1.4.2 状态码 1.4.3 Web页面中可以包含多个对象 1.5 报文 1.6 连接 1.6.1 TCP/IP 1.6…

java初学者笔记总结day9

异常的概念throwable&#xff1a;异常&#xff0c;程序非正常执行的情况error&#xff1a;错误&#xff0c;程序非正常执行的情况&#xff0c;这种问题不能处理&#xff0c;或不应该处理exception&#xff1a;例外&#xff0c;程序非正常执行的情况&#xff0c;这种问题可以通过…

1小时学会:最简单的iOS直播推流(一)介绍

最简单的iOS 推流代码&#xff0c;视频捕获&#xff0c;软编码(faac&#xff0c;x264)&#xff0c;硬编码&#xff08;aac&#xff0c;h264&#xff09;&#xff0c;美颜&#xff0c;flv编码&#xff0c;rtmp协议&#xff0c;陆续更新代码解析&#xff0c;你想学的知识这里都有…

leetcode dfs_深度优先搜索:具有6个Leetcode示例的DFS图遍历指南

leetcode dfsHave you ever solved a real-life maze? The approach that most of us take while solving a maze is that we follow a path until we reach a dead end, and then backtrack and retrace our steps to find another possible path. 您是否解决了现实生活中的迷…

MySQL排序原理与MySQL5.6案例分析【转】

本文来自&#xff1a;http://www.cnblogs.com/cchust/p/5304594.html&#xff0c;其中对于自己觉得是重点的加了标记&#xff0c;方便自己查阅。更多详细的说明可以看沃趣科技的文章说明。 前言 排序是数据库中的一个基本功能&#xff0c;MySQL也不例外。用户通过Order by…

7.RabbitMQ RFC同步调用

RabbitMQ RFC同步调用是使用了两个异步调用完成的&#xff0c;生产者调用消费者的同时&#xff0c;自己也作为消费者等待某一队列的返回消息&#xff0c;消费者接受到生产者的消息同时&#xff0c;也作为消息发送者发送一消息给生产者。参考下图&#xff1a; 调用流程如下&…