24 lines
635 B
Lua
24 lines
635 B
Lua
local port = os.getenv('GDScript_Port') or 6005
|
|
local cmd = vim.lsp.rpc.connect('127.0.0.1', port)
|
|
local pipe = '/tmp/godot.pipe'
|
|
|
|
vim.lsp.start({
|
|
name = 'Godot',
|
|
cmd = cmd,
|
|
root_dir = vim.fs.dirname(vim.fs.find({ 'project.godot', '.git' }, { upward = true })[1]),
|
|
on_attach = function(client, bufnr)
|
|
print("gdscipt.lua on_attach")
|
|
vim.api.nvim_command('echo serverstart("' .. pipe .. '")')
|
|
end
|
|
})
|
|
|
|
vim.api.nvim_create_autocmd('BufWritePost',
|
|
{
|
|
pattern = '*.gd',
|
|
callback = function()
|
|
local file = vim.api.nvim_buf_get_name(0)
|
|
local job = vim.fn.jobstart({ "gdformat", file })
|
|
vim.fn.jobwait({ job })
|
|
end,
|
|
})
|