Code Monkey home page Code Monkey logo

async-clj-omni's Introduction

clj-async.nvim

Provides async clojure completion for:

Trying to use Fireplace's omnicompletion with auto-complete is painfully slow at times, making typing blocked. Using this module will be faster as it does not block, it runs in it's own thread.

Installation

CIDER

For this plugin to work, your nREPL must have CIDER available. You can install it for lein and boot.

Deoplete

Follow the install instructions for deoplete.nvim. Then just include with your favourite plugin manager, mine is vim-plug

Plug 'clojure-vim/async-clj-omni'

You also need to include the following line in your init.vim:

call deoplete#custom#option('keyword_patterns', {'clojure': '[\w!$%&*+/:<=>?@\^_~\-\.#]*'})

Nvim Completion Manager 2

  1. Follow the install instructions for ncm2.
  2. Add this plugin using your favourite plugin manager,
    Plug 'clojure-vim/async-clj-omni'

asyncomplete.vim

Registration:

au User asyncomplete_setup call asyncomplete#register_source({
    \ 'name': 'async_clj_omni',
    \ 'whitelist': ['clojure'],
    \ 'completor': function('async_clj_omni#sources#complete'),
    \ })

coc.nvim

  1. Follow the install instructions for coc.nvim.
  2. Add this plugin using your favourite plugin manager,
    Plug 'clojure-vim/async-clj-omni'

nvim-cmp

  1. Follow the install instructions for nvim-cmp.
  2. Add { name = 'async_clj_omni' }, a complete example:
    cmp.setup({
      sources = {
        { name = 'async_clj_omni' },
      }
    })

Developing

Deoplete

A few snippets and tidbits for development:

:call deoplete#custom#set('async_clj', 'debug_enabled', 1)
:call deoplete#enable_logging("DEBUG", "/tmp/deopletelog")

Then you can this command to watch debug statements:

$ tail -f /tmp/deopletelog

Debug statements can be made in the source via:

self.debug(msg)

Nvim Completion Manager

NVIM_PYTHON_LOG_FILE=logfile NVIM_PYTHON_LOG_LEVEL=DEBUG nvim

FAQ

  1. Why do you include nrepl-python-client via submodule.

    I made the decision that it was more complex to have users try and manage a version of nrepl-python-client, than it was for them to "just" have it included. In an ideal world, I'd be able to use virtualenv with the Python/Neovim, but this isn't currently a realistic expectation for all users to be able to use.

async-clj-omni's People

Contributors

daveyarwood avatar deraen avatar finalfantasia avatar hkupty avatar roxma avatar severeoverfl0w avatar waffle-iron avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

async-clj-omni's Issues

Uncaught BrokenPipeError makes Neovim+deoplete unusable while error message is printing

I run into this problem fairly often, where I am developing in Neovim, connected to a REPL, and for one reason or another, I end up needing to restart the REPL, so I Ctrl-C it and restart. This breaks the plugin's connection to the REPL, so the next time deoplete needs to autocomplete something (i.e. I start typing), my typing is interrupted by a stacktrace, which I have to ENTER through one line at a time:

[deoplete] Traceback (most recent call last):
[deoplete]   File "/home/dave/.vim/bundle/deoplete.nvim/rplugin/python3/deoplete/deoplete.py", line 123, in gather_results
[deoplete]     ctx['candidates'] = source.gather_candidates(ctx)
[deoplete]   File "/home/dave/.vim/bundle/async-clj-omni/rplugin/python3/deoplete/sources/async_clj.py", line 24, in gather_candidates
[deoplete]     return self.__cider_completion_manager.gather_candidates(context["complete_str"])
[deoplete]   File "/home/dave/.vim/bundle/async-clj-omni/rplugin/python3/deoplete/sources/../../../../pythonx/async_clj_omni/fireplace.py", line 87, in gather_candidates
[deoplete]     ns)
[deoplete]   File "/home/dave/.vim/bundle/async-clj-omni/rplugin/python3/deoplete/sources/../../../../pythonx/async_clj_omni/cider.py", line 60, in cider_gather
[deoplete]     "ns": ns
[deoplete]   File "/home/dave/.vim/bundle/async-clj-omni/rplugin/python3/deoplete/sources/../../../../pythonx/async_clj_omni/fireplace.py", line 53, in send
[deoplete]     self.wc.send(msg)
[deoplete]   File "/home/dave/.vim/bundle/async-clj-omni/rplugin/python3/deoplete/sources/vim_nrepl_python_client/nrepl/__init__.py", line 78, in send
[deoplete]     self._IO.write(message)
[deoplete]   File "/home/dave/.vim/bundle/async-clj-omni/rplugin/python3/deoplete/sources/vim_nrepl_python_client/nrepl/bencode.py", line 175, in write
[deoplete]     return _write_datum(v, self._file)
[deoplete]   File "/home/dave/.vim/bundle/async-clj-omni/rplugin/python3/deoplete/sources/vim_nrepl_python_client/nrepl/bencode.py", line 125, in _write_datum
[deoplete]     _write_datum(v, out)
[deoplete]   File "/home/dave/.vim/bundle/async-clj-omni/rplugin/python3/deoplete/sources/vim_nrepl_python_client/nrepl/bencode.py", line 127, in _write_datum
[deoplete]     out.flush()
[deoplete]   File "/usr/lib/python3.5/socket.py", line 593, in write
[deoplete]     return self._sock.send(b)
[deoplete] Could not get completions from: async_clj.  Use :messages for error details.

