GithubHelp home page GithubHelp logo

ms-jpq / coq_nvim Goto Github PK

View Code? Open in Web Editor NEW
3.4K 16.0 95.0 5.05 MB

Fast as FUCK nvim completion. SQLite, concurrent scheduler, hundreds of hours of optimization.

License: GNU General Public License v3.0

Python 89.83% Lua 5.53% Dockerfile 0.27% PLpgSQL 3.28% Vim Script 0.75% Makefile 0.32% C 0.01% CSS 0.01% TypeScript 0.01%
neovim neovim-plugin completion

coq_nvim's Introduction

Named after the famous theorem prover

coq also means in français québécois, and I guess 🥖.

Fast as FUCK and loads of features.

Faster Than Pure Lua

  • Native C in-memory B-trees

  • SQLite VM interrupts

  • Coroutine based incremental & interruptible scheduler

  • TCP-esque flow control

More details at the PERFORMANCE.md

Features

Note: Due to compression, reality is faster than gifs

Fast as fuck

  • Results on every keystroke

  • Throttling? Never heard of her

  • Real time performance statistics

  • Look at the gifs! The bottom few are the fastest when I didn't slow down on purpose to show features.

Fuzzy Search

Error correction: cour -> colour_space, flgr -> flag_group, nasp -> Namespace

fuzz_search.img

Preview

  • Press key to view documentation in big buffer

  • Auto open preview on side with most space

  • Customizable location: n, s, w, e

  • Ubiquitous: Tags, LSP, TreeSitter, Paths, Snippets

doc_popup.img

LSP

  • Incremental completion

  • Client-side caching

  • Multi-server completion (i.e. tailwind + cssls)

  • Multi-encoding utf-8, utf-16, utf-32

  • Header imports

lsp_imports.img

  • Snippet Support

lsp_snippets.img

Install the Nvim Official LSP integration

Requires 2 lines of change to support LSP snippets

local lsp = require "lspconfig"
local coq = require "coq" -- add this

lsp.<server>.setup(<stuff...>)                              -- before
lsp.<server>.setup(coq.lsp_ensure_capabilities(<stuff...>)) -- after

Snippets

snippet_norm.img

  • Linked regions

snippet_expand.img

snip_load.img

The % statistic comes from compiling the 10,000 snippets

TreeSitter

  • Shows context

  • Partial document parsing

  • Auto-disable if document is too big

  • Unicode ready

treesitter.img

Treesitter is still unstable in nvim0.5: slow and crash prone

The promise is that Treesitter will have real time parsing on every keystroke, but it's actually too slow on big files.

The Treesitter source only parses a limited number of lines about the cursor and only on Idle events due to unrealized performance promises.

CTags

  • LSP like

  • Incremental & automatic background compilation

  • Non-blocking

ctags.img

Requires Universal CTags, NOT ctags

# MacOS
brew uninstall ctags           # bad
brew install   universal-ctags # good

# Ubuntu
apt remove  ctags              # bad
apt install universal-ctags    # good

Paths

  • Preview contents

  • $VARIABLE expansion, %EVEN_UNDER_WINDOWS%

  • Relative to both cwd and file path

paths.img

Buffers

  • Real time completion

  • Fast in files with thousands of lines

buffers.img

Registers

  • words Last yank 0 + custom a-z coq_settings.clients.registers.words

  • lines coq_settings.clients.registers.lines (a-z)

Tmux

tmux.img

Tabnine

  • CPU preserving flow control

  • Auto download & install & update

  • Platform specific cgroupv2 & taskpolicy core pinning / CPU management.

tabnine.img

T9 is disabled by default, I might remove it, if they do not improve the CPU usage. Their own bug tracker.

Enable via: coq_settings.clients.tabnine.enabled=true

Modular lua sources & external third party integrations

repl.img

Shown above: shell repl.

Some other built-ins:

Statistics

:COQstats

statistics.img

Validating config parser

  • Prevents typos & type errors in your config

Here I make a type error on purpose inputting string instead of an integer.

conf_demo.img

Pretty

pretty.gif

If you can't see icons properly:

Either set let g:coq_settings = { 'display.icons.mode': 'none' } to disable icons, or install a supported font

Install

Windows requires symlinks support in git.

git config --global core.symlinks true

Needs python virtual env

apt install --yes -- python3-venv

Minimum version: python:3.8.2, nvim: 0.5, sqlite: recentish

Install the usual way, ie. VimPlug, Vundle, etc

