niscolas / nvim-godot

Use Neovim as your Godot code editor!
https://hub.docker.com/repository/docker/niscolas/nvim-godot/
MIT License
58 stars 3 forks source link

If you are having problems with file paths containing spaces #1

Closed ThomasT75 closed 4 days ago

ThomasT75 commented 6 months ago

I was having problem with nvim opening multiple not existing files after the first one so i fixed the script

#!/usr/bin/env bash

# CHANGE IF NEEDED:
# - replace with your Terminal Emulator executable
term_exec="alacritty"
# - replace with your Neovim executable
nvim_exec="nvim"
# - replace with other path for the Neovim server pipe
server_path="$HOME/.cache/nvim/godot-server.pipe"

start_server() {
    "$term_exec" -e "$nvim_exec" --listen "$server_path"
}

open_file_in_server() {
    # - escape stuff because nvim will not
    filename=$(printf %q "$1")
    "$term_exec" -e "$nvim_exec" --server "$server_path" --remote-send "<C-\><C-n>:n $filename<CR>:call cursor($2)<CR>"
}

if ! [ -e "$server_path" ]; then
    # - start server FIRST then open the file
    start_server &
    sleep 200ms # - wait for the server to start 
    open_file_in_server "$1" "$2"
else
    open_file_in_server "$1" "$2"
fi

the original version of the script would work if your file paths had no spaces in them there is one more problem and it is with the {line} param in godot is that if the bug is at line 10 godot will send line 9 to the nvim-server i can't test the {col} param but it might have the same problem or my nvim config reads 1 as the first line not 0 as the first line for cursor cmd (didn't fix it)

niscolas commented 3 months ago

Thanks for noticing, I would be glad to merge the changes if you get a PR up for it!

niscolas commented 4 days ago

Closing since I just merged the PR