try neovim

This commit is contained in:
Erik Winter 2023-12-15 07:58:31 +01:00
parent 3bf1327666
commit 97fb0206cf
2 changed files with 55 additions and 2 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
content

56
main.go
View File

@ -1,7 +1,59 @@
package main package main
import "fmt" import (
"fmt"
"log"
"os"
"os/exec"
"path/filepath"
"time"
)
type Scene struct {
Path string
}
func main() { func main() {
fmt.Println("Hoi")
// Start Neovim with a server name
cmd := exec.Command("nvim", "--servername", "NVIM_SERVER", tempFile.Name())
cmd.Stdin = os.Stdin
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
err := cmd.Start()
if err != nil {
log.Fatal(err)
}
// Wait for Neovim to start
time.Sleep(time.Second)
// Send a command to the running Neovim instance
cmd = exec.Command("nvim", "--servername", "NVIM_SERVER", "--remote-send", ":edit /path/to/new/file<CR>")
err = cmd.Run()
if err != nil {
log.Fatal(err)
}
}
func getScenes() ([]Scene, error) {
scenes := make([]Scene, 0)
root := "content"
err := filepath.Walk(root, func(path string, info os.FileInfo, err error) error {
if err != nil {
return err
}
if !info.IsDir() {
if filepath.Ext(path) == ".md" {
scenes = append(scenes, Scene{Path: path})
}
}
return nil
})
if err != nil {
fmt.Printf("error walking the path %v: %v\n", root, err)
}
return scenes, nil
} }