" main one
Plug 'ms-jpq/coq_nvim', {'branch': 'coq'}
" 9000+ Snippets
Plug 'ms-jpq/coq.artifacts', {'branch': 'artifacts'}

" lua & third party sources -- See https://github.com/ms-jpq/coq.thirdparty
" Need to **configure separately**

Plug 'ms-jpq/coq.thirdparty', {'branch': '3p'}
" - shell repl
" - nvim lua api
" - scientific calculator
" - comment banner
" - etc

Documentation

To start coq

" the [-s, --shut-up] flag will remove the greeting message
:COQnow [--shut-up]

🌟 If required, it will ask you to run :COQdeps, please run it and do :COQnow again.

There is built-in help command

:COQhelp [--web] [topic]

FAQ

Default hotkeys?

Always:

key function
<c-space> manual completion
<c-h> edit snippet placeholder

When completion menu is open:

key function
<c-k> move preview to bigger window
<esc> exit to normal
<backspace> backspace
<enter> select completion
<tab> next result
<s-tab> prev result

Unbound:

keymap function
coq_settings.keymap.repeat repeat last edit
coq_settings.keymap.eval_snips evulate snippet in document / under selection

When hovering over a result, entering any key [a-z] will select it

This is a vim thing, I have zero control over :(

. Repeat

Set coq_settings.keymap.repeat to a hotkey.

See :COQhelp keybind for details

Flickering

By default, the old results are cleared on each keystroke, so the popup menu is closed right away.

You can disable this: at the cost of having stale results shown until the new ones come in.

let g:coq_settings = { 'display.pum.fast_close': v:false }

This is not the default because some LSP servers are very slow (ie. tailwindcss), leading to stale results being shown for too long.

Autostart COQ

let g:coq_settings = { 'auto_start': v:true } or let g:coq_settings = { 'auto_start': 'shut-up' }

This must be set BEFORE require("coq")

LSP too slow to show up on keystroke.

You have some options, each has its trade off:

  1. Increase the coq_settings.limits.completion_auto_timeout.

This will slow down feedback on every keystroke, as coq waits for LSP.

  1. Use the manual completion hotkey (default <c-space>)

Annoying! And the manual completion also has a timeout coq_settings.limits.completion_manual_timeout.

Some LSP servers will still fail to respond within the default .66 seconds, in that case pressing <c-space> multiple times might actually help some LSP servers catch up, depending on their implementation.

LSP sometimes not importing

Increase coq_settings.clients.lsp.resolve_timeout

This will however, make applying edits slower.

Missing Results

On keystroke only a max of coq_settings.match.max_results are shown.

Use manual completion hotkey to show all results.

Some LSP servers give inconsistent completions

This happens when certain LSP servers give you 1000s of unfiltered results in alphabetical order and you still have to respond in a few dozen milliseconds.

To eliminate a-z bias, coq does a random sort on the resultset and process and cache as many of them as possible within the performance window.

So if some results are not in the SQLite cache, and have yet to be processed, they will be missing. They might however still show up on later keystrokes.

Use the manual hotkey if you need to see everything.

My vim crashed!

Disable TreeSitter

Treesitter still needs stability work.

I want to use a different python version

vim.g.python3_host_prog=<absolute path to python>

If you like this...

Also check out

  • sad, it's a modern sed that does previews with syntax highlighting, and lets you pick and choose which chunks to edit.

  • CHADTree, it's a FULLY featured file manager.

  • isomorphic-copy, it's a cross platform clipboard that is daemonless, and does not require third party support.

Special Thanks & Acknowledgements

The snippets are compiled from the following open source projects:

Super special thanks goes to Typescript LSP.

Nothing like good motivation to improve my design than dumping 1000 results on my client every other keystroke.

coq_nvim's People

Contributors

3rfaan avatar bachhh avatar bakks avatar baod-rate avatar cclauss avatar dimacodota avatar dnaaun avatar eriedaberrie avatar ilan-schemoul avatar ilyailya avatar ioreshnikov avatar judaew avatar markjaroski avatar mathjiajia avatar matu3ba avatar mcchrish avatar ms-jpq avatar mte90 avatar nikklassen avatar not-a-duck avatar rcarriga avatar s1n7ax avatar skoenen avatar skylerberg avatar ta-tikoma avatar theleop avatar ultirequiem avatar vegerot avatar zeertzjq avatar zexi 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  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

coq_nvim's Issues

Cannot import 'join'

When typing any command :COQ:

Traceback (most recent call last):
File "/usr/lib/python3.6/runpy.py", line 193, in _run_module_as_main
"main", mod_spec)
File "/usr/lib/python3.6/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/home/user/.local/share/nvim/site/pack/packer/opt/coq_nvim/coq/main.py", line 6, in
from shlex import join
ImportError: cannot import name 'join'

