Geany 2.x - IDE with LSP...


Geany 2.x - IDE with LSP...

Geany is my favorite text editor! I am using it for years and 95% of my scripts/projects are made with it. I like it's simplicity on the outside, but still powerful on the inside.

For sure it's not VIM and it doesn't need to be. For me it's exactly what i want, with the only exception, that until now, it lacked an LSP, aka Language Server Protocol. In short an LSP, is what gives your editor the ability to provide you, with help on the fly, about the syntax of a function, errors in your code etc.

With version 2.x Geany, has the ability to use such servers and improve a lot, your experience, programming with Geany. So let's install Geany 2.x and some LSPs...

Install Geany 2.x

Download the file at: Geany Releases

At the time i am writing this, version 2.1 is out and this is the version i installed, but even for future versions, the same commands would apply.

Extract the archive and go into the folder, where you extracted the files. Then type these commands to install Geany.

./configure 
make 
sudo make install

Do the same for the plugins. Download the tar.gz file, extract it and inside the folder, execute the above commands once again.

You should have installed, globally your version of Geany. Open it and play with the settings and activate some plugins. The most important, activate the LSP Client plugin.

Other plugins to install are:

  • addons
  • overview
  • tree file manager
  • vimode

Next, lets install LSP servers for BASH, Python and Lua. Similar you can find and install other LSPs for other languages.

BASH

The BASH, LSP can be found here BASH LSP. I preferred to use the snap method for simplicity. Just type:

sudo snap install bash-language-server --classic

Python

For Python, although is recommended to install pyright-python-langserver, i had troubles using it. It was installing fine, but when trying to use it with Geany, nothing worked. So i preferred to install pylsp. Just type:

pip install 'python-lsp-server[all]'

Lua

For Lua is a bit complicated. Download the .gz file that meets your architecture from the github repo. I used this folder: ~/.local/share/lua-lang-server. You can choose what ever directory you like. Extract the archive:

mkdir -p ~/.local/share/lua-lang-server 
tar --extract --file <YOUR .gz FILE> -av -C ~/.local/share/lua-lang-server

To be able to start the server from where ever in the system, create a symbolic link in ~/.local/bin to the executable. You can use other folder, but it must be a folder that is in the $PATH env. variable. To create the symbolic link type:

ln -s ~/.local/share/lua-lang-server/bin/lua-language-server ~/.local/bin/lua-language-server

Test it with lua-language-server

Config

After installing the server, we must configure some settings... nothing much. First, open Geany and open this menu: Tools > LSP Client > User Configuration

Inside the file, read the comments and activate/deactivate the settings you want, mainly in the [all] stanza. For example:

enable_by_default=true
use_without_project=true
use_outside_project_dir=true
...

Now go to the Python, Lus and Sh stanzas and make sure, in each stanza to remove the comment character from in front the command line of the LSP server we installed. For Lua and BASH, would be all ready activated, but for Python, comment this line:

#cmd=pyright-python-langserver --stdio

...and uncomment this.

cmd=pylsp

You are finished... restart Geany and open some files. Everything should work, just fine.

Add a comment

Previous