Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Contributing guide #35

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions src/components/layout/Footer.astro
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,7 @@ const { class: className } = Astro.props;
</ExternalLink>
</li>
<li>
<a href="/wiki/developing/">Development guide</a>
</li>
<li>
<ExternalLink url="https://github.com/LuaLS/LuaLS.github.io/blob/main/docs/CONTRIBUTING.md">Wiki</ExternalLink>
</li>
<li>
<a href="/wiki/translations/#contributing">Translate</a>
<a href="/wiki/contributing/">Contributing guide</a>
</li>
<li>
<ExternalLink
Expand Down
34 changes: 34 additions & 0 deletions src/content/wiki/contributing.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---
title: Contributing
description: A guide to contributing to the Lua Language Server.
getting-started: true
---

Thank you for your interest in contributing to the Lua Language Server! Your contributions help improve the experience for all users.

> I want to...

- [Contribute features/fixes](#contributing-code)
- [Create LuaCATS annotations](#contributing-luacats-annotations)
- [Help translate to another language](/wiki/translations)
- [Improve this wiki](https://github.com/LuaLS/LuaLS.github.io/blob/main/docs/CONTRIBUTING.md)

> Is there something else I can do?

- [Star the repository](https://github.com/LuaLS/lua-language-server) if you find the project helpful
- Spread the word!
- You can [sponsor](https://github.com/LuaLS/lua-language-server/issues/484) the project

## Contributing code

If you're familiar with Lua, you can grab the [source code](https://github.com/LuaLS/lua-language-server) and dive in. There are additional wiki articles that go more in-depth on [building from source](/wiki/build) and [developing](/wiki/developing). An overview of the project's file structure can be found [on the developing page](/wiki/developing#file-structure).

We don't have a strict git workflow that needs to be followed. When you have some changes ready to merge, [open a pull request](https://github.com/LuaLS/lua-language-server/pulls). If you need some help, feel free to open a draft pull request – although please be patient and keep in mind that the team is very small.

When making changes to the language server, please make sure to add an entry to the project's [changelog](https://github.com/LuaLS/lua-language-server/blob/master/changelog.md) file, so it is documented and advertised to users.

## Contributing LuaCATS Annotations

The Lua Language Server implements a system for defining and documenting code called LuaCATS (Lua Comment And Type System). You can contribute to our ecosystem by writing [LuaCATS annotations](/wiki/annotations) for widely used Lua libraries. These can help give users out-of-the-box autocompletion and type checking for the library. This is done by creating [definition files](/wiki/definition-files) that can then be included in an [addon](/wiki/addons) and distributed using the [addon manager](/wiki/addons#addon-manager).

You can browse annotations maintained by the community in the [LuaCATS organization](https://github.com/LuaCATS).
61 changes: 47 additions & 14 deletions src/content/wiki/developing.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,50 @@ import Remark from "~/components/common/Remark.astro";
import Accordion from "~/components/common/Accordion.astro";
import FileTreeItem from "~/components/common/FileTreeItem.astro";

import windowsImg from "~/assets/images/windows.svg"
import macImg from "~/assets/images/mac.svg"
import linuxImg from "~/assets/images/linux.svg"
import windowsImg from "~/assets/images/windows.svg";
import macImg from "~/assets/images/mac.svg";
import linuxImg from "~/assets/images/linux.svg";

Thank you for taking an interest in helping improve the language server!

## Overview

The Lua Language Server is written, rather fittingly, in Lua. As a result of Lua being designed for embedding in other programs, its standard library is pretty basic. This means that in order for it to be run as a standalone program, with better io, threading, etc., it requires a runtime written in another language. The language server uses [bee.lua](https://github.com/actboy168/bee.lua) (C++) as its runtime.

An advantage of Lua being an interpreted language is that the source files can be quickly edited and tested with no compile step needed, although hot-reloading is not supported (the server must be restarted).

## Debugging

Debugging can be performed in a few ways. You can [do a quick `print()`](#quick-print), [write to the log file](#append-to-log-file), or [attach a debugger](#attach-debugger) to get all the info you need.
Debugging can be performed in a few ways:

- [Print](#print)
- [Log](#append-to-log-file)
- [Debugger](#attach-debugger)

### Quick Print
### Print

You can quickly `print()` to the `OUTPUT` panel (<kbd>Ctrl + Shift + U</kbd>) in Visual Studio Code.
A quick call to the familiar `print()` will, as expected, write the given parameters out to `stdout`. When running the language server using Visual Studio Code, the output can be seen in the `OUTPUT` panel (<kbd>Ctrl + Shift + U</kbd>):

![outputPanel](https://user-images.githubusercontent.com/61925890/181308229-52b7e9b7-2893-429b-bca2-8386670df6b0.png)

Below is an example of how a [plugin](/wiki/plugins) can be debugged.
This allows for pretty quick and easy development entirely in VS Code by opening up the language server source:

<Tabs
active="Windows"
buttons={[
{ name: "Windows", image: windowsImg, accent: "#23a9f2" },
{ name: "MacOS", image: macImg, accent: "#ffffff" },
{ name: "Linux", image: linuxImg, accent: "#ffff00" },
]}
>
<div data-tab="Windows">
`%USERPROFILE%\.vscode\extensions\sumneko.lua-VERSION\server`
</div>
<div data-tab="MacOS">`~/.vscode/extensions/sumneko.lua-VERSION/server`</div>
<div data-tab="Linux">`~/.vscode/extensions/sumneko.lua-VERSION/server`</div>
</Tabs>

A [plugin](/wiki/plugins) can also be debugged quickly this way:

```Lua
local util = require 'utility'
Expand All @@ -35,9 +62,9 @@ function OnSetText(uri, text)
end
```

### Append to Log File
### Log

You can add an entry to the [log file](/wiki/FAQ#where-can-i-find-the-log-file). Below is an example of how a [plugin](/wiki/plugins) can be debugged.
You can add an entry to the [log file](/wiki/FAQ#where-can-i-find-the-log-file) using the levels `trace`, `debug`, `info`, `warn`, `error`, and `fatal`. Below is an example of how a [plugin](/wiki/plugins) can be debugged.

```Lua
local util = require 'utility'
Expand All @@ -48,14 +75,14 @@ function OnSetText(uri, text)
end
```

### Attach Debugger
### Debugger

This is the most advanced method, but provides all kinds of useful info and is the most "proper" way to debug the language server.

You will need two Visual Studio Code instances open:

1. The **Debug Host**
- This instance has the language server open which can be found in one of these locations:
- This instance has the language server open, which can be found in one of these locations:
<Tabs
active="Windows"
buttons={[
Expand All @@ -64,9 +91,15 @@ You will need two Visual Studio Code instances open:
{ name: "Linux", image: linuxImg, accent: "#ffff00" },
]}
>
<div data-tab="Windows">`%USERPROFILE%\.vscode\extensions\sumneko.lua-VERSION\server`</div>
<div data-tab="MacOS">`~/.vscode/extensions/sumneko.lua-VERSION/server`</div>
<div data-tab="Linux">`~/.vscode/extensions/sumneko.lua-VERSION/server`</div>
<div data-tab="Windows">
`%USERPROFILE%\.vscode\extensions\sumneko.lua-VERSION\server`
</div>
<div data-tab="MacOS">
`~/.vscode/extensions/sumneko.lua-VERSION/server`
</div>
<div data-tab="Linux">
`~/.vscode/extensions/sumneko.lua-VERSION/server`
</div>
</Tabs>
2. The **Debug Target**
- This instance is where you will test the language server. It should have a folder opened where you can write Lua to test the various features of the language server and use it as normal.
Expand Down
6 changes: 6 additions & 0 deletions src/scss/main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,12 @@ hr {
border: 0.05em solid white;
}

blockquote {
border-left: var(--link-color) 0.3em solid;
padding-left: 0.5em;
margin-left: 1em;
}

button {
&:hover {
cursor: pointer;
Expand Down