Every other key stroke fails to return results

Thanks for all your work. I'm working on seeing if this could replace the last completion engine I was using and ran into the following odd behavior.

This occurs in multiple languages, but the gist of the problem is that as I type, I'm only getting results on every other keystroke.

Aug-17-2021 13-45-31

RTP not found

When running the plugin as mentioned in the readme, when starting it it says, RTP not found from lua/coq.lua in 9th line

Random error popup

Hey,
I get the following error randomly. I could not figure out why it's happening.

my coq config:

local g = vim.g
g.coq_settings = {
    keymap = {jump_to_mark = "<C-p>"},
    display = {pum = {source_context = {"[", "]"}}}

}

packer:

    use {
        'neovim/nvim-lspconfig',
        config = function() require('nvim.plugins.lsp') end,
        requires = {
            {'ms-jpq/coq_nvim', branch = 'coq'},
            {'ms-jpq/coq.artifacts', branch = 'artifacts'}
        }
    }

image

Traceback (most recent call last):
  File "/home/samuel/.local/share/nvim/site/pack/packer/start/coq_nvim/.vars/runtime/lib/python3.9/site-packages/pynvim_pp/logging.py", line 31, in with_suppress                                                           
    yield None
  File "/home/samuel/.local/share/nvim/site/pack/packer/start/coq_nvim/coq/shared/runtime.py", line 152, in cont
    assert not self._lock.locked()
AssertionError
Press ENTER or type command to continue
'NoneType' object is not iterable
Traceback (most recent call last):
  File "/home/samuel/.local/share/nvim/site/pack/packer/start/coq_nvim/.vars/runtime/lib/python3.9/site-packages/pynvim_pp/logging.py", line 31, in with_suppress
    yield None
  File "/home/samuel/.local/share/nvim/site/pack/packer/start/coq_nvim/.vars/runtime/lib/python3.9/site-packages/pynvim_pp/lib.py", line 21, in wrapper
    return await aw
  File "/home/samuel/.local/share/nvim/site/pack/packer/start/coq_nvim/coq/server/registrants/omnifunc.py", line 54, in c0
    vim_comps = tuple(trans(stack, context=ctx, metrics=metrics))
  File "/home/samuel/.local/share/nvim/site/pack/packer/start/coq_nvim/coq/server/trans.py", line 148, in trans
    w_adjust = _cum(stack.settings.weights, metrics=metrics)
  File "/home/samuel/.local/share/nvim/site/pack/packer/start/coq_nvim/coq/server/trans.py", line 25, in _cum
    for metric in metrics:
TypeError: 'NoneType' object is not iterable

coq with nix

Basically the same issue as ms-jpq/chadtree#110 (which the provided solution was not working for me some minutes ago).
Nix support would be nice :)

More user-friendly customization with respect to keybindings (documentation)

Currently there are some "sane defaults" set by the author, which users can use by having coq_settings.keymap.recommended remain true.
These are then translated to the relevant keybindings.

    if mapping.recommended:
        keymap.i("<esc>", expr=True) << "pumvisible() ? '<c-e><esc>' : '<esc>'"
        keymap.i("<c-c>", expr=True) << "pumvisible() ? '<c-e><c-c>' : '<c-c>'"
        keymap.i("<bs>", expr=True) << "pumvisible() ? '<c-e><bs>' : '<bs>'"
        (
            keymap.i("<cr>", expr=True)
            << "pumvisible() ? (complete_info().selected == -1 ? '<c-e><cr>' : '<c-y>') : '<cr>'"
        )
        keymap.i("<tab>", expr=True) << "pumvisible() ? '<c-n>' : '<tab>'"
        keymap.i("<s-tab>", expr=True) << "pumvisible() ? '<c-p>' : '<bs>'"

What I would like to see, is to have each and every keybinding exposed to the user slightly more explicitly so the user can customize each one individually by just a copy and paste and then applying very minor edits.
So the user can change only the <tab> and <s-tab> part of the recommended settings if they prefer <c-n> and <c-p> for browsing completion results for instance, without having to redefine all other recommended keybindings.

