From 553da607fee342e394ad49aeceb4305915e6bc60 Mon Sep 17 00:00:00 2001 From: Dominic Monroe Date: Tue, 23 Jul 2019 16:03:04 +0100 Subject: [PATCH 1/8] Add basic coc.nvim source --- autoload/coc/source/async_clj_omni.vim | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 autoload/coc/source/async_clj_omni.vim diff --git a/autoload/coc/source/async_clj_omni.vim b/autoload/coc/source/async_clj_omni.vim new file mode 100644 index 0000000..244e2b7 --- /dev/null +++ b/autoload/coc/source/async_clj_omni.vim @@ -0,0 +1,16 @@ +function! coc#source#async_clj_omni#init() abort + return { + \'shortcut': 'clj', + \'priority': 1, + \'filetypes': ['clojure'], + \'firstMatch': 0, + \'triggerCharacters': ['.', '/', ':'], + \} +endfunction + +function! coc#source#async_clj_omni#complete(opt, cb) abort + call fireplace#omnicomplete({candidates -> + \ a:cb(candidates) + \ }, + \ a:opt.input) +endfunction From dab81a380bb2fd93efcd416a19c85671cf9c1a8c Mon Sep 17 00:00:00 2001 From: Dominic Monroe Date: Tue, 23 Jul 2019 16:07:28 +0100 Subject: [PATCH 2/8] Remove waffle reference --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index 35f1f08..1606b08 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,3 @@ -[![Stories in Ready](https://badge.waffle.io/SevereOverfl0w/async-clj-omni.png?label=ready&title=Ready)](https://waffle.io/SevereOverfl0w/async-clj-omni) # clj-async.nvim Provides async clojure completion through [deoplete.nvim][] or [ncm][] and From 744ec7b5653872262ebbcefabfd345c8f9fd8b85 Mon Sep 17 00:00:00 2001 From: Dominic Monroe Date: Tue, 23 Jul 2019 16:10:26 +0100 Subject: [PATCH 3/8] Update README.md --- README.md | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 1606b08..a8022e5 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,10 @@ # clj-async.nvim -Provides async clojure completion through [deoplete.nvim][] or [ncm][] and -[nrepl-python-client][]. +Provides async clojure completion for: + +* [ncm2][] +* [asyncomplete.vim][] +* [coc.nvim][] Trying to use Fireplace's omnicompletion with auto-complete is painfully slow at times, making typing blocked. Using this module will be faster as @@ -32,19 +35,16 @@ let g:deoplete#keyword_patterns.clojure = '[\w!$%&*+/:<=>?@\^_~\-\.#]*' As I improve them, they may be PR'd into deoplete.vim, but I'm not yet comfortable suggesting that change upstream. -### Nvim Completion Manager +### Nvim Completion Manager 2 -1. Follow the install instructions for [ncm][]. +1. Follow the install instructions for [ncm2][]. 2. Add this plugin using your favourite plugin manager, ```vim Plug 'clojure-vim/async-clj-omni' ``` -That's it. It should "just" work, whether you're using Acid or Fireplace. - ### asyncomplete.vim - Registration: ``` @@ -55,6 +55,14 @@ au User asyncomplete_setup call asyncomplete#register_source({ \ }) ``` +### coc.nvim + +1. Follow the install instructions for [coc.nvim][]. +2. Add this plugin using your favourite plugin manager, + ```vim + Plug 'clojure-vim/async-clj-omni' + ``` + ## Developing ### Deoplete @@ -96,3 +104,6 @@ NVIM_PYTHON_LOG_FILE=logfile NVIM_PYTHON_LOG_LEVEL=DEBUG nvim [nrepl-python-client]: https://github.com/clojure-vim/nrepl-python-client [vim-plug]: https://github.com/junegunn/vim-plug [ncm]: https://github.com/roxma/nvim-completion-manager +[ncm2]: https://github.com/ncm2/ncm2 +[coc.nvim]: https://github.com/neoclide/coc.nvim +[asyncomplete.vim]: https://github.com/prabirshrestha/asyncomplete.vim From 5620d102eb029c7e0f4c4500b6adc88a67dca0f2 Mon Sep 17 00:00:00 2001 From: Salam Elbilig Date: Tue, 17 Sep 2019 19:24:56 -0700 Subject: [PATCH 4/8] Update Deoplete configuration snippet --- README.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index a8022e5..0aa2036 100644 --- a/README.md +++ b/README.md @@ -25,11 +25,10 @@ your favourite plugin manager, mine is [vim-plug][] Plug 'clojure-vim/async-clj-omni' ``` -You also need to include the following lines in your init.vim: +You also need to include the following line in your init.vim: ```vim -let g:deoplete#keyword_patterns = {} -let g:deoplete#keyword_patterns.clojure = '[\w!$%&*+/:<=>?@\^_~\-\.#]*' +call deoplete#custom#option('keyword_patterns', {'clojure': '[\w!$%&*+/:<=>?@\^_~\-\.#]*'}) ``` As I improve them, they may be PR'd into deoplete.vim, but I'm not yet From 87827ab933a19b1510750f01f24d687d768cfeba Mon Sep 17 00:00:00 2001 From: Salam Elbilig Date: Tue, 17 Sep 2019 19:35:30 -0700 Subject: [PATCH 5/8] Delete note about upstreaming keyword patterns Now that the author of Deoplete.nvim made it clear[1] that he is not interested in accepting and including default keyword patterns for languages in Deoplete.nvim, delete the note. [1] https://github.com/Shougo/deoplete.nvim/issues/1015 --- README.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/README.md b/README.md index 0aa2036..ed52bc2 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,7 @@ Provides async clojure completion for: +* [deoplete.nvim][] * [ncm2][] * [asyncomplete.vim][] * [coc.nvim][] @@ -31,9 +32,6 @@ You also need to include the following line in your init.vim: call deoplete#custom#option('keyword_patterns', {'clojure': '[\w!$%&*+/:<=>?@\^_~\-\.#]*'}) ``` -As I improve them, they may be PR'd into deoplete.vim, but I'm not yet -comfortable suggesting that change upstream. - ### Nvim Completion Manager 2 1. Follow the install instructions for [ncm2][]. From 2987d31382e0189e0ad1fc55b02662248b95df3b Mon Sep 17 00:00:00 2001 From: Dominic Monroe Date: Wed, 22 Sep 2021 20:02:38 +0100 Subject: [PATCH 6/8] Add nvim-cmp support --- README.md | 15 ++++++++ autoload/async_clj_omni/cmp.vim | 65 +++++++++++++++++++++++++++++++++ plugin/cmp_fireplace.vim | 5 +++ 3 files changed, 85 insertions(+) create mode 100644 autoload/async_clj_omni/cmp.vim create mode 100644 plugin/cmp_fireplace.vim diff --git a/README.md b/README.md index ed52bc2..6b34560 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,7 @@ Provides async clojure completion for: * [ncm2][] * [asyncomplete.vim][] * [coc.nvim][] +* [nvim-cmp][] Trying to use Fireplace's omnicompletion with auto-complete is painfully slow at times, making typing blocked. Using this module will be faster as @@ -60,6 +61,19 @@ au User asyncomplete_setup call asyncomplete#register_source({ 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: + ```lua + cmp.setup({ + sources = { + { name = 'async_clj_omni' }, + } + }) + ``` +3. Add `call async_clj_omni#cmp#register()` somewhere in your init.vim. + ## Developing ### Deoplete @@ -104,3 +118,4 @@ NVIM_PYTHON_LOG_FILE=logfile NVIM_PYTHON_LOG_LEVEL=DEBUG nvim [ncm2]: https://github.com/ncm2/ncm2 [coc.nvim]: https://github.com/neoclide/coc.nvim [asyncomplete.vim]: https://github.com/prabirshrestha/asyncomplete.vim +[nvim-cmp]: https://github.com/hrsh7th/nvim-cmp diff --git a/autoload/async_clj_omni/cmp.vim b/autoload/async_clj_omni/cmp.vim new file mode 100644 index 0000000..566dd0e --- /dev/null +++ b/autoload/async_clj_omni/cmp.vim @@ -0,0 +1,65 @@ +let s:source = {} + +function! s:source.new() abort + return deepcopy(s:source) +endfunction + +function! s:source.is_available() + if fireplace#op_available('complete') + return v:true + else + return v:false + endif +endfunction + +function! s:source.get_keyword_pattern(params) + " Minimum 2 letters because completion on "y" doesn't resolve any + " namespaces, but "ya" will resolve on "yada". + return '\k\k\+' +endfunction + +function! s:source.get_trigger_characters(params) + return ['/', '.', ':'] +endfunction + +" unfortunately f is for both function & static method. to workaround, we'll +" need to go to a lower level than fireplace#omnicomplete, which would lose us +" the context of the completion from surrounding lines. +let s:lsp_kinds = luaeval(" +\ (function() +\ local cmp = require'cmp' +\ return {f = cmp.lsp.CompletionItemKind.Function, +\ m = cmp.lsp.CompletionItemKind.Function, +\ v = cmp.lsp.CompletionItemKind.Variable, +\ s = cmp.lsp.CompletionItemKind.Keyword, +\ c = cmp.lsp.CompletionItemKind.Class, +\ k = cmp.lsp.CompletionItemKind.Keyword, +\ l = cmp.lsp.CompletionItemKind.Variable, +\ n = cmp.lsp.CompletionItemKind.Module, +\ i = cmp.lsp.CompletionItemKind.Field, +\ r = cmp.lsp.CompletionItemKind.File,} +\ end)()") + +function! s:coerce_to_lsp(vc) + return {'label': a:vc.word, + \ 'labelDetails': { + \ 'detail': a:vc.menu, + \ }, + \ 'documentation': a:vc.info, + \ 'kind': get(s:lsp_kinds, a:vc.kind, 1) + \ } +endf + +function! s:source.complete(params, callback) abort + let l:kw = a:params.context.cursor_before_line[(a:params.offset-1):] + + call fireplace#omnicomplete({candidates -> + \ a:callback(map(candidates, + \ {_, val -> s:coerce_to_lsp(val)})) + \ }, + \ l:kw) +endfunction + +function async_clj_omni#cmp#register() + call cmp#register_source('async_clj_omni', s:source.new()) +endf diff --git a/plugin/cmp_fireplace.vim b/plugin/cmp_fireplace.vim new file mode 100644 index 0000000..e7565af --- /dev/null +++ b/plugin/cmp_fireplace.vim @@ -0,0 +1,5 @@ +" cmp isn't guaranteed to be loaded before this file runs, which is why we +" leave the option to manually register. +if exists('*cmp#register_source') + call async_clj_omni#cmp#register() +endif From 368d52fdcb525e81a901dbaa566c2aba7bcfb723 Mon Sep 17 00:00:00 2001 From: Dominic Monroe Date: Sun, 3 Oct 2021 20:41:44 +0100 Subject: [PATCH 7/8] Remove manual register with cmp This is no longer needed now that cmp#ready allows async_clj_omni to register only when cmp is installed. --- README.md | 1 - plugin/cmp_fireplace.vim | 9 ++++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 6b34560..1337876 100644 --- a/README.md +++ b/README.md @@ -72,7 +72,6 @@ au User asyncomplete_setup call asyncomplete#register_source({ } }) ``` -3. Add `call async_clj_omni#cmp#register()` somewhere in your init.vim. ## Developing diff --git a/plugin/cmp_fireplace.vim b/plugin/cmp_fireplace.vim index e7565af..69c4eab 100644 --- a/plugin/cmp_fireplace.vim +++ b/plugin/cmp_fireplace.vim @@ -1,5 +1,4 @@ -" cmp isn't guaranteed to be loaded before this file runs, which is why we -" leave the option to manually register. -if exists('*cmp#register_source') - call async_clj_omni#cmp#register() -endif +augroup async_clj_omni_plugins + autocmd! + autocmd User cmp#ready call async_clj_omni#cmp#register() +augroup END From 1c683073d67f1397af4cd071b4136eb55cca47b7 Mon Sep 17 00:00:00 2001 From: Dominic Monroe Date: Thu, 7 Sep 2023 16:42:20 +0100 Subject: [PATCH 8/8] Fix autocmd for nvim-cmp --- plugin/cmp_fireplace.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/cmp_fireplace.vim b/plugin/cmp_fireplace.vim index 69c4eab..0874a62 100644 --- a/plugin/cmp_fireplace.vim +++ b/plugin/cmp_fireplace.vim @@ -1,4 +1,4 @@ augroup async_clj_omni_plugins autocmd! - autocmd User cmp#ready call async_clj_omni#cmp#register() + autocmd User CmpReady call async_clj_omni#cmp#register() augroup END pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy