Thanks to visit codestin.com
Credit goes to github.com

Skip to content

huyhoang8398/gitlab-lsp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GitLab CI YAML Language Server

A Language Server Protocol (LSP) implementation for GitLab CI YAML files, designed for Neovim.

Demo

Features

  • Syntax validation for .gitlab-ci.yml files
  • Autocompletion for GitLab CI keywords
  • Hover information for keywords
  • Document symbols for navigation
  • Formatting support

Dependencies

  • yaml-language-server

Installation

  1. Clone the repository:
    git clone https://github.com/huyhoang8398/gitlab-lsp
    cd gitlab-lsp
  2. Install dependencies:
    npm install
  3. Build the project:
    npm run build

Neovim Integration

  1. Ensure you have an LSP client installed in Neovim (e.g., nvim-lspconfig).
  2. 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,
})

Usage

  • Open a .gitlab-ci.yml file 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())

Development

  • Build: npm run build
  • Start: npm start
  • Add new features by extending the providers in src/.

License

Licensed under the Apache License, Version 2.0. See the LICENSE file for details.

About

Simple Gitlab CI language server to use in neovim and maybe in vscode

Resources

License

Stars

Watchers

Forks

Packages

No packages published