Example #1
0
    def completions(self,
                    line,
                    col,
                    path,
                    data,
                    dir,
                    target=None,
                    cmdargs=None):

        data = {
            'line_num': line,
            'column_num': col,
            'filepath': path,
            'file_data': data
        }

        url = '%s/completions' % self.url

        hmac_secret = self.hmac_req('POST', '/completions', data,
                                    self.hmac_secret)

        headers = {
            'X-YCM-HMAC': hmac_secret,
        }

        req = self.post(url, json=data, headers=headers, timeout=2)
        printd('Request data:', req.json())
        return self.build_docs(req.json())
Example #2
0
 def c_path(cls, path='ag'):
     """
     Set the ag path. If ag is known to your environment then
     there is no need to set it.
     """
     pass
     cls.path = path
     printd('Sniper - Setting ag path = ', path)
Example #3
0
    def set_path(self, event):
        """    
        Set the project root automatically.
        """

        self.area.project = get_sentinel_file(self.area.filename,
                                              *Project.sentinels)
        printd('Project - Setting project path = ', self.area.project)
Example #4
0
    def ready(self, line, col, path, data):
        """
        Send file ready.
        """

        req = self.e_send('FileReadyToParse', line, col, path, data)
        printd('Ycmd - /FileReadyToParse status', req.status_code)
        printd('Ycmd - FileReadyToParse Event Response JSON:\n', req.json())
        return req
Example #5
0
    def c_appearance(cls, **confs):
        """
        Used to set matched region properties. These properties
        can be background, foreground etc. 

        Check Tkinter Text widget documentation on tags for more info.
        """

        cls.confs.update(confs)
        printd('Find - Setting confs = ', cls.confs)
Example #6
0
    def buffer_unload(self, line, col, path, data):
        """
        When an AreaVi instance is destroyed it is sent.
        It is useful to lower resource consume.
        """

        req = self.e_send('BufferUnload', line, col, path, data)
        printd('Ycmd - BufferUnload status', req.status_code)
        printd('Ycmd - BufferUnload Event Response JSON:\n', req.json())
        return req
Example #7
0
    def c_appearance(cls, dir, file):
        """
        Used to configure foreground/background for directory entries.

        Check Tkinter Text widget tags for more info.
        """

        cls.confs['(MC-DIRECTORY)'] = dir
        cls.confs['(MC-FILE)'] = file

        printd('(Mc) Setting dir/file appearance confs = ', cls.confs)
Example #8
0
    def on_unload(self, event):
        """
        """
        data = {
            self.area.filename: {
                'filetypes': [FILETYPES[self.area.extension]],
                'contents': self.area.get('1.0', 'end')
            }
        }

        req = self.server.buffer_unload(1, 1, self.area.filename, data)
        printd('Ycmd - BufferUnload status', req.status_code)
        printd('Ycmd - BufferUnload JSON response', req.json())
Example #9
0
    def is_alive(self):
        """
        """
        hmac_secret = self.hmac_req('GET', '/healthy', '', self.hmac_secret)

        url = '%s/healthy' % self.url
        headers = {
            'X-YCM-HMAC': hmac_secret,
        }

        req = self.get(url, headers=headers)
        printd('Ycmd - /healthy response status..\n', req.status_code)
        printd('Ycmd - /healthy response JSON', req.json())
Example #10
0
    def debug_info(self, line, col, path, data):
        data = {
            'line_num': line,
            'column_num': col,
            'filepath': path,
            'file_data': data
        }

        url = '%s/debug_info' % self.url
        hmac_secret = self.hmac_req('POST', '/debug_info', data,
                                    self.hmac_secret)

        headers = {
            'X-YCM-HMAC': hmac_secret,
        }

        req = self.post(url, json=data, headers=headers, timeout=2)
        printd('Ycmd - debug_info Event Response JSON:\n', req.json())
        return req
Example #11
0
    def start(self):
        printd('(ibash) Bash process started...')
        self.child = Popen(self.cmd,
                           shell=0,
                           stdout=PIPE,
                           stdin=PIPE,
                           preexec_fn=setsid,
                           stderr=STDOUT,
                           env=environ)

        self.stdout = Device(self.child.stdout)
        self.stdin = Device(self.child.stdin)

        Stdout(self.stdout)
        Stdin(self.stdin)

        xmap(self.stdout, LOAD,
             lambda con, data: sys.stdout.write(data.decode('utf8')))
        xmap(self.stdin, CLOSE, lambda dev, err: lose(dev))
        xmap(self.stdout, CLOSE, lambda dev, err: lose(dev))
Example #12
0
    def load_conf(self, path):
        """
        """

        data = {
            'filepath': path,
        }

        url = '%s/load_extra_conf_file' % self.url
        hmac_secret = self.hmac_req('POST', '/load_extra_conf_file', data,
                                    self.hmac_secret)

        headers = {
            'X-YCM-HMAC': hmac_secret,
        }

        req = self.post(url, json=data, headers=headers)

        printd('Ycmd - Loading extra conf...', path)
        printd('Ycmd - Load conf response:', req.json())
Example #13
0
    def __init__(self, area):
        self.area = area

        area.install(
            'sniper',
            ('NORMAL', '<Key-b>', lambda event: self.options.display()),
            ('NORMAL', '<Key-B>', lambda event: Get(
                events={
                    '<Return>': self.find,
                    '<Control-i>': self.set_ignore_regex,
                    '<Control-x>': self.set_type_lax,
                    '<Control-r>': self.set_type_regex,
                    '<Control-l>': self.set_type_literal,
                    '<Control-g>': self.set_file_regex,
                    '<Control-s>': self.set_nocase,
                    '<Control-w>': self.set_wide,
                    '<Control-m>': self.set_multiline,
                    '<Escape>': lambda wid: True
                })))

        if not self.dirs:
            printd('Sniper - Sniper.dirs is not set.')
Example #14
0
 def c_path(cls, path):
     printd('Deadcode - Setting Vulture path = ', cls.path)
     cls.path = path
Example #15
0
 def c_dirs(cls, *dirs):
     """
     Folders where ag will be searching for data.
     """
     cls.dirs = dirs
     printd('Sniper - Setting dirs =', *dirs)
Example #16
0
 def c_sentinels(cls, *sentinels):
     cls.sentinels = sentinels
     printd('Project - Setting sentinels = ', cls.sentinels)
Example #17
0
    def hook_class(self, id, seq, callback, add=True):
        modn = 'mode%s%s' % (self, id)
        if self.bind_class(modn, seq):
            printd('Warning: %s %s already binded!' % (id, seq))

        self.bind_class(modn, seq, callback, add)
Example #18
0
 def c_path(cls, path):
     printd('Snakerr - Setting Mypy path = ', cls.path)
     cls.path = path
Example #19
0
 def c_path(cls, path='ag'):
     cls.path = path
     printd('Fstmt - Setting ag path = ', path)
Example #20
0
 def c_path(cls, path):
     printd('Snakerr - Setting Pyflakes path = ', cls.path)
     cls.path = path