Skip to content
This repository has been archived by the owner on Feb 3, 2024. It is now read-only.

Generate daemon_command #73

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions editor/sublime/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,21 @@ def pipe_reader(name, pipe, output=False):
break
daemon = None

def generate_daemon_command(settings):
proto = get_setting(view, settings, "proto")
if proto == "unix" and get_setting(view, settings, "remove"):
proto += " -remove=true"
daemon_path = get_setting(view, settings, "daemon_path")
port = get_setting(view, settings, "port")

return "%s daemon -proto=%s -port=%s" % (daemon_path, proto, port)

def start_daemon(daemon_command=None):
global daemon
global last_launch
if daemon_command == None:
settings = sublime.load_settings("completion.sublime-settings")
daemon_command = settings.get("daemon_command")
daemon_command = generate_daemon_command()

now = time.time()
output = False
Expand Down Expand Up @@ -222,7 +231,7 @@ def __init__(self, view):
def run(self, edit):
settings = sublime.load_settings("completion.sublime-settings")
launch_daemon = settings.get("launch_daemon", False)
daemon_command = settings.get("daemon_command")
daemon_command = generate_daemon_command()
debug = settings.get("debug", False)

locations = [a.b for a in self.view.sel()]
Expand Down Expand Up @@ -274,7 +283,7 @@ def on_query_completions(self, view, prefix, locations):

settings = sublime.load_settings("completion.sublime-settings")
launch_daemon = settings.get("launch_daemon", False)
daemon_command = settings.get("daemon_command")
daemon_command = generate_daemon_command()
debug = settings.get("debug", False)

driver, args = prepare_request(view, prefix, locations, settings)
Expand Down
3 changes: 2 additions & 1 deletion editor/sublime/sublime.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,10 @@ func (s *Sublime) writeDefaultConfig(user, p string) error {
bin_ := string(bin_bytes[:])

f.WriteString(fmt.Sprintf(`{
"daemon_command": [%s, "daemon", "-proto=unix", "-port=%s", "-remove=true"],
"daemon_path": %s,
"launch_daemon": true,
"proto": "unix",
"remove": true,
"port": "%s"
}
`, bin_, rpc, rpc))
Expand Down