Skip to content

Commit

Permalink
docs: Document Editor and LSP setup (#12)
Browse files Browse the repository at this point in the history
* docs: Document Editor and LSP setup

Closes #7

* Use correct callout syntax
  • Loading branch information
gamebox authored Jan 6, 2024
1 parent d9667f2 commit aa3e38a
Showing 1 changed file with 84 additions and 0 deletions.
84 changes: 84 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,85 @@ func main() {
}
```

## Editor Support and LSP usage

### Neovim

Right now, the only editor that is supported for the Gwirl LSP is Neovim.

#### Installation

Until we have registered our config with nvim-lspconfig, you will have to create
a custom LSP config manually. If you are using `nvim-lspconfig`, the config
should look like this:


```lua
local lsp_configurations = require('lspconfig.configs')

if not lsp_configurations.gwirl then
lsp_configurations.gwirl = {
default_config = {
name = 'gwirl',
cmd = { 'gwirl-lsp' },
filetypes = { 'gwirl' },
root_dir = function()
local dir = vim.fs.dirname(vim.fs.find({ 'go.mod' }, { upward = true })[1])
return dir
end,
on_attach = function()
-- setup your LSP keybinds here.
end,
capabilities = {
textDocument = {
augmentsSyntaxTokens = true,
dynamicRegistration = true,
formats = { "relative" },
multilineTokenSupport = false,
overlappingTokenSupport = true,
requests = {
full = {
delta = false
},
range = false
},
serverCancelSupport = false,
},
},
}
}
end
```

#### Configuration

To make your Gwirl experience the best it can be in Neovim, we suggest adding
a `gwirl.lua` file to your `ft` directory in the root of your Neovim config
directory. That file should contain the following:

```lua
vim.api.nvim_create_autocmd({"BufRead", "BufNewFile"}, {
pattern = {"*.html.gwirl"},
callback = function ()
vim.cmd("set filetype=gwirl")

vim.treesitter.language.register("html", {"gwirl"})
vim.treesitter.language.require_language("html")
end
})

-- add similar autocmds for other file types (txt, md, xml) if you use them with Gwirl
```

It's also recommended to add the following in some module called by your `init.lua`:

```lua
vim.treesitter.language.register("html", {"gwirl"})
vim.treesitter.language.require_language("html")
```

And hopefully you have treesitter set up correctly.

## Supported features

### Template parameters
Expand Down Expand Up @@ -150,6 +229,11 @@ and other functionality.

### If/Else if/Else statements

> [!NOTE]
> Currently only `if` is supported, `if else` and `else` will be supported as part of
[#11](https://github.com/gamebox/gwirl/issues/11).


```html
<section @if showBorders {class="b-w-sm b-"}>
```
Expand Down

0 comments on commit aa3e38a

Please sign in to comment.