EDIT: I could have swore there was a BrokenPipeError printed at the bottom, before... I may have accidentally deleted that line. Ugh, sorry...

It's not clear to me if the root of the problem lies in deoplete or clj-async-omni, as I'm not sure how they interact with each other.

Assuming that clj-async-omni is at the top of the stack, would it make sense for clj-async-omni to catch BrokenPipeError and do something less cumbersome? (e.g. print an "nREPL connection was lost." message and stop trying to connect to it)

Cant get it working

I cant seem to get it working, I have tried everything, but to no avail,
I installed the plugin and deoplete setup as instructed:

let g:deoplete#keyword_patterns = {}
let g:deoplete#keyword_patterns.clojure = '[\w!$%&+/:<=>?@^_~-.#]'
doing :checkhealth
1 health#deoplete#check
2 ========================================================================
3 ## deoplete.nvim
4 - OK: has("nvim") was successful
5 - OK: exists("v:t_list") was successful
6 - OK: has("timers") was successful
7 - OK: has("python3") was successful
8 - INFO: If you're still having problems, try the following commands:
9 $ export NVIM_PYTHON_LOG_FILE=/tmp/log
10 $ export NVIM_PYTHON_LOG_LEVEL=DEBUG
11 $ nvim
12 $ cat /tmp/log_{PID}
13 and then create an issue on github
14

nothing absolutely happens, when editing a clojure file, does this still work with current version of deoplete?

Deoplete not working

Hi

With everything setup correctly as in issue 20 I am getting deoplete crashing in the async_clj source with a socket error.

I have tried with cider version 0.17.0 and the latest beta resulting in the same problem.

I can send more details if you need.

Can you help please.

cheers

This is the stack trace