This probably boils down to just a mere documentation change for the KEYBIND.md file.
Maybe by simply adding these to the markdown file, users may get a better idea how to customize the defaults to their liking.

" Coq default keybindings
ino <silent><expr> <Esc>   pumvisible() ? "\<C-e><Esc>" : "\<Esc>"
ino <silent><expr> <C-c>   pumvisible() ? "\<C-e><C-c>" : "\<C-c>"
ino <silent><expr> <BS>    pumvisible() ? "\<C-e><BS>"  : "\<BS>"
ino <silent><expr> <CR>    pumvisible() ? (complete_info().selected == -1 ? "\<C-e><CR>" : "\<C-y>") : "\<CR>"
ino <silent><expr> <Tab>   pumvisible() ? "\<C-n>" : "\<Tab>"
ino <silent><expr> <S-Tab> pumvisible() ? "\<C-p>" : "\<BS>"

Thanks for reading. Have a nice day. 🌞

How to import coq

In the readme it shows following snippet.

local lsp = require "lspconfig"

lsp.<server>.setup(<stuff...>)                              -- before
lsp.<server>.setup(coq.lsp_ensure_capabilities(<stuff...>)) -- after

Apparently require('coq') is a function and what needs to be passed in to the function?

Auto imports not triggering for typescript

The plugin seems to work very well (and most importantly, fast as fuck) however, I can't seem to get the auto imports to work. I probably messed something up but I can't quite figure out what. Auto import works fine for me today via the built-in nvim LSP + lspinstall + compe so I think my LSP integration works as it should.

OS: OSX and Linux

After removing compe and trying to get auto imports using coq I end up with this:
image

coq properly prints the correct import path in the pum footer but when I press enter to complete and add the import, the import is never added (although the symbol is auto completed properly). I run this very minimal coq lua config and use the default keybinds:

local coq = require('coq')
...
nvim_lsp[lsp].setup(coq().lsp_ensure_capabilities(lsp_config))

Is this a known issue or do I need to do some deep-diving to figure out what is up with my setup?

Jump to next snippet location with Tab

Is this possible? I tried setting jump to mark to both <tab> and <c-n> but it didn't seem to change it.

vim.g.coq_settings = {
  ["keymap.jump_to_mark"] = "<c-n>"
}

Possible to use without auto completion?

Is it possible to use coq without the popup window and just open a popup when pressing <c-space>?
If yes, would it still cache results in the background?

It's really fast but I'd prefer no autocompletion 👍

Request for simple working configuration

This plugin is interesting.
But, I am unable to configure auto-complete with LSP.

Following is my minimal vimrc

call plug#begin('~/.vim/plugged')

Plug 'neovim/nvim-lspconfig'
Plug 'ms-jpq/kok.nvim', {'branch': 'kok', 'do': ':UpdateRemotePlugins'}

call plug#end()

lua <<EOF

require("lspconfig").gopls.setup{}
require("kok/recommends").all()

EOF  ⏎

I am unable to see autocomplete without the KoKstart command just like other autocomplete plugins.

  • I am not sure where to put the config.json file. Can you mention this in README?
  • Can you please put minimal working vimrc configuration in README with few sources enabled.
  • The hyperlinks in README are not working (probably not updated after the plugin got renamed). Can you please update?

LICENSE file

Would be nice for potential code reuse or works based on coq_nvim etc to know the LICENSE.

Is istance vs. instance an intentional choice?

codespell - -ignore-words-list="thats,wit" --skip="*.po,*.yml"

./coq_nvim/coq/server/reviewer.py:55: istance ==> instance
./coq_nvim/coq/server/trans.py:113: istance ==> instance
./coq_nvim/coq/shared/runtime.py:48: istance ==> instance
./coq_nvim/coq/shared/types.py:31: Trigged ==> Triggered
./coq_nvim/coq/shared/types.py:33: Trigged ==> Triggered

Shut up on autostart

There's the --shut-up flag for :COQnow, but when using the auto_start option, I haven't been able to find a way to mute the welcome message.

Have I missed it, or would it need to be added?

UnicodeEncodeError: 'utf-8' codec can't encode character '\udcc2'

When using coq with trouble.nvim, I'm getting this error any time I press a key.

Traceback:

