Nurbol Alpysbayev
Nurbol Alpysbayev

Reputation: 21891

Is it possible to make a proxy between IDE and language server?

Say, I want to slightly change the behavior of some language.

Can this be done? Has it been done before?

UPD: Typescript has very limited possibilites to work with property names (for example you can not with the help of typescript create a propname that is derived from another one, e.g. uppercased or with a prefix prepended), whereas Javascript (which is what Typescript compiles to) is very flexible. So I wanted with the help of LSP to modify some of the Typescript's LSP messages that carry autocompletion options.

Upvotes: 0

Views: 396

Answers (1)

Yes, but how to do that is operating system specific. From the compiler's point of view, the proxy would appear as your IDE. LSP is a network protocol

I want to slightly change the behavior of some language.

So you want to change the semantics of some language (and you don't tell which). Then LSP is not the best place to do so.

For example, in some simple cases, with GCC, writing your GCC plugin is more appropriate.

In most cases, changing the "behavior" is really changing the language itself. Then you might need to make your own implementation of that language. Sometimes, you might patch an existing free software implementation of the original languages. In other cases, you'll need to make your language implementation by yourself. Then read the Dragon Book and consider compiling or transpiling to C your language in your language implementation. Be sure to specify it on paper first.

Don't confuse a programming language (which is a specification, generally written in English - perhaps with some formalization in some specific notation, e.g. n1570 for C11, R5RS for Scheme) with its implementation (which is a software). Read Scott's Programming Language Pragmatics.

Don't confuse an IDE with a language implementation. For example, all C or C++ compilers I know about don't have any IDE and are command line programs (e.g. GCC, Clang, etc...), and most of them don't even know about LSP. The IDE might start the C++ compiler, but it is not a compiler. You can code (in C, C++, Java, C#, Ocaml, ....) with a plain source code editor (even a simple language-agnostic one such as Notepad on Windows, or Leafpad or nano on Linux).

Most programming languages are defining source programs as a set of "translation units", practically of "source files", each being a sequence of characters with some complex syntax and semantics. How these source files are created is outside of the scope of the programming language specification (you could use editors, you could write your own generators for these source files, ....)

LSP is a proposal for a protocol between "IDE"s and language implementations.

Notice that autocompletion (mentioned in your comment) is not a feature of the programming language (and is not part of the semantics of C or C++). It might be a feature of some IDEs (not all of them). It could be done in a language neutral way (e.g. in Emacs).

Upvotes: 1

Related Questions