[deoplete] Traceback (most recent call last): File "/Users/user1/.cache/vim/dein/repos/github.com/Shougo/deoplete.nvim/rplugin/python3/deoplete/child.py", line 182, in _gather_results result = self._get_result(context, source) File "/Users/user1/.cache/vim/dein/repos/github.com/Shougo/deoplete.nvim/rplugin/python3/deoplete/child.py", line 241, in _get_result ctx['candidates'] = source.gather_candidates(ctx) File "/Users/user1/.cache/vim/dein/repos/github.com/clojure-vim/async-clj-omni/rplugin/python3/deoplete/sources/async_clj.py", line 24, in gather_candidates return self.__cider_completion_manager.gather_candidates(context["complete_str"]) File "/Users/user1/.cache/vim/dein/repos/github.com/clojure-vim/async-clj-omni/rplugin/python3/deoplete/sources/../../../../pythonx/async_clj_omni/fireplace.py", line 88, in gather_candidates wc = self.__connmanager.get_conn(conn_string) File "/Users/user1/.cache/vim/dein/repos/github.com/clojure-vim/async-clj-omni/rplugin/python3/deoplete/sources/../../../../pythonx/async_clj_omni/fireplace.py", line 36, in get_conn conn = nrepl.connect(conn_string) File "/Users/user1/.cache/vim/dein/repos/github.com/clojure-vim/async-clj-omni/rplugin/python3/deoplete/sources/vim_nrepl_python_client/nrepl/__init__.py", line 129, in connect return f(uri) File "/Users/user1/.cache/vim/dein/repos/github.com/clojure-vim/async-clj-omni/rplugin/python3/deoplete/sources/vim_nrepl_python_client/nrepl/__init__.py", line 31, in _bencode_connect s = socket.create_connection(uri.netloc.split(":")) File "/Users/user1/.cache/pyenv/versions/3.7.2/lib/python3.7/socket.py", line 707, in create_connection for res in getaddrinfo(host, port, 0, SOCK_STREAM): File "/Users/user1/.cache/pyenv/versions/3.7.2/lib/python3.7/socket.py", line 748, in getaddrinfo for res in _socket.getaddrinfo(host, port, family, type, proto, flags): socket.gaierror: [Errno 8] nodename nor servname provided, or not known Error from async_clj: [Errno 8] nodename nor servname provided, or not known. Use :messages / see above for error details. [deoplete] Traceback (most recent call last): File "/Users/user1/.cache/vim/dein/repos/github.com/Shougo/deoplete.nvim/rplugin/python3/deoplete/child.py", line 182, in _gather_results result = self._get_result(context, source) File "/Users/user1/.cache/vim/dein/repos/github.com/Shougo/deoplete.nvim/rplugin/python3/deoplete/child.py", line 241, in _get_result ctx['candidates'] = source.gather_candidates(ctx) File "/Users/user1/.cache/vim/dein/repos/github.com/clojure-vim/async-clj-omni/rplugin/python3/deoplete/sources/async_clj.py", line 24, in gather_candidates return self.__cider_completion_manager.gather_candidates(context["complete_str"]) File "/Users/user1/.cache/vim/dein/repos/github.com/clojure-vim/async-clj-omni/rplugin/python3/deoplete/sources/../../../../pythonx/async_clj_omni/fireplace.py", line 88, in gather_candidates wc = self.__connmanager.get_conn(conn_string) File "/Users/user1/.cache/vim/dein/repos/github.com/clojure-vim/async-clj-omni/rplugin/python3/deoplete/sources/../../../../pythonx/async_clj_omni/fireplace.py", line 36, in get_conn conn = nrepl.connect(conn_string) File "/Users/user1/.cache/vim/dein/repos/github.com/clojure-vim/async-clj-omni/rplugin/python3/deoplete/sources/vim_nrepl_python_client/nrepl/__init__.py", line 129, in connect return f(uri) File "/Users/user1/.cache/vim/dein/repos/github.com/clojure-vim/async-clj-omni/rplugin/python3/deoplete/sources/vim_nrepl_python_client/nrepl/__init__.py", line 31, in _bencode_connect s = socket.create_connection(uri.netloc.split(":")) File "/Users/user1/.cache/pyenv/versions/3.7.2/lib/python3.7/socket.py", line 707, in create_connection for res in getaddrinfo(host, port, 0, SOCK_STREAM): File "/Users/user1/.cache/pyenv/versions/3.7.2/lib/python3.7/socket.py", line 748, in getaddrinfo for res in _socket.getaddrinfo(host, port, family, type, proto, flags): socket.gaierror: [Errno 8] nodename nor servname provided, or not known Error from async_clj: [Errno 8] nodename nor servname provided, or not known. Use :messages / see above for error details. [deoplete] Too many errors from "async_clj". This source is disabled until Neovim is restarted.

Use watchable connection

It occurs to me that the recreation of the connections may have been caused by me reading from sessions of other instances of the reader.

To prevent creating thousands of connections per-session, I propose a singleton listener which uses the WatchableConnection aspect of nrepl-python-client, and then each run of gather_candidates should listen for it's own session to complete, and return that information.

This should solve the cached connection issue.

It's also worth double checking our origin sessions for things.

How big a deal would it be to make this work with Slimv?

I have decided to do my Clojure development with Slimv.
I completely missed that this is targeted at fireplace - until I started browsing the sources looking
for why it didn't seem to be working.... sigh.
Would it be appropriate for use with Slimv also?
If so would it be a big effort to accomplish?

Thanks,
Dave Day

Bencode error

