Code Monkey home page Code Monkey logo

refact-sublime's People

Contributors

digital-phoenix avatar olegklimov avatar reymondzzzz avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar

refact-sublime's Issues

Completion doesn't start after "pause refact"

Steps to reproduce:
Checking completion - completion is working
Press "pause refact" (in Tools menu) and check - completion is not working (OK)
Press pause again - check completion.

Expected result:
Completion started and working.

Actual result:
Completion not working.
No error messages.
In console:

reloading settings Packages/User/refact.sublime-settings
reloading settings Packages/User/refact.sublime-settings

Additional info:
If you restart sublime, completion still won't work. If then press "pause refact", console will display the following:
Traceback (most recent call last): File "/snap/sublime-text/156/opt/sublime_text/Lib/python38/sublime_plugin.py", line 1704, in run_ return self.run(edit) File "/home/fupfv/.config/sublime-text/Packages/refact/__init__.py", line 128, in run refact_session_manager.get_session(self.view).clear_completion() AttributeError: 'NoneType' object has no attribute 'get_session' reloading settings Packages/User/refact.sublime-settings
If you manually change "pause_completion" setting to false in .config/sublime-text/Packages/User/refact.sublime-settings, completion will work.

Versions:
Refact 0.0.1
Sublime Text? Build 4169

refact-lsp process handling

process_server_errors() approach is probably not a good idea (a thread?), it's better to save logs to ~/.cache/refact/logs/ by removing --logs-stderr.

The process does not restart with relevant settings change, specifically api_key, address_url, telemetry_code_snippets.

Errors that are kind of caught there:

			print(line)
			if "error" in line:
				self.statusbar.update_statusbar("error", line)

-- but they really need to go via LSP RPC. The simple test is to turn off wi-fi, does this produce a disconnected icon in the status bar or not?

Status bar is flickering

Is there a timer that updates the status bar all the time?

One solution might be to change status bar whenever Refact plugin actually works, and leave it alone in other times.

CleanShot.2024-02-19.at.08.56.37.mp4

Fix closing brackets

It's important to delete spaces before asking the model, because there should be a way for the model to suggest code with less indent. Typical example of this:

int main()
{
    printf("Hello world!\n");
    |

Now the completion is "}", but it will not work unless there are no spaces on that line. With spaces, the model is constrained to " }".

Need LSP workspace folders and events

Now refact-lsp receives:

2024-02-07T09:12:02.530871Z  INFO refact_lsp::lsp:180: LSP client_info None
2024-02-07T09:12:02.530875Z  INFO refact_lsp::lsp:184: LSP workspace_folders RwLock { data: None }

But it needs workspace folders to index the files inside. I have two Sublime windows open, with different paths. Both need to be visible in workspace_folders.

Another problem is it needs these LSP events for specific files:

did_open
did_change
did_save
did_close

And finally for statistics we need handle_v1_snippet_accepted (actually an analog of this in LSP RPC) when a grey text code completion is accepted (Tab).

[WIN] When creating a new unsaved file, autocompletion does not work in it

Create new file - Try completion in it -> Completion not working
In console:
Traceback (most recent call last): File "C:\Program Files\Sublime Text\Lib\python38\sublime_plugin.py", line 959, in on_modified run_view_callbacks('on_modified', view_id) File "C:\Program Files\Sublime Text\Lib\python38\sublime_plugin.py", line 741, in run_view_callbacks callback(v, *args) File "C:\Program Files\Sublime Text\Lib\python38\sublime_plugin.py", line 162, in profiler return event_handler(*args) File "C:\Users\agzam\AppData\Roaming\Sublime Text\Packages\refact\__init__.py", line 21, in on_modified session = refact_session_manager.get_session(view) File "C:\Users\agzam\AppData\Roaming\Sublime Text\Packages\refact\src\refact_sessions.py", line 35, in get_session self.views[view_id] = RefactSession(view, self.get_connection, view_id == "UI") File "C:\Users\agzam\AppData\Roaming\Sublime Text\Packages\refact\src\refact_sessions.py", line 58, in __init__ self.connection().load_document(self.file_name, get_text(self.view), self.languageId) File "C:\Users\agzam\AppData\Roaming\Sublime Text\Packages\refact\src\refact_lsp.py", line 19, in load_document uri = pathlib.Path(file_name).as_uri() File "./python3.8/pathlib.py", line 748, in as_uri ValueError: relative path can't be expressed as a file URI
If you save the file, the compliment will start working

Versions:
Sublime plugin v 0.0.1
Sublime Text Build 4169

Version v0.1

Following https://github.com/smallcloudai/refact-vs-classic/ , we need a first version of a plugin for Sublime Text that starts refact-lsp server, has completion, status bar, settings, and that's about it.

Completion should behave generally like in VS Code, more details about multiline and single line completion are here in a VS Classic issue and here is some more.

Clarification: this has nothing to do with completions that go inside a popup. Here we are only interested in inline completions (multiline or single line), also known as "grey text" or "ghost text".

Refact-LSP is an executable file that gets built here, download one for your platform, run it with --help to see what kind of options it accepts.

The relevant LSP part is textDocument/didOpen, textDocument/didChange, textDocument/didClose, workspace/didDeleteFiles -- to inform the LSP server about the source files open or changed. This is used for context, for a good completion for file1 probably it needs a context from file2. That's why refact-lsp needs those calls to happen.

The completion itself is a LSP call refact/getCompletions, but there's an effort to switch to a more standard 3.18.

Status bar like in this VS issue needs an idle state, rotating icon when it asks for a new completion, and an error state that shows text error in a tooltip.

Settings can be similar to VS Code settings, those are mainly go directly to refact-lsp command line. One that doesn't is "pause", it should be accessible via a context menu in the status bar or a hotkey -- an ability to pause completions if they get annoying in some cases.

This bounty supersedes the previous attempt over here that got stalled.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.