A Language Server Protocol (LSP) implementation for GitLab CI YAML files, designed for Neovim.
- Syntax validation for
.gitlab-ci.ymlfiles - Autocompletion for GitLab CI keywords
- Hover information for keywords
- Document symbols for navigation
- Formatting support
yaml-language-server
- Clone the repository:
git clone https://github.com/huyhoang8398/gitlab-lsp cd gitlab-lsp - Install dependencies:
npm install
- Build the project:
npm run build
- Ensure you have an LSP client installed in Neovim (e.g.,
nvim-lspconfig). - Configure the language server in your Neovim setup:
vim.api.nvim_create_autocmd({ "BufRead", "BufNewFile" }, {
pattern = "*.gitlab-ci*.{yml,yaml}",
callback = function()
vim.bo.filetype = "yaml.gitlab"
end,
})
vim.api.nvim_create_autocmd("FileType", {
pattern = "yaml.gitlab",
callback = function()
vim.lsp.start({
name = "gitlab_ci_ls",
cmd = { "node", "/path/to/gitlab-lsp/dist/server.js", "--stdio" },
root_dir = vim.fs.dirname(
vim.fs.find(
{ ".gitlab-ci.yml", ".gitlab-ci.yaml", "*.gitlab-ci*.yml", "*.gitlab-ci*.yaml" },
{ upward = true }
)[1]
),
})
end,
})- Open a
.gitlab-ci.ymlfile in Neovim. - Use LSP features like:
- Autocompletion (
<C-x><C-o>or your mapping) - Hover (
:lua vim.lsp.buf.hover()) - Go to symbol (
:lua vim.lsp.buf.document_symbol()) - Format document (
:lua vim.lsp.buf.format())
- Autocompletion (
- Build:
npm run build - Start:
npm start - Add new features by extending the providers in
src/.
Licensed under the Apache License, Version 2.0. See the LICENSE file for details.