[deoplete] Traceback (most recent call last):                                                                                                                                                                                                                 
[deoplete]   File "/home/juho/.config/nvim/bundle/deoplete.nvim/rplugin/python3/deoplete/deoplete.py", line 98, in gather_results                                                                                                                             
[deoplete]     ctx['candidates'] = source.gather_candidates(ctx)                                                                                                                                                                                              
[deoplete]   File "/home/juho/.config/nvim/bundle_clojure/async-clj-omni/rplugin/python3/deoplete/sources/async_clj.py", line 83, in gather_candidates                                                                                                        
[deoplete]     response = conn.read()                                                                                                                                                                                                                         
[deoplete]   File "/home/juho/.vim/bundle_clojure/async-clj-omni/rplugin/python3/deoplete/sources/nrepl_python_client/nrepl/bencode.py", line 154, in read                                                                                                    
[deoplete]     return _read_datum(self._file)                                                                                                                                                                                                                 
[deoplete]   File "/home/juho/.vim/bundle_clojure/async-clj-omni/rplugin/python3/deoplete/sources/nrepl_python_client/nrepl/bencode.py", line 99, in _read_datum                                                                                              
[deoplete]     return _read_fns.get(delim, lambda s: _read_bytes(s, delim))(s)                                                                                                                                                                                
[deoplete]   File "/home/juho/.vim/bundle_clojure/async-clj-omni/rplugin/python3/deoplete/sources/nrepl_python_client/nrepl/bencode.py", line 84, in _read_map                                                                                                
[deoplete]     i = iter(_read_list(s))                                                                                                                                                                                                                        
[deoplete]   File "/home/juho/.vim/bundle_clojure/async-clj-omni/rplugin/python3/deoplete/sources/nrepl_python_client/nrepl/bencode.py", line 76, in _read_list                                                                                               
[deoplete]     datum = _read_datum(s)                                                                                                                                                                                                                         
[deoplete]   File "/home/juho/.vim/bundle_clojure/async-clj-omni/rplugin/python3/deoplete/sources/nrepl_python_client/nrepl/bencode.py", line 99, in _read_datum                                                                                              
[deoplete]     return _read_fns.get(delim, lambda s: _read_bytes(s, delim))(s)                                                                                                                                                                                
[deoplete]   File "/home/juho/.vim/bundle_clojure/async-clj-omni/rplugin/python3/deoplete/sources/nrepl_python_client/nrepl/bencode.py", line 76, in _read_list                                                                                               
[deoplete]     datum = _read_datum(s)                                                                                                                                                                                                                         
[deoplete]   File "/home/juho/.vim/bundle_clojure/async-clj-omni/rplugin/python3/deoplete/sources/nrepl_python_client/nrepl/bencode.py", line 99, in _read_datum                                                                                              
[deoplete]     return _read_fns.get(delim, lambda s: _read_bytes(s, delim))(s)                                                                                                                                                                                
[deoplete]   File "/home/juho/.vim/bundle_clojure/async-clj-omni/rplugin/python3/deoplete/sources/nrepl_python_client/nrepl/bencode.py", line 84, in _read_map                                                                                                
[deoplete]     i = iter(_read_list(s))                                                                                                                                                                                                                        
[deoplete]   File "/home/juho/.vim/bundle_clojure/async-clj-omni/rplugin/python3/deoplete/sources/nrepl_python_client/nrepl/bencode.py", line 76, in _read_list                                                                                               
[deoplete]     datum = _read_datum(s)                                                                                                                                                                                                                         
[deoplete]   File "/home/juho/.vim/bundle_clojure/async-clj-omni/rplugin/python3/deoplete/sources/nrepl_python_client/nrepl/bencode.py", line 99, in _read_datum                                                                                              
[deoplete]     return _read_fns.get(delim, lambda s: _read_bytes(s, delim))(s)                                                                                                                                                                                
[deoplete]   File "/home/juho/.vim/bundle_clojure/async-clj-omni/rplugin/python3/deoplete/sources/nrepl_python_client/nrepl/bencode.py", line 99, in <lambda>                                                                                                 
[deoplete]     return _read_fns.get(delim, lambda s: _read_bytes(s, delim))(s)                                                                                                                                                                                
[deoplete]   File "/home/juho/.vim/bundle_clojure/async-clj-omni/rplugin/python3/deoplete/sources/nrepl_python_client/nrepl/bencode.py", line 51, in _read_bytes                                                                                              
[deoplete]     while cnt < n:                                                                                                                                                                                                                                 
[deoplete] TypeError: unorderable types: int() < str()                                                                                                                                                                                                        
[deoplete] Could not get completions from: async_clj.  Use :messages for error details.  

Unit tests

Would help with some more complex logic (like #2)

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.