Use Neovim and Sublime Text 4 to edit Defold scripts

Neovim

My Neovim init.lua on Windows

vim.pack.add({
    "https://github.com/mfussenegger/nvim-dap",
    "https://github.com/L3MON4D3/LuaSnip",
    "https://github.com/neovim/nvim-lspconfig",
    "https://github.com/williamboman/mason.nvim",
})

vim.pack.add({ 'https://github.com/saghen/blink.lib', 'https://github.com/saghen/blink.cmp' })
local cmp = require('blink.cmp')
cmp.build():wait(60000)
cmp.setup()

require("mason").setup()

vim.lsp.config('lua_ls', {
    settings = {
        Lua = {
            runtime = {
                version = "Lua 5.1",
            },

            workspace = {
                library = {
                    vim.fn.expand("E:\\defold-nvim-api\\defold_api"),
                    vim.fn.expand("E:\\Defold_Projects\\defold-sublime-test\\.internal\\lua-annotations"),
                },
                checkThirdParty = false,
            },

            diagnostics = {
                globals = {
                    "go",
                    "msg",
                    "gui",
                    "vmath",
                    "hash",
                    "pprint",
                    "sprite",
                    "factory"
                },
            },
        },
    },
})

vim.lsp.enable('lua_ls')

vim.filetype.add({
    extension = {
        script = "lua",
        gui_script = "lua",
        render_script = "lua",
    },
})

vim.g.mapleader = " "

vim.pack.add({
    "https://github.com/nvim-neo-tree/neo-tree.nvim",
    "https://github.com/nvim-lua/plenary.nvim",
    "https://github.com/nvim-tree/nvim-web-devicons",
    "https://github.com/MunifTanjim/nui.nvim",
})

require("neo-tree").setup({})

vim.keymap.set("n", "<leader>e", ":Neotree toggle<CR>")

Use Meson to install lua-language-server

You have to install rust for using blink plugin

E:\\defold-nvim-api\\defold_api I download it from

E:\\Defold_Projects\\defold-sublime-test\\.internal\\lua-annotations you can find it from your defold project


Sublime Text 4

Note: you can add your defold project’s .internal\lua-annotations path to the LSP-Lua setting so that LSP-Lua can know these extensions’ APIs.

Or if you don’t want to change the lua-language-server’s global settings , you can create a .luarc.jsonon your project

{
        "Lua.workspace.library":
        [
            "C:\\Users\\cw\\AppData\\Roaming\\Sublime Text\\Packages\\Defold\\annotations\\defold_api",
            "E:\\Your Project Path\\.internal\\lua-annotations"
        ]    
}

By the way, the VSCode is also a great choice. But it is too beautiful, powerful and heavy that I can’t focus on coding and my computer will become slow.


I highly recommend use Sublime Text 4 to edit Defold scripts because it is more comfortable than neovim on windows and is more concise than VS Code.


But finally, I decided only use Defold Editor because I don’t want to waste time in comparing which external editor is better. I want to focus on gamedev itself.

3 Likes

It’s great that you are showcasing this, but please also share links to the plugins/packages to make this possible so that other’s can try!

1 Like

Absolutely, I just added tutorial so others can easily try it out too.

1 Like