nvim-godot icon indicating copy to clipboard operation
nvim-godot copied to clipboard

If you are having problems with file paths containing spaces

Open ThomasT75 opened this issue 1 year ago • 1 comments

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)

ThomasT75 avatar Apr 03 '24 02:04 ThomasT75

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

niscolas avatar Jul 03 '24 14:07 niscolas

Closing since I just merged the PR

niscolas avatar Oct 16 '24 16:10 niscolas