Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/monkoose/DoNe
Defold on Neovim (extended)
https://github.com/monkoose/DoNe
defold neovim neovim-plugin
Last synced: about 1 month ago
JSON representation
Defold on Neovim (extended)
- Host: GitHub
- URL: https://github.com/monkoose/DoNe
- Owner: monkoose
- Created: 2024-09-07T10:19:21.000Z (2 months ago)
- Default Branch: main
- Last Pushed: 2024-09-21T18:15:35.000Z (about 2 months ago)
- Last Synced: 2024-09-26T18:21:46.958Z (about 2 months ago)
- Topics: defold, neovim, neovim-plugin
- Language: Lua
- Homepage:
- Size: 125 KB
- Stars: 6
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-defold - DoNe
README
> [!Note]
> Work in progress. Tested only on Linux, but it should work on macOS as well.- Configures lua_ls to better support defold projects
- Includes defold API annotations
- Adds a command to extract dependency annotations
- Adds commands to build, hot-reload and fetch
- Configures all defold filetypes to be properly detected and highlighted
- Works with built-in LSP and with [coc.nvim](https://github.com/neoclide/coc.nvim)Intended to be used as [external editor](#script-for-opening-neovim-as-defold-external-editor).
## Dependencies
The plugin can work without dependencies, but if you want to get LSP documentation
and completions for external libraries in the ".internal" directory, you need to install
these dependencies and invoke `DoNe annotate` command.
To run remote actions, `curl` and one of `ss` or `lsof` utils must be exucutable
(most Linux distros and MacOS include them by default).Make sure luarocks is using 5.1 lua version
```sh
luarocks config | grep lua_version
```
if its not then change it to 5.1
```sh
luarocks config lua_version 5.1
``````sh
sudo luarocks install sha1
sudo luarocks install luazip
sudo luarocks install lyaml# luazip requires zziplib library
# on ArchLinux zziplib can be installed with
sudo pacman -S zziplib
# On other distros or on macos you can build it from source
# https://github.com/gdraheim/zziplib
```## Install
Using lazy.nvim and lazy loading only by `:Lazy load DoNe` command
```lua
{
"monkoose/DoNe",
lazy = true,
-- optional configuration
config = function()
-- as example adding some keybindings
vim.keymap.set("n", "", "DoNe build")
--- ...
end,
}
```## Usage
DoNe provides neovim user command with the same name `:DoNe`:
- **`:DoNe build`** - builds and runs defold project
- **`:DoNe reload`** - hot-reloads defold project
- **`:DoNe fetch`** - fetches project dependencies
- **`:DoNe annotate`** - collects dependency annotations for improved autocompletion and documentation. You may need to restart
LSP client to get them in the current neovim session.
- **`:DoNe clear`** - removes annotations of all dependencies (useful when you change projects, so autocompletion wouldn't show them)
- **`:DoNe actions`** - lists all available commands accepted by defold editor (it can be used with `lua require('done.remote').actions()`)
- **`:DoNe delete_server_pipe`** - if neovim started as an external editor with instructions below and `servername=$HOME/.cache/nvim/defold.pipe`,
then removes the server pipe. Required because from time to time something goes wrong, so neovim stops connectiong to this pipe.
Use it when opening an external editor creates new neovim windows.## Script for opening neovim as defold external editor
Name the script how you want (for example, `neovim-for-defold`), make it executable and put in any directory in your $PATH environment variable.
On defold's menu `File > Preferences > Code` change the `Custom Editor` field to `neovim-for-defold` (or the name you chose).
`Open File at Line` should be changed to `{file} {line}`.Change `st` in the script to your favorite terminal in which you would like to start neovim. You don't need to change anything else.
```sh
#!/bin/sh# change this to your favorite terminal
term_exec="st"
servername="$HOME/.cache/nvim/defold.pipe"if [[ "$#" -eq 2 ]]; then
command="edit +$2 $1"
else
command="edit $1"
fiif [[ -e "$servername" ]]; then
nvim --server "$servername" --remote-send ":$command"
else
"$term_exec" -e nvim --listen "$servername" +"lua require('lazy').load({ plugins = 'DoNe' })" +"$command"
fi
```I'm using slightly modified version for better awesomewm integration.
```sh
#!/bin/shterm_exec="st"
servername="$HOME/.cache/nvim/defold.pipe"if [[ "$#" -eq 2 ]]; then
command="edit +$2 $1"
else
command="edit $1"
fiif [[ -e "$servername" ]]; then
nvim --server "$servername" --remote-send ":$command"
awesome-client '
for _, c in ipairs(client.get()) do
if string.match(c.name, "=defold=") then
c:jump_to()
break
end
end
'
else
"$term_exec" -e nvim --listen "$servername" +"lua require('lazy').load({ plugins = 'DoNe' })" \
+"let &titlestring = '=defold= %t'" +"$command"
fi
```Misc notes
Defold api annotations were generated with https://github.com/astrochili/defold-annotations
TODO: add github workflow to update them automatically