-
Notifications
You must be signed in to change notification settings - Fork 10
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
How to use pico8-ls with neovim? #34
Comments
Support for neovim (any editors aside from vscode, really) still needs to be built out. Contributions are welcome! I haven't made an LSP extension for neovim before, but these look like some good starting resources: |
It looks like if you use this: https://github.com/autozimu/LanguageClient-neovim it might be as simple as adding a new language-server config (see readme for that file). I'm guessing you'd just want to build the Typescript files under |
This seems to work for me: git clone https://github.com/japhib/pico8-ls
cd pico8-ls
npm install
cd server
npm run compile
echo -e '#!/usr/bin/env bash\n'"node $PWD/out/server.js" '"$@"' > ~/bin/pico8-ls # or any other folder in your $PATH I might submit it to mason later on to make it easier to install for neovim users. |
for me i have some errors when i try to launch the server : PICO-8 Language Server starting. Error: Connection input stream is not set. Use arguments of createConnection or set command line parameters: '--node-ipc', '--stdio' or '--socket={number}' Node.js v18.10.0 Update: i started with --stdio seems to have launched without the error but then no idea what to do to make it work in neovim ? thanks for any help |
So, that only gets you the language server part. The other half is getting a language-server client. The thing I linked to above, https://github.com/autozimu/LanguageClient-neovim, provides the client. I think you have to install that as a plugin though. Anyways, the thing about |
could you please share your configuration for the client side ? and what you are using ? it could be nice to submit that to mason as well like you mentioned it if you have any time to do so. |
Here's my attempt at adding support for this LSP in mason: mason-org/mason-registry#2365 I could not find a way to add a "client" there - I am not sure that is needed. |
The mason PR above was merged |
Despite the above being merged, I was not able to make pico-ls work in any fashion. I am not knowledgeable enough about LSPs to know what is wrong. I see no difference at all when I open a p8 file, independently of whether I have the mason plugin enabled or not. |
I don't use this LSP anymore, but if you're using neovim you don't need a plugin because it has a built-in LSP client. A simple setup could look like this (untested): vim.api.nvim_create_autocmd("FileType", {
pattern = "pico8", -- or whatever filetype you have for *.p8 files
callback = function(args)
-- For now, the root directory is set to the directory of your *.p8 file.
-- If you want a more complex root matching behavior, see `:help vim.fs.find()`
local path = vim.fs.dirname(vim.api.nvim_buf_get_name(args.buf))
vim.lsp.start {
name = "pico8-ls",
cmd = { "pico8-ls", "--stdio" }, -- you might need to tweak this
root_dir = path,
}
end,
}) Most users however, would use the nvim-lspconfig plugin because it's more convenient. Unfortunately, there is no configuration for |
The following configuration gets the server up and running for me (more options at :h lsp), however, without syntax highlighting. I've spent sometime trying to get syntax highlighting to work to no avail. But this will get the server attached auto-completing for you though. vim.api.nvim_create_autocmd({'BufNew', 'BufEnter'}, {
pattern = { '*.p8' },
callback = function(args)
vim.lsp.start({
name = 'pico8-ls',
cmd = { 'pico8-ls', '--stdio' },
root_dir = vim.fs.dirname(vim.api.nvim_buf_get_name(args.buf)),
-- Setup your keybinds in the on_attach function
on_attach = on_attach,
})
end
}) |
For syntax highlighter there's https://github.com/Bakudankun/PICO-8.vim, but it's very bare-bones. If you want richer syntax highlighting, you can try using tree-sitter's lua parser for Btw, you can set a filetype for |
Thanks for the suggestions, much appreciated. |
quick guide
vim.api.nvim_create_autocmd({'BufNew', 'BufEnter'}, {
pattern = { '*.p8' },
callback = function(args)
vim.lsp.start({
name = 'pico8-ls',
cmd = { 'pico8-ls', '--stdio' },
root_dir = vim.fs.dirname(vim.api.nvim_buf_get_name(args.buf)),
-- Setup your keybinds in the on_attach function
on_attach = on_attach,
})
end
})
for highlighting, I use the pico8.vim plugin but as @musjj said it is "very bare bones" should work from that point on |
Any pointers how to install pico8-ls for non-vscode setups?
The text was updated successfully, but these errors were encountered: