zuul-ls and zuul-search aim to provide a more efficient way to search and edit Zuul CI config.
zuul-ls provides a small LSP with go-to-definition, auto-complete and workspace symbols method for jobs, variables, playbooks, project-templates and roles.
zuul-search can search jobs, project-templates or a job's variables or job hierarchy.
- Package the project into a VSCode plugin and release it
zuul-ls does not have any dependencies. zuul-search is wrapped by a zs
script.
It requires fzf and bat.
The project is tested with neovim and VSCode(partial). Need clone the repo and
copy/link the zs
script
git clone https://github.com/birnevogel11/zuul-ls
cd zuul-ls
cargo build # or `cargo build --release`
cargo install
cp zuul-ls/scripts/zs <bin>/ # e.g. `cp zuul-ls/scripts/zs /usr/local/bin`
# If the soure folder is not removed later ...
ln -sf zuul-s/scripts/zs <bin>/zs
The program can search zuul configs cross multiple projects with config file in
~/.config/zuul-ls/config.yaml
. The file format is:
# The search scope is tenant. It supports multiple tenants
tenant:
# The name of the tenant. Only for debug
example_tenant_name:
# The base directory of the tenant. Zuul-ls searches all jobs,
# project-templates in the directory
# It searches ansible roles in `<base_dir>/zuul-shared` and
# `<base_dir>/zuul-trusted`
base_dir: ~/code/ci/tenant
# The extra base directory of the tenant. It searches all jobs,
# project-templates in the directory
# It searches ansible roles in `<extra_base_dir>/zuul-shared` and
# `<extra_base_dir>/zuul-trusted`
extra_base_dir:
- ~/ci/common-repo
- ~/ci/common-repo2
# The extra role directory of the tenant. It searches ansible roles in
# `<extra_role_dir>/roles` directory.
extra_role_dir:
- ~/ci/common-rule-repo
- ~/ci/common-rule-repo2
-
Assume
neovim/nvim-lspconfig
is installed with lazy.nvim. Add the if code block in config functionreturn { { "neovim/nvim-lspconfig", dependencies = { { "nvim-lua/plenary.nvim" }, }, config = function() local configs = require("lspconfig.configs") local lspconfig = require("lspconfig") if not configs.zuul_ls then local util = require("lspconfig.util") configs.zuul_ls = { default_config = { cmd = { "zuul-ls" }, filetypes = { "yaml", "yaml.ansible" }, root_dir = util.find_git_ancestor, single_file_support = true, settings = {}, }, docs = { description = [[ zuul language server ]], default_config = { root_dir = [[ util.find_git_ancestor ]], }, }, } end end, }, }
-
Add lsp config
require("lspconfig").zuul_ls.setup(...)
-
Install telescope-zuul-search.nvim
The document is copied from IWANABETHATGUY/tower-lsp-boilerplate.
Known limitations
- The plugin can not work with ansible-ls together in VSCode.
- It requires run with yaml plugin.
Steps:
pnpm i
cargo build
- Open the project in VSCode:
code .
- In VSCode, press F5 or change to the Debug panel and click Launch Client.
- In the newly launched VSCode instance, open the file
examples/test.nrs
from this project. - If the LSP is working correctly you should see syntax highlighting and the features described below should work.
The reason to create the project is that I would like to learn Rust and it's useful for my daily job. It's always welcome to send patches for any reason.
I know tower-lsp is a async program but the code has a lot of blocking IO call. The most important reason is that I am unfamiliar with async in Rust. Maybe we can change/rewrite these parts in the future.
Thanks to IWANABETHATGUY/tower-lsp-boilerplate. It saves me a lot of time to learn how to write a LS from scratch.