Raylib example using the package manager

I get immediate success with the approach as far as building is concerned; I’ve also replaced raylib back with master which just worked. Nice.

Regarding zls, I’ve not been as successful.

If anybody has a guide “from 0 to working zls even with this raylib setup in nvim using lazy using a zvm managed zig & zls” I’d appreciate it.

I could not get Zls working on Windows using this method (package manager).
But I did manage to get it working with raylib as a submodule. Example here GitHub - everystone/raylib-zig-template

Updated zigraylib example to a zig 0.12.0 compatible commit.
Via: zig fetch --save=raylib https://github.com/raysan5/raylib/archive/b03c8ba945a06ed1ec3d6ed7c3185e1264909323.tar.gz
Commit: https://github.com/raysan5/raylib/tree/b03c8ba945a06ed1ec3d6ed7c3185e1264909323

Tested with zig version 0.12.0
Zls tagged release 0.12.0

Updating zls:

git pull
git checkout tags/0.12.0 -b 0.12.0
zig build -Doptimize=ReleaseSafe

Tested on linux, zls is working.
Now that zls has a 0.12.0 release everything seems to work fine.
@msw and @Eirik if you want, you could try again with these versions?

1 Like

I logged what I did in case it would prove useful to communicate what’s going wrong if there’s something wrong or what mistake(s) I might’ve made – turns out this now is a log of a successful test’s “debug output”:

mkdir zls-test
## NVIM config
# Start with a fresh nvim config
# I am a newbie to nvim (coming from pluginless vim)
# so I use what others think is a "modern" editing experience
git clone https://github.com/LazyVim/starter ./zls-test/config/nvim
rm -Rf zls-test/config/nvim/.git
# let lazyvim starter kit plugin cascade setup & install..
env XDG_CONFIG_HOME=${HOME}/zls-test/config\
 XDG_STATE_HOME=${HOME}/zls-test/state\
 XDG_DATA_HOME=${HOME}/zls-test/data\
 nvim

## ZLS
# get zls as per instructions;
# install zls by copying the binary to zls-test/zls

## RAYLIB example
cd zls-test
git clone https://github.com/SimonLSchlee/zigraylib.git zrl
cd zrl
zig build run ;# ok - works

## Now for the hard (for me) part. Configure to use zls.
# disable mason:
<<EOF cat > ~/zls-test/config/nvim/lua/plugins/no-mason.lua
return {
  -- disable mason
  { "williamboman/mason.nvim", enabled = false },
}
EOF
# configure via nvim-lspconfig
<<EOF cat > ~/zls-test/config/nvim/lua/plugins/zls-lspconfig.lua
return {
  {
    "neovim/nvim-lspconfig",
    opts = {
      servers = {
        zls = {
          cmd = {
            "/home/phaeton/zls-test/zls",
          },
          settings = {
            zls = {
              zig_exe_path = "/home/phaeton/.zvm/bin/zig",
            },
          },
        },
      },
    },
  },
}
EOF
## fine, let's try this?
env XDG_CONFIG_HOME=${HOME}/zls-test/config\
 XDG_STATE_HOME=${HOME}/zls-test/state\
 XDG_DATA_HOME=${HOME}/zls-test/data\
 nvim src/main.zig
# check lsp attachment via :LspInfo, outputs attached client:
#  Client: zls (id: 1, bufnr: [1])
# 	filetypes:       zig, zir
#	autostart:       true
# 	root directory:  /home/phaeton/zls-test/zrl
# 	cmd:             /home/phaeton/zls-test/zls
#
# toying around: yes, indeed it works!

So, it seems to me I can make this work from scratch.
Thanks!

(tested with zvm-installed zig 0.12.0, manually installed zls as per above, no ${XDG_CONFIG_HOME}/zls.json etc., all config present above in log)

1 Like

A post was split to a new topic: How to use raylib as a dependency of a dependency?

Thanks to nat3Github Adding raygui · Issue #5 · SimonLSchlee/zigraylib · GitHub

I took another look at raylib’s build.zig and raygui, and realized that it can be integrated more easily than I thought (or than it could in the past / not quite sure which) into an example.

Checkout the raygui branch if you want to use raylib + raygui.