Skip to content
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

lsp#complete omnifunc isn't triggered #285

Open
kmARC opened this issue Feb 23, 2020 · 3 comments
Open

lsp#complete omnifunc isn't triggered #285

kmARC opened this issue Feb 23, 2020 · 3 comments

Comments

@kmARC
Copy link
Contributor

kmARC commented Feb 23, 2020

Omnifunc completion works very nicely with the css completer:

let g:completor_css_omni_trigger = '([\w-]+|@[\w-]*|[\w-]+:\s*[\w-]*)$'

I would love to use the omnifunc completer from prabirshrestha/vim-lsp, however, It is not listing matches.

My configuration is similar to the css completion, I tried it with bash-language-server.

set omnifunc=lsp#complete
let g:completor_sh_omni_trigger = '(\w*)$'

The debug log shows that - supposedly - the omnifunc is called:

2020-02-23 08:45:50,912 [INFO][.../completor.vim/pythonx/completers/common/omni.py] omnifunc: b'lsp#complete'
2020-02-23 08:45:50,913 [INFO][.../completor.vim/pythonx/completers/common/omni.py] start: 9,0

If I press i_Ctrl-X_Ctrl_O, the completion popup appears, the omnifunc is working.


I understand that completor itself could be configured to use LSP directly, however, vim-lsp (with mattn/vim-lsp-settings) is a super nice and scalable solution to maintain LSP enginges easily.

I could also use the suggested prabirshrestha/asyncomplete.vim and prabirshrestha/asyncomplete-lsp.vim async engines, however completor gives a more configurable and nicer representation, and better configurability for triggers etc.

@kmARC kmARC changed the title lsp#complete omnifunc isn't triggered lsp#complete omnifunc isn't triggered Feb 23, 2020
@kmARC
Copy link
Contributor Author

kmARC commented Feb 23, 2020

Maybe the sh shell example wasn't the best. The original reason I started fiddling with it is the json/yaml schema completion.

vim-lsp can be configured for example like below, and omnicompletion works perfectly with the selected schema (when I open a package.json file then then dictionary keys are completed from the json schema on schemastore.

let g:lsp_settings = {
    \ 'json-languageserver': {
    \    'workspace_config': {
    \       'json': {
    \          'schemas': [
    \             {
    \               'url': 'http://json.schemastore.org/package',
    \               'fileMatch': ['package.json'],
    \             },
    \           ],
    \          'format': {
    \             'enable': v:true,
    \           }
    \        },
    \     },
    \  },

With completor, this configuration is never passed - obviously - to the languages server (is there a way to do that?).

Note: for the json example it can be worked around by specifying "$shcema" as the first key, but that doesn't work with yamls, completion returned using $1 placeholders are not correctly interpreted

@antoniomo
Copy link

With completor, this configuration is never passed - obviously - to the languages server (is there a way to do that?).

Looking for a way to pass configurations to LSP servers as well, any workarounds?

@maralla
Copy link
Owner

maralla commented Aug 2, 2020

Update completor to the latest and the LSP workspace configuration can be set using the following settings:

let g:completor_filetype_map = {}

let g:completor_filetype_map.json = {
      \ 'ft': 'lsp',
      \ 'cmd': 'vscode-json-languageserver --stdio',
      \ 'insertText': 'label',
      \ 'config': {
      \   'json': {
      \      'format': { 'enable': v:false },
      \      'schemas': [
      \        {'fileMatch': ['package.json'], 'url': 'http://json.schemastore.org/package'},
      \      ]
      \    }
      \  }
      \ }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants