There probably aren't that many people using neovim, but it has great LSP support. And also since all the plugins and configuration are in lua these days, it's been pretty easy to get going with lua for playdate. So I figured to make a central thread here for anyone to talk about using Neovim, vs just one-off threads that the rest of the playdate community probably wouldn't care about.
To start off, I was able to get the sumneko_lua LSP server to pull in the sdk files but only when editing a playdate project directory, otherwise keep with completing all the neovim APIs. I'm still on lsp installer, and not the new maven replacement, but you can probably figure out how to make this work with maven just as easily.
local path = require "plenary.path"
local exists = function(name) return path:new(vim.fn.getcwd() .. "/" .. name):exists() end
lsp_installer.on_server_ready(function(server)
local setup = true
local opts = {
on_attach = require("user.lsp.handlers").on_attach,
-- You can disable features with this function
capabilities = require("user.lsp.handlers").capabilities,
}
if server.name == "sumneko_lua" then
if exists "source/main.lua" then -- playdate
opts = vim.tbl_deep_extend("force", {
settings = {
Lua = {
completion = { callSnippet = "Replace" },
runtime = { nonstandardSymbol = { "+=", "-=", "*=", "/=" } },
telemetry = { enable = false },
diagnostics = { globals = { "playdate" } },
workspace = {
library = { os.getenv("HOME") .. "/Developer/PlaydateSDK/CoreLibs/" },
},
},
},
}, opts)
else
local luadev = prequire "lua-dev"
if luadev then opts = vim.tbl_deep_extend("force", luadev.setup(), opts) end
end
end
end
One thing I wish that the __stub.lua file had comments above each function with documentation. Maybe even EmmyLua styled comments with the expected types of all the params. Then it'd show up in the cmp popups. Maybe the panic staff will add that one day?
Hi Will, neovim user here. Thank you so much for sharing your config. However it seems there's a syntax error in the snippet, or somehow I messed up copying/pasting.
I tried modifying the code but didn't work out how to make sumneko_lua recognize Playdate SDK using just the on_attach function. Could you share your code if possible?
The only strange thing in there is my prequire which is
---@diagnostic disable-next-line: lowercase-global
function prequire(package)
local status, lib = pcall(require, package)
if status then
return lib
else
vim.notify("Failed to require '" .. package .. "' from " .. debug.getinfo(2).source)
return nil
end
end
Hi all, thanks for this helpful guide! I've got neovim set up for playdate dev now, using coc-lua and the helpful configs posted here. I'm new to playdate, and new to lua, so I'm struggling now to figure out if this issue is one that can be resolved:
I'm guessing this may be because the language server doesn't know about playdate's special object orientation 'library'? Has anyone else run into this issue and got it working? It's not the end of the world, but it does litter my code with these diagnostic errors, and I'm not really clear if the 'objects' returned by the call to .new actually have the correct methods available on them.
Glad to see I'm not the only one struggling with this same issue... developing only with a TUI is possible ? How do you do when testing on the Playdate? The simulator is cool but when we have no GUI..