'utf-8' codec can't encode character '\udcc2' in position 195: surrogates not allowed
Traceback (most recent call last):
  File "/Users/nathan/.local/share/nvim/site/pack/packer/start/coq_nvim/.vars/runtime/lib/python3.9/site-packages/pynvim_pp/logging.py", line 31, in with_suppress
    yield None
  File "/Users/nathan/.local/share/nvim/site/pack/packer/start/coq_nvim/coq/server/registrants/attachment.py", line 56, in cont
    await stack.bdb.set_lines(
  File "/Users/nathan/.local/share/nvim/site/pack/packer/start/coq_nvim/coq/databases/buffers/database.py", line 143, in set_lines
    await run_in_executor(self._ex.submit, cont)
  File "/Users/nathan/.local/share/nvim/site/pack/packer/start/coq_nvim/.vars/runtime/lib/python3.9/site-packages/std2/asyncio/_prelude.py", line 41, in run_in_executor
    return await loop.run_in_executor(None, cont)
  File "/Users/nathan/.pyenv/versions/3.9.6/lib/python3.9/concurrent/futures/thread.py", line 52, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/Users/nathan/.local/share/nvim/site/pack/packer/start/coq_nvim/coq/shared/executor.py", line 33, in submit
    return cast(T, fut.result())
  File "/Users/nathan/.pyenv/versions/3.9.6/lib/python3.9/concurrent/futures/_base.py", line 445, in result
    return self.__get_result()
  File "/Users/nathan/.pyenv/versions/3.9.6/lib/python3.9/concurrent/futures/_base.py", line 390, in __get_result
    raise self._exception
  File "/Users/nathan/.local/share/nvim/site/pack/packer/start/coq_nvim/coq/shared/executor.py", line 24, in cont
    ret = f(*args, **kwargs)
  File "/Users/nathan/.local/share/nvim/site/pack/packer/start/coq_nvim/coq/databases/buffers/database.py", line 128, in cont
    cursor.executemany(sql("insert", "line"), m1())
UnicodeEncodeError: 'utf-8' codec can't encode character '\udcc2' in position 195: surrogates not allowed
Press ENTER or type command to continue

How to run COQnow on startup?

I don't really want to have to run COQnow everytime

I tried to run it in init.lua but its giving me an error that it is not an editor command

Package manager to update tabnine. Clarifying tabnine CPU usage.

  1. I dont see a way in the manual to disable downloads.
    I dont understand why it is needed at all, since packer.nvim etc can copy git projects easily.
    Would changing the README to explain how to setup packer etc be okay for you?

  2. The associated issues were closed via some commits (only starting lsp on request and not searching through ignored files).
    Other issues were closed with like 20% CPU usage. Ideally some statistics what to expect on an example project would be nice.

Error starting python process when python is symlinked

I get the following error when running :COQnow

E5108: Error executing lua Vim:E475: Invalid value for argument cmd: '~/.pyenv/versions/neovim3/bin/python' is not executable

I specify the python interpreters used by nvim as follows:

let g:python3_host_prog='~/.pyenv/versions/neovim3/bin/python'
let g:python_host_prog='~/.pyenv/versions/neovim/bin/python'

Running :checkhealth confirms that (apparently) nvim is fine with my choice of Python interpreters. Just as a sanity check I confirmed that indeed the specified interpreters are executable

❯ ls -lh ~/.pyenv/versions/neovim3/bin/python
Permissions Size User     Date Modified Name
lrwxr-xr-x     9 garfield 24 Sep  2020  /Users/garfield/.pyenv/versions/neovim3/bin/python -> python3.8

Maybe it's the symlink?

Edit:
I tried to remove the python_host_prog so that I use the global Python interpreter and everything works then. So it looks like it's the symlink created by pyenv.

COQnow throws error regarding \u2728 (sparkles character??)

Running COQnow, on a recent reinstall with Packer (after running COQnow) with both coq + the snippets codebase gives this error:

image

Looking up \u2728 returns the sparkles emoji?? Error is the same on neovide as is on windows terminal, plugin is on the start folder. Error is after the first character is inserted.

COQdeps returns non-zero status code

Output of python3 -V:

Python 3.9.6

Also tried with Python 3.8.11, same result.

Traceback (most recent call last):                                                                                                                                                                                            
  File "/usr/lib/python3.9/runpy.py", line 197, in _run_module_as_main                                                                                                                                                          
    return _run_code(code, main_globals, None,
  File "/usr/lib/python3.9/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/home/user/.local/share/nvim/site/pack/packer/opt/coq_nvim/coq/__main__.py", line 58, in <module>
    EnvBuilder(
  File "/usr/lib/python3.9/venv/__init__.py", line 75, in create
    self._setup_pip(context)
  File "/usr/lib/python3.9/venv/__init__.py", line 298, in _setup_pip
    subprocess.check_output(cmd, stderr=subprocess.STDOUT)
  File "/usr/lib/python3.9/subprocess.py", line 424, in check_output
    return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
  File "/usr/lib/python3.9/subprocess.py", line 528, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['/home/user/.local/share/nvim/site/pack/packer/opt/coq_nvim/.vars/runtime/bin/python3', '-Im', 'ensurepip', '--upgrade', '--default-pip']' returned non-zero exit status 1.

Snippets

This works:

require("lspconfig").pyright.setup(coq.lsp_ensure_capabilities({}))

But no snippets:

image

But this dont

vim.schedule(function ()
  local lsp = require "lspconfig"
  require("packer").loader("coq_nvim coq.artifacts")
  lsp.pyright.setup(require("coq")().lsp_ensure_capabilities({}))
end)

What I'm doing wrong?

image

some questions

Yes, It's fast. But I still have some questions:

  1. How to define user snippets?
  2. How to auto expand completion on tab?
  3. Relative path not starting with ./ can not trigger path completion. But <c-x><c-f> can. For example in home directory, type .config/ then <c-space> won't suggest paths.
  4. Path completion does not work well with upper case character. For example ./.config/b suggests ./.config/BaiduPCS-Go/, but ./.config/B does not.
  5. In python, <c-space> is needed when importing each package and the first two modules. For example from torch import abs, cuda. Can this be automaticly triggered.

Thanks!

Adding new source completion?

Thanks for the great work on this plugin 👍

But i have question,
I use orgmode for note-taking (kristijanhusak/orgmode.nvim), in compe, I just add new line for source orgmode like this:

screenshot_18-Aug-2021_1548

how bout coq_nvim?

What is the use case for the AGP bot?

I saw that every day, the agp bot pushes commit to this repo, but it actually does nothing. What is the use for that agp bot? To keep this repo active or it has real usage?

Feature: Look-ahead search to be even faster

I am proposing an idea to make coq_nvim even faster, if you feel like it is necessary. The idea is that if we can predict the next keystroke accurately, we could already run the search on the line of code + the predicted character during the idle time between two keystrokes. When the user presses the right keystroke, we just have to display the result instead of doing the search and then displaying.

Issues to address and make this idea work:

  1. How to predict the next key?

That can be done with various degrees of complexity, if we want to be fast we can use a markov chain fitted on some source code from github. Once fitted on some dataset, it is basically a lookup table. For a given letter, it gives the probability of the next letters following. If I press 'i', then 'm' (import) or ' ' (for i in...) will be likely in python, but not 'y' for instance. What is important is to quantify the hit and miss rate in practice.

  1. What happens if we can't predict accurately?
    We can run multiple searches on the different most probable next letters. If we press another letter than predicted, we drop the search altogether and fallback to the normal non-predictive version of the search. I suppose it can also be optimized for not completely dropping the search and help the fuzzy search?

We could have multiple threads running, let's say 4 and they would look for the 4 most likely next keystrokes.

Example:
Let's assume only one thread is available at all times.

  • I type 'i'
  • The engine gives the regular suggestions for 'i'
  • There is some idle time, so it predicts that 'm' (10%) and ' ' (5%) are likely, so it searches for 'im' (most likely option)
  • I type 'm'
  • The engine prints the already searched suggestions for 'im'
  • There is some idle time, 'p' is the most likely, so the look-ahead search begins
  • I type an 'a'
  • The engine drops the look-ahead search if it is still running and searches on-the-fly for 'ima'

There is already some look ahead going on in the code but I am not certain what it entices, so maybe this - or something similar - is already implemented? Sorry if I just invented the square wheel :)

Tabnine can't be installed

Hi, I'm currently trying this wonderful plugin, but i'm getting the current error after enabling tabnine and running :COQnow :

[Errno 18] Invalid cross-device link: '/tmp/tmpbf8w4pkx' -> '/home/michaelb/.local/share/nvim/plugged/coq_nvim/.vars/cli
ents/t9/TabNine'                                                                                                        
Traceback (most recent call last):                                                                                      
  File "/home/michaelb/.local/share/nvim/plugged/coq_nvim/.vars/runtime/lib/python3.9/site-packages/pynvim_pp/logging.py
", line 31, in with_suppress                                                                                            
    yield None                                                                                                          
  File "/home/michaelb/.local/share/nvim/plugged/coq_nvim/.vars/runtime/lib/python3.9/site-packages/pynvim_pp/lib.py", l
ine 21, in wrapper                                                                                                      
    return await aw                                                                                                     
  File "/home/michaelb/.local/share/nvim/plugged/coq_nvim/coq/clients/t9/worker.py", line 119, in _install              
    self._installed = await ensure_updated(                                                                             
  File "/home/michaelb/.local/share/nvim/plugged/coq_nvim/coq/clients/t9/install.py", line 77, in ensure_updated        
    await run_in_executor(_update, timeout=timeout)                                                                     
  File "/home/michaelb/.local/share/nvim/plugged/coq_nvim/.vars/runtime/lib/python3.9/site-packages/std2/asyncio/_prelud
e.py", line 41, in run_in_executor                                                                                      
    return await loop.run_in_executor(None, cont)                                                                       
  File "/usr/lib/python3.9/concurrent/futures/thread.py", line 52, in run                                               
    result = self.fn(*self.args, **self.kwargs)                                                                         
  File "/home/michaelb/.local/share/nvim/plugged/coq_nvim/coq/clients/t9/install.py", line 68, in _update               
    Path(fd.name).replace(T9_BIN)                                                                                       
  File "/usr/lib/python3.9/pathlib.py", line 1385, in replace                                                           
    self._accessor.replace(self, target)                                                                                
OSError: [Errno 18] Invalid cross-device link: '/tmp/tmpbf8w4pkx' -> '/home/michaelb/.local/share/nvim/plugged/coq_nvim/
.vars/clients/t9/TabNine'

I figure that's because I actually use different partition for / and /home and/or have a BTRFS setup, but that should probably be supported. There's usually a cross-device-safe alternative like shutil to in-library methods.

cgn does not insert entire completion text

Running cgn on highlighted text and replacing with a completion doesn't work.

Run *ncgnimp<C-n><CR><Esc>. on the following:

hello
hello

Expected result:

import
import

Actual result:

import
imp

Off topic

Side note: it would be neat to also have vim's default behavior of inserting the completion text without needing to hit enter so it's one less keystroke, i.e. *ncgnimp<C-n><Esc>..

EDIT: I fixed this by overriding the <CR> binding:

inoremap <silent><expr> <Esc> pumvisible() ? (complete_info().selected == -1 ? "\<Esc>" : "\<C-y>\<Esc>") : "\<Esc>"

sqlite3.OperationalError: no such column: TRUE

On any keypress, I get

sqlite3.OperationalError: no such column: TRUE 

Full Trace:

Traceback (most recent call last):
File "~/.vim/plugged/coq_nvim/.vars/runtime/lib/python3.8/site-packages/pynvim_pp/logging.py", line 31, in with_suppress
 yield None                                                                                                                                                                                                                                                 File "~/.vim/plugged/coq_nvim/coq/server/registrants/attachment.py", line 56, in cont
await stack.bdb.set_lines(                                                                                                                                                                                                                                 File "~/.vim/plugged/coq_nvim/coq/databases/buffers/database.py", line 152, in set_lines
await run_in_executor(self._ex.submit, cont)                                                                                                                                                                                                               File "~/.vim/plugged/coq_nvim/.vars/runtime/lib/python3.8/site-packages/std2/asyncio/_prelude.py", line 41, in run_in_executor
return await loop.run_in_executor(None, cont)
File "/usr/lib/python3.8/concurrent/futures/thread.py", line 57, in run
result = self.fn(*self.args, **self.kwargs)
File "~/.vim/plugged/coq_nvim/coq/shared/executor.py", line 33, in submit 
return cast(T, fut.result())
File "/usr/lib/python3.8/concurrent/futures/_base.py", line 444, in result
return self.__get_result()
File "/usr/lib/python3.8/concurrent/futures/_base.py", line 389, in __get_result
raise self._exception
File "~/.vim/plugged/coq_nvim/coq/shared/executor.py", line 24, in cont
ret = f(*args, **kwargs)
File "~/.vim/plugged/coq_nvim/coq/databases/buffers/database.py", line 128, in cont
cursor.execute(
sqlite3.OperationalError: no such column: TRUE   

I just installed the latest version of sqlite3 (3.26?)

Could you share your dotfiles?

It would be useful to be guided when configuring this plugin.

Btw very good work, I really love this plugin, it has made me change almost all my configuration :D

Automatically start?

Is there a more graceful way to start coq when vim starts besides au BufEnter * :COQnow<CR>, or is that the way I'm supposed to do it?

Edit: I'd also like it if I could get the No snippets loaded message to not show. I passed [--shut-up].

LSP Setup Not Working: `attempt to index local 'coq'`

Saw your reddit post last night and I'm excited to try this out. Having some trouble installing it and getting it to work.

From the readme:

Install the Nvim Official LSP integration

Requires 1 line of change to support LSP snippets

local lsp = require "lspconfig"

lsp.<server>.setup(<stuff...>)                              -- before
lsp.<server>.setup(coq.lsp_ensure_capabilities(<stuff...>)) -- after

When I do this and then open neovim I get an error of

Error detected while processing /Users/sambernheim/.config/nvim/init.vim:
line  201:
E5108: Error executing lua [string ":lua"]:53: attempt to index local 'coq' (a function value)

My lsp config setup currently is

lspconfig.tsserver.setup{
    root_dir = lspconfig.util.root_pattern("package.json", "tsconfig.json", ".git")
}

Following your suggestions I make it

lspconfig.tsserver.setup{
    coq.lsp_ensure_capabilities(
        root_dir = lspconfig.util.root_pattern("package.json", "tsconfig.json", ".git")
    )
}

and then I see the error.
I've also tried several different variations (parentheses instead of curly braces, removing the root_dir line, etc)

I'm on an M1 Mac if its relevant. I've run COQdeps and COQnow as well and both succeeded.

I think at least one other person on the reddit thread is also having this issue.

Sqlite traceback

Hello. This is the current traceback when I am trying to use this

near "ON": syntax error
Traceback (most recent call last):
  File "/home/evanr/.config/nvim/plugged/coq_nvim/.vars/runtime/lib/python3.9/site-packages/pynvim_pp/logging.py", line 31, in with_suppress
    yield None
  File "/home/evanr/.config/nvim/plugged/coq_nvim/.vars/runtime/lib/python3.9/site-packages/pynvim_pp/lib.py", line 21, in wrapper
    return await aw
  File "/home/evanr/.config/nvim/plugged/coq_nvim/coq/server/registrants/autocmds.py", line 167, in cont
    await stack.bdb.ft_update(buf.number, filetype=ft)
  File "/home/evanr/.config/nvim/plugged/coq_nvim/coq/databases/buffers/database.py", line 83, in ft_update
    await run_in_executor(self._ex.submit, cont)
  File "/home/evanr/.config/nvim/plugged/coq_nvim/.vars/runtime/lib/python3.9/site-packages/std2/asyncio/_prelude.py", line 41, in run_in_executor
    return await loop.run_in_executor(None, cont)
  File "/usr/lib/python3.9/concurrent/futures/thread.py", line 52, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/evanr/.config/nvim/plugged/coq_nvim/coq/shared/executor.py", line 33, in submit
    return cast(T, fut.result())
  File "/usr/lib/python3.9/concurrent/futures/_base.py", line 440, in result
    return self.__get_result()
  File "/usr/lib/python3.9/concurrent/futures/_base.py", line 389, in __get_result
    raise self._exception
  File "/home/evanr/.config/nvim/plugged/coq_nvim/coq/shared/executor.py", line 24, in cont
    ret = f(*args, **kwargs)
  File "/home/evanr/.config/nvim/plugged/coq_nvim/coq/databases/buffers/database.py", line 81, in cont
    _ensure_buffer(cursor, buf_id=buf_id, filetype=filetype)
  File "/home/evanr/.config/nvim/plugged/coq_nvim/coq/databases/buffers/database.py", line 21, in _ensure_buffer
    cursor.execute(
sqlite3.OperationalError: near "ON": syntax error

I am using the latest DEV release of NVIM and Python3.9.2

I can provide any other details that you need.

Thanks!

Feature Idea: Inline suggestion using virtual text like fish shell

An example from the fish shell website
image

Fish shell implements a kind of 'inline' suggestions, wherein the first completion is showed as dull text after the cursor, the user can hit to get that completion, and then hit it again to get the full list.

I think something similar to the first part could be implemented using virtual text from neovim. Plus some configuration and keymaps to choose when to expand the full completion list, when to accept the first suggestion, when to cycle completion in virtual without opening the completion list, etc

The current completion popup window works fine, and should be the default for parity with other IDE, but this behaviour could be a more sleek and less visually disruptive way of presenting autocompletions for some people

(I also asked about this idea to compe but it hasn't been implemented yet)

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.