Пример #1
0
from ycmd.completers.language_server import language_server_completer


PATH_TO_GOPLS = os.path.abspath( os.path.join( os.path.dirname( __file__ ),
  '..',
  '..',
  '..',
  'third_party',
  'go',
  'src',
  'golang.org',
  'x',
  'tools',
  'cmd',
  'gopls',
  utils.ExecutableName( 'gopls' ) ) )


def ShouldEnableGoCompleter( user_options ):
  server_exists = os.path.isfile( PATH_TO_GOPLS )
  if server_exists:
    return True
  utils.LOGGER.info( 'No gopls executable at %s.', PATH_TO_GOPLS )
  return False


class GoCompleter( simple_language_server_completer.SimpleLSPCompleter ):
  def GetServerName( self ):
    return 'gopls'

# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with ycmd.  If not, see <http://www.gnu.org/licenses/>.

import json
import logging
import os

from ycmd import responses
from ycmd import utils
from ycmd.completers.language_server import language_server_completer

PATH_TO_GOPLS = os.path.abspath(
    os.path.join(os.path.dirname(__file__), '..', '..', '..', 'third_party',
                 'go', 'bin', utils.ExecutableName('gopls')))


def ShouldEnableGoCompleter(user_options):
    server_exists = utils.FindExecutableWithFallback(
        user_options['gopls_binary_path'], PATH_TO_GOPLS)
    if server_exists:
        return True
    utils.LOGGER.info('No gopls executable at %s.', PATH_TO_GOPLS)
    return False


class GoCompleter(language_server_completer.LanguageServerCompleter):
    def __init__(self, user_options):
        super().__init__(user_options)
        self._user_supplied_gopls_args = user_options['gopls_args']