I'm using Geany Nightly (Windows). I can't find it on Plugin Manager. I want to configure Geany to use Clangd for C/C++ code completion. Please help.
The plugin hasn't been merged to the geany-plugins repository yet so there are no nightlies.
That said, you could try the artifact of the pull request. At the bottom of the page here
https://github.com/geany/geany-plugins/actions/runs/12050135179
you can find the installer with the plugin.
In fact, I'm super-curious how/if it runs under Windows - nobody had the courage to try it yet ;-). Please let me know how it goes.
`libjpeg-8.dll` is missing. Can't even run Geany!
Also missing `libtiff-6.dll`, `libdeflate.dll`, `libjbig-0.dll`, `libLerc.dll`, `libwebp-7.dll`, and `libsharpyuv-0.dll`.
This isn't related to the plugin itself, I suspect it might be some problem with the installer. I've rebased the pull request on top of master which might contain some fix (at least there seems to be some commit related to Windows). Try the installer from here:
https://github.com/geany/geany-plugins/actions/runs/12055317340
Nothing changed. Note: I downloaded the file geany-plugins-installer-ci-23e3699-pr1331-merge.zip, it contains both Geany and Geany Plugins. I uninstall my locally installed Geany and Geany Plugins to install them.
No idea, sorry.
@eht16 Any idea what could be wrong or missing? The plugin has no external dependency so I doubt it's caused by it.
Probably some dependencies changed and we need to update the gtk bundle script. See also https://github.com/geany/geany/issues/4084#issuecomment-2504789070.
I have some bad news regarding the LSP plugin on Windows - I was able to install geany-plugins from some older installer I had but I did run in the following problems when launching the LSP server using gsubprocess: 1. I was getting "Failed to execute child process" - after searching for the problem, I found https://discourse.gnome.org/t/g-subprocess-new-behavior-on-windows/22189 which suggested to copy gspawn-win64-helper.exe and gspawn-win64-helper-console.exe under bin which I did from the glib msys2 package. 2. After that, the server process started, but in a separate console window and it seems that the server process uses the console's stdin/stdout. I need to be able to read/write from/to the server using stdin/stdout using G_SUBPROCESS_FLAGS_STDIN_PIPE | G_SUBPROCESS_FLAGS_STDOUT_PIPE parameters of gsubprocess but I'm not even sure if these are supported because the unit tests don't test them on Windows.
So it's a question whether the LSP plugin will be available on Windows.
- I was getting "Failed to execute child process" - after searching
for the problem, I found https://discourse.gnome.org/t/g-subprocess-new-behavior-on-windows/22189 which suggested to copy gspawn-win64-helper.exe and gspawn-win64-helper-console.exe under bin which I did from the glib msys2 package.
Those should be included already though in https://github.com/geany/geany/blob/master/scripts/gtk-bundle-from-msys2.sh#... we still have "win32". Maybe I missed to update ir accordingly.
I'll have a look at the weekend.
- After that, the server process started, but in a separate console
window and it seems that the server process uses the console's stdin/stdout. I need to be able to read/write from/to the server using stdin/stdout using G_SUBPROCESS_FLAGS_STDIN_PIPE | G_SUBPROCESS_FLAGS_STDOUT_PIPE parameters of gsubprocess but I'm not even sure if these are supported because the unit tests don't test them on Windows.
Ohhhh. Did you try Geany's spawn API (`spawn_async_with_pipes` etc.)? IIRC these use Windows native APIs on Windows and maybe this helps.
Admittedly, I have no clue about LSP but some how intuitively I assumed the client and server communicate via network. Could this be a solution, to (at least on Windows) have the plugin talk to the server via TCP/UDP/whatever network protocol?
Those should be included already though in
https://github.com/geany/geany/blob/master/scripts/gtk-bundle-from-msys2.sh#... we still have "win32". Maybe I missed to update ir accordingly.
No, `gspawn-win64-helper.exe` and `gspawn-win64-helper-console.exe` seem to be missing from the script.
Ohhhh.
Did you try Geany's spawn API (`spawn_async_with_pipes` etc.)? IIRC these use Windows native APIs on Windows and maybe this helps.
I'm afraid that for jsonrpc-glib I need the GIOStream interface which I get from gsubprocess using https://docs.gtk.org/gio/ctor.SimpleIOStream.new.html. But there's nothing like that in the spawn API.
That said, I have an idea (or hope at least). I've only been testing this on an arm64 VM under macOS. This means that the Geany x86_64 process is emulated there (works surprisingly well) and launches an arm64 server (I tested it with the go LSP) so what happens is that there's this launch sequence: ``` Geany (x86_64) -> gspawn-win64-helper.exe (x86_64) -> gopls (arm64) ``` So something emulation-related can go wrong on the way and it may work correctly on a x86_64 native machine (I'll try to test it if I survive Windows update on that machine after 1 year of inactivity).
Admittedly, I have no clue about LSP but some how intuitively I assumed
the client and server communicate via network. Could this be a solution, to (at least on Windows) have the plugin talk to the server via TCP/UDP/whatever network protocol?
Some servers support TCP/IP communication but typically stdin/stdout is used (the client, i.e. the LSP plugin, is responsible for launching/terminating servers so it normally has access to their stdin/stdout).
(I can see you haven't tried the LSP plugin yet :-P)
The only LSP server I've seen so far that requires TCP/IP is the one for Godot but this is because this server runs as some game-development server regardless of LSP and LSP clients just connect/disconnect to/from it.
Since most servers support stdin/stdout communication, I actually didn't implement TCP/IP support in the server and kept the "simple" (well, apart all of the process management) logic that LSP servers are launched by the client. Instead, I developed this proxy (written in python so the development was much easier than the usual C + glib)
https://github.com/techee/lsp-proxy
that communicates with the LSP client (i.e. the LSP plugin) using stdin/stdout but can use TCP/IP towards the server (or support multiple servers for a single language).
In any case, yes, in the worst case I could try to implement the TCP/IP communication in the plugin but not many servers support it (clangd which the OP wants to use does support it though).
That said, I have an idea (or hope at least).
The same problem on a native x86_64 machine. I suspect the cause is the `g_spawn_async_with_pipes_and_fds()` call here
https://gitlab.gnome.org/GNOME/glib/-/blob/main/gio/gsubprocess.c?ref_type=h...
because it uses the helper binary. If I replaced it with Geany's `spawn_async_with_pipes()`, it might work. But that means creating my own copy of gsubprocess.c and related files like the windows implementations of input/output streams. And worst, developing it under Windows. I probably won't do it in the short term.
Those should be included already though in https://github.com/geany/geany/blob/master/scripts/gtk-bundle-from-msys2.sh#... we still have "win32". Maybe I missed to update ir accordingly.
No, `gspawn-win64-helper.exe` and `gspawn-win64-helper-console.exe` seem to be missing from the script.
Fixed via https://github.com/geany/geany/pull/4088.
Admittedly, I have no clue about LSP but some how intuitively I assumed the client and server communicate via network. Could this be a solution, to (at least on Windows) have the plugin talk to the server via TCP/UDP/whatever network protocol?
Some servers support TCP/IP communication but typically stdin/stdout is used (the client, i.e. the LSP plugin, is responsible for launching/terminating servers so it normally has access to their stdin/stdout).
Ok, thanks for clarification.
(I can see you haven't tried the LSP plugin yet :-P)
Yeah, sorry. I blame work and going on vacation for being distracted to play with the LSP plugin :D.
That said, I have an idea (or hope at least).
The same problem on a native x86_64 machine. I suspect the cause is the `g_spawn_async_with_pipes_and_fds()` call here
https://gitlab.gnome.org/GNOME/glib/-/blob/main/gio/gsubprocess.c?ref_type=h...
because it uses the helper binary. If I replaced it with Geany's `spawn_async_with_pipes()`, it might work. But that means creating my own copy of gsubprocess.c and related files like the windows implementations of input/output streams. And worst, developing it under Windows. I probably won't do it in the short term.
Fair enough. Windows is so much a hassle, at least with Geany's tech stack and probably not worth the efforts to get the LSP integration running. Or someone actually using it need to provide the necessary code changes.
No, gspawn-win64-helper.exe and gspawn-win64-helper-console.exe seem to be missing from the script.
Fixed via https://github.com/geany/geany/pull/4088.
Possibly not needed at all because these probably cause the extra console window with the server and if I manage to get it running with the Geany's spawn module, they won't be necessary either.
Windows is so much a hassle, at least with Geany's tech stack and probably not worth the efforts to get the LSP integration running. Or someone actually using it need to provide the necessary code changes.
I wanted to give it a try and followed https://wiki.geany.org/howtos/win32/msys2 to build geany and geany-plugins which I managed to do. However, when I start Geany using `/c/geany/bin/geany.exe`, no plugins are loaded (even not those bundled with geany itself). I also tried to set "extra plugin path" within Geany to the directory containing them but that didn't help. Any hints?
No, gspawn-win64-helper.exe and gspawn-win64-helper-console.exe seem to be missing from the script.
Fixed via #4088.
Possibly not needed at all because these probably cause the extra console window with the server and if I manage to get it running with the Geany's spawn module, they won't be necessary either.
Yeah but probably won't cause harm and might help if plugins or any code uses `g_spawn_*` API.
Windows is so much a hassle, at least with Geany's tech stack and probably not worth the efforts to get the LSP integration running. Or someone actually using it need to provide the necessary code changes.
I wanted to give it a try and followed https://wiki.geany.org/howtos/win32/msys2 to build geany and geany-plugins which I managed to do.
However, when I start Geany using `/c/geany/bin/geany.exe`, no plugins are loaded (even not those bundled with geany itself). I also tried to set "extra plugin path" within Geany to the directory containing them but that didn't help. Any hints?
I assume the `g_win32_get_package_installation_directory_of_module()` might not work. Maybe the "System data dir" (as reported in Help->Debug Messages) is wrong.
I usually start Geany from "c:\program files\geany" directly in Windows, not from the MSYS2 shell.
I was able to modify the LSP plugin to use Geany's spawn module (I needed the `spawn_async_with_pipes()` API which isn't public so I made a copy of the spawn file in the plugin at least for now). The key point is
https://github.com/geany/geany/blob/34c97386f471df7dc923145dda30df3d879f0c66...
and the `CREATE_NO_WINDOW` here
https://github.com/geany/geany/blob/34c97386f471df7dc923145dda30df3d879f0c66...
My hope is that once the CI builds work, this will just work and I won't have to do any development under Windows ;-).
The good news is that after the manual build of libLerc as described in https://github.com/geany/geany/pull/4094, the LSP plugin works now when using Geany's spawn module.
So no need to develop anything under Windows for me 🎉
Can you re-run the Github Actions?
Can you re-run the Github Actions?
It won't help, the executables won't run until the conflicts between the two libstdc++ libraries are resolved somehow.
@techee Come back to the original problem. How to use the LSP Client? I have enabled it on Plugins Manager. But nothing happens when I open a .cpp file. No code completion. Nothing at all. I check Task Manager and don't see clangd running.
Please follow https://github.com/techee/geany-lsp?tab=readme-ov-file#quick-start. I expect for Windows you will have to set the `cmd` to be the absolute path to the clangd executable.
Also, for clangd you must make sure that `compile_commands.json` is present under the `build` directory of your project. How you get it depends on what build system you use - `meson`, for instance, generates it automatically when you run `meson setup build`. For autotools-based build, you have to use [Bear](https://github.com/rizsotto/Bear). I believe `cmake` also has some support for generating `compile_commands.json`.
Why does `cmd` must be absolute path to `clangd`? I have `clangd` binary in `PATH` and other LSP Client are fine with that.
BTW, how does this absolute path look like? Forward slashes `C:/clangd_19.1.2/bin/clangd`? Normal backward slashes `C:\clangd_19.1.2\bin\clangd`? Double backward slashes (UNC) `C:\clangd_19.1.2\bin\clangd`? Is the extension `.exe` needed?
Why does cmd must be absolute path to clangd? I have clangd binary in PATH and other LSP Client are fine with that.
Maybe it's not necessary, you have to try (if the plugin doesn't find clangd, you get corresponding messages in the Status tab).
As it seems the plugin didn't even attempt to start clangd in your case, I suspect you didn't enable the plugin for your project in step (5) of https://github.com/techee/geany-lsp?tab=readme-ov-file#quick-start
BTW, how does this absolute path look like? Forward slashes C:/clangd_19.1.2/bin/clangd? Normal backward slashes C:\clangd_19.1.2\bin\clangd? Double backward slashes (UNC) C:\clangd_19.1.2\bin\clangd? Is the extension .exe needed?
I think both forward slashes `/` and double backward slashes `\` work. Not sure about `exe`, I think it doesn't matter.
Yes, I forgot to enable the LSP Client plugin for the project.
Starting LSP server clangd Sending initialize request to LSP server clangd File C:\test1\test.cpp opened (1). LSP initialize request failed for LSP server, terminating clangd LSP server clangd stopped unexpectedly, restarting ... LSP server clangd terminated 10 times, giving up
Using absolute path to `clangd` doesn't help.
You mentioned `gspawn-win64-helper.exe` and `gspawn-win64-helper-console.exe`. I can't find them on Geany's installation directory in Program Files.
You mentioned gspawn-win64-helper.exe and gspawn-win64-helper-console.exe. I can't find them on Geany's installation directory in Program Files.
Those shouldn't be needed now.
``` Starting LSP server clangd Sending initialize request to LSP server clangd File C:\test1\test.cpp opened (1). LSP initialize request failed for LSP server, terminating clangd LSP server clangd stopped unexpectedly, restarting ``` You could try setting ``` rpc_log=some_file.txt rpc_log_full=true ``` under the `[C]` section and check the log file if it contains some useful information.
Also, did you use an absolute path under Project->Properties->Base Path? This should point to the root directory of your project.
What happens when you run `clangd` from the console? (It should block until you press Ctrl+C after which it should quit)
Just to be sure, are you using the LSP plugin from the installer here https://github.com/geany/geany-plugins/actions/runs/12283983695 ?
Because before I made the changes related to process spawning, the plugin behaved so that it launched a separate console window in which it launched the server and one got the same logs as you did. No console window should appear now with the above installer.
``` Starting LSP server clangd Sending initialize request to LSP server clangd File C:\test1\test.cpp opened (1). LSP initialize request failed for LSP server, terminating clangd LSP server clangd stopped unexpectedly, restarting ```
Hmm, I'm seeing these too now. This used to work - I wonder if I changed anything in the code in the meantime that breaks the Windows build. I'll investigate.
Alright, this artifact works for me:
https://github.com/geany/geany-plugins/actions/runs/12148667128
Even though the changes I made after that look innocent to me, apparently they aren't and break the plugin under Windows. Can you confirm this geany-plugins artifact works?
You could try setting
rpc_log=some_file.txt rpc_log_full=true
under the `[C]` section and check the log file if it contains some useful information.
This is very very useless. If the project is open, I can't open this file. Windows simply tells me Access Denied. If I close the project, this file will also gone.
Also, did you use an absolute path under Project->Properties->Base Path? This should point to the root directory of your project.
The default value is absolute path and I have never touched it.
What happens when you run `clangd` from the console? (It should block until you press Ctrl+C after which it should quit)
I can confirm that the problem is not from `clangd`.
Alright, this artifact works for me:
https://github.com/geany/geany-plugins/actions/runs/12148667128
Even though the changes I made after that look innocent to me, apparently they aren't and break the plugin under Windows. Can you confirm this geany-plugins artifact works?
``` This is Geany 2.1_ci_20241203211600_34c9738 . New file "untitled" opened. File untitled closed. Project "test1" opened. New file "untitled" opened. File untitled closed. Starting LSP server clangd Sending initialize request to LSP server clangd File C:\test1\test.cpp opened . LSP initialize request failed for LSP server, terminating clangd LSP server clangd stopped unexpectedly, restarting Starting LSP server clangd Failed to create log file: C:\log\log.txt Sending initialize request to LSP server clangd LSP initialize request failed for LSP server, terminating clangd LSP server clangd stopped unexpectedly, restarting Starting LSP server clangd Failed to create log file: C:\log\log.txt Sending initialize request to LSP server clangd LSP server clangd initialized ```
As you can see, it will try two times before it could start `clangd`. I can confirm that `clangd` is in Task Manager. It will always said it failed to create the log file, but the log file is there. I can see it on Windows Explorer, but can't do anything with it.
BTW, `clangd` is in Task Manager, but there is no code completion at all.
Alright, I hope I've fixed all the problems and geany-plugins from
https://github.com/geany/geany-plugins/actions/runs/12422122251/
should (hopefully) work. Please give it a try.
It seems to work now. But I have only tested with a very simple single source file program.
github-comments@lists.geany.org