Skip to content

Commit

Permalink
Allow global opt-in to snippets
Browse files Browse the repository at this point in the history
This is required for generic_lsp_completer thingies that _only_ support
snippets (like json, yaml) and allows the configuration to be global:

    {
      'name': 'json',
      'cmdline': [ 'node', s:lsp_dir . '/json/node_modules/.bin/vscode-json-languageserver', '--stdio' ],
      'filetypes': [ 'json' ],
      'capabilities': #{ textDocument: #{ completion: #{ completionItem: #{ snippetSupport: v:true } } } },
    },

We _also_ allow this to be set in extra conf files, but that's way less
convenient and we should probably ditch it.
  • Loading branch information
puremourning committed Jul 11, 2020
1 parent 6202e96 commit 1afb240
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions ycmd/completers/language_server/generic_lsp_completer.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,25 @@
class GenericLSPCompleter( language_server_completer.LanguageServerCompleter ):
def __init__( self, user_options, server_settings ):
self._name = server_settings[ 'name' ]
self._supported_filetypes = server_settings[ 'filetypes' ]
self._project_root_files = server_settings.get( 'project_root_files', [] )
self._server_settings = server_settings

super().__init__( user_options )

self._command_line = server_settings[ 'cmdline' ]
self._command_line[ 0 ] = utils.FindExecutable( self._command_line[ 0 ] )


def GetSettings( self, module, request_data ):
settings = {}
settings = super().GetSettings( module, request_data )
utils.UpdateDict( settings.setdefault( 'capabilities', {} ),
self._server_settings.get( 'capabilities', {} ) )
return settings



def GetProjectRootFiles( self ):
return self._project_root_files
return self._server_settings.get( 'project_root_files', [] )


def Language( self ):
Expand Down Expand Up @@ -76,4 +86,4 @@ def GetCodepointForCompletionRequest( self, request_data ):


def SupportedFiletypes( self ):
return self._supported_filetypes
return self._server_settings[ 'filetypes' ]

0 comments on commit 1afb240

Please sign in to comment.