Skip to content

Fix and improve "type at cursor" command; show errors in phantoms #20

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 20 commits 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
6 changes: 5 additions & 1 deletion Default.sublime-commands
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@
},
{
"caption": "Merlin: Type expression under cursor",
"command": "merlin_type_command"
"command": "merlin_type_at_cursor_cmd"
},
{
"caption": "Merlin: Widen type range",
"command": "merlin_widen_type_at_cursor_cmd"
},
{
"caption": "Merlin: Enable syntax extension",
Expand Down
Binary file removed gutter-icon.png
Binary file not shown.
14 changes: 6 additions & 8 deletions merlin/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@

import sublime

from .helpers import merlin_bin
from merlin.helpers import merlin_bin

main_protocol_version = 3


class MerlinExc(Exception):
""" Exception returned by merlin. """

Expand Down Expand Up @@ -87,7 +86,6 @@ def restart(self):
finally:
if err_msg:
sublime.error_message(err_msg)
print(err_msg)

except (OSError, FileNotFoundError) as e:
print("Failed starting ocamlmerlin. Please ensure that ocamlmerlin"
Expand Down Expand Up @@ -143,13 +141,13 @@ def __init__(self, process, view):
self.process = process
self.view = view

def send_query(self, *query):
def send_query(self, *query, verbosity=None):
if self.process.protocol_version() == 1:
self.process.send_command(["reset", "auto", self.view.file_name()])
return self.process.send_command(query)
else:
document = ["auto", self.view.file_name()]
command = {'assoc': None, 'document': document, 'query': query}
command = {'assoc': None, 'printer_verbosity': verbosity, 'document': document, 'query': query}
return self.process.send_command(command)

def complete_cursor(self, base, line, col):
Expand All @@ -164,7 +162,7 @@ def report_errors(self):
"""
Return all errors detected by merlin while parsing the current file.
"""
return self.send_query("errors")
return self.send_query("errors", verbosity=-1)

def find_list(self):
""" List all possible external modules to load. """
Expand Down Expand Up @@ -220,9 +218,9 @@ def which_with_ext(self, extensions):
return self.send_query("which", "with_ext", extensions)

# Type information
def type_enclosing(self, line, col):
def type_enclosing(self, line, col, verbosity=None):
pos = {'line': line, 'col': col}
return self.send_query("type", "enclosing", "at", pos)
return self.send_query("type", "enclosing", "at", pos, verbosity=verbosity)

# Extensions management
def extension_list(self, crit=None):
Expand Down
Loading