2

Bored of VS Code? Try Lite-XL

 3 years ago
source link: https://betterprogramming.pub/bored-of-vs-code-try-lite-xl-76d4cb3f8dda
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Bored of VS Code? Try Lite-XL

Your tired computer will ask you to try a Visual Studio Code alternative, like Lite-XL

Image showing XCode vs. Lite-XL
Visual Studio Code vs. Lite-XL, a cover designed by the author with Canva.

I was a die-hard fan of Visual Studio Code for three years. But I started using a lightweight alternative called Lite after Visual Studio Code started behaving similar to Visual Studio by taking all the resources that other processes wished to take. Lite is a minimal code editor written in Lua and C. It is indeed implemented minimally as much as possible. The Lite editor core is an application that consists of a multi-line textbox made with the SDL graphics library. All the other modern code editor features, such as syntax highlighting, are made as plugins. It just takes one megabyte in your disk and consumes around 20 megabytes of physical memory.

However, it doesn’t offer all the required features for all developers. The maintainer of the Lite project mentioned that the project aims to provide something practical, pretty, small, and fast implemented as simply as possible — easy to modify and extend, or to use without doing either. In other words, the Lite editor itself may not deliver any features further, and if someone needs more features, they have to fork the source repository and extend.

Lite-XL is an actively maintained fork of the Lite editor, and it offers almost all basic productivity features that Visual Studio Code has. Three months ago, I wrote a story explaining how Lite-XL technically performs better than Visual Studio Code. In this story, I will take you through Lite-XL’s new features that make it better than Visual Studio Code.

Problems With Visual Studio Code

If Lite-XL is just a code editor that does the same job as your favorite Visual Studio Code, why should you try an alternative? Well, there is a considerable technical difference between both. Visual Studio Code is built on top of the Electron framework that lets developers build cross-platform desktop apps with web technologies. Visual Studio Code is a web application that runs inside a frameless native window.

On the other hand, Lite-XL is a native desktop application built with the SDL graphics library. Lite-XL works on Linux, macOS, and Windows because SDL is a cross-platform graphics library like Google’s Skia. SDL doesn’t render elements to a Chromium webview like Visual Studio Code, and it renders graphical elements natively via OpenGL or DirectX. One Lite-XL instance typically takes around 10 megabytes of physical memory — while one Visual Studio Code instance takes more than 400 megabytes. Visual Studio Code is adding new features to the editor core every day. Now it takes around 300 megabytes of disk space without any extensions, and we won’t wonder if it takes one gigabyte after several years.

Ever heard of VSCodium? Even though Visual Studio Code’s source code is MIT-licensed, Microsoft makes releases with a different non-FLOSS (Free/Libre and Open Source Software) license by adding a kind of commercial flavor that includes telemetry (tracking). The VSCodium project releases the latest binary builds with the MIT-licensed codebase. However, VSCodium is technically the same Visual Studio Code which consumes above-average resources.

In the worst-case scenarios, you may run multiple Visual Studio Code instances with other Electron-based hybrid desktop apps and a web browser. Then you might blame your computer’s hardware, but in reality, your computer became a playground for modern bloatware.

The following story addresses this modern bloatware issue further:

How To Customize Lite-XL As Visual Studio Code

As mentioned earlier, Lite-XL’s features (even the context menu and tree view) typically come as plugins. However, Lite-XL core includes several crucial features such as the status bar, command executor, and file search. Lite-XL is just a text editor without any plugin, as shown below:

1*9XX4OBiviEdkOJsahE0g7g.png?q=20
bored-of-vs-code-try-lite-xl-76d4cb3f8dda
Lite-XL core, a screenshot by the author.

It looks like this if we customize it similar to Visual Studio Code.

1*VKbtxvdc8SAzS15O2NxNgw.png?q=20
bored-of-vs-code-try-lite-xl-76d4cb3f8dda
Lite-XL is customized similar to Visual Studio Code, a screenshot by the author.

The memory usage will never go above 15 megabytes even after these customizations.

Let’s begin the Lite-XL customization process. First of all, make sure to download the latest Lite-XL version from GitHub releases. After that, open the preferences file (init.lua) and add the following line to enable Visual Studio Code’s default theme.

core.reload_module("colors.vscode-dark")

Every Lite-XL release has pre-installed plugins such as auto-complete, tree-view, context menu, syntax highlighting for some languages, etc. But you may need to install the following plugins to make it more like Visual Studio Code. Installing a Lite-XL plugin is a piece of cake. You can copy the plugin to the data/plugins directory and restart the editor to get a particular plugin activated. You can restart the editor with the command executer by pressing Ctrl + Shift + P.

1*8vUo8gEBC15oiEWB9lprjA.png?q=20
bored-of-vs-code-try-lite-xl-76d4cb3f8dda
The restart command in Lite-XL, a screenshot by the author.

Now, install the following plugins with the above method. All plugin source files are available here.

indentguide

The indent guide plugin draws a vertical line per each indentation, similar to Visual Studio Code.

minimap

This plugin renders a visual map of the source code on the right side of the editor, similar to Visual Studio Code. Visual Studio Code renders the source code map via an HTML canvas, but Lite-XL renders it natively. Therefore, the resources usage won’t go up when you work with larger files.

Additional syntax highlighting support

Lite-XL doesn’t include syntax highlighting support for all supported programming languages by default. For example, it doesn’t offer you JSX and TypeScript syntax highlighting support right after the installation process. Therefore, you need to install syntax highlighting plugins as you wish.

Conclusion

Visual Studio Code is backed by Microsoft and has a larger developer audience around it. But Lite-XL is new and still has a small developer audience (Still less than hundreds of members on Discord). Nowadays, native application development is so underrated and getting replaced by hybrid application development created by Electron. Hybrid application development frameworks motivate developers to make native-like hybrid apps so fast by hiding performance issues with modern hardware. However, frameworks/libraries like Flutter and SDL offer better performance-first solutions to develop cross-platform applications.

Also, cross-platform frameworks like Tauri and Neutralinojs try to give the Electron-like development environment with lightweight architectures. Lite-XL is built with SDL and is a truly native desktop app. Protect apps like these by using them because this could be the final era of native desktop apps.

Thanks